[#31320] Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...>

-----BEGIN PGP SIGNED MESSAGE-----

124 messages 2007/08/01
[#31321] Re: Import RubyGems to Ruby 1.9 — Nobuyoshi Nakada <nobu@...> 2007/08/01

なかだです。

[#31329] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/08/01

-----BEGIN PGP SIGNED MESSAGE-----

[#31918] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/09/30

-----BEGIN PGP SIGNED MESSAGE-----

[#31970] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/10/08

-----BEGIN PGP SIGNED MESSAGE-----

[#32023] Re: Import RubyGems to Ruby 1.9 — Yukihiro Matsumoto <matz@...> 2007/10/11

まつもと ゆきひろです

[#32062] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/10/15

-----BEGIN PGP SIGNED MESSAGE-----

[#32066] Re: Import RubyGems to Ruby 1.9 — Yukihiro Matsumoto <matz@...> 2007/10/15

まつもと ゆきひろです

[#32068] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/10/15

-----BEGIN PGP SIGNED MESSAGE-----

[#32069] Re: Import RubyGems to Ruby 1.9 — Yukihiro Matsumoto <matz@...> 2007/10/15

まつもと ゆきひろです

[#32070] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/10/15

-----BEGIN PGP SIGNED MESSAGE-----

[#32073] Re: Import RubyGems to Ruby 1.9 — Yukihiro Matsumoto <matz@...> 2007/10/15

まつもと ゆきひろです

[#32079] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/10/16

-----BEGIN PGP SIGNED MESSAGE-----

[#32080] Re: Import RubyGems to Ruby 1.9 — Yukihiro Matsumoto <matz@...> 2007/10/16

まつもと ゆきひろです

[#32132] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/10/23

-----BEGIN PGP SIGNED MESSAGE-----

[#32081] Re: Import RubyGems to Ruby 1.9 — Takahiro Kambe <taca@...> 2007/10/16

In message <471447D5.5050902@sarion.co.jp>

[#32087] Re: Import RubyGems to Ruby 1.9 — "Akinori MUSHA" <knu@...> 2007/10/17

 Rubygems は、基本的に他のパッケージシステムから包みやすい作り

[#32104] Re: Import RubyGems to Ruby 1.9 — akira yamada <akira@...> 2007/10/20

Tuesday 16 October 2007 14:09:13 に NAKAMURA, Hiroshi さんは書きました:

[#32109] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/10/20

-----BEGIN PGP SIGNED MESSAGE-----

[#31332] Re: Import RubyGems to Ruby 1.9 — Tadayoshi Funaba <tadf@...> 2007/08/01

> ちなみに「ruby/1.9.1の標準添付からどのライブラリを外すか?」という議論も

[#31858] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/09/25

-----BEGIN PGP SIGNED MESSAGE-----

[#31872] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/09/27

-----BEGIN PGP SIGNED MESSAGE-----

[#31905] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/09/29

-----BEGIN PGP SIGNED MESSAGE-----

[#31906] Re: Import RubyGems to Ruby 1.9 — Yukihiro Matsumoto <matz@...> 2007/09/29

まつもと ゆきひろです

[#31910] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/09/30

-----BEGIN PGP SIGNED MESSAGE-----

[#31920] Re: Import RubyGems to Ruby 1.9 — Yukihiro Matsumoto <matz@...> 2007/09/30

まつもと ゆきひろです

[#31323] Bignum#to_s の Karatsuba 基数変換による高速化 — "Kenta Murata" <muraken@...>

むらけんです.

16 messages 2007/08/01
[#31326] Re: Bignum#to_s の Karatsuba 基数変換による高速化 — Yukihiro Matsumoto <matz@...> 2007/08/01

まつもと ゆきひろです

[#31327] Re: Bignum#to_s の Karatsuba 基数変換による高速化 — "Kenta Murata" <muraken@...> 2007/08/01

むらけんです.

[#31328] Re: Bignum#to_s の Karatsuba 基数変換による高速化 — Yukihiro Matsumoto <matz@...> 2007/08/01

まつもと ゆきひろです

[#31525] いくつかのバグ報告と提案(5点) — eklerni <eklerni@...>

From:eklerni

13 messages 2007/08/20

[#31539] strtod の精度 — Satoshi Nakagawa <snakagawa@...>

中川といいます。

27 messages 2007/08/20
[#31542] Re: strtod の精度 — Yukihiro Matsumoto <matz@...> 2007/08/20

まつもと ゆきひろです

[ruby-dev:31615] Re: catch without a tag argument

From: Nobuyoshi Nakada <nobu@...>
Date: 2007-08-22 23:03:19 UTC
List: ruby-dev #31615
なかだです。

At Thu, 23 Aug 2007 00:34:12 +0900,
Tanaka Akira wrote in [ruby-dev:31609]:
> matzruby にある、引数なしで catch が呼べる機能は 1.9 には入
> らないのでしょうか。

いろいろと変わってるようでそのままでは動きませんでした。


Index: eval_jump.ci
===================================================================
--- eval_jump.ci	(revision 13128)
+++ eval_jump.ci	(working copy)
@@ -6,5 +6,6 @@
 #include "eval_intern.h"
 
-NORETURN(static VALUE rb_f_throw _((int, VALUE *)));
+NORETURN(static VALUE rb_f_throw(int, VALUE *));
+int rb_vm_catch_p(VALUE dst, VALUE tag);
 
 /*
@@ -24,25 +25,8 @@ rb_f_throw(int argc, VALUE *argv)
 {
     VALUE tag, value;
-    rb_thread_t *th = GET_THREAD();
-    struct rb_vm_tag *tt = th->tag;
 
     rb_scan_args(argc, argv, "11", &tag, &value);
-    tag = ID2SYM(rb_to_id(tag));
-
-    while (tt) {
-	if (tt->tag == tag) {
-	    tt->retval = value;
-	    break;
-	}
-	tt = tt->prev;
-    }
-    if (!tt) {
-	rb_name_error(SYM2ID(tag), "uncaught throw `%s'",
-		      rb_id2name(SYM2ID(tag)));
-    }
-    rb_trap_restore_mask();
-    th->errinfo = tag;
 
-    JUMP_TAG(TAG_THROW);
+    rb_throw_obj(tag, value);
 #ifndef __GNUC__
     return Qnil;		/* not reached */
@@ -53,14 +37,11 @@ void
 rb_throw(const char *tag, VALUE val)
 {
-    VALUE argv[2];
-
-    argv[0] = ID2SYM(rb_intern(tag));
-    argv[1] = val;
-    rb_f_throw(2, argv);
+    rb_throw_obj(ID2SYM(rb_intern(tag)), val);
 }
 
 /*
  *  call-seq:
- *     catch(symbol) {| | block }  > obj
+ *     catch(symbol) { block }  => obj
+ *     catch() {|tag| block }   => obj
  *
  *  +catch+ executes its block. If a +throw+ is
@@ -92,41 +73,22 @@ rb_throw(const char *tag, VALUE val)
 
 static VALUE
-rb_f_catch(VALUE dmy, VALUE tag)
+rb_f_catch(int argc, VALUE *argv)
 {
-    int state;
-    VALUE val = Qnil;		/* OK */
-    rb_thread_t *th = GET_THREAD();
-
-    tag = ID2SYM(rb_to_id(tag));
-    PUSH_TAG();
+    VALUE tag;
 
-    th->tag->tag = tag;
-
-    if ((state = EXEC_TAG()) == 0) {
-	val = rb_yield_0(1, &tag);
-    }
-    else if (state == TAG_THROW && th->errinfo == tag) {
-	val = th->tag->retval;
-	th->errinfo = Qnil;
-	state = 0;
+    rb_scan_args(argc, argv, "01", &tag);
+    if (argc == 0) {
+	tag = Qundef;
     }
-    POP_TAG();
-    if (state)
-	JUMP_TAG(state);
-
-    return val;
-}
-
-static VALUE
-catch_i(VALUE tag)
-{
-    return rb_funcall(Qnil, rb_intern("catch"), 1, tag);
+    return rb_catch_obj(tag, rb_yield, Qnil);
 }
 
 VALUE
-rb_catch(const char *tag, VALUE (*func)(), VALUE data)
+rb_catch(const char *tag, VALUE (*func)(ANYARGS), VALUE data)
 {
-    return rb_iterate((VALUE (*)_((VALUE)))catch_i, ID2SYM(rb_intern(tag)),
-		      func, data);
+    if (!tag) {
+	return rb_catch_obj(Qundef, func, data);
+    }
+    return rb_catch_obj(ID2SYM(rb_intern(tag)), func, data);
 }
 
@@ -277,5 +239,5 @@ void
 Init_jump(void)
 {
-    rb_define_global_function("catch", rb_f_catch, 1);
+    rb_define_global_function("catch", rb_f_catch, -1);
     rb_define_global_function("throw", rb_f_throw, -1);
     rb_define_global_function("at_exit", rb_f_at_exit, 0);
Index: vm.c
===================================================================
--- vm.c	(revision 13128)
+++ vm.c	(working copy)
@@ -982,4 +995,76 @@ rb_iter_break()
 }
 
+static inline int
+catching_p(VALUE dst, VALUE tag)
+{
+    if (dst == tag) return Qtrue;
+    if (SPECIAL_CONST_P(dst)) return Qfalse;
+    if (BUILTIN_TYPE(dst) != T_NODE) return Qfalse;
+    if (GET_THROWOBJ_STATE(dst) != TAG_THROW) return Qfalse;
+    if (GET_THROWOBJ_VAL(dst) != tag) return Qfalse;
+    return Qtrue;
+}
+
+void
+rb_throw_obj(VALUE tag, VALUE value)
+{
+    rb_thread_t *th = GET_THREAD();
+    struct rb_vm_tag *tt = th->tag;
+
+    while (tt) {
+	if (catching_p(tt->tag, tag)) {
+	    tag = tt->tag;
+	    tt->retval = value;
+	    break;
+	}
+	tt = tt->prev;
+    }
+    if (!tt) {
+	VALUE argv[2];
+	argv[0] = rb_sprintf("uncaught throw `%s'", RSTRING_PTR(rb_obj_as_string(tag)));
+	argv[1] = tag;
+	rb_exc_raise(rb_class_new_instance(2, argv, rb_eNameError));
+    }
+    rb_trap_restore_mask();
+    th->errinfo = tag;
+    TH_JUMP_TAG(th, TAG_THROW);
+#ifndef __GNUC__
+    return Qnil;		/* not reached */
+#endif
+}
+
+VALUE
+rb_catch_obj(VALUE tag, VALUE (*func)(ANYARGS), VALUE data)
+{
+    int state;
+    VALUE val = Qnil;		/* OK */
+    VALUE dest = tag;
+    rb_thread_t *th = GET_THREAD();
+
+    if (tag == Qundef) {
+	tag = rb_obj_alloc(rb_cObject);
+	dest = (VALUE)NEW_THROW_OBJECT(tag, GC_GUARDED_PTR_REF(*th->cfp->dfp),
+				       TAG_THROW);
+    }
+
+    TH_PUSH_TAG(th);
+
+    th->tag->tag = dest;
+
+    if ((state = EXEC_TAG()) == 0) {
+	val = (*func)(tag, data);
+    }
+    else if (state == TAG_THROW && th->errinfo == dest) {
+	val = th->tag->retval;
+	th->errinfo = Qnil;
+	state = 0;
+    }
+    TH_POP_TAG();
+    if (state)
+	JUMP_TAG(state);
+
+    return val;
+}
+
 /* optimization: redefine management */
 
Index: include/ruby/ruby.h
===================================================================
--- include/ruby/ruby.h	(revision 13128)
+++ include/ruby/ruby.h	(working copy)
@@ -723,5 +723,7 @@ VALUE rb_rescue2(VALUE(*)(ANYARGS),VALUE
 VALUE rb_ensure(VALUE(*)(ANYARGS),VALUE,VALUE(*)(ANYARGS),VALUE);
 VALUE rb_catch(const char*,VALUE(*)(ANYARGS),VALUE);
+VALUE rb_catch_obj(VALUE,VALUE(*)(ANYARGS),VALUE);
 NORETURN(void rb_throw(const char*,VALUE));
+NORETURN(void rb_throw_obj(VALUE,VALUE));
 
 VALUE rb_require(const char*);


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

In This Thread