diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-03-10 07:32:37 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-03-10 07:32:37 +0000 |
commit | 881844786748c130b364bd935e968f4ab82aeaa5 (patch) | |
tree | 24db84ba2e520d93e893597a138bb5bda7a60d37 /eval.c | |
parent | 7c097dc8914e035dc4e1fb6913064e59fcb3d08c (diff) | |
download | ruby-881844786748c130b364bd935e968f4ab82aeaa5.tar.gz |
* eval.c (return_jump): set return value to the return
destination. separated from localjump_destination().
* eval.c (break_jump): break innermost loop (or thread or proc).
* eval.c (rb_yield_0): set exit_value for block break.
* eval.c (eval): Only print backtrace if generating the backtrace
doesn't generate an exception. [ruby-core:02621]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5935 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 68 |
1 files changed, 11 insertions, 57 deletions
@@ -4505,42 +4505,6 @@ rb_f_block_given_p() static VALUE rb_eThreadError; -static void -localjump_jump(state, retval) - int state; - VALUE retval; -{ - struct tag *tt = prot_tag; - VALUE tag = (state == TAG_BREAK) ? PROT_LOOP : PROT_FUNC; - int yield = Qfalse; - - if (retval == Qundef) retval = Qnil; - while (tt) { - if (tt->tag == PROT_YIELD) { - yield = Qtrue; - tt = tt->prev; - } - if ((tt->tag == PROT_THREAD && state == TAG_BREAK) || - ((tt->tag == PROT_LAMBDA || tt->tag == PROT_LOOP) && - tt->frame->uniq == ruby_frame->uniq)) { - tt->dst = (VALUE)ruby_frame->uniq; - tt->retval = retval; - JUMP_TAG(state); - } - if (tt->tag == PROT_LAMBDA && !yield) { - tt->dst = (VALUE)tt->frame->uniq; - tt->retval = retval; - JUMP_TAG(state); - } - if (tt->tag == PROT_FUNC && tt->frame->uniq == ruby_frame->uniq) break; - if (tt->tag == PROT_THREAD) { - rb_raise(rb_eThreadError, "return jump can't across threads"); - } - tt = tt->prev; - } - jump_tag_but_local_jump(state, retval); -} - NORETURN(static void proc_jump_error(int, VALUE)); static void proc_jump_error(state, result) @@ -4621,26 +4585,6 @@ break_jump(retval) proc_jump_error(TAG_BREAK, retval); } -NORETURN(static void break_jump2 _((VALUE))); -static void -break_jump2(retval) - VALUE retval; -{ - struct tag *tt = prot_tag; - int yield = Qfalse; - - if (retval == Qundef) retval = Qnil; - while (tt) { - if (tt->tag == PROT_LOOP && tt->blkid == ruby_block->uniq) { - tt->dst = (VALUE)tt->frame->uniq; - tt->retval = retval; - JUMP_TAG(TAG_BREAK); - } - tt = tt->prev; - } - proc_jump_error(TAG_BREAK, retval); -} - static VALUE rb_yield_0(val, self, klass, flags, avalue) VALUE val, self, klass; /* OK */ @@ -4822,7 +4766,17 @@ rb_yield_0(val, self, klass, flags, avalue) break; case TAG_BREAK: if (!lambda) { - break_jump2(result); + struct tag *tt = prot_tag; + + while (tt) { + if (tt->tag == PROT_LOOP && tt->blkid == ruby_block->uniq) { + tt->dst = (VALUE)tt->frame->uniq; + tt->retval = result; + JUMP_TAG(TAG_BREAK); + } + tt = tt->prev; + } + proc_jump_error(TAG_BREAK, result); } /* fall through */ default: |