diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-10-20 08:33:49 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-10-20 08:33:49 +0000 |
commit | 6eb98c5ebe264eb0be6488c7db875137a44d8279 (patch) | |
tree | 8c8b6e6962798bc57a9519a6f140b79c009ee050 | |
parent | 8405551e6d05c08c4e6a25672e009d349d888aa1 (diff) |
* eval.c (PUSH_FRAME): generate unique number to be TAG_JUMP()
destination.
* eval.c (localjump_destination): use unique number in ruby_frame
for localjump destination.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4811 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | env.h | 1 | ||||
-rw-r--r-- | eval.c | 26 | ||||
-rw-r--r-- | test/ruby/test_iterator.rb | 2 |
4 files changed, 24 insertions, 13 deletions
@@ -1,3 +1,11 @@ +Mon Oct 20 17:31:46 2003 Yukihiro Matsumoto <matz@ruby-lang.org> + + * eval.c (PUSH_FRAME): generate unique number to be TAG_JUMP() + destination. + + * eval.c (localjump_destination): use unique number in ruby_frame + for localjump destination. + Mon Oct 20 11:31:44 2003 Nobuyoshi Nakada <nobu@ruby-lang.org> * test/ruby/test_signal.rb (test_signal): restore old trap. @@ -25,6 +25,7 @@ extern struct FRAME { struct RNode *node; int iter; int flags; + unsigned long uniq; } *ruby_frame; void rb_gc_mark_frame _((struct FRAME *)); @@ -604,6 +604,8 @@ struct SCOPE *ruby_scope; static struct FRAME *top_frame; static struct SCOPE *top_scope; +static unsigned long frame_unique = 0; + #define PUSH_FRAME() do { \ struct FRAME _frame; \ _frame.prev = ruby_frame; \ @@ -613,6 +615,7 @@ static struct SCOPE *top_scope; _frame.argc = 0; \ _frame.argv = 0; \ _frame.flags = FRAME_ALLOCA; \ + _frame.uniq = frame_unique++; \ ruby_frame = &_frame #define POP_FRAME() \ @@ -875,7 +878,7 @@ static struct tag *prot_tag; prot_tag = _tag.prev; \ } while (0) -#define TAG_DST() (_tag.dst == (VALUE)_tag.scope) +#define TAG_DST() (_tag.dst == (VALUE)ruby_frame->uniq) #define TAG_RETURN 0x1 #define TAG_BREAK 0x2 @@ -2448,7 +2451,7 @@ class_prefix(self, cpath) }\ } while (0) -NORETURN(static void localjump_destination _((int, struct SCOPE*, VALUE))); +NORETURN(static void localjump_destination _((int, VALUE))); static VALUE rb_eval(self, n) @@ -2771,7 +2774,7 @@ rb_eval(self, n) break; case NODE_BREAK: - localjump_destination(TAG_BREAK, ruby_scope, rb_eval(self, node->nd_stts)); + localjump_destination(TAG_BREAK, rb_eval(self, node->nd_stts)); break; case NODE_NEXT: @@ -2952,7 +2955,7 @@ rb_eval(self, n) break; case NODE_RETURN: - localjump_destination(TAG_RETURN, ruby_scope, rb_eval(self, node->nd_stts)); + localjump_destination(TAG_RETURN, rb_eval(self, node->nd_stts)); break; case NODE_ARGSCAT: @@ -3106,7 +3109,7 @@ rb_eval(self, n) break; case TAG_RETURN: case TAG_BREAK: - localjump_destination(state, ruby_scope, result); + localjump_destination(state, result); default: JUMP_TAG(state); } @@ -3882,7 +3885,7 @@ rb_f_abort(argc, argv) void rb_iter_break() { - localjump_destination(TAG_BREAK, ruby_scope, Qnil); + localjump_destination(TAG_BREAK, Qnil); } NORETURN(static void rb_longjmp _((int, VALUE))); @@ -4056,9 +4059,8 @@ rb_f_block_given_p() static VALUE rb_eThreadError; static void -localjump_destination(state, scope, retval) +localjump_destination(state, retval) int state; - struct SCOPE *scope; VALUE retval; { struct tag *tt = prot_tag; @@ -4067,12 +4069,12 @@ localjump_destination(state, scope, retval) if (retval == Qundef) retval = Qnil; while (tt) { if (tt->tag == PROT_PCALL || (tt->tag == PROT_THREAD && state == TAG_BREAK) || - (tt->tag == PROT_CALL || tt->tag == tag) && tt->scope == scope) { - tt->dst = (VALUE)scope; + (tt->tag == PROT_CALL || tt->tag == tag) && tt->frame->uniq == ruby_frame->uniq) { + tt->dst = (VALUE)ruby_frame->uniq; tt->retval = retval; JUMP_TAG(state); } - if (tt->tag == PROT_FUNC && tt->scope == scope) break; + 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"); } @@ -7087,7 +7089,7 @@ proc_invoke(proc, args, self, klass) localjump_error(mesg, result, state); } if (result != Qundef) { - localjump_destination(state, ruby_scope, result); + localjump_destination(state, result); } default: JUMP_TAG(state); diff --git a/test/ruby/test_iterator.rb b/test/ruby/test_iterator.rb index f91bf81644..60bfad50a9 100644 --- a/test/ruby/test_iterator.rb +++ b/test/ruby/test_iterator.rb @@ -419,7 +419,7 @@ class TestIterator < Test::Unit::TestCase def test_return_trace_func ok = "returned gracefully" result = "skipped" - result = _test_return_from_builtin(ok) + result = _test_return_trace_func(ok) ensure assert_equal(ok, result) return |