Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make use of QAST::Want v when processing statement lists.
  • Loading branch information
jnthn committed Jul 21, 2012
1 parent a3fbc99 commit 1668e70
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/QAST/Compiler.nqp
Expand Up @@ -492,7 +492,11 @@ class QAST::Compiler is HLL::Compiler {
my $last;
my $ops := self.post_new('Ops');
my $i := 0;
my $n := +@stmts;
for @stmts {
if nqp::istype($_, QAST::Want) && $i + 1 < $n {
$_ := want($_, 'v');
}
$last := self.as_post($_);
$ops.push($last);
if nqp::defined($resultchild) && $resultchild == $i {
Expand All @@ -506,6 +510,17 @@ class QAST::Compiler is HLL::Compiler {
$ops
}

sub want($node, $type) {
my @possibles := nqp::clone($node.list);
my $best := @possibles.shift;
for @possibles -> $sel, $ast {
if $sel eq $type {
$best := $ast;
}
}
$best
}

multi method as_post(QAST::Op $node) {
my $hll := '';
try $hll := $*HLL;
Expand Down

0 comments on commit 1668e70

Please sign in to comment.