diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-07-18 08:31:02 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-07-18 08:31:02 +0000 |
commit | 1f67a3900fbd45482ed36ad3b148b321307c1576 (patch) | |
tree | 7d61b1b855149f8a357603065e85761cb7d43202 /vm_eval.c | |
parent | 8ffb23c2e1f2f292c8ed85b51ffb85f4811e5a9e (diff) | |
download | bundler-1f67a3900fbd45482ed36ad3b148b321307c1576.tar.gz |
vm_eval.c: rb_lambda_call
* enum.c (enum_collect): make the block arity same as the given
block. [Bug #13391]
* internal.h (vm_ifunc): store arity instead of unused id.
* proc.c (rb_vm_block_min_max_arity): return ifunc arity.
* vm_eval.c (rb_lambda_call): call method with lambda block.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59358 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_eval.c')
-rw-r--r-- | vm_eval.c | 19 |
1 files changed, 18 insertions, 1 deletions
@@ -1159,7 +1159,7 @@ rb_iterate(VALUE (* it_proc)(VALUE), VALUE data1, VALUE (* bl_proc)(ANYARGS), VALUE data2) { return rb_iterate0(it_proc, data1, - bl_proc ? IFUNC_NEW(bl_proc, data2, rb_frame_this_func()) : 0, + bl_proc ? rb_vm_ifunc_proc_new(bl_proc, (void *)data2) : 0, GET_THREAD()); } @@ -1192,6 +1192,23 @@ rb_block_call(VALUE obj, ID mid, int argc, const VALUE * argv, return rb_iterate(iterate_method, (VALUE)&arg, bl_proc, data2); } +VALUE +rb_lambda_call(VALUE obj, ID mid, int argc, const VALUE *argv, + rb_block_call_func_t bl_proc, int min_argc, int max_argc, + VALUE data2) +{ + struct iter_method_arg arg; + struct vm_ifunc *block; + + if (!bl_proc) rb_raise(rb_eArgError, "NULL lambda function"); + arg.obj = obj; + arg.mid = mid; + arg.argc = argc; + arg.argv = argv; + block = rb_vm_ifunc_new(bl_proc, (void *)data2, min_argc, max_argc); + return rb_iterate0(iterate_method, (VALUE)&arg, block, GET_THREAD()); +} + static VALUE iterate_check_method(VALUE obj) { |