Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Implement INIT as r-value.
  • Loading branch information
jnthn committed Nov 5, 2012
1 parent 64208d7 commit 0dd4514
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Perl6/Actions.pm
Expand Up @@ -966,7 +966,7 @@ class Perl6::Actions is HLL::Actions does STDActions {

method statement_prefix:sym<BEGIN>($/) { make $*W.add_phaser($/, 'BEGIN', ($<blorst>.ast)<code_object>); }
method statement_prefix:sym<CHECK>($/) { make $*W.add_phaser($/, 'CHECK', ($<blorst>.ast)<code_object>); }
method statement_prefix:sym<INIT>($/) { make $*W.add_phaser($/, 'INIT', ($<blorst>.ast)<code_object>); }
method statement_prefix:sym<INIT>($/) { make $*W.add_phaser($/, 'INIT', ($<blorst>.ast)<code_object>, ($<blorst>.ast)<past_block>); }
method statement_prefix:sym<START>($/) { make $*W.add_phaser($/, 'START', ($<blorst>.ast)<code_object>); }
method statement_prefix:sym<ENTER>($/) { make $*W.add_phaser($/, 'ENTER', ($<blorst>.ast)<code_object>); }
method statement_prefix:sym<FIRST>($/) { make $*W.add_phaser($/, 'FIRST', ($<blorst>.ast)<code_object>); }
Expand Down
26 changes: 21 additions & 5 deletions src/Perl6/World.pm
Expand Up @@ -1397,12 +1397,28 @@ class Perl6::World is HLL::World {
return $result_node;
}
elsif $phaser eq 'INIT' {
unless $*UNIT.symbol('!INIT_VALUES') {
my $mu := self.find_symbol(['Mu']);
my %info;
%info<container_type> := %info<container_base> := self.find_symbol(['Hash']);
%info<bind_constraint> := self.find_symbol(['Associative']);
%info<value_type> := $mu;
self.install_lexical_container($*UNIT, '!INIT_VALUES', %info,
self.create_container_descriptor($mu, 1, '!INIT_VALUES'));
}
$*UNIT[0].push(QAST::Op.new(
:op('call'),
QAST::WVal.new( :value($block) )
));
# XXX should keep value for r-value usage
return QAST::Var.new(:name('Nil'), :scope('lexical'));
:op('callmethod'), :name('bind_key'),
QAST::Var.new( :name('!INIT_VALUES'), :scope('lexical') ),
QAST::SVal.new( :value($phaser_past.cuid) ),
QAST::Op.new(
:op('call'),
QAST::WVal.new( :value($block) )
)));
return QAST::Op.new(
:op('callmethod'), :name('at_key'),
QAST::Var.new( :name('!INIT_VALUES'), :scope('lexical') ),
QAST::SVal.new( :value($phaser_past.cuid) )
);
}
elsif $phaser eq 'END' {
$*UNIT[0].push(QAST::Op.new(
Expand Down

0 comments on commit 0dd4514

Please sign in to comment.