Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Allow for itemization to prevent iteration for statement modfier for
foo() for $@arr; will now iterate only once, just like for $@arr { foo() }
Fixes t/spec/S04-statement-modifiers/for.t
  • Loading branch information
niner committed Sep 16, 2015
1 parent 9fb93a9 commit 197fbbf
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions src/Perl6/Actions.nqp
Expand Up @@ -871,15 +871,31 @@ Compilation unit '$file' contained the following violations:
unless $past.ann('past_block') {
$past := make_topic_block_ref($/, $past, migrate_stmt_id => $*STATEMENT_ID);
}
$past := QAST::Op.new(
:op<callmethod>, :name<map>, :node($/),
$cond,
block_closure($past)
);
my $for-list-name := QAST::Node.unique('for-list');
my $iscont := QAST::Op.new(:op('iscont'), QAST::Var.new( :name($for-list-name), :scope('local') ));
$iscont.named('item');
my $call := QAST::Op.new(
:op<callmethod>, :name<map>, :node($/),
QAST::Var.new( :name($for-list-name), :scope('local') ),
block_closure($past),
$iscont,
);
my $bind := QAST::Op.new(
:op('bind'),
QAST::Var.new( :name($for-list-name), :scope('local'), :decl('var') ),
$cond,
);
$past := QAST::Want.new(
QAST::Op.new( :op<callmethod>, :name<eager>, $past ),
'v', QAST::Op.new( :op<callmethod>, :name<sink>, $past ));
my $sinkee := $past[0];
QAST::Stmts.new(
$bind,
QAST::Op.new( :op<callmethod>, :name<eager>, $call )
),
'v', QAST::Stmts.new(
$bind,
QAST::Op.new( :op<callmethod>, :name<sink>, $call )
),
);
my $sinkee := $past[0][1];
$past.annotate('statement_level', -> { $sinkee.name('sink') });
}
else {
Expand Down

0 comments on commit 197fbbf

Please sign in to comment.