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

ruby-changes:5517

From: wanabe <ko1@a...>
Date: Sun, 8 Jun 2008 22:26:36 +0900 (JST)
Subject: [ruby-changes:5517] Ruby:r17021 (trunk): * vm_insnhelper.c, vm.c, proc.c (proc_call): allow call method with

wanabe	2008-06-08 22:24:13 +0900 (Sun, 08 Jun 2008)

  New Revision: 17021

  Modified files:
    trunk/ChangeLog
    trunk/proc.c
    trunk/vm.c
    trunk/vm_insnhelper.c

  Log:
    * vm_insnhelper.c, vm.c, proc.c (proc_call): allow call method with
      block that both is written in C. [ruby-dev:34273] [ruby-core:15551]
    
    *  proc.c (curry): use proc_call instead of rb_proc_call.
      [ruby-dev:34273] [ruby-core:15551]


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=17021&r2=17020&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/proc.c?r1=17021&r2=17020&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/vm.c?r1=17021&r2=17020&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/vm_insnhelper.c?r1=17021&r2=17020&diff_format=u

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 17020)
+++ ChangeLog	(revision 17021)
@@ -1,3 +1,11 @@
+Sun Jun  8 22:22:20 2008  wanabe  <s.wanabe@g...>
+
+	* vm_insnhelper.c, vm.c, proc.c (proc_call): allow call method with
+	  block that both is written in C. [ruby-dev:34273] [ruby-core:15551]
+
+	*  proc.c (curry): use proc_call instead of rb_proc_call.
+	  [ruby-dev:34273] [ruby-core:15551]
+
 Sun Jun  8 21:50:27 2008  Yusuke Endoh  <mame@t...>
 
 	* test/zlib/test_zlib.rb: add tests to achieve over 90% test coverage
Index: proc.c
===================================================================
--- proc.c	(revision 17020)
+++ proc.c	(revision 17021)
@@ -490,7 +490,7 @@
     rb_block_t *blockptr = 0;
     GetProcPtr(procval, proc);
 
-    if (BUILTIN_TYPE(proc->block.iseq) != T_NODE &&
+    if (BUILTIN_TYPE(proc->block.iseq) == T_NODE ||
 	proc->block.iseq->arg_block != -1) {
 
 	if (rb_block_given_p()) {
@@ -1613,7 +1613,7 @@
 	arity = make_curry_proc(proc, passed, arity);
 	return arity;
     }
-    arity = rb_proc_call(proc, passed);
+    arity = proc_call(RARRAY_LEN(passed), RARRAY_PTR(passed), proc);
     return arity;
 }
 
Index: vm.c
===================================================================
--- vm.c	(revision 17020)
+++ vm.c	(revision 17021)
@@ -448,7 +448,7 @@
 	return vm_eval_body(th);
     }
     else {
-	return vm_yield_with_cfunc(th, block, self, argc, argv);
+	return vm_yield_with_cfunc(th, block, self, argc, argv, blockptr);
     }
 }
 
Index: vm_insnhelper.c
===================================================================
--- vm_insnhelper.c	(revision 17020)
+++ vm_insnhelper.c	(revision 17021)
@@ -651,7 +651,8 @@
 
 static inline VALUE
 vm_yield_with_cfunc(rb_thread_t *th, const rb_block_t *block,
-		    VALUE self, int argc, const VALUE *argv)
+		    VALUE self, int argc, const VALUE *argv,
+		    rb_block_t *blockptr)
 {
     NODE *ifunc = (NODE *) block->iseq;
     VALUE val;
@@ -672,7 +673,15 @@
 		  self, (VALUE)block->dfp,
 		  0, th->cfp->sp, block->lfp, 1);
 
-    val = (*ifunc->nd_cfnc) (arg, ifunc->nd_tval, argc, argv);
+    if (blockptr) {
+	VALUE store_block = th->cfp->lfp[0];
+	th->cfp->lfp[0] = GC_GUARDED_PTR(blockptr);
+	val = (*ifunc->nd_cfnc) (arg, ifunc->nd_tval, argc, argv);
+	th->cfp->lfp[0] = store_block;
+    }
+    else {
+	val = (*ifunc->nd_cfnc) (arg, ifunc->nd_tval, argc, argv);
+    }
 
     th->cfp++;
     return val;
@@ -831,7 +840,7 @@
 	return Qundef;
     }
     else {
-	VALUE val = vm_yield_with_cfunc(th, block, block->self, argc, STACK_ADDR_FROM_TOP(argc));
+	VALUE val = vm_yield_with_cfunc(th, block, block->self, argc, STACK_ADDR_FROM_TOP(argc), 0);
 	POPN(argc); /* TODO: should put before C/yield? */
 	return val;
     }

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

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

->    5517 2008-06-08 22:26 [ko1@a...            ] Ruby:r17021 (trunk): * vm_insnhelper.c, vm.c, proc.c (proc_call): allow call method with
      5519 2008-06-09 01:23 ┗[ko1@a...            ]