summaryrefslogtreecommitdiff
path: root/vm_insnhelper.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-09-02 05:36:49 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-09-02 05:36:49 +0000
commit7dddaf680710795bba628db7ca02f4d3f1a57b1c (patch)
treee53fcda157022f459185c63023a2064bbea55a6a /vm_insnhelper.c
parent5e14b979476566916d2ff0dd255a6d1694ac7166 (diff)
* vm_insnhelper.c (vm_search_const_defined_class): search
ancestors only when global scope. [ruby-core:39227] [Bug #5264] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33163 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r--vm_insnhelper.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index 91c335c99b..98f6ea93e1 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -1253,15 +1253,18 @@ vm_get_cvar_base(NODE *cref)
return klass;
}
-static int
-vm_const_defined_at(VALUE cbase, ID id, int newclass)
+static VALUE
+vm_search_const_defined_class(const VALUE cbase, ID id)
{
- int ret = rb_const_defined_at(cbase, id);
- if (!ret && !newclass) {
- while ((cbase = RCLASS_SUPER(cbase)) != 0 && cbase != rb_cObject &&
- !(ret = rb_const_defined_at(cbase, id)));
+ if (rb_const_defined_at(cbase, id)) return cbase;
+ if (cbase == rb_cObject) {
+ VALUE tmp = RCLASS_SUPER(cbase);
+ while (tmp) {
+ if (rb_const_defined_at(tmp, id)) return tmp;
+ tmp = RCLASS_SUPER(tmp);
+ }
}
- return ret;
+ return 0;
}
#ifndef USE_IC_FOR_IVAR