Skip to content

Commit

Permalink
Fixed a bug in NODE_XSTR code generation; fix #3605
Browse files Browse the repository at this point in the history
  • Loading branch information
matz committed Apr 12, 2017
1 parent 4e84bdb commit 3123549
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions mrbgems/mruby-compiler/core/codegen.c
Original file line number Diff line number Diff line change
Expand Up @@ -2377,9 +2377,7 @@ codegen(codegen_scope *s, node *tree, int val)
int ai = mrb_gc_arena_save(s->mrb);
int sym = new_sym(s, mrb_intern_lit(s->mrb, "Kernel"));

if (val == NOVAL) { push(); }
genop(s, MKOP_A(OP_OCLASS, cursp()));
genop(s, MKOP_ABx(OP_GETMCNST, cursp(), sym));
genop(s, MKOP_A(OP_LOADSELF, cursp()));
push();
codegen(s, tree->car, VAL);
n = tree->cdr;
Expand All @@ -2394,12 +2392,11 @@ codegen(codegen_scope *s, node *tree, int val)
push();
n = n->cdr;
}
pop();
pop();
push(); /* for block */
pop_n(3);
sym = new_sym(s, mrb_intern_lit(s->mrb, "`"));
genop(s, MKOP_ABC(OP_SEND, cursp(), sym, 1));
if (val == NOVAL) { pop(); }
else { push(); }
if (val) push();
mrb_gc_arena_restore(s->mrb, ai);
}
break;
Expand All @@ -2409,19 +2406,17 @@ codegen(codegen_scope *s, node *tree, int val)
char *p = (char*)tree->car;
size_t len = (intptr_t)tree->cdr;
int ai = mrb_gc_arena_save(s->mrb);
int sym = new_sym(s, mrb_intern_lit(s->mrb, "Kernel"));
int off = new_lit(s, mrb_str_new(s->mrb, p, len));
int sym;

if (val == NOVAL) { push(); }
genop(s, MKOP_A(OP_OCLASS, cursp()));
genop(s, MKOP_ABx(OP_GETMCNST, cursp(), sym));
genop(s, MKOP_A(OP_LOADSELF, cursp()));
push();
genop(s, MKOP_ABx(OP_STRING, cursp(), off));
pop();
push(); push();
pop_n(3);
sym = new_sym(s, mrb_intern_lit(s->mrb, "`"));
genop(s, MKOP_ABC(OP_SEND, cursp(), sym, 1));
if (val == NOVAL) { pop(); }
else { push(); }
if (val) push();
mrb_gc_arena_restore(s->mrb, ai);
}
break;
Expand Down

0 comments on commit 3123549

Please sign in to comment.