[前][次][番号順一覧][スレッド一覧]

ruby-changes:12317

From: nobu <ko1@a...>
Date: Fri, 10 Jul 2009 10:26:57 +0900 (JST)
Subject: [ruby-changes:12317] Ruby:r24012 (trunk): * vm_insnhelper.c (vm_search_superclass): checks for implicit

nobu	2009-07-10 10:25:26 +0900 (Fri, 10 Jul 2009)

  New Revision: 24012

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=24012

  Log:
    * vm_insnhelper.c (vm_search_superclass): checks for implicit
      argument passing before method search.  [ruby-core:24244]

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_super.rb
    trunk/vm_insnhelper.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 24011)
+++ ChangeLog	(revision 24012)
@@ -1,3 +1,8 @@
+Fri Jul 10 10:25:19 2009  Nobuyoshi Nakada  <nobu@r...>
+
+	* vm_insnhelper.c (vm_search_superclass): checks for implici
+	  argument passing before method search.  [ruby-core:24244]
+
 Fri Jul 10 07:22:29 2009  Nobuyoshi Nakada  <nobu@r...>
 
 	* parse.y (parser_data_type): typed.
Index: vm_insnhelper.c
===================================================================
--- vm_insnhelper.c	(revision 24011)
+++ vm_insnhelper.c	(revision 24012)
@@ -360,10 +360,18 @@
 	      int num, ID id, ID oid, VALUE recv, VALUE klass,
 	      VALUE flag, const NODE *mn, const rb_block_t *blockptr)
 {
-    VALUE val;
+    VALUE val = 0;
+    int state = 0;
 
     EXEC_EVENT_HOOK(th, RUBY_EVENT_C_CALL, recv, id, klass);
-    {
+    TH_PUSH_TAG(th);
+    if (th->event_flags & RUBY_EVENT_C_RETURN) {
+	state = TH_EXEC_TAG();
+    }
+    else {
+	_th->tag = _tag.prev;
+    }
+    if (state == 0) {
 	rb_control_frame_t *cfp =
 	    vm_push_frame(th, 0, VM_FRAME_MAGIC_CFUNC,
 			  recv, (VALUE) blockptr, 0, reg_cfp->sp, 0, 1);
@@ -381,7 +389,9 @@
 
 	vm_pop_frame(th);
     }
+    TH_POP_TAG();
     EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, recv, id, klass);
+    if (state) TH_JUMP_TAG(th, state);
 
     return val;
 }
@@ -1228,6 +1238,11 @@
 	/* defined by Module#define_method() */
 	rb_control_frame_t *lcfp = GET_CFP();
 
+	if (!sigval) {
+	    /* zsuper */
+	    rb_raise(rb_eRuntimeError, "implicit argument passing of super from method defined by define_method() is not supported. Specify all arguments explicitly.");
+	}
+
 	while (lcfp->iseq != ip) {
 	    VALUE *tdfp = GET_PREV_DFP(lcfp->dfp);
 	    while (1) {
@@ -1240,11 +1255,6 @@
 
 	id = lcfp->method_id;
 	klass = vm_search_normal_superclass(lcfp->method_class, recv);
-
-	if (sigval == Qfalse) {
-	    /* zsuper */
-	    rb_raise(rb_eRuntimeError, "implicit argument passing of super from method defined by define_method() is not supported. Specify all arguments explicitly.");
-	}
     }
     else {
 	klass = vm_search_normal_superclass(ip->klass, recv);
Index: test/ruby/test_super.rb
===================================================================
--- test/ruby/test_super.rb	(revision 24011)
+++ test/ruby/test_super.rb	(revision 24012)
@@ -130,5 +130,13 @@
     a = A.new
     a.uu(12)
     assert_equal("A#tt", a.tt(12), "[ruby-core:3856]")
+    e = assert_raise(RuntimeError, "[ruby-core:24244]") {
+      lambda {
+        Class.new do
+          define_method(:a) {super}.call
+        end
+      }.call
+    }
+    assert_match(/implicit argument passing of super from method defined by define_method/, e.message)
   end
 end

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]