mirror of
https://github.com/verilator/verilator.git
synced 2025-01-10 08:37:35 +00:00
Commentary: Report children node types
This commit is contained in:
parent
7654add5e5
commit
954e127f1d
25
src/astgen
25
src/astgen
@ -7,7 +7,7 @@ use Getopt::Long;
|
||||
use IO::File;
|
||||
use Pod::Usage;
|
||||
use strict;
|
||||
use vars qw ($Debug @Types %Classes %ClassRefs %Stages);
|
||||
use vars qw ($Debug @Types %Classes %Children %ClassRefs %Stages);
|
||||
|
||||
#======================================================================
|
||||
# main
|
||||
@ -88,6 +88,7 @@ sub read_types {
|
||||
$class =~ s/^Ast//;
|
||||
$inh =~ s/^Ast//;
|
||||
$Classes{$class} = $inh;
|
||||
$Children{$inh}{$class} = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -152,6 +153,22 @@ sub subclasses_of {
|
||||
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 {
|
||||
@ -172,6 +189,12 @@ sub write_report {
|
||||
printf $fh "Ast%-12s ",$subclass;
|
||||
}
|
||||
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}"}) {
|
||||
$fh->print("\tnewed:\t");
|
||||
foreach my $stage (sort {($Stages{$a}||-1) <=> ($Stages{$b}||-1)}
|
||||
|
Loading…
Reference in New Issue
Block a user