Skip to content

Commit

Permalink
[viv] Store generated class information in compiled files
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.pugscode.org/pugs@30820 c213334d-75ef-0310-aa23-eaa082d1ae64
  • Loading branch information
sorear committed May 26, 2010
1 parent c875dc8 commit 7af2d68
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Actions.pm
Expand Up @@ -6,6 +6,7 @@ package Actions;

our $AUTOLOAD;
my $SEQ = 1;
our %GENCLASS;

sub AUTOLOAD {
my $self = shift;
Expand Down Expand Up @@ -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;
}
Expand Down
6 changes: 5 additions & 1 deletion viv
Expand Up @@ -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'};
Expand Down Expand Up @@ -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";
Expand Down

0 comments on commit 7af2d68

Please sign in to comment.