1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* eval.c (struct tag): dst should be VALUE.

* eval.c (localjump_destination): stop at the scope where the current
  block was created.  [ruby-dev:21353]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4539 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2003-09-09 01:39:58 +00:00
parent 9edcc5e99a
commit 80edcf82a1
3 changed files with 19 additions and 10 deletions

View file

@ -1,3 +1,12 @@
Tue Sep 9 10:39:51 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (struct tag): dst should be VALUE.
Tue Sep 9 10:39:51 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (localjump_destination): stop at the scope where the current
block was created. [ruby-dev:21353]
Tue Sep 9 05:17:04 2003 GOTOU Yuuzou <gotoyuzo@notwork.org> Tue Sep 9 05:17:04 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/ossl_config.rb: avoid compile error in OpenSSL-0.9.6. * ext/openssl/ossl_config.rb: avoid compile error in OpenSSL-0.9.6.
@ -7,11 +16,11 @@ Tue Sep 9 01:50:45 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
* lib/webrick/httpserver.rb (HTTPServer#access_log): add "\n" to * lib/webrick/httpserver.rb (HTTPServer#access_log): add "\n" to
the message. the message.
* lib/webrick/log.rb (BasicLog#log): add "\n" only if needed. * lib/webrick/log.rb (BasicLog#log): add "\n" only if needed.
Mon Sep 8 22:15:33 2003 <nagai@ai.kyutech.ac.jp> Mon Sep 8 22:15:33 2003 <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/multi-tk.rb: modify security check at creating * ext/tk/lib/multi-tk.rb: modify security check at creating
a new interpreter a new interpreter
Mon Sep 8 20:00:12 2003 Nobuyoshi Nakada <nobu@ruby-lang.org> Mon Sep 8 20:00:12 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>

11
eval.c
View file

@ -822,7 +822,7 @@ struct tag {
VALUE tag; VALUE tag;
VALUE retval; VALUE retval;
struct SCOPE *scope; struct SCOPE *scope;
int dst; VALUE dst;
struct tag *prev; struct tag *prev;
}; };
static struct tag *prot_tag; static struct tag *prot_tag;
@ -1520,6 +1520,7 @@ localjump_reason(exc)
return rb_iv_get(exc, "@reason"); return rb_iv_get(exc, "@reason");
} }
NORETURN(static void jump_tag_but_local_jump _((int)));
static void static void
jump_tag_but_local_jump(state) jump_tag_but_local_jump(state)
int state; int state;
@ -4023,18 +4024,16 @@ localjump_destination(state, scope, retval)
(tt->tag == PROT_CALL || tt->tag == tag) && tt->scope == scope) { (tt->tag == PROT_CALL || tt->tag == tag) && tt->scope == scope) {
tt->dst = (VALUE)scope; tt->dst = (VALUE)scope;
tt->retval = retval; tt->retval = retval;
break; JUMP_TAG(state);
} }
if (tt->tag == PROT_FUNC && tt->scope == scope) break;
if (tt->tag == PROT_THREAD) { if (tt->tag == PROT_THREAD) {
rb_raise(rb_eThreadError, "%s jump can't across threads", rb_raise(rb_eThreadError, "%s jump can't across threads",
(state == TAG_BREAK) ? "break" : "return"); (state == TAG_BREAK) ? "break" : "return");
} }
tt = tt->prev; tt = tt->prev;
} }
if (!tt) { jump_tag_but_local_jump(state);
jump_tag_but_local_jump(state);
}
JUMP_TAG(state);
} }
static VALUE static VALUE

View file

@ -179,7 +179,7 @@ class TestIterator < Test::Unit::TestCase
m(block_given?,&proc{}) m(block_given?,&proc{})
end end
def test_block_in_arg def test_block_given
assert(m1{p 'test'}) assert(m1{p 'test'})
assert(m2{p 'test'}) assert(m2{p 'test'})
assert(!m1()) assert(!m1())
@ -299,6 +299,7 @@ class TestIterator < Test::Unit::TestCase
lambda = lambda{44} lambda = lambda{44}
assert_raises(LocalJumpError) {get_block{break}.call} assert_raises(LocalJumpError) {get_block{break}.call}
assert_nothing_raised {lambda{break}.call} assert_nothing_raised {lambda{break}.call}
assert_instance_of(LocalJumpError, (get_block{break}.call rescue $!))
assert_equal(-1, block.arity) assert_equal(-1, block.arity)
assert_equal(-1, lambda.arity) assert_equal(-1, lambda.arity)
@ -319,7 +320,7 @@ class TestIterator < Test::Unit::TestCase
marity_test(:p) marity_test(:p)
lambda(&method(:assert)).call(true) lambda(&method(:assert)).call(true)
lambda(&get_block{|a,n| assert(a,n)}).call(true, 2) lambda(&get_block{|a,n| assert(a,n)}).call(true, "marity")
end end
class ITER_TEST1 class ITER_TEST1