summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorYuichiro MASUI <[email protected]>2012-05-05 00:14:56 +0900
committerYuichiro MASUI <[email protected]>2012-05-05 00:14:56 +0900
commit885cb32d1c744e288fb8fd3b0b8834cd603f793f (patch)
tree3c05b0f5fff6c2c766a8d9c6fa7e4d5706013083 /src
parent91a90540737ddc233d0c68dea05d779fafc32e8e (diff)
downloadmruby-885cb32d1c744e288fb8fd3b0b8834cd603f793f.tar.gz
mruby-885cb32d1c744e288fb8fd3b0b8834cd603f793f.zip
add Object.const_missing
Diffstat (limited to 'src')
-rw-r--r--src/variable.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/variable.c b/src/variable.c
index f4ec46789..38306d4ba 100644
--- a/src/variable.c
+++ b/src/variable.c
@@ -259,6 +259,16 @@ const_get(mrb_state *mrb, struct RClass *base, mrb_sym sym)
}
c = c->super;
}
+
+ if (!c) {
+ c = mrb->object_class;
+ }
+
+ if (mrb_respond_to(mrb, mrb_obj_value(c), mrb_intern(mrb, "const_missing"))) {
+ mrb_value argv = mrb_symbol_value(sym);
+ return mrb_funcall_argv(mrb, mrb_obj_value(c), "const_missing", 1, &argv);
+ }
+
mrb_raise(mrb, E_NAME_ERROR, "uninitialized constant %s",
mrb_sym2name(mrb, sym));
/* not reached */