1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Expand cross-recursion to a loop

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66442 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2018-12-18 15:11:17 +00:00
parent 011bee2d32
commit a80cc953aa

View file

@ -921,50 +921,37 @@ rb_callable_method_entry_without_refinements(VALUE klass, ID id, VALUE *defined_
return prepare_callable_method_entry(*dcp, id, me);
}
static const rb_method_entry_t *
refined_method_original_method_entry(VALUE refinements, const rb_method_entry_t *me, VALUE *defined_class_ptr)
{
VALUE super;
if (me->def->body.refined.orig_me) {
if (defined_class_ptr) *defined_class_ptr = me->def->body.refined.orig_me->defined_class;
return me->def->body.refined.orig_me;
}
else if (!(super = RCLASS_SUPER(me->owner))) {
return 0;
}
else {
rb_method_entry_t *tmp_me;
tmp_me = method_entry_get(super, me->called_id, defined_class_ptr);
return resolve_refined_method(refinements, tmp_me, defined_class_ptr);
}
}
static const rb_method_entry_t *
resolve_refined_method(VALUE refinements, const rb_method_entry_t *me, VALUE *defined_class_ptr)
{
if (me && me->def->type == VM_METHOD_TYPE_REFINED) {
while (me && me->def->type == VM_METHOD_TYPE_REFINED) {
VALUE refinement;
rb_method_entry_t *tmp_me;
VALUE super;
refinement = find_refinement(refinements, me->owner);
if (NIL_P(refinement)) {
return refined_method_original_method_entry(refinements, me, defined_class_ptr);
}
else {
if (!NIL_P(refinement)) {
tmp_me = method_entry_get(refinement, me->called_id, defined_class_ptr);
if (tmp_me && tmp_me->def->type != VM_METHOD_TYPE_REFINED) {
return tmp_me;
}
else {
return refined_method_original_method_entry(refinements, me, defined_class_ptr);
}
}
tmp_me = me->def->body.refined.orig_me;
if (tmp_me) {
if (defined_class_ptr) *defined_class_ptr = tmp_me->defined_class;
return tmp_me;
}
super = RCLASS_SUPER(me->owner);
if (!super) {
return 0;
}
me = method_entry_get(super, me->called_id, defined_class_ptr);
}
else {
return me;
}
return me;
}
const rb_method_entry_t *