support break from fiber block; fix #1766

This commit is contained in:
Yukihiro "Matz" Matsumoto
2014-02-28 18:43:35 +09:00
parent 03fde35760
commit 6bd3d88edd
+8 -1
View File
@@ -955,7 +955,7 @@ mrb_context_run(mrb_state *mrb, struct RProc *proc, mrb_value self, unsigned int
if (!ci->target_class) { /* return from context modifying method (resume/yield) */
if (!MRB_PROC_CFUNC_P(ci[-1].proc)) {
proc = ci[-1].proc;
irep = ci[-1].proc->body.irep;
irep = proc->body.irep;
pool = irep->pool;
syms = irep->syms;
}
@@ -1359,6 +1359,13 @@ mrb_context_run(mrb_state *mrb, struct RProc *proc, mrb_value self, unsigned int
localjump_error(mrb, LOCALJUMP_ERROR_BREAK);
goto L_RAISE;
}
/* break from fiber block */
if (mrb->c->ci == mrb->c->cibase && mrb->c->ci->pc) {
struct mrb_context *c = mrb->c;
mrb->c = c->prev;
c->prev = NULL;
}
ci = mrb->c->ci = mrb->c->cibase + proc->env->cioff + 1;
break;
default: