Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Teach as_mast_constant about QAST::Want.
Makes some of the nqp::ops usable from Rakudo that previously weren't.
  • Loading branch information
jnthn committed Feb 7, 2015
1 parent 773a92b commit ef8fa52
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/vm/moar/QAST/QASTCompilerMAST.nqp
Expand Up @@ -1414,6 +1414,18 @@ my class MASTCompilerInstance {
multi method as_mast_constant(QAST::NVal $nv) {
MAST::NVal.new( :value($nv.value) )
}
multi method as_mast_constant(QAST::Want $want) {
my int $finger := 1;
my @children := $want.list;
while $finger < nqp::elems(@children) {
my str $got := @children[$finger];
if $got eq 'Ss' || $got eq 'Ii' || $got eq 'Nn' {
return self.as_mast_constant(@children[$finger + 1]);
}
$finger := $finger + 2;
}
return self.as_mast_constant(@children[0]);
}
multi method as_mast_constant(QAST::Node $qast) {
nqp::die("expected QAST constant; didn't get one");
}
Expand Down

0 comments on commit ef8fa52

Please sign in to comment.