зеркало из https://github.com/github/ruby.git
refactoring rb_method_call_status()
This commit is contained in:
Родитель
1ecda21366
Коммит
98e27016c9
27
vm_eval.c
27
vm_eval.c
|
@ -770,33 +770,30 @@ rb_search_method_entry(VALUE recv, ID mid)
|
||||||
static inline enum method_missing_reason
|
static inline enum method_missing_reason
|
||||||
rb_method_call_status(rb_execution_context_t *ec, const rb_callable_method_entry_t *me, call_type scope, VALUE self)
|
rb_method_call_status(rb_execution_context_t *ec, const rb_callable_method_entry_t *me, call_type scope, VALUE self)
|
||||||
{
|
{
|
||||||
VALUE klass;
|
if (UNLIKELY(UNDEFINED_METHOD_ENTRY_P(me))) {
|
||||||
ID oid;
|
|
||||||
rb_method_visibility_t visi;
|
|
||||||
|
|
||||||
if (UNDEFINED_METHOD_ENTRY_P(me)) {
|
|
||||||
goto undefined;
|
goto undefined;
|
||||||
}
|
}
|
||||||
if (me->def->type == VM_METHOD_TYPE_REFINED) {
|
else if (UNLIKELY(me->def->type == VM_METHOD_TYPE_REFINED)) {
|
||||||
me = rb_resolve_refined_method_callable(Qnil, me);
|
me = rb_resolve_refined_method_callable(Qnil, me);
|
||||||
if (UNDEFINED_METHOD_ENTRY_P(me)) goto undefined;
|
if (UNDEFINED_METHOD_ENTRY_P(me)) goto undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
klass = me->owner;
|
rb_method_visibility_t visi = METHOD_ENTRY_VISI(me);
|
||||||
oid = me->def->original_id;
|
|
||||||
visi = METHOD_ENTRY_VISI(me);
|
|
||||||
|
|
||||||
if (oid != idMethodMissing) {
|
|
||||||
/* receiver specified form for private method */
|
/* receiver specified form for private method */
|
||||||
if (UNLIKELY(visi != METHOD_VISI_PUBLIC)) {
|
if (UNLIKELY(visi != METHOD_VISI_PUBLIC)) {
|
||||||
if (visi == METHOD_VISI_PRIVATE && scope == CALL_PUBLIC) {
|
if (me->def->original_id == idMethodMissing) {
|
||||||
|
return MISSING_NONE;
|
||||||
|
}
|
||||||
|
else if (visi == METHOD_VISI_PRIVATE &&
|
||||||
|
scope == CALL_PUBLIC) {
|
||||||
return MISSING_PRIVATE;
|
return MISSING_PRIVATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* self must be kind of a specified form for protected method */
|
/* self must be kind of a specified form for protected method */
|
||||||
if (visi == METHOD_VISI_PROTECTED && scope == CALL_PUBLIC) {
|
else if (visi == METHOD_VISI_PROTECTED &&
|
||||||
VALUE defined_class = klass;
|
scope == CALL_PUBLIC) {
|
||||||
|
|
||||||
|
VALUE defined_class = me->owner;
|
||||||
if (RB_TYPE_P(defined_class, T_ICLASS)) {
|
if (RB_TYPE_P(defined_class, T_ICLASS)) {
|
||||||
defined_class = RBASIC(defined_class)->klass;
|
defined_class = RBASIC(defined_class)->klass;
|
||||||
}
|
}
|
||||||
|
@ -806,9 +803,9 @@ rb_method_call_status(rb_execution_context_t *ec, const rb_callable_method_entry
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return MISSING_NONE;
|
return MISSING_NONE;
|
||||||
|
|
||||||
undefined:
|
undefined:
|
||||||
return scope == CALL_VCALL ? MISSING_VCALL : MISSING_NOENTRY;
|
return scope == CALL_VCALL ? MISSING_VCALL : MISSING_NOENTRY;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче