Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix code-gen of nested whatever curries.
Makes this construct work on MoarVM, and may be more efficient on
other backends.
  • Loading branch information
jnthn committed Jan 23, 2014
1 parent 2834f75 commit 75f0284
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/Perl6/Actions.nqp
Expand Up @@ -6508,6 +6508,11 @@ class Perl6::Actions is HLL::Actions does STDActions {
}
nqp::push(@old_args, $new);
} else {
# Have to move the nested thunk inside this one, to get the
# correct lexical scoping.
my $old_ast := $old<past_block>;
remove_block($*W.cur_lexpad(), $old_ast);
$block[0].push($old_ast);
$new := QAST::Op.new( :op<call>, :node($/), $old );
my $acount := 0;
while $acount < $old.arity {
Expand Down Expand Up @@ -6557,6 +6562,20 @@ class Perl6::Actions is HLL::Actions does STDActions {
}
$past
}
sub remove_block($from, $block) {
# Remove the QAST::Block $block from $from[0]; die if not found.
my @decls := $from[0].list;
my int $i := 0;
my int $n := nqp::elems(@decls);
while $i < $n {
if @decls[$i] =:= $block {
@decls[$i] := QAST::Op.new( :op('null') );
return 1;
}
$i++;
}
nqp::die('Internal error: failed to remove block');
}

sub wrap_return_type_check($wrappee, $code_obj) {
QAST::Op.new(
Expand Down

0 comments on commit 75f0284

Please sign in to comment.