diff --git a/Actions.pm b/Actions.pm index a515c7d..358a99a 100644 --- a/Actions.pm +++ b/Actions.pm @@ -6,6 +6,7 @@ package Actions; our $AUTOLOAD; my $SEQ = 1; +our %GENCLASS; sub AUTOLOAD { my $self = shift; @@ -392,6 +393,7 @@ sub gen_class { print STDERR "Existing class $class\n" if $OPT_log; return; } + $GENCLASS{$class} = $base; print STDERR "Creating class $class\n" if $OPT_log; @{$class . '::ISA'} = $base; } diff --git a/viv b/viv index bfe0961..30cc48b 100755 --- a/viv +++ b/viv @@ -103,6 +103,9 @@ sub MAIN { my $raw = retrieve($_[0]); $::ORIG = $raw->{ORIG}; $r = $raw->{AST}; + for my $cl (keys %{$raw->{GENCLASS}}) { + Actions::gen_class($cl, $raw->{GENCLASS}->{$cl}); + } } elsif (@_ and -f $_[0]) { $r = STD->parsefile($_[0], actions => 'Actions')->{'_ast'}; @@ -137,7 +140,8 @@ sub MAIN { print fixpod($r->ret(0,$r->emit_p5(0))); } elsif ($output eq 'store') { - Storable::store_fd({ AST => $r, ORIG => $::ORIG }, \*STDOUT); + Storable::store_fd({ AST => $r, GENCLASS => \%Actions::GENCLASS, + ORIG => $::ORIG }, \*STDOUT); } else { die "Unknown output mode";