Skip to content

Commit

Permalink
* eval.c (return_jump): set return value to the return
Browse files Browse the repository at this point in the history
  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
  • Loading branch information
matz committed Mar 10, 2004
1 parent 7c097dc commit 8818447
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 57 deletions.
9 changes: 9 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -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
Expand Down
68 changes: 11 additions & 57 deletions eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 8818447

Please sign in to comment.