diff options
author | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-06-09 15:52:51 +0000 |
---|---|---|
committer | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-06-09 15:52:51 +0000 |
commit | f2400eca0b30cb60273c9526b4501dbe4bcca50f (patch) | |
tree | cd89b99c576f1f74416395d00aecf3ab06fbe55c /proc.c | |
parent | 4879ae65fde1f7cd9b6133fe9e732d0ddcfadc12 (diff) | |
download | ruby-f2400eca0b30cb60273c9526b4501dbe4bcca50f.tar.gz |
* include/ruby/ruby.h, vm_core.h: add a type rb_blockptr.
* vm_insnhelper.c (vm_yield_with_cfunc): vm_yield_with_cfunc receives
blockptr and passes it to iterating block.
* proc.c (rb_proc_call), include/ruby/intern.h: rb_proc_call receives
blockptr. "rb_proc_call(self, args, blockptr)" in C corresponds to
"self.call(*args, &block)" in Ruby.
* proc.c (proc_call): pass blockptr to block that is written in C.
* proc.c (curry): receive blockptr and pass it to original proc.
[ruby-core:15551]
* vm.c (invoke_block_from_c): fix for change of vm_yield_with_cfunc.
* thread.c (call_trace_proc), eval_jump.c (rb_call_end_proc): fix for
change of rb_proc_call.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17065 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'proc.c')
-rw-r--r-- | proc.c | 15 |
1 files changed, 9 insertions, 6 deletions
@@ -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()) { @@ -507,12 +507,12 @@ proc_call(int argc, VALUE *argv, VALUE procval) } VALUE -rb_proc_call(VALUE self, VALUE args) +rb_proc_call(VALUE self, VALUE args, rb_blockptr blockptr) { rb_proc_t *proc; GetProcPtr(self, proc); return vm_invoke_proc(GET_THREAD(), proc, proc->block.self, - RARRAY_LEN(args), RARRAY_PTR(args), 0); + RARRAY_LEN(args), RARRAY_PTR(args), blockptr); } /* @@ -1584,7 +1584,7 @@ proc_binding(VALUE self) return bindval; } -static VALUE curry(VALUE dummy, VALUE args, int argc, VALUE *argv); +static VALUE curry(VALUE dummy, VALUE args, int argc, VALUE *argv, rb_blockptr blockptr); static VALUE make_curry_proc(VALUE proc, VALUE passed, VALUE arity) @@ -1600,7 +1600,7 @@ make_curry_proc(VALUE proc, VALUE passed, VALUE arity) } static VALUE -curry(VALUE dummy, VALUE args, int argc, VALUE *argv) +curry(VALUE dummy, VALUE args, int argc, VALUE *argv, rb_blockptr blockptr) { VALUE proc, passed, arity; proc = RARRAY_PTR(args)[0]; @@ -1610,10 +1610,13 @@ curry(VALUE dummy, VALUE args, int argc, VALUE *argv) passed = rb_ary_plus(passed, rb_ary_new4(argc, argv)); rb_ary_freeze(passed); if(RARRAY_LEN(passed) < FIX2INT(arity)) { + if (blockptr) { + rb_warn("given block not used"); + } arity = make_curry_proc(proc, passed, arity); return arity; } - arity = rb_proc_call(proc, passed); + arity = rb_proc_call(proc, passed, blockptr); return arity; } |