Skip to content

Commit ef8fa52

Browse files
committed
Teach as_mast_constant about QAST::Want.
Makes some of the nqp::ops usable from Rakudo that previously weren't.
1 parent 773a92b commit ef8fa52

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/vm/moar/QAST/QASTCompilerMAST.nqp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,6 +1414,18 @@ my class MASTCompilerInstance {
14141414
multi method as_mast_constant(QAST::NVal $nv) {
14151415
MAST::NVal.new( :value($nv.value) )
14161416
}
1417+
multi method as_mast_constant(QAST::Want $want) {
1418+
my int $finger := 1;
1419+
my @children := $want.list;
1420+
while $finger < nqp::elems(@children) {
1421+
my str $got := @children[$finger];
1422+
if $got eq 'Ss' || $got eq 'Ii' || $got eq 'Nn' {
1423+
return self.as_mast_constant(@children[$finger + 1]);
1424+
}
1425+
$finger := $finger + 2;
1426+
}
1427+
return self.as_mast_constant(@children[0]);
1428+
}
14171429
multi method as_mast_constant(QAST::Node $qast) {
14181430
nqp::die("expected QAST constant; didn't get one");
14191431
}

0 commit comments

Comments
 (0)