Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
visit more blocks with wanted/unwanted
(We still have a few that we don't get to, and so are relying on
the defaulting in the optimizer.  All in good time.)
  • Loading branch information
TimToady committed Dec 14, 2015
1 parent 90586ef commit 1d96ed3
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/Perl6/Actions.nqp
Expand Up @@ -37,6 +37,11 @@ sub wanted($ast) {
if nqp::istype($ast,QAST::Stmt) ||
nqp::istype($ast,QAST::Stmts)
{
my int $i := 0;
while $i < $e {
$ast[$i] := unwanted($ast[$i]);
++$i;
}
$ast[$e] := wanted($ast[$e]) if +@($ast) > 0;
$ast.annotate('WANTED',1);
}
Expand All @@ -50,6 +55,9 @@ sub wanted($ast) {
$ast.annotate('past_block', wanted($ast.ann('past_block')));
$ast.annotate('WANTED',1);
}
elsif nqp::istype($ast,QAST::Want) {
$ast.annotate('WANTED',1);
}
$ast;
}

Expand All @@ -69,7 +77,13 @@ sub unwanted($ast) {
if nqp::istype($ast,QAST::Stmt) ||
nqp::istype($ast,QAST::Stmts)
{
$ast[$e] := unwanted($ast[$e]) if +@($ast) > 0;
# Unwant all kids, not just last one, so we recurse into blocks and such,
# don't just rely on the optimizer to default to void.
my int $i := 0;
while $i <= $e {
$ast[$i] := unwanted($ast[$i]);
++$i;
}
$ast.annotate('context','sink');
}
elsif nqp::istype($ast,QAST::Block) {
Expand All @@ -87,6 +101,9 @@ sub unwanted($ast) {
$ast[1] := UNWANTED($ast[1]);
}
}
elsif nqp::istype($ast,QAST::Want) {
$ast.annotate('context','sink');
}
$ast;
}

Expand Down

0 comments on commit 1d96ed3

Please sign in to comment.