Skip to content

Commit

Permalink
Implement with/without for JVM backend
Browse files Browse the repository at this point in the history
  • Loading branch information
hoelzro committed Aug 12, 2015
1 parent 4de65a5 commit a8c8ee4
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/vm/jvm/QAST/Compiler.nqp
Expand Up @@ -724,7 +724,8 @@ sub boolify_instructions($il, $cond_type) {
$il.append($LCMP);
}
}
for <if unless> -> $op_name {
for <if unless with without> -> $op_name {
my $is_withy := $op_name eq 'with' || $op_name eq 'without';
QAST::OperationsJAST.add_core_op($op_name, -> $qastcomp, $op {
# Check operand count.
my $operands := +$op.list;
Expand Down Expand Up @@ -790,9 +791,18 @@ for <if unless> -> $op_name {
}

# Emit test.
boolify_instructions($il, $cond.type);
if $is_withy {
$il.append($ALOAD_1);
$il.append(JAST::Instruction.new(:op('invokestatic'),
$TYPE_OPS, 'isconcrete', 'Long', $TYPE_SMO, $TYPE_TC));
$il.append($IVAL_ZERO);
$il.append($LCMP);
}
else {
boolify_instructions($il, $cond.type);
}
$il.append(JAST::Instruction.new($else_lbl,
:op($op_name eq 'if' ?? 'ifeq' !! 'ifne')));
:op($op_name eq 'if' || $op_name eq 'with' ?? 'ifeq' !! 'ifne')));

# Compile the "then".
my $then;
Expand Down

0 comments on commit a8c8ee4

Please sign in to comment.