Commit 92f19252 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge pull request #225 from MobiRuby/fixed_const_missing

fixed const_get && const_missing issue
parents 8dc9e0d8 e473ce1a
......@@ -233,26 +233,8 @@ const_get(mrb_state *mrb, struct RClass *base, mrb_sym sym)
struct RClass *c = base;
khash_t(iv) *h;
khiter_t k;
mrb_sym cm = mrb_intern(mrb, "const_missing");
if (c->iv) {
h = c->iv;
k = kh_get(iv, h, sym);
if (k != kh_end(h)) {
return kh_value(h, k);
}
}
for (;;) {
c = mrb_class_outer_module(mrb, c);
if (!c) break;
if (c->iv) {
h = c->iv;
k = kh_get(iv, h, sym);
if (k != kh_end(h)) {
return kh_value(h, k);
}
}
}
c = base->super;
while (c) {
if (c->iv) {
h = c->iv;
......@@ -260,18 +242,13 @@ const_get(mrb_state *mrb, struct RClass *base, mrb_sym sym)
if (k != kh_end(h)) {
return kh_value(h, k);
}
}
c = c->super;
}
if (!c) {
c = mrb->object_class;
}
if (mrb_respond_to(mrb, mrb_obj_value(c), mrb_intern(mrb, "const_missing"))) {
if (mrb_respond_to(mrb, mrb_obj_value(c), cm)) {
mrb_value argv = mrb_symbol_value(sym);
return mrb_funcall_argv(mrb, mrb_obj_value(c), "const_missing", 1, &argv);
}
}
c = c->super;
}
mrb_raise(mrb, E_NAME_ERROR, "uninitialized constant %s",
mrb_sym2name(mrb, sym));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment