summaryrefslogtreecommitdiffhomepage
path: root/src/variable.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/variable.c')
-rw-r--r--src/variable.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/variable.c b/src/variable.c
index 992663408..147373bd4 100644
--- a/src/variable.c
+++ b/src/variable.c
@@ -673,26 +673,38 @@ mrb_mod_class_variables(mrb_state *mrb, mrb_value mod)
return ary;
}
-
mrb_value
-mrb_vm_cv_get(mrb_state *mrb, mrb_sym sym)
+mrb_mod_cv_get(mrb_state *mrb, struct RClass * c, mrb_sym sym)
{
- struct RClass *c = mrb->ci->proc->target_class;
-
- if (!c) c = mrb->ci->target_class;
while (c) {
if (c->iv) {
iv_tbl *t = c->iv;
mrb_value v;
if (iv_get(mrb, t, sym, &v))
- return v;
+ return v;
}
c = c->super;
}
return mrb_nil_value();
}
+mrb_value
+mrb_cv_get(mrb_state *mrb, mrb_value mod, mrb_sym sym)
+{
+ return mrb_mod_cv_get(mrb, mrb_class_ptr(mod), sym);
+}
+
+mrb_value
+mrb_vm_cv_get(mrb_state *mrb, mrb_sym sym)
+{
+ struct RClass *c = mrb->ci->proc->target_class;
+
+ if (!c) c = mrb->ci->target_class;
+
+ return mrb_mod_cv_get(mrb, c, sym);
+}
+
void
mrb_vm_cv_set(mrb_state *mrb, mrb_sym sym, mrb_value v)
{