[前][次][番号順一覧][スレッド一覧][生データ]

yarv-diff:188

From: ko1 atdot.net
Date: 30 Dec 2005 21:06:36 -0000
Subject: [yarv-diff:188] r346 - in trunk: . yarvtest

Author: ko1
Date: 2005-12-31 06:06:35 +0900 (Sat, 31 Dec 2005)
New Revision: 346

Modified:
   trunk/ChangeLog
   trunk/test.rb
   trunk/vm.c
   trunk/vm_macro.def
   trunk/yarvtest/test_method.rb
Log:
	* vm.c (eval_search_super_klass) : pass block to method missing

	* vm_macro.def (macro_eval_invoke_method) : ditto

	* yarvtest/test_method.rb : add a test for above



Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2005-12-30 18:19:44 UTC (rev 345)
+++ trunk/ChangeLog	2005-12-30 21:06:35 UTC (rev 346)
@@ -4,6 +4,15 @@
 #  from Mon, 03 May 2004 01:24:19 +0900
 #
 
+2005-12-31(Sat) 06:05:00 +0900  Koichi Sasada  <ko1 atdot.net>
+
+	* vm.c (eval_search_super_klass) : pass block to method missing
+
+	* vm_macro.def (macro_eval_invoke_method) : ditto
+
+	* yarvtest/test_method.rb : add a test for above
+
+
 2005-12-31(Sat) 03:11:14 +0900  Koichi Sasada  <ko1 atdot.net>
 
 	* eval.c (eval), eval_proc.c (rb_f_binding) : save klass, etc to

Modified: trunk/test.rb
===================================================================
--- trunk/test.rb	2005-12-30 18:19:44 UTC (rev 345)
+++ trunk/test.rb	2005-12-30 21:06:35 UTC (rev 346)
@@ -1,7 +1,23 @@
-C = 1; C::D
 
+class C
+  def method_missing *args, &b
+    b.call(args)
+  end
+end
+
+C.new.foo(1){|args|
+  p args
+}
+
 __END__
 
+10000.times{
+  Thread.new {}
+  Thread.pass
+}
+
+__END__
+
 p eval('a', $b)
 
 

Modified: trunk/vm.c
===================================================================
--- trunk/vm.c	2005-12-30 18:19:44 UTC (rev 345)
+++ trunk/vm.c	2005-12-30 21:06:35 UTC (rev 346)
@@ -932,12 +932,14 @@
 }
 
 EVALBODY_HELPER_FUNCTION VALUE
-eval_method_missing(yarv_thread_t *th, ID id, VALUE recv, int num, int opt){
+eval_method_missing(yarv_thread_t *th, ID id, VALUE recv, int num,
+                    yarv_block_t *blockptr, int opt){
   yarv_control_frame_t *reg_cfp = th->cfp;
   VALUE *argv = STACK_ADDR_FROM_TOP(num+1);
   VALUE val;
   argv[0] = ID2SYM(id);
   th->method_missing_reason = opt;
+  th->passed_block = blockptr;
   val = rb_funcall2(recv, idMethodMissing, num+1, argv);
   POPN(num+1);
   return val;

Modified: trunk/vm_macro.def
===================================================================
--- trunk/vm_macro.def	2005-12-30 18:19:44 UTC (rev 345)
+++ trunk/vm_macro.def	2005-12-30 21:06:35 UTC (rev 346)
@@ -253,7 +253,7 @@
       if(flag & VM_CALL_VCALL_BIT){
         stat |= NOEX_VCALL;
       }
-      val = eval_method_missing(th, id, recv, num, stat);
+      val = eval_method_missing(th, id, recv, num, blockptr, stat);
     }
   }
   else if(!(flag & VM_CALL_FCALL_BIT) &&
@@ -262,7 +262,7 @@
     if(flag & VM_CALL_VCALL_BIT){
       stat |= NOEX_VCALL;
     }
-    val = eval_method_missing(th, id, recv, num, stat);
+    val = eval_method_missing(th, id, recv, num, blockptr, stat);
   }
   else if((mn->nd_noex & NOEX_MASK) & NOEX_PROTECTED){
     VALUE defined_class = mn->nd_clss;
@@ -271,7 +271,7 @@
       defined_class = RBASIC(defined_class)->klass;
     }
     if (!rb_obj_is_kind_of(GET_SELF(), rb_class_real(defined_class))){
-      val = eval_method_missing(th, id, recv, num, NOEX_PROTECTED);
+      val = eval_method_missing(th, id, recv, num, blockptr, NOEX_PROTECTED);
     }
     else{
       goto INSN_LABEL(normal_method_dispatch);

Modified: trunk/yarvtest/test_method.rb
===================================================================
--- trunk/yarvtest/test_method.rb	2005-12-30 18:19:44 UTC (rev 345)
+++ trunk/yarvtest/test_method.rb	2005-12-30 21:06:35 UTC (rev 346)
@@ -431,7 +431,23 @@
     } do
       remove_const :C
     end
-    
+
+    ae %q{
+      class C
+        def method_missing *args, &b
+          b.call(args)
+        end
+      end
+      C.new.foo(1){|args|
+        args
+      }
+      C.new.foo(1){|args|
+        args
+      } +
+      C.new.foo(1, 2){|args|
+        args
+      }
+    }
   end
 
   def test_svar


-- 
ML: yarv-diff quickml.atdot.net
Info: http://www.atdot.net/~ko1/quickml

[前][次][番号順一覧][スレッド一覧][生データ]