Created
August 4, 2009 17:54
-
-
Save methodmissing/161379 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static void | |
| return_jump(retval) | |
| VALUE retval; | |
| { | |
| struct tag *tt = prot_tag; | |
| int yield = Qfalse; | |
| if (retval == Qundef) retval = Qnil; | |
| while (tt) { | |
| if (tt->tag == PROT_YIELD) { | |
| yield = Qtrue; | |
| tt = tt->prev; | |
| } | |
| if (tt->tag == PROT_FUNC && tt->frame->uniq == ruby_frame->uniq) { | |
| tt->dst = (VALUE)ruby_frame->uniq; | |
| tt->retval = retval; | |
| JUMP_TAG(TAG_RETURN); | |
| } | |
| if (tt->tag == PROT_LAMBDA && !yield) { | |
| tt->dst = (VALUE)tt->frame->uniq; | |
| tt->retval = retval; | |
| JUMP_TAG(TAG_RETURN); | |
| } | |
| if (tt->tag == PROT_THREAD) { | |
| rb_raise(rb_eThreadError, "return can't jump across threads"); | |
| } | |
| tt = tt->prev; | |
| } | |
| localjump_error("unexpected return", retval, TAG_RETURN); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct tag { | |
| rb_jmpbuf_t buf; | |
| struct FRAME *frame; | |
| struct iter *iter; | |
| VALUE tag; | |
| VALUE retval; | |
| struct SCOPE *scope; | |
| VALUE dst; | |
| struct tag *prev; | |
| int blkid; | |
| }; | |
| static struct tag *prot_tag; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment