diff --git a/ChangeLog b/ChangeLog index b3db26f8ab..d4253b0849 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Wed Mar 10 16:28:42 2004 Yukihiro Matsumoto + + * 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. + Wed Mar 10 16:00:14 2004 Yukihiro Matsumoto * struct.c (rb_struct_s_def): Struct::new executes block with 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: