Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Prepare QAST -> JVM compiler for closure changes.
We'll experiment with this on MoarVM first; this just does enough to
have QAST -> JVM not choke on some small changes to NQP.
  • Loading branch information
jnthn committed Sep 27, 2013
1 parent 8bcdb14 commit f19118f
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/vm/jvm/QAST/Compiler.nqp
Expand Up @@ -729,11 +729,11 @@ for <if unless> -> $op_name {

# See if any immediate block wants to be passed the condition.
my $im_then := nqp::istype($op[1], QAST::Block) &&
$op[1].blocktype eq 'immediate' &&
($op[1].blocktype eq 'immediate' || $op[1].blocktype eq 'immediate_static') &&
$op[1].arity > 0;
my $im_else := $operands == 3 &&
nqp::istype($op[2], QAST::Block) &&
$op[2].blocktype eq 'immediate' &&
($op[2].blocktype eq 'immediate' || $op[2].blocktype eq 'immediate_static') &&
$op[2].arity > 0;

# Create labels and a place to store the overall result.
Expand Down Expand Up @@ -1026,7 +1026,7 @@ for ('', 'repeat_') -> $repness {

# See if there's an immediate block wanting to be passed the condition.
my $has_im := nqp::istype(@operands[1], QAST::Block) &&
@operands[1].blocktype eq 'immediate' &&
(@operands[1].blocktype eq 'immediate' || @operands[1].blocktype eq 'immediate_static') &&
@operands[1].arity > 0;

# Create labels.
Expand Down Expand Up @@ -1178,6 +1178,9 @@ QAST::OperationsJAST.add_core_op('for', -> $qastcomp, $op {
if @operands[1].blocktype eq 'immediate' {
@operands[1].blocktype('declaration');
}
elsif @operands[1].blocktype eq 'immediate_static' {
@operands[1].blocktype('declaration_static');
}

# Create result temporary if we'll need one.
my $res := $*WANT == $RT_VOID ?? 0 !! $*TA.fresh_o();
Expand Down Expand Up @@ -3555,10 +3558,10 @@ class QAST::CompilerJAST {
# the top-level, where we need no result.
if nqp::istype((try $*STACK), StackState) {
my $blocktype := $node.blocktype;
if $blocktype eq '' || $blocktype eq 'declaration' {
if $blocktype eq '' || $blocktype eq 'declaration' || $blocktype eq 'declaration_static' {
return self.as_jast(QAST::BVal.new( :value($node) ));
}
elsif $blocktype eq 'immediate' {
elsif $blocktype eq 'immediate' || $blocktype eq 'immediate_static' {
# Can emit a direct JVM level call. First, get self, TC,
# code ref, callsite descriptor and args (both empty) onto
# the stack.
Expand Down

0 comments on commit f19118f

Please sign in to comment.