summaryrefslogtreecommitdiff
path: root/variable.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-08-30 00:04:02 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-08-30 00:04:02 +0000
commit8e9fbbf6d6f4c47286a6fbc4e2c4e77189be119b (patch)
tree2018232d06deec66076a9ddff0988f737c367366 /variable.c
parentda84ad63ee95265dfbdd51c370cdfe5f91e58d59 (diff)
* eval.c (struct BLOCK): remove BLOCKTAG, use scope instead.
* eval.c (POP_TAG): no longer propagate retval. retval is now set directly by localjump_destination(). * eval.c (localjump_destination): new function to cast return/break local jump. * eval.c (rb_yield_0): stop TAG_RETURN/TAG_BREAK escaping. * variable.c (rb_autoload_load): call const_missing if autoloading constant is not defined to allow hook. * eval.c (rb_eval): use rb_const_get_from() instead of rb_const_get_at(). * eval.c (is_defined): forgot to check NODE_COLON3. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4462 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'variable.c')
-rw-r--r--variable.c68
1 files changed, 27 insertions, 41 deletions
diff --git a/variable.c b/variable.c
index d182a703cc..444e2eed62 100644
--- a/variable.c
+++ b/variable.c
@@ -1207,11 +1207,8 @@ rb_autoload_load(klass, id)
VALUE file;
file = autoload_delete(klass, id);
- if (NIL_P(file)) {
- uninitialized_constant(klass, id);
- }
- if (rb_provided(RSTRING(file)->ptr)) {
- uninitialized_constant(klass, id);
+ if (NIL_P(file) || rb_provided(RSTRING(file)->ptr)) {
+ const_missing(klass, id);
}
FL_UNSET(file, FL_TAINT);
rb_f_require(Qnil, file);
@@ -1268,8 +1265,7 @@ static VALUE
rb_const_get_0(klass, id, exclude, recurse)
VALUE klass;
ID id;
- int exclude;
- int recurse;
+ int exclude, recurse;
{
VALUE value, tmp;
int mod_retry = 0;
@@ -1429,28 +1425,11 @@ rb_mod_constants(mod)
return rb_const_list(rb_mod_const_of(mod, 0));
}
-int
-rb_const_defined_at(klass, id)
- VALUE klass;
- ID id;
-{
- VALUE value;
-
- if (RCLASS(klass)->iv_tbl && st_lookup(RCLASS(klass)->iv_tbl, id, &value)) {
- if (value == Qundef && NIL_P(autoload_file(klass, id)))
- return Qfalse;
- return Qtrue;
- }
- if (klass == rb_cObject) {
- return rb_const_defined(klass, id);
- }
- return Qfalse;
-}
-
-int
-rb_const_defined_from(klass, id)
+static int
+rb_const_defined_0(klass, id, exclude, recurse)
VALUE klass;
ID id;
+ int exclude, recurse;
{
VALUE tmp = klass, value;
@@ -1463,30 +1442,37 @@ rb_const_defined_from(klass, id)
return Qfalse;
return Qtrue;
}
+ if (!recurse && klass != rb_cObject) break;
tmp = RCLASS(tmp)->super;
}
+ if (!exclude && BUILTIN_TYPE(klass) == T_MODULE) {
+ return rb_const_defined(rb_cObject, id);
+ }
return Qfalse;
}
int
-rb_const_defined(klass, id)
+rb_const_defined_at(klass, id)
VALUE klass;
ID id;
{
- VALUE tmp = klass, value;
+ return rb_const_defined_0(klass, id, Qtrue, Qfalse);
+}
- while (tmp) {
- if (RCLASS(tmp)->iv_tbl && st_lookup(RCLASS(tmp)->iv_tbl, id, &value)) {
- if (value == Qundef && NIL_P(autoload_file(klass, id)))
- return Qfalse;
- return Qtrue;
- }
- tmp = RCLASS(tmp)->super;
- }
- if (BUILTIN_TYPE(klass) == T_MODULE) {
- return rb_const_defined(rb_cObject, id);
- }
- return Qfalse;
+int
+rb_const_defined_from(klass, id)
+ VALUE klass;
+ ID id;
+{
+ return rb_const_defined_0(klass, id, Qfalse, Qtrue);
+}
+
+int
+rb_const_defined(klass, id)
+ VALUE klass;
+ ID id;
+{
+ return rb_const_defined_0(klass, id, Qtrue, Qtrue);
}
static void