[#25808] break & retry in block — Shin-ichiro HARA <sinara@...>

原です。

15 messages 2005/03/04

[#25812] Re: [ruby-cvs] ruby/test/ruby, ruby/test/logger, ruby/sample, ruby/misc, ruby/lib/xmlrpc, ruby/lib/wsdl/soap, ruby/lib/rexml, ruby/lib/rdoc/parsers, ruby/lib/rdoc/generators, ruby/lib/irb, ruby/lib, ruby/ext/zlib, ruby/ext/win32ole, ruby/ext/tk, ruby/ext/strscan, ruby/ext/socket, ruby/ext/readline, ruby/ext/pty, ruby/ext/openssl, ruby/ext/iconv, ruby/ext/etc, ruby/ext/dl, ruby/ext/curses, ruby/ext/bigdecimal, ruby/ext/Win32API, ruby: * array.c: replace rb_protect_inspect() and rb_inspecting_p() by — Tanaka Akira <akr@...17n.org>

In article <20050304064753.53859C671F@lithium.ruby-lang.org>,

3 messages 2005/03/06

[#25853] conflict method and local variable — Hidetoshi NAGAI <nagai@...>

永井@知能.九工大です.

56 messages 2005/03/10
[#25854] Re: conflict method and local variable — Yukihiro Matsumoto <matz@...> 2005/03/10

まつもと ゆきひろです

[#25855] Re: conflict method and local variable — Hidetoshi NAGAI <nagai@...> 2005/03/10

永井@知能.九工大です.

[#25856] Re: conflict method and local variable — Yukihiro Matsumoto <matz@...> 2005/03/10

まつもと ゆきひろです

[#25857] Re: conflict method and local variable — Hidetoshi NAGAI <nagai@...> 2005/03/11

永井@知能.九工大です.

[#25858] Re: conflict method and local variable — Yukihiro Matsumoto <matz@...> 2005/03/11

まつもと ゆきひろです

[#25861] Re: conflict method and local variable — Hidetoshi NAGAI <nagai@...> 2005/03/11

永井@知能.九工大です.

[#25863] Re: conflict method and local variable — Yukihiro Matsumoto <matz@...> 2005/03/11

まつもと ゆきひろです

[#25864] Re: conflict method and local variable — Hidetoshi NAGAI <nagai@...> 2005/03/11

永井@知能.九工大です.

[#25865] Re: conflict method and local variable — Yukihiro Matsumoto <matz@...> 2005/03/11

まつもと ゆきひろです

[#25866] Re: conflict method and local variable — Hidetoshi NAGAI <nagai@...> 2005/03/11

永井@知能.九工大です.

[#25869] Re: conflict method and local variable — Shugo Maeda <shugo@...> 2005/03/13

前田です。

[#25875] Re: conflict method and local variable — Yukihiro Matsumoto <matz@...> 2005/03/13

まつもと ゆきひろです

[#25878] Re: conflict method and local variable — Hidetoshi NAGAI <nagai@...> 2005/03/13

永井@知能.九工大です.

[#25882] Re: conflict method and local variable — Yukihiro Matsumoto <matz@...> 2005/03/13

まつもと ゆきひろです

[#25884] Re: conflict method and local variable — Hidetoshi NAGAI <nagai@...> 2005/03/14

永井@知能.九工大です.

[#25885] Re: conflict method and local variable — Yukihiro Matsumoto <matz@...> 2005/03/14

まつもと ゆきひろです

[#25888] Re: conflict method and local variable — Shugo Maeda <shugo@...> 2005/03/14

前田です。

[#25946] ext/tk/sample/**/*.gif are broken — "H.Yamamoto" <ocean@...2.ccsnet.ne.jp>

山本です。

16 messages 2005/03/27

[#25959] some trouble on ext/tk/sample — "H.Yamamoto" <ocean@...2.ccsnet.ne.jp>

山本です。

20 messages 2005/03/29
[#25969] Re: some trouble on ext/tk/sample — Hidetoshi NAGAI <nagai@...> 2005/03/30

永井@知能.九工大です.

[#25970] Re: some trouble on ext/tk/sample — "H.Yamamoto" <ocean@...2.ccsnet.ne.jp> 2005/03/30

山本です。

[#25973] Re: some trouble on ext/tk/sample — Hidetoshi NAGAI <nagai@...> 2005/03/31

永井@知能.九工大です.

[ruby-dev:25814] Re: [ruby-cvs] ruby/test/ruby, ruby/test/logger, ruby/sample, ruby/misc, ruby/lib/xmlrpc, ruby/lib/wsdl/soap, ruby/lib/rexml, ruby/lib/rdoc/parsers, ruby/lib/rdoc/generators, ruby/lib/irb, ruby/lib, ruby/ext/zlib, ruby/ext/win32ole, ruby/ext/tk, ruby/ext/strscan, ruby/ext/socket, ruby/ext/readline, ruby/ext/pty, ruby/ext/openssl, ruby/ext/iconv, ruby/ext/etc, ruby/ext/dl, ruby/ext/curses, ruby/ext/bigdecimal, ruby/ext/Win32API, ruby: * array.c: replace rb_protect_inspect() and rb_inspecting_p() by

From: nobu@...
Date: 2005-03-06 09:20:05 UTC
List: ruby-dev #25814
なかだです。

At Sun, 6 Mar 2005 12:57:25 +0900,
Tanaka Akir wrote in [ruby-dev:25812]:
> Ruby スクリプトから見える所に NODE を置くのはよろしくないんじゃないでしょうか。

とりあえずこんなところでどうでしょうか。

* eval.c (rb_exec_recursive): wrap recursive key NODE by Data class.
  fixed:  [ruby-dev:25812]

Index: eval.c
===================================================================
RCS file: /src/ruby/eval.c,v
retrieving revision 1.760
diff -u -2 -p -d -r1.760 eval.c
--- eval.c	5 Mar 2005 03:52:19 -0000	1.760
+++ eval.c	6 Mar 2005 09:15:19 -0000
@@ -4634,5 +4634,4 @@ static VALUE bmcall _((VALUE, VALUE));
 static int method_arity _((VALUE));
 
-/*:nodoc:*/
 static VALUE
 rb_yield_0(val, self, klass, flags, avalue)
@@ -12774,5 +12773,5 @@ thgroup_add(group, thread)
 /* variables for recursive traversals */
 static ID recursive_key;
-static VALUE recursive_tbl;
+static VALUE rb_cRecursion;
 
 
@@ -12863,4 +12862,5 @@ Init_Thread()
     curr_thread = main_thread->prev = main_thread->next = main_thread;
     recursive_key = rb_intern("__recursive_key__");
+    rb_cRecursion = rb_define_class("__recursive_key__", rb_cData);
 }
 
@@ -12998,29 +12998,34 @@ rb_exec_recursive(func, obj, arg)
 {
     VALUE list = rb_thread_local_aref(rb_thread_current(), recursive_key);
-    int found = Qfalse;
+    NODE *node = 0;
+    volatile VALUE olist;
 
-    if (NIL_P(list) || TYPE(list) != T_NODE) {
+    if (NIL_P(list) || TYPE(list) != T_DATA ||
+	RBASIC(list)->klass != rb_cRecursion) {
 	list = Qnil;
     }
     else {
-	NODE *tmp = (NODE*)list;
-	
+	NODE *tmp = DATA_PTR(list);
+	node = tmp;
 	while (!NIL_P(tmp)) {
 	    if (tmp->nd_cfnc == func && tmp->nd_tval == obj) {
-		found = Qtrue;
-		break;
+		return (*func)(obj, arg, Qtrue);
 	    }
 	    tmp = tmp->nd_next;
 	}
     }
-    if (found) {
-	return (*func)(obj, arg, Qtrue);
-    }
-    else {
-	NODE *node = rb_node_newnode(NODE_MEMO, (VALUE)func, obj, list);
+    {
 	VALUE result;
 	int state;
 
-	rb_thread_local_aset(rb_thread_current(), recursive_key, (VALUE)node);
+	node = rb_node_newnode(NODE_MEMO, (VALUE)func, obj, (VALUE)node);
+	olist = list;
+	if (NIL_P(list)) {
+	    list = Data_Wrap_Struct(rb_cRecursion, rb_gc_mark, 0, node);
+	    rb_thread_local_aset(rb_thread_current(), recursive_key, list);
+	}
+	else {
+	    DATA_PTR(list) = node;
+	}
 	PUSH_TAG(PROT_NONE);
 	if ((state = EXEC_TAG()) == 0) {
@@ -13028,11 +13033,14 @@ rb_exec_recursive(func, obj, arg)
 	}
 	POP_TAG();
-	if (state) JUMP_TAG(state);
 
 	/* remove pushed tag */
-	list = rb_thread_local_aref(rb_thread_current(), recursive_key);
-	node = (NODE*)list;
+	list = olist;
+	if (!NIL_P(list)) {
+	    DATA_PTR(list) = ((NODE *)DATA_PTR(list))->nd_next;
+	}
+	rb_thread_local_aset(rb_thread_current(), recursive_key, list);
+
+	if (state) JUMP_TAG(state);
 
-	rb_thread_local_aset(rb_thread_current(), recursive_key, (VALUE)node->nd_next);
 	return result;
     }


-- 
--- 僕の前にBugはない。
--- 僕の後ろにBugはできる。
    中田 伸悦



In This Thread