resources/mruby/src/vm.c in esruby-0.0.9 vs resources/mruby/src/vm.c in esruby-0.0.10

- old
+ new

@@ -514,11 +514,11 @@ if (MRB_PROC_CFUNC_P(p)) { return MRB_PROC_CFUNC(p)(mrb, self); } ci->nregs = p->body.irep->nregs; if (ci->argc < 0) keep = 3; - else keep = ci->argc + 1; + else keep = ci->argc + 2; if (ci->nregs < keep) { stack_extend(mrb, keep); } else { stack_extend(mrb, ci->nregs); @@ -1349,10 +1349,11 @@ a = mrb->c->eidx - epos; pc = pc + 1; for (n=0; n<a; n++) { proc = mrb->c->ensure[epos+n]; mrb->c->ensure[epos+n] = NULL; + if (proc == NULL) continue; irep = proc->body.irep; ci = cipush(mrb); ci->mid = ci[-1].mid; ci->argc = 0; ci->proc = proc; @@ -1659,10 +1660,13 @@ mrb->c->stack[0] = recv; if (MRB_METHOD_CFUNC_P(m)) { mrb_value v; ci->nregs = (argc < 0) ? 3 : n+2; + if (MRB_METHOD_PROC_P(m)) { + ci->proc = MRB_METHOD_PROC(m); + } v = MRB_METHOD_CFUNC(m)(mrb, recv); mrb_gc_arena_restore(mrb, ai); if (mrb->exc) goto L_RAISE; ci = mrb->c->ci; if (!ci->target_class) { /* return from context modifying method (resume/yield) */ @@ -2932,12 +2936,9 @@ } CASE(OP_STOP) { /* stop VM */ L_STOP: - while (mrb->c->ci > mrb->c->cibase) { - cipop(mrb); - } while (mrb->c->eidx > 0) { ecall(mrb); } ERR_PC_CLR(mrb); mrb->jmp = prev_jmp;