diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-02-17 08:40:52 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-02-17 08:40:52 +0000 |
commit | de107086de30354decab4d434064679e325e18dd (patch) | |
tree | 3603c905bbb81de90e8de49e1b476c96137a7370 /eval.c | |
parent | 35bd64b5d517faf8e4e0f40f214312e6bfbaede6 (diff) | |
download | ruby-de107086de30354decab4d434064679e325e18dd.tar.gz ruby-de107086de30354decab4d434064679e325e18dd.tar.xz ruby-de107086de30354decab4d434064679e325e18dd.zip |
* eval.c (ev_const_get): simplified using rb_const_get_fallback().
* eval.c (ev_const_defined): adopt to ev_const_get() using
rb_const_defined_fallback().
* variable.c (rb_const_get_fallback): new function to implement
constant search.
* variable.c (rb_const_defined_fallback): new function to
implement constant definition check.
* variable.c (rb_const_get_0): adopt to new behavior. constants
are looked up in the order of: current class, super classes (but
Object), lexically external classes/modules, and Object.
* variable.c (rb_const_defined_0): ditto.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@9949 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 36 |
1 files changed, 2 insertions, 34 deletions
@@ -1776,45 +1776,13 @@ ruby_current_class_object() static VALUE ev_const_defined(ID id, VALUE self) { - NODE *cbase = ruby_cref; - VALUE result; - - while (cbase && cbase->nd_next) { - struct RClass *klass = RCLASS(cbase->nd_clss); - - if (NIL_P(klass)) return rb_const_defined(CLASS_OF(self), id); - if (klass->iv_tbl && st_lookup(klass->iv_tbl, id, &result)) { - if (result == Qundef && NIL_P(rb_autoload_p((VALUE)klass, id))) { - return Qfalse; - } - return Qtrue; - } - cbase = cbase->nd_next; - } - return rb_const_defined(ruby_cbase, id); + return rb_const_defined_fallback(ruby_cbase, id, ruby_cref->nd_next); } static VALUE ev_const_get(ID id, VALUE self) { - NODE *cbase = ruby_cref; - VALUE result; - - while (cbase && cbase->nd_next) { - VALUE klass = cbase->nd_clss; - - if (NIL_P(klass)) return rb_const_get(CLASS_OF(self), id); - while (RCLASS(klass)->iv_tbl && - st_lookup(RCLASS(klass)->iv_tbl, id, &result)) { - if (result == Qundef) { - if (!RTEST(rb_autoload_load(klass, id))) break; - continue; - } - return result; - } - cbase = cbase->nd_next; - } - return rb_const_get(ruby_cbase, id); + return rb_const_get_fallback(ruby_cbase, id, ruby_cref->nd_next); } static VALUE |