From 881844786748c130b364bd935e968f4ab82aeaa5 Mon Sep 17 00:00:00 2001 From: matz Date: Wed, 10 Mar 2004 07:32:37 +0000 Subject: * 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 --- eval.c | 68 +++++++++++------------------------------------------------------- 1 file changed, 11 insertions(+), 57 deletions(-) (limited to 'eval.c') diff --git a/eval.c b/eval.c index 8cca8c68f9..d308a2b8e1 100644 --- a/eval.c +++ b/eval.c @@ -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: -- cgit v1.2.3