mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Restore the value of ci->cci with fiber_switch()
If `mrb_fiber_resume()` was called from a C function as a method definition, the mruby VM was not processed afterwards.
Called Fiber.yield
mrb_vm_exec() <<-- returns from the function by CINFO_RESUMED
fiber_switch() <<-- this patch causes the value to return to its pre-call state
mrb_fiber_resume()
mrb_vm_exec() <<-- previously, returns from the function immediately as it was CINFO_RESUMED
...
main()
This commit is contained in:
@@ -277,9 +277,11 @@ fiber_switch(mrb_state *mrb, mrb_value self, mrb_int len, const mrb_value *a, mr
|
||||
}
|
||||
|
||||
if (vmexec) {
|
||||
int cci = old_c->ci->cci;
|
||||
c->vmexec = TRUE;
|
||||
value = mrb_vm_exec(mrb, c->ci->proc, c->ci->pc);
|
||||
mrb->c = old_c;
|
||||
old_c->ci->cci = cci; /* restore values as they may have changed in Fiber.yield */
|
||||
}
|
||||
else {
|
||||
MARK_CONTEXT_MODIFY(c);
|
||||
|
||||
Reference in New Issue
Block a user