summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-compiler/core/codegen.c
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2017-04-13 00:38:47 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2017-04-13 00:38:47 +0900
commit3123549bcb3a7d76e2f890760fe4b36f50d415b5 (patch)
treeb9d86c77c6714a3b83edb29c3352c827b22ed47a /mrbgems/mruby-compiler/core/codegen.c
parent4e84bdb507885bd37b4b0fa6b6359ac8c8b7b886 (diff)
downloadmruby-3123549bcb3a7d76e2f890760fe4b36f50d415b5.tar.gz
mruby-3123549bcb3a7d76e2f890760fe4b36f50d415b5.zip
Fixed a bug in NODE_XSTR code generation; fix #3605
Diffstat (limited to 'mrbgems/mruby-compiler/core/codegen.c')
-rw-r--r--mrbgems/mruby-compiler/core/codegen.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/mrbgems/mruby-compiler/core/codegen.c b/mrbgems/mruby-compiler/core/codegen.c
index 901e87934..7d3785f36 100644
--- a/mrbgems/mruby-compiler/core/codegen.c
+++ b/mrbgems/mruby-compiler/core/codegen.c
@@ -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;
@@ -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;
@@ -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;