Skip to content
Permalink
Browse files

Track usages of $_ during topic preservation

Once we will lower $_, then we shall need to be able to update these
references.
  • Loading branch information...
jnthn committed Jan 3, 2019
1 parent 83c2070 commit ab7f07dbbebc8354e545f076114ecbe66457e604
Showing with 4 additions and 2 deletions.
  1. +4 −2 src/Perl6/Optimizer.nqp
@@ -2908,15 +2908,17 @@ class Perl6::Optimizer {
if $preserve_topic {
my $pres_topic_name := QAST::Node.unique('pres_topic_');
$outer[0].push(QAST::Var.new( :scope('local'), :name($pres_topic_name), :decl('var') ));
my $topic_lex := QAST::Var.new( :name('$_'), :scope('lexical') );
@!block_var_stack[nqp::elems(@!block_var_stack) - 1].add_usage($topic_lex);
return QAST::Stmts.new(
:resultchild(1),
QAST::Op.new( :op('bind'),
QAST::Var.new( :name($pres_topic_name), :scope('local') ),
QAST::Var.new( :name('$_'), :scope('lexical') )
$topic_lex
),
$stmts,
QAST::Op.new( :op('bind'),
QAST::Var.new( :name('$_'), :scope('lexical') ),
$topic_lex,
QAST::Var.new( :name($pres_topic_name), :scope('local') )
)
);

0 comments on commit ab7f07d

Please sign in to comment.
You can’t perform that action at this time.