mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
add method_def_aritry()
This commit is contained in:
parent
2f79d6d3f2
commit
4d0cb1a54b
Notes:
git
2021-12-13 10:24:24 +09:00
1 changed files with 11 additions and 7 deletions
18
proc.c
18
proc.c
|
@ -2637,10 +2637,8 @@ umethod_bind_call(int argc, VALUE *argv, VALUE method)
|
|||
* if there is no maximum.
|
||||
*/
|
||||
static int
|
||||
rb_method_entry_min_max_arity(const rb_method_entry_t *me, int *max)
|
||||
method_def_min_max_arity(const rb_method_definition_t *def, int *max)
|
||||
{
|
||||
const rb_method_definition_t *def = me->def;
|
||||
|
||||
again:
|
||||
if (!def) return *max = 0;
|
||||
switch (def->type) {
|
||||
|
@ -2696,15 +2694,21 @@ rb_method_entry_min_max_arity(const rb_method_entry_t *me, int *max)
|
|||
*max = UNLIMITED_ARGUMENTS;
|
||||
return 0;
|
||||
}
|
||||
rb_bug("rb_method_entry_min_max_arity: invalid method entry type (%d)", def->type);
|
||||
rb_bug("method_def_min_max_arity: invalid method entry type (%d)", def->type);
|
||||
UNREACHABLE_RETURN(Qnil);
|
||||
}
|
||||
|
||||
static int
|
||||
method_def_aritry(const rb_method_definition_t *def)
|
||||
{
|
||||
int max, min = method_def_min_max_arity(def, &max);
|
||||
return min == max ? min : -min-1;
|
||||
}
|
||||
|
||||
int
|
||||
rb_method_entry_arity(const rb_method_entry_t *me)
|
||||
{
|
||||
int max, min = rb_method_entry_min_max_arity(me, &max);
|
||||
return min == max ? min : -min-1;
|
||||
return method_def_aritry(me->def);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -2786,7 +2790,7 @@ method_min_max_arity(VALUE method, int *max)
|
|||
const struct METHOD *data;
|
||||
|
||||
TypedData_Get_Struct(method, struct METHOD, &method_data_type, data);
|
||||
return rb_method_entry_min_max_arity(data->me, max);
|
||||
return method_def_min_max_arity(data->me->def, max);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
Loading…
Reference in a new issue