ruby-changes:46901
From: ko1 <ko1@a...>
Date: Mon, 5 Jun 2017 15:15:32 +0900 (JST)
Subject: [ruby-changes:46901] ko1:r59016 (trunk): rename functions and clean parameters.
ko1 2017-06-05 15:15:28 +0900 (Mon, 05 Jun 2017) New Revision: 59016 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59016 Log: rename functions and clean parameters. * internal.h (rb_yield_lambda): rename to rb_yield_force_blockarg() because this function prohibt lambda arg setup (strict setup). * vm.c (invoke_iseq_block_from_c): remove splattable argument because it is not used. * vm.c (invoke_block_from_c_splattable): rename to invoke_block_from_c_bh() because `splattable` doesn't make sense on current this function. Also accept `force_blockarg' parameter instead of `splattable` parameter. It is more clear. * vm.c (invoke_block_from_c_unsplattable): rename to invoke_block_from_c_proc() and accept `proc` instead of `block'. This function is used only by proc block invocation. Modified files: trunk/enum.c trunk/internal.h trunk/vm.c trunk/vm_eval.c Index: vm.c =================================================================== --- vm.c (revision 59015) +++ vm.c (revision 59016) @@ -1004,7 +1004,7 @@ invoke_bmethod(rb_thread_t *th, const rb https://github.com/ruby/ruby/blob/trunk/vm.c#L1004 static inline VALUE invoke_iseq_block_from_c(rb_thread_t *th, const struct rb_captured_block *captured, VALUE self, int argc, const VALUE *argv, VALUE passed_block_handler, - const rb_cref_t *cref, const int splattable, int is_lambda) + const rb_cref_t *cref, int is_lambda) { const rb_iseq_t *iseq = rb_iseq_check(captured->code.iseq); int i, opt_pc; @@ -1033,10 +1033,10 @@ invoke_iseq_block_from_c(rb_thread_t *th https://github.com/ruby/ruby/blob/trunk/vm.c#L1033 } static inline VALUE -invoke_block_from_c_splattable(rb_thread_t *th, VALUE block_handler, - int argc, const VALUE *argv, - VALUE passed_block_handler, const rb_cref_t *cref, - int splattable, int is_lambda) +invoke_block_from_c_bh(rb_thread_t *th, VALUE block_handler, + int argc, const VALUE *argv, + VALUE passed_block_handler, const rb_cref_t *cref, + int is_lambda, int force_blockarg) { again: switch (vm_block_handler_type(block_handler)) { @@ -1045,16 +1045,19 @@ invoke_block_from_c_splattable(rb_thread https://github.com/ruby/ruby/blob/trunk/vm.c#L1045 const struct rb_captured_block *captured = VM_BH_TO_ISEQ_BLOCK(block_handler); return invoke_iseq_block_from_c(th, captured, captured->self, argc, argv, passed_block_handler, - cref, splattable, is_lambda); + cref, is_lambda); } case block_handler_type_ifunc: - return vm_yield_with_cfunc(th, VM_BH_TO_IFUNC_BLOCK(block_handler), VM_BH_TO_IFUNC_BLOCK(block_handler)->self, + return vm_yield_with_cfunc(th, VM_BH_TO_IFUNC_BLOCK(block_handler), + VM_BH_TO_IFUNC_BLOCK(block_handler)->self, argc, argv, passed_block_handler); case block_handler_type_symbol: - return vm_yield_with_symbol(th, VM_BH_TO_SYMBOL(block_handler), argc, argv, passed_block_handler); + return vm_yield_with_symbol(th, VM_BH_TO_SYMBOL(block_handler), + argc, argv, passed_block_handler); case block_handler_type_proc: - if (!splattable) + if (force_blockarg == FALSE) { is_lambda = block_proc_is_lambda(VM_BH_TO_PROC(block_handler)); + } block_handler = vm_proc_to_block_handler(VM_BH_TO_PROC(block_handler)); goto again; } @@ -1077,42 +1080,45 @@ check_block_handler(rb_thread_t *th) https://github.com/ruby/ruby/blob/trunk/vm.c#L1080 static VALUE vm_yield_with_cref(rb_thread_t *th, int argc, const VALUE *argv, const rb_cref_t *cref, int is_lambda) { - return invoke_block_from_c_splattable(th, check_block_handler(th), - argc, argv, VM_BLOCK_HANDLER_NONE, - cref, FALSE, is_lambda); + return invoke_block_from_c_bh(th, check_block_handler(th), + argc, argv, VM_BLOCK_HANDLER_NONE, + cref, is_lambda, FALSE); } static VALUE vm_yield(rb_thread_t *th, int argc, const VALUE *argv) { - return invoke_block_from_c_splattable(th, check_block_handler(th), - argc, argv, VM_BLOCK_HANDLER_NONE, - NULL, FALSE, FALSE); + return invoke_block_from_c_bh(th, check_block_handler(th), + argc, argv, VM_BLOCK_HANDLER_NONE, + NULL, FALSE, FALSE); } static VALUE vm_yield_with_block(rb_thread_t *th, int argc, const VALUE *argv, VALUE block_handler) { - return invoke_block_from_c_splattable(th, check_block_handler(th), - argc, argv, block_handler, - NULL, FALSE, FALSE); + return invoke_block_from_c_bh(th, check_block_handler(th), + argc, argv, block_handler, + NULL, FALSE, FALSE); } static VALUE -vm_yield_lambda_splattable(rb_thread_t *th, VALUE args) +vm_yield_force_blockarg(rb_thread_t *th, VALUE args) { - return invoke_block_from_c_splattable(th, check_block_handler(th), 1, &args, VM_BLOCK_HANDLER_NONE, NULL, TRUE, FALSE); + return invoke_block_from_c_bh(th, check_block_handler(th), 1, &args, + VM_BLOCK_HANDLER_NONE, NULL, FALSE, TRUE); } static inline VALUE -invoke_block_from_c_unsplattable(rb_thread_t *th, const struct rb_block *block, - VALUE self, int argc, const VALUE *argv, - VALUE passed_block_handler, int is_lambda) +invoke_block_from_c_proc(rb_thread_t *th, const rb_proc_t *proc, + VALUE self, int argc, const VALUE *argv, + VALUE passed_block_handler, int is_lambda) { + const struct rb_block *block = &proc->block; + again: switch (vm_block_type(block)) { case block_type_iseq: - return invoke_iseq_block_from_c(th, &block->as.captured, self, argc, argv, passed_block_handler, NULL, FALSE, is_lambda); + return invoke_iseq_block_from_c(th, &block->as.captured, self, argc, argv, passed_block_handler, NULL, is_lambda); case block_type_ifunc: return vm_yield_with_cfunc(th, &block->as.captured, self, argc, argv, passed_block_handler); case block_type_symbol: @@ -1122,7 +1128,7 @@ invoke_block_from_c_unsplattable(rb_thre https://github.com/ruby/ruby/blob/trunk/vm.c#L1128 block = vm_proc_block(block->as.proc); goto again; } - VM_UNREACHABLE(invoke_block_from_c_unsplattable); + VM_UNREACHABLE(invoke_block_from_c_proc); return Qundef; } @@ -1137,7 +1143,7 @@ vm_invoke_proc(rb_thread_t *th, rb_proc_ https://github.com/ruby/ruby/blob/trunk/vm.c#L1143 TH_PUSH_TAG(th); if ((state = EXEC_TAG()) == 0) { th->safe_level = proc->safe_level; - val = invoke_block_from_c_unsplattable(th, &proc->block, self, argc, argv, passed_block_handler, proc->is_lambda); + val = invoke_block_from_c_proc(th, proc, self, argc, argv, passed_block_handler, proc->is_lambda); } TH_POP_TAG(); @@ -1153,7 +1159,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/vm.c#L1159 vm_invoke_bmethod(rb_thread_t *th, rb_proc_t *proc, VALUE self, int argc, const VALUE *argv, VALUE block_handler) { - return invoke_block_from_c_unsplattable(th, &proc->block, self, argc, argv, block_handler, TRUE); + return invoke_block_from_c_proc(th, proc, self, argc, argv, block_handler, TRUE); } VALUE Index: vm_eval.c =================================================================== --- vm_eval.c (revision 59015) +++ vm_eval.c (revision 59016) @@ -19,7 +19,7 @@ static inline VALUE method_missing(VALUE https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L19 static inline VALUE vm_yield_with_cref(rb_thread_t *th, int argc, const VALUE *argv, const rb_cref_t *cref, int is_lambda); static inline VALUE vm_yield(rb_thread_t *th, int argc, const VALUE *argv); static inline VALUE vm_yield_with_block(rb_thread_t *th, int argc, const VALUE *argv, VALUE block_handler); -static inline VALUE vm_yield_lambda_splattable(rb_thread_t *th, VALUE args); +static inline VALUE vm_yield_force_blockarg(rb_thread_t *th, VALUE args); static VALUE vm_exec(rb_thread_t *th); static void vm_set_eval_stack(rb_thread_t * th, const rb_iseq_t *iseq, const rb_cref_t *cref, const struct rb_block *base_block); static int vm_collect_local_variables_in_heap(rb_thread_t *th, const VALUE *dfp, const struct local_var_list *vars); @@ -1067,9 +1067,9 @@ rb_yield_splat(VALUE values) https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1067 } VALUE -rb_yield_lambda(VALUE values) +rb_yield_force_blockarg(VALUE values) { - return vm_yield_lambda_splattable(GET_THREAD(), values); + return vm_yield_force_blockarg(GET_THREAD(), values); } VALUE Index: internal.h =================================================================== --- internal.h (revision 59015) +++ internal.h (revision 59016) @@ -1741,7 +1741,7 @@ VALUE rb_check_funcall_with_hook(VALUE r https://github.com/ruby/ruby/blob/trunk/internal.h#L1741 VALUE rb_check_funcall_default(VALUE, ID, int, const VALUE *, VALUE); VALUE rb_catch_protect(VALUE t, rb_block_call_func *func, VALUE data, int *stateptr); VALUE rb_yield_1(VALUE val); -VALUE rb_yield_lambda(VALUE values); +VALUE rb_yield_force_blockarg(VALUE values); /* vm_insnhelper.c */ VALUE rb_equal_opt(VALUE obj1, VALUE obj2); Index: enum.c =================================================================== --- enum.c (revision 59015) +++ enum.c (revision 59016) @@ -43,7 +43,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/enum.c#L43 enum_yield(int argc, VALUE ary) { if (argc > 1) - return rb_yield_lambda(ary); + return rb_yield_force_blockarg(ary); if (argc == 1) return rb_yield(ary); return rb_yield_values2(0, 0); @@ -55,7 +55,7 @@ enum_yield_array(VALUE ary) https://github.com/ruby/ruby/blob/trunk/enum.c#L55 long len = RARRAY_LEN(ary); if (len > 1) - return rb_yield_lambda(ary); + return rb_yield_force_blockarg(ary); if (len == 1) return rb_yield(RARRAY_AREF(ary, 0)); return rb_yield_values2(0, 0); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/