mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
eliminate C99 compound literals
Ko1 prefers variables be assgined, instead of bare literals in function arguments.
This commit is contained in:
parent
98d099be7e
commit
324038c66e
Notes:
git
2020-06-09 09:53:15 +09:00
2 changed files with 39 additions and 30 deletions
26
vm_eval.c
26
vm_eval.c
|
@ -45,20 +45,18 @@ static VALUE vm_call0_body(rb_execution_context_t* ec, struct rb_calling_info *c
|
||||||
MJIT_FUNC_EXPORTED VALUE
|
MJIT_FUNC_EXPORTED VALUE
|
||||||
rb_vm_call0(rb_execution_context_t *ec, VALUE recv, ID id, int argc, const VALUE *argv, const rb_callable_method_entry_t *me, int kw_splat)
|
rb_vm_call0(rb_execution_context_t *ec, VALUE recv, ID id, int argc, const VALUE *argv, const rb_callable_method_entry_t *me, int kw_splat)
|
||||||
{
|
{
|
||||||
return vm_call0_body(
|
struct rb_calling_info calling = {
|
||||||
ec,
|
.block_handler = VM_BLOCK_HANDLER_NONE,
|
||||||
&(struct rb_calling_info) {
|
.recv = recv,
|
||||||
.block_handler = VM_BLOCK_HANDLER_NONE,
|
.argc = argc,
|
||||||
.recv = recv,
|
.kw_splat = kw_splat,
|
||||||
.argc = argc,
|
};
|
||||||
.kw_splat = kw_splat,
|
struct rb_call_data cd = {
|
||||||
},
|
.ci = &VM_CI_ON_STACK(id, kw_splat ? VM_CALL_KW_SPLAT : 0, argc, NULL),
|
||||||
&(struct rb_call_data) {
|
.cc = &VM_CC_ON_STACK(Qfalse, vm_call_general, { 0 }, me),
|
||||||
.ci = &VM_CI_ON_STACK(id, kw_splat ? VM_CALL_KW_SPLAT : 0, argc, NULL),
|
};
|
||||||
.cc = &VM_CC_ON_STACK(Qfalse, vm_call_general, { 0 }, me),
|
|
||||||
},
|
return vm_call0_body(ec, &calling, &cd, argv);
|
||||||
argv
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
|
|
@ -2685,11 +2685,13 @@ aliased_callable_method_entry(const rb_callable_method_entry_t *me)
|
||||||
static VALUE
|
static VALUE
|
||||||
vm_call_alias(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, struct rb_call_data *cd)
|
vm_call_alias(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, struct rb_call_data *cd)
|
||||||
{
|
{
|
||||||
return vm_call_method_each_type(ec, cfp, calling, &(struct rb_call_data) {
|
struct rb_call_data aliased = {
|
||||||
.ci = cd->ci,
|
.ci = cd->ci,
|
||||||
.cc = &VM_CC_ON_STACK(Qundef, vm_call_general, { 0 },
|
.cc = &VM_CC_ON_STACK(Qundef, vm_call_general, { 0 },
|
||||||
aliased_callable_method_entry(vm_cc_cme(cd->cc))),
|
aliased_callable_method_entry(vm_cc_cme(cd->cc))),
|
||||||
});
|
};
|
||||||
|
|
||||||
|
return vm_call_method_each_type(ec, cfp, calling, &aliased);
|
||||||
}
|
}
|
||||||
|
|
||||||
static enum method_missing_reason
|
static enum method_missing_reason
|
||||||
|
@ -2759,13 +2761,15 @@ vm_call_symbol(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return vm_call_method(ec, reg_cfp, calling, &(struct rb_call_data) {
|
struct rb_call_data cd = {
|
||||||
.ci = &VM_CI_ON_STACK(mid, flags, argc, vm_ci_kwarg(ci)),
|
.ci = &VM_CI_ON_STACK(mid, flags, argc, vm_ci_kwarg(ci)),
|
||||||
.cc = &VM_CC_ON_STACK(klass, vm_call_general, {
|
.cc = &VM_CC_ON_STACK(klass, vm_call_general, {
|
||||||
.method_missing_reason = missing_reason
|
.method_missing_reason = missing_reason
|
||||||
},
|
},
|
||||||
rb_callable_method_entry_with_refinements(klass, mid, NULL)),
|
rb_callable_method_entry_with_refinements(klass, mid, NULL)),
|
||||||
});
|
};
|
||||||
|
|
||||||
|
return vm_call_method(ec, reg_cfp, calling, &cd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
@ -2880,11 +2884,13 @@ vm_call_method_missing_body(rb_execution_context_t *ec, rb_control_frame_t *reg_
|
||||||
INC_SP(1);
|
INC_SP(1);
|
||||||
|
|
||||||
ec->method_missing_reason = reason;
|
ec->method_missing_reason = reason;
|
||||||
return vm_call_method(ec, reg_cfp, calling, &(struct rb_call_data) {
|
struct rb_call_data cd = {
|
||||||
.ci = &VM_CI_ON_STACK(idMethodMissing, flag, argc, vm_ci_kwarg(orig_ci)),
|
.ci = &VM_CI_ON_STACK(idMethodMissing, flag, argc, vm_ci_kwarg(orig_ci)),
|
||||||
.cc = &VM_CC_ON_STACK(Qundef, vm_call_general, { 0 },
|
.cc = &VM_CC_ON_STACK(Qundef, vm_call_general, { 0 },
|
||||||
rb_callable_method_entry_without_refinements(CLASS_OF(calling->recv), idMethodMissing, NULL)),
|
rb_callable_method_entry_without_refinements(CLASS_OF(calling->recv), idMethodMissing, NULL)),
|
||||||
});
|
};
|
||||||
|
|
||||||
|
return vm_call_method(ec, reg_cfp, calling, &cd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
@ -2909,10 +2915,12 @@ vm_call_zsuper(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_ca
|
||||||
cme = refined_method_callable_without_refinement(cme);
|
cme = refined_method_callable_without_refinement(cme);
|
||||||
}
|
}
|
||||||
|
|
||||||
return vm_call_method_each_type(ec, cfp, calling, &(struct rb_call_data) {
|
struct rb_call_data zsuper = {
|
||||||
.ci = cd->ci,
|
.ci = cd->ci,
|
||||||
.cc = &VM_CC_ON_STACK(Qundef, vm_call_general, { 0 }, cme),
|
.cc = &VM_CC_ON_STACK(Qundef, vm_call_general, { 0 }, cme),
|
||||||
});
|
};
|
||||||
|
|
||||||
|
return vm_call_method_each_type(ec, cfp, calling, &zsuper);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline VALUE
|
static inline VALUE
|
||||||
|
@ -3017,13 +3025,14 @@ search_refined_method(rb_execution_context_t *ec, rb_control_frame_t *cfp, struc
|
||||||
static VALUE
|
static VALUE
|
||||||
vm_call_refined(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, struct rb_call_data *cd)
|
vm_call_refined(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, struct rb_call_data *cd)
|
||||||
{
|
{
|
||||||
const rb_callable_method_entry_t *cme = search_refined_method(ec, cfp, cd);
|
struct rb_call_data refined = {
|
||||||
|
.ci = cd->ci,
|
||||||
|
.cc = &VM_CC_ON_STACK(Qundef, vm_call_general, { 0 },
|
||||||
|
search_refined_method(ec, cfp, cd)),
|
||||||
|
};
|
||||||
|
|
||||||
if (cme != NULL) {
|
if (vm_cc_cme(refined.cc)) {
|
||||||
return vm_call_method(ec, cfp, calling, &(struct rb_call_data) {
|
return vm_call_method(ec, cfp, calling, &refined);
|
||||||
.ci = cd->ci,
|
|
||||||
.cc = &VM_CC_ON_STACK(Qundef, vm_call_general, { 0 }, cme),
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return vm_call_method_nome(ec, cfp, calling, cd);
|
return vm_call_method_nome(ec, cfp, calling, cd);
|
||||||
|
@ -3160,10 +3169,12 @@ vm_call_method(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_ca
|
||||||
/* caching method info to dummy cc */
|
/* caching method info to dummy cc */
|
||||||
VM_ASSERT(vm_cc_cme(cc) != NULL);
|
VM_ASSERT(vm_cc_cme(cc) != NULL);
|
||||||
const struct rb_callcache cc_on_stack = *cc;
|
const struct rb_callcache cc_on_stack = *cc;
|
||||||
return vm_call_method_each_type(ec, cfp, calling, &(struct rb_call_data) {
|
struct rb_call_data dummy = {
|
||||||
.ci = ci,
|
.ci = ci,
|
||||||
.cc = &cc_on_stack,
|
.cc = &cc_on_stack,
|
||||||
});
|
};
|
||||||
|
|
||||||
|
return vm_call_method_each_type(ec, cfp, calling, &dummy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return vm_call_method_each_type(ec, cfp, calling, cd);
|
return vm_call_method_each_type(ec, cfp, calling, cd);
|
||||||
|
|
Loading…
Reference in a new issue