diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2012-12-23 06:27:17 -0800 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2012-12-23 06:27:17 -0800 |
| commit | 210193478a367db9912907cb822c176e8161300f (patch) | |
| tree | e44769acdba7e82d937275454aa1140edce3d71a /src/variable.c | |
| parent | b42d17adb3d4a8481b3399b5e2ce2a8b783f9aea (diff) | |
| parent | bdd0cc01119d6bd0d6f9d4e4ad16f7af56e6834f (diff) | |
| download | mruby-210193478a367db9912907cb822c176e8161300f.tar.gz mruby-210193478a367db9912907cb822c176e8161300f.zip | |
Merge pull request #669 from skandhas/pr-add-Module-class-variable-defined
Add Module#class_variable_defined? for mruby
Diffstat (limited to 'src/variable.c')
| -rw-r--r-- | src/variable.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/variable.c b/src/variable.c index 71187af5f..5d46ffc60 100644 --- a/src/variable.c +++ b/src/variable.c @@ -730,6 +730,26 @@ mrb_cv_set(mrb_state *mrb, mrb_value mod, mrb_sym sym, mrb_value v) mrb_mod_cv_set(mrb, mrb_class_ptr(mod), sym, v); } +int +mrb_mod_cv_defined(mrb_state *mrb, struct RClass * c, mrb_sym sym) +{ + while (c) { + if (c->iv) { + iv_tbl *t = c->iv; + if (iv_get(mrb, t, sym, NULL)) return TRUE; + } + c = c->super; + } + + return FALSE; +} + +int +mrb_cv_defined(mrb_state *mrb, mrb_value mod, mrb_sym sym) +{ + return mrb_mod_cv_defined(mrb, mrb_class_ptr(mod), sym); +} + mrb_value mrb_vm_cv_get(mrb_state *mrb, mrb_sym sym) { |
