mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
7c097dc891
commit
8818447867
2 changed files with 20 additions and 57 deletions
|
@ -1,3 +1,12 @@
|
|||
Wed Mar 10 16:28:42 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* 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 <matz@ruby-lang.org>
|
||||
|
||||
* struct.c (rb_struct_s_def): Struct::new executes block with
|
||||
|
|
68
eval.c
68
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:
|
||||
|
|
Loading…
Reference in a new issue