summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/mruby/variable.h1
-rw-r--r--src/variable.c15
2 files changed, 16 insertions, 0 deletions
diff --git a/include/mruby/variable.h b/include/mruby/variable.h
index 7189ef690..d33a20d5e 100644
--- a/include/mruby/variable.h
+++ b/include/mruby/variable.h
@@ -55,6 +55,7 @@ mrb_value mrb_obj_instance_variables(mrb_state*, mrb_value);
mrb_value mrb_obj_iv_inspect(mrb_state*, struct RObject*);
mrb_sym mrb_class_sym(mrb_state *mrb, struct RClass *c, struct RClass *outer);
mrb_value mrb_mod_class_variables(mrb_state*, mrb_value);
+mrb_value mrb_mod_cv_get(mrb_state *mrb, struct RClass * c, mrb_sym sym);
/* GC functions */
void mrb_gc_mark_gv(mrb_state*);
diff --git a/src/variable.c b/src/variable.c
index 992663408..b4e262f8d 100644
--- a/src/variable.c
+++ b/src/variable.c
@@ -673,6 +673,21 @@ mrb_mod_class_variables(mrb_state *mrb, mrb_value mod)
return ary;
}
+mrb_value
+mrb_mod_cv_get(mrb_state *mrb, struct RClass * c, mrb_sym sym)
+{
+ while (c) {
+ if (c->iv) {
+ iv_tbl *t = c->iv;
+ mrb_value v;
+
+ if (iv_get(mrb, t, sym, &v))
+ return v;
+ }
+ c = c->super;
+ }
+ return mrb_nil_value();
+}
mrb_value
mrb_vm_cv_get(mrb_state *mrb, mrb_sym sym)