diff options
author | wanabe <wanabe@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-06-08 13:24:13 +0000 |
---|---|---|
committer | wanabe <wanabe@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-06-08 13:24:13 +0000 |
commit | a5fdfa5884e56ecb700c0b241e8e57a8afa3b34f (patch) | |
tree | 6e92ea04058a89d4e9b45ece6b9c2b0c7c21428c | |
parent | 65ec3ed9ca7c74b0ac66abdf576720ddc6549717 (diff) | |
download | ruby-a5fdfa5884e56ecb700c0b241e8e57a8afa3b34f.tar.gz |
* 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]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17021 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | proc.c | 4 | ||||
-rw-r--r-- | vm.c | 2 | ||||
-rw-r--r-- | vm_insnhelper.c | 15 |
4 files changed, 23 insertions, 6 deletions
@@ -1,3 +1,11 @@ +Sun Jun 8 22:22:20 2008 wanabe <s.wanabe@gmail.com> + + * 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@tsg.ne.jp> * test/zlib/test_zlib.rb: add tests to achieve over 90% test coverage @@ -490,7 +490,7 @@ proc_call(int argc, VALUE *argv, VALUE procval) 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 @@ curry(VALUE dummy, VALUE args, int argc, VALUE *argv) 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; } @@ -448,7 +448,7 @@ invoke_block_from_c(rb_thread_t *th, const rb_block_t *block, 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); } } diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 2b32a3c94a..35fe3e9785 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -651,7 +651,8 @@ block_proc_is_lambda(const VALUE procval) 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 @@ vm_yield_with_cfunc(rb_thread_t *th, const rb_block_t *block, 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 @@ vm_invoke_block(rb_thread_t *th, rb_control_frame_t *reg_cfp, rb_num_t num, rb_n 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; } |