Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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
arnsholt committed Mar 14, 2013
1 parent fb2a2fd commit 0b76d55
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions src/QAST/Operations.nqp
Expand Up @@ -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 {
Expand Down

0 comments on commit 0b76d55

Please sign in to comment.