diff options
Diffstat (limited to 'src/codegen.c')
| -rw-r--r-- | src/codegen.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/src/codegen.c b/src/codegen.c index fc83244f2..83018c627 100644 --- a/src/codegen.c +++ b/src/codegen.c @@ -421,7 +421,7 @@ new_lit(codegen_scope *s, mrb_value val) case MRB_TT_FIXNUM: for (i=0; i<s->irep->plen; i++) { pv = &s->irep->pool[i]; - if (mrb_type(*pv) != MRB_TT_FIXNUM) continue; + if (!mrb_fixnum_p(*pv)) continue; if (mrb_fixnum(*pv) == mrb_fixnum(val)) return i; } break; @@ -661,7 +661,7 @@ scope_body(codegen_scope *s, node *tree, int val) { codegen_scope *scope = scope_new(s->mrb, s, tree->car); - codegen(scope, tree->cdr, val); + codegen(scope, tree->cdr, VAL); if (!s->iseq) { genop(scope, MKOP_A(OP_STOP, 0)); } @@ -674,9 +674,7 @@ scope_body(codegen_scope *s, node *tree, int val) genop(scope, MKOP_AB(OP_RETURN, 0, OP_R_NORMAL)); } else { - pop(); - genop_peep(scope, MKOP_AB(OP_RETURN, cursp(), OP_R_NORMAL), NOVAL); - push(); + genop_peep(scope, MKOP_AB(OP_RETURN, scope->sp-1, OP_R_NORMAL), NOVAL); } } scope_finish(scope); @@ -1388,7 +1386,12 @@ codegen(codegen_scope *s, node *tree, int val) if (head) { genop(s, MKOP_AB(OP_MOVE, cursp(), head)); pop(); - genop(s, MKOP_ABC(OP_SEND, cursp(), new_msym(s, mrb_intern_lit(s->mrb, "===")), 1)); + if ((intptr_t)n->car->car == NODE_SPLAT) { + genop(s, MKOP_ABC(OP_SEND, cursp(), new_msym(s, mrb_intern_lit(s->mrb, "__case_eqq")), 1)); + } + else { + genop(s, MKOP_ABC(OP_SEND, cursp(), new_msym(s, mrb_intern_lit(s->mrb, "===")), 1)); + } } else { pop(); @@ -1512,7 +1515,14 @@ codegen(codegen_scope *s, node *tree, int val) break; case NODE_SPLAT: - codegen(s, tree, VAL); + { + int idx = new_msym(s, mrb_intern_lit(s->mrb, "to_a")); + + codegen(s, tree, VAL); + pop(); + genop(s, MKOP_ABC(OP_SEND, cursp(), idx, 0)); + push(); + } break; case NODE_ASGN: @@ -2897,7 +2907,7 @@ codedump_recur(mrb_state *mrb, mrb_irep *irep) void codedump_all(mrb_state *mrb, struct RProc *proc) { - return codedump_recur(mrb, proc->body.irep); + codedump_recur(mrb, proc->body.irep); } struct RProc* |
