Skip to content

Commit

Permalink
Enable use of BEGIN phasers as r-values.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed Mar 1, 2012
1 parent 4536120 commit 2aa69ed
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Perl6/Actions.pm
Expand Up @@ -880,7 +880,7 @@ class Perl6::Actions is HLL::Actions {
make PAST::Var.new( :name('Nil'), :scope('lexical') );
}

method statement_prefix:sym<BEGIN>($/) { $*W.add_phaser($/, ($<blorst>.ast)<code_object>, 'BEGIN'); }
method statement_prefix:sym<BEGIN>($/) { make $*W.add_phaser($/, ($<blorst>.ast)<code_object>, 'BEGIN'); }
method statement_prefix:sym<CHECK>($/) { $*W.add_phaser($/, ($<blorst>.ast)<code_object>, 'CHECK'); }
method statement_prefix:sym<INIT>($/) { $*W.add_phaser($/, ($<blorst>.ast)<code_object>, 'INIT'); }
method statement_prefix:sym<END>($/) { $*W.add_phaser($/, ($<blorst>.ast)<code_object>, 'END'); }
Expand Down
3 changes: 2 additions & 1 deletion src/Perl6/World.pm
Expand Up @@ -1135,7 +1135,8 @@ class Perl6::World is HLL::World {
method add_phaser($/, $block, $phaser) {
if $phaser eq 'BEGIN' {
# BEGIN phasers get run immediately.
$block();
my $result := $block();
return self.add_constant_folded_result($result);
}
elsif $phaser eq 'CHECK' {
@*CHECK_PHASERS.unshift($block);
Expand Down

0 comments on commit 2aa69ed

Please sign in to comment.