Commentary: Report children node types

This commit is contained in:
Wilson Snyder 2011-11-01 19:33:11 -04:00
parent 7654add5e5
commit 954e127f1d

View File

@ -7,7 +7,7 @@ use Getopt::Long;
use IO::File; use IO::File;
use Pod::Usage; use Pod::Usage;
use strict; use strict;
use vars qw ($Debug @Types %Classes %ClassRefs %Stages); use vars qw ($Debug @Types %Classes %Children %ClassRefs %Stages);
#====================================================================== #======================================================================
# main # main
@ -88,6 +88,7 @@ sub read_types {
$class =~ s/^Ast//; $class =~ s/^Ast//;
$inh =~ s/^Ast//; $inh =~ s/^Ast//;
$Classes{$class} = $inh; $Classes{$class} = $inh;
$Children{$inh}{$class} = 1;
} }
} }
} }
@ -152,6 +153,22 @@ sub subclasses_of {
return (reverse @cllist); return (reverse @cllist);
} }
sub children_of {
my $type = shift;
my @cllist;
my @todo;
push @todo, $type;
while (my $subclass = shift @todo) {
foreach my $child (sort keys %{$::Children{$subclass}}) {
push @todo, $child;
push @cllist, $child;
}
}
return (@cllist);
}
#---------------------------------------------------------------------- #----------------------------------------------------------------------
sub write_report { sub write_report {
@ -172,6 +189,12 @@ sub write_report {
printf $fh "Ast%-12s ",$subclass; printf $fh "Ast%-12s ",$subclass;
} }
printf $fh "\n"; printf $fh "\n";
$fh->print("\tchilds:\t");
foreach my $subclass (children_of($type)) {
next if $subclass eq 'Node';
printf $fh "Ast%-12s ",$subclass;
}
printf $fh "\n";
if (my $refs = $ClassRefs{"Ast${type}"}) { if (my $refs = $ClassRefs{"Ast${type}"}) {
$fh->print("\tnewed:\t"); $fh->print("\tnewed:\t");
foreach my $stage (sort {($Stages{$a}||-1) <=> ($Stages{$b}||-1)} foreach my $stage (sort {($Stages{$a}||-1) <=> ($Stages{$b}||-1)}