Commit e91b6a03 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge pull request #4080 from 'ukrainskiysergey-node_negate_fix'

parents 98c759e8 441ff45a
...@@ -2406,12 +2406,11 @@ codegen(codegen_scope *s, node *tree, int val) ...@@ -2406,12 +2406,11 @@ codegen(codegen_scope *s, node *tree, int val)
case NODE_NEGATE: case NODE_NEGATE:
{ {
nt = nint(tree->car); nt = nint(tree->car);
tree = tree->cdr;
switch (nt) { switch (nt) {
#ifndef MRB_WITHOUT_FLOAT #ifndef MRB_WITHOUT_FLOAT
case NODE_FLOAT: case NODE_FLOAT:
if (val) { if (val) {
char *p = (char*)tree; char *p = (char*)tree->cdr;
mrb_float f = mrb_float_read(p, NULL); mrb_float f = mrb_float_read(p, NULL);
int off = new_lit(s, mrb_float_value(s->mrb, -f)); int off = new_lit(s, mrb_float_value(s->mrb, -f));
...@@ -2423,8 +2422,8 @@ codegen(codegen_scope *s, node *tree, int val) ...@@ -2423,8 +2422,8 @@ codegen(codegen_scope *s, node *tree, int val)
case NODE_INT: case NODE_INT:
if (val) { if (val) {
char *p = (char*)tree->car; char *p = (char*)tree->cdr->car;
int base = nint(tree->cdr->car); int base = nint(tree->cdr->cdr->car);
mrb_int i; mrb_int i;
mrb_bool overflow; mrb_bool overflow;
...@@ -2455,13 +2454,11 @@ codegen(codegen_scope *s, node *tree, int val) ...@@ -2455,13 +2454,11 @@ codegen(codegen_scope *s, node *tree, int val)
default: default:
if (val) { if (val) {
int sym = new_sym(s, mrb_intern_lit(s->mrb, "-")); int sym = new_sym(s, mrb_intern_lit(s->mrb, "-@"));
genop_1(s, OP_LOADI_0, cursp());
push();
codegen(s, tree, VAL); codegen(s, tree, VAL);
pop(); pop(); pop();
genop_2(s, OP_SUB, cursp(), sym); genop_3(s, OP_SEND, cursp(), sym, 0);
push();
} }
else { else {
codegen(s, tree, NOVAL); codegen(s, tree, NOVAL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment