Skip to content

Instantly share code, notes, and snippets.

@mrbrdo
Created October 14, 2014 15:19
Show Gist options
  • Save mrbrdo/d4d504fd3b222e229508 to your computer and use it in GitHub Desktop.
Save mrbrdo/d4d504fd3b222e229508 to your computer and use it in GitHub Desktop.
struct mrb_jmpbuf buf;
int stoff = mrb->c->stack - mrb->c->stbase;
int cioff = mrb->c->ci - mrb->c->cibase;
MRB_TRY(&buf) {
mrb->jmp = &buf;
}
MRB_CATCH(&buf) {
// if rescued from method that was called from this method
// and didn't have its own rescue
// fix global state, be careful if stbase or cibase changed
mrb->c->ci = mrb->c->cibase + cioff;
regs = mrb->c->stack = mrb->c->stbase + stoff;
// handle error
}
MRB_END_EXC(&buf);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment