Permalink
Browse files

Make nqp::list create NQPArrays rather than RPAs.

Unfortunately this means the self-compilation breaks, since some places rely
on nqp::list being an RPA. Fixing that remains to be done.
  • Loading branch information...
1 parent fb2a2fd commit 0b76d5528cffe0dea7e3a441ce4b22f8b756093a @arnsholt arnsholt committed Mar 14, 2013
Showing with 16 additions and 10 deletions.
  1. +16 −10 src/QAST/Operations.nqp
@@ -261,25 +261,31 @@ QAST::Operations.add_core_op('hlllist', :inlinable(1), -> $qastcomp, $op {
# Just invoke nqp::getlex to find the "NQPArray" type
$qastcomp.as_post(QAST::Op.new(
:op('getlex'),
- #$qastcomp.coerce('NQPArray', 's')
QAST::SVal.new(:value('NQPArray'))
));
});
QAST::Operations.add_core_op('list', :inlinable(1), -> $qastcomp, $op {
# Create register for the resulting list and make an empty one.
- my $list_reg := $*REGALLOC.fresh_p();
- my $ops := PIRT::Ops.new(:result($list_reg));
- $ops.push_pirop('new', $list_reg, "'ResizablePMCArray'");
+ my $arr := $qastcomp.as_post(QAST::Op.new(:op('create'), QAST::Op.new(:op('hlllist'))));
# Push all the things.
- for $op.list {
- my $post := $qastcomp.coerce($qastcomp.as_post($_), 'P');
- $ops.push($post);
- $ops.push_pirop('push', $list_reg, $post.result);
+ if +$op.list {
+ my $list_reg := $*REGALLOC.fresh_p();
+ my $ops := PIRT::Ops.new(:result($list_reg));
+ $ops.push_pirop('assign', $list_reg, $arr);
+
+ for $op.list {
+ my $post := $qastcomp.coerce($qastcomp.as_post($_), 'P');
+ $ops.push($post);
+ $ops.push_pirop('push', $list_reg, $post.result);
+ }
+
+ $ops
+ }
+ else {
+ $arr
}
-
- $ops
});
QAST::Operations.add_core_op('qlist', :inlinable(1), -> $qastcomp, $op {

0 comments on commit 0b76d55

Please sign in to comment.