Skip to content

Commit

Permalink
support break from fiber block; fix #1766
Browse files Browse the repository at this point in the history
  • Loading branch information
matz authored and cremno committed Mar 4, 2014
1 parent 535c636 commit 9bb2eba
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/vm.c
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 9bb2eba

Please sign in to comment.