Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Implement nqp::neg_n
  • Loading branch information
pmurias committed Aug 16, 2014
1 parent 1ea1882 commit ae2122e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/vm/js/QAST/Compiler.nqp
Expand Up @@ -202,6 +202,11 @@ class QAST::OperationsJS {
# TODO - think about divide by zero
QAST::OperationsJS.add_infix_op('div_n', $T_NUM, '/', $T_NUM, $T_NUM);

QAST::OperationsJS.add_op('neg_n', sub ($comp, $node, :$want) {
my $num := $comp.as_js($node[0], :want($T_NUM));
Chunk.new($T_INT, "(-{$num.expr})" , [$num], :$node);
});

QAST::OperationsJS.add_infix_op('concat', $T_STR, '+', $T_STR, $T_STR);

QAST::OperationsJS.add_infix_op('isle_n', $T_NUM, '<=', $T_NUM, $T_BOOL);
Expand Down

0 comments on commit ae2122e

Please sign in to comment.