Created
March 16, 2013 21:53
-
-
Save arnsholt/5178485 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
QAST::Operations.add_core_op('list', :inlinable(1), -> $qastcomp, $op { | |
# Create register for the resulting list and make an empty one. | |
my $arr := $qastcomp.as_post(QAST::Op.new(:op('create'), QAST::Op.new(:op('hlllist')))); | |
# Push all the things. | |
if +$op.list { | |
my $list_reg := $*REGALLOC.fresh_p(); | |
my $ops := PIRT::Ops.new(:result($list_reg)); | |
$ops.push_pirop('set', $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 | |
} | |
}); | |
QAST::Operations.add_core_op('list_b', :inlinable(1), -> $qastcomp, $op { | |
my $list := $qastcomp.as_post(QAST::Op.new(:op('list'))); | |
my $list_reg := $*REGALLOC.fresh_p(); | |
my $block_reg := $*REGALLOC.fresh_p(); | |
my $ops := PIRT::Ops.new(:result($list_reg)); | |
$ops.push_pirop('set', $list_reg, $list.result); | |
$ops.push_pirop('say "# Before list_b push"'); | |
for $op.list { | |
my $cuid := $_.cuid; | |
$ops.push_pirop('say " # Creating block"'); | |
$ops.push_pirop(".const 'Sub' $block_reg = \"$cuid\""); | |
$ops.push_pirop('say " # Pushing block"'); | |
$ops.push_pirop('push', $list_reg, $block_reg); | |
} | |
$ops.push_pirop('say "# After list_b push"'); | |
$ops | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment