Skip to content

Commit

Permalink
want feed ops wantonly
Browse files Browse the repository at this point in the history
  • Loading branch information
TimToady committed Dec 16, 2015
1 parent a5bf8f5 commit 99294ba
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/Perl6/Actions.nqp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use Perl6::Ops;
use QRegex;
use QAST;

my $wantwant := NQPMu;
my $wantwant := Mu;

sub block_closure($code) {
my $closure := QAST::Op.new(
Expand Down Expand Up @@ -80,7 +80,7 @@ sub wanted($ast,$by) {
$ast.annotate('past_block', wanted($ast.ann('past_block'), $byby));
$ast.annotate('WANTED',1);
}
elsif $ast.op eq 'call' || $ast.op eq 'callstatic' || $ast.op eq 'handle' {
elsif $ast.op eq 'call' || $ast.op eq 'callstatic' || $ast.op eq 'callmethod' || $ast.op eq 'handle' || $ast.op eq 'locallifetime' {
$ast[0] := WANTED($ast[0], $byby) if +@($ast);
}
elsif $ast.op eq 'while' {
Expand Down Expand Up @@ -114,10 +114,13 @@ sub wanted($ast,$by) {
}

sub WANTED($ast, $by) {
if nqp::isconcrete($ast) {
if nqp::istype($ast, QAST::Node) {
$ast := wanted($ast, $by ~ ' W');
$ast.annotate('WANTED',1); # force in case it's just a thunk
}
else {
note("Non ast passed to WANTED: " ~ $ast.HOW.name($ast));
}
$ast;
}

Expand Down Expand Up @@ -153,7 +156,7 @@ sub unwanted($ast, $by) {
$ast.annotate('past_block', unwanted($ast.ann('past_block'), $byby));
$ast.annotate('context','sink');
}
elsif $ast.op eq 'call' {
elsif $ast.op eq 'call' || $ast.op eq 'callstatic' || $ast.op eq 'callmethod' || $ast.op eq 'handle' || $ast.op eq 'locallifetime' {
$ast[0] := UNWANTED($ast[0], $byby) if +@($ast);
}
elsif $ast.op eq 'while' {
Expand Down Expand Up @@ -183,10 +186,13 @@ sub unwanted($ast, $by) {
}

sub UNWANTED($ast, $by) {
if nqp::isconcrete($ast) {
if nqp::istype($ast, QAST::Node) {
$ast := unwanted($ast, $by ~ ' U');
$ast.annotate('context','sink'); # force in case it's just a thunk
}
else {
note("Non ast passed to UNWANTED: " ~ $ast.HOW.name($ast));
}
$ast;
}

Expand Down Expand Up @@ -6041,10 +6047,10 @@ Compilation unit '$file' contained the following violations:
# Assemble into list of AST of each step in the pipeline.
my @stages;
if $/<infix><sym> eq '==>' {
for @($/) { @stages.push($_.ast); }
for @($/) { @stages.push(WANTED($_.ast,'==>')); }
}
elsif $/<infix><sym> eq '<==' {
for @($/) { @stages.unshift($_.ast); }
for @($/) { @stages.unshift(WANTED($_.ast,'<==')); }
}
else {
$*W.throw($/, 'X::Comp::NYI',
Expand Down Expand Up @@ -6099,6 +6105,7 @@ Compilation unit '$file' contained the following violations:
$result := $_;
}

WANTED($result,'make_feed');
$result
}

Expand Down

0 comments on commit 99294ba

Please sign in to comment.