Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Implement missing falsey(num) for MoarVM backend.
Closes #194.
  • Loading branch information
jnthn committed Jan 5, 2015
1 parent 806f945 commit 3933e32
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/vm/moar/NQP/Ops.nqp
Expand Up @@ -123,6 +123,14 @@ $ops.add_hll_op('nqp', 'falsey', -> $qastcomp, $op {
push_op(@ins, 'isfalse_s', $not_reg, $val.result_reg);
MAST::InstructionList.new(@ins, $not_reg, $MVM_reg_int64)
}
elsif $val.result_kind == $MVM_reg_num64 {
my $tmp_reg := $regalloc.fresh_register($MVM_reg_num64);
my $res_reg := $regalloc.fresh_register($MVM_reg_int64);
my @ins := $val.instructions;
push_op(@ins, 'const_n64', $tmp_reg, MAST::NVal.new( :value(0.0) ));
push_op(@ins, 'eq_n', $res_reg, $val.result_reg, $tmp_reg);
MAST::InstructionList.new(@ins, $res_reg, $MVM_reg_int64)
}
else {
nqp::die("This case of nqp falsey op NYI");
}
Expand Down
3 changes: 2 additions & 1 deletion t/nqp/13-op.t
Expand Up @@ -2,7 +2,7 @@

# checking basic operands and circumfix:( )

plan(32);
plan(33);

##Additive operators
ok( 1+2 == 3, 'Checking addition 1+2');
Expand Down Expand Up @@ -45,6 +45,7 @@ ok( ?(2 > 1) );
ok( !(2 > 3) );
ok( ?(2 >= 1) );
ok( !(2 >= 3) );
ok( !0.0 );

#Bitwise operators
ok( (1 +| 3) == 3, 'Checking 1 +| 3' );
Expand Down

0 comments on commit 3933e32

Please sign in to comment.