From ed4139e39bb3ceda2985b2ea2ebd9a91479d25da Mon Sep 17 00:00:00 2001 From: ko1 Date: Tue, 10 Jun 2008 16:33:51 +0000 Subject: * include/ruby/intern.h, proc.c: revert rb_proc_call() and create rb_proc_call_with_block() instaed. * include/ruby/ruby.h, eval_jump.c, thread.c, vm_insnhelper.c: rb_blockptr should not be exposed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17081 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- proc.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) (limited to 'proc.c') diff --git a/proc.c b/proc.c index 5446c82815..f681f46bc9 100644 --- a/proc.c +++ b/proc.c @@ -507,12 +507,26 @@ proc_call(int argc, VALUE *argv, VALUE procval) } VALUE -rb_proc_call(VALUE self, VALUE args, rb_blockptr blockptr) +rb_proc_call(VALUE self, VALUE args) { rb_proc_t *proc; GetProcPtr(self, proc); return vm_invoke_proc(GET_THREAD(), proc, proc->block.self, - RARRAY_LEN(args), RARRAY_PTR(args), blockptr); + RARRAY_LEN(args), RARRAY_PTR(args), 0); +} + +VALUE +rb_proc_call_with_block(VALUE self, int argc, VALUE *argv, VALUE pass_procval) +{ + rb_proc_t *proc, *pass_proc = 0; + GetProcPtr(self, proc); + + if (!NIL_P(pass_procval)) { + GetProcPtr(pass_procval, pass_proc); + } + + return vm_invoke_proc(GET_THREAD(), proc, proc->block.self, + argc, argv, &pass_proc->block); } /* @@ -1584,7 +1598,7 @@ proc_binding(VALUE self) return bindval; } -static VALUE curry(VALUE dummy, VALUE args, int argc, VALUE *argv, rb_blockptr blockptr); +static VALUE curry(VALUE dummy, VALUE args, int argc, VALUE *argv, VALUE passed_proc); static VALUE make_curry_proc(VALUE proc, VALUE passed, VALUE arity) @@ -1600,7 +1614,7 @@ make_curry_proc(VALUE proc, VALUE passed, VALUE arity) } static VALUE -curry(VALUE dummy, VALUE args, int argc, VALUE *argv, rb_blockptr blockptr) +curry(VALUE dummy, VALUE args, int argc, VALUE *argv, VALUE passed_proc) { VALUE proc, passed, arity; proc = RARRAY_PTR(args)[0]; @@ -1609,15 +1623,17 @@ curry(VALUE dummy, VALUE args, int argc, VALUE *argv, rb_blockptr blockptr) passed = rb_ary_plus(passed, rb_ary_new4(argc, argv)); rb_ary_freeze(passed); + if(RARRAY_LEN(passed) < FIX2INT(arity)) { - if (blockptr) { + if (!NIL_P(passed_proc)) { rb_warn("given block not used"); } arity = make_curry_proc(proc, passed, arity); return arity; } - arity = rb_proc_call(proc, passed, blockptr); - return arity; + else { + return rb_proc_call_with_block(proc, RARRAY_LEN(passed), RARRAY_PTR(passed), passed_proc); + } } /* -- cgit v1.2.3