mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* class.c (rb_define_class, rb_define_module): also set constant under
Object. [ruby-dev:20445] * object.c (boot_defclass): ditto. * variable.c (rb_const_get_at, rb_const_get_0, rb_mod_const_at, rb_const_defined, mod_av_set, rb_const_assign): toplevel constants are now under Object, rb_class_tbl remains for GC. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4019 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7bb1e40d8b
commit
442c836bfe
4 changed files with 15 additions and 27 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
Tue Jul 1 10:36:19 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
|
||||
|
||||
* class.c (rb_define_class, rb_define_module): also set constant under
|
||||
Object. [ruby-dev:20445]
|
||||
|
||||
* object.c (boot_defclass): ditto.
|
||||
|
||||
* variable.c (rb_const_get_at, rb_const_get_0, rb_mod_const_at,
|
||||
rb_const_defined, mod_av_set, rb_const_assign): toplevel constants
|
||||
are now under Object, rb_class_tbl remains for GC.
|
||||
|
||||
Mon Jun 30 17:53:06 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
|
||||
|
||||
* eval.c (mnew): ignore metaclasses have no influence, for rklass.
|
||||
|
|
2
class.c
2
class.c
|
@ -213,6 +213,7 @@ rb_define_class(name, super)
|
|||
}
|
||||
klass = rb_define_class_id(id, super);
|
||||
st_add_direct(rb_class_tbl, id, klass);
|
||||
rb_const_set(rb_cObject, id, klass);
|
||||
rb_class_inherited(super, klass);
|
||||
|
||||
return klass;
|
||||
|
@ -292,6 +293,7 @@ rb_define_module(name)
|
|||
}
|
||||
module = rb_define_module_id(id);
|
||||
st_add_direct(rb_class_tbl, id, module);
|
||||
rb_const_set(rb_cObject, id, module);
|
||||
|
||||
return module;
|
||||
}
|
||||
|
|
1
object.c
1
object.c
|
@ -1341,6 +1341,7 @@ boot_defclass(name, super)
|
|||
|
||||
rb_name_class(obj, id);
|
||||
st_add_direct(rb_class_tbl, id, obj);
|
||||
rb_const_set((rb_cObject ? rb_cObject : obj), id, obj);
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
|
28
variable.c
28
variable.c
|
@ -1254,16 +1254,6 @@ rb_autoload_p(mod, id)
|
|||
return autoload_file(mod, id);
|
||||
}
|
||||
|
||||
static int
|
||||
top_const_get(id, klassp)
|
||||
ID id;
|
||||
VALUE *klassp;
|
||||
{
|
||||
/* pre-defined class */
|
||||
if (st_lookup(rb_class_tbl, id, klassp)) return Qtrue;
|
||||
return Qfalse;
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_const_get_at(klass, id)
|
||||
VALUE klass;
|
||||
|
@ -1278,9 +1268,6 @@ rb_const_get_at(klass, id)
|
|||
}
|
||||
return value;
|
||||
}
|
||||
if (klass == rb_cObject && top_const_get(id, &value)) {
|
||||
return value;
|
||||
}
|
||||
uninitialized_constant(klass, id);
|
||||
return Qnil; /* not reached */
|
||||
}
|
||||
|
@ -1308,7 +1295,6 @@ rb_const_get_0(klass, id, exclude)
|
|||
}
|
||||
return value;
|
||||
}
|
||||
if (tmp == rb_cObject && top_const_get(id, &value)) return value;
|
||||
tmp = RCLASS(tmp)->super;
|
||||
}
|
||||
if (!mod_retry && BUILTIN_TYPE(klass) == T_MODULE) {
|
||||
|
@ -1393,9 +1379,6 @@ rb_mod_const_at(mod, data)
|
|||
if (RCLASS(mod)->iv_tbl) {
|
||||
st_foreach(RCLASS(mod)->iv_tbl, sv_i, (st_data_t)tbl);
|
||||
}
|
||||
if ((VALUE)mod == rb_cObject) {
|
||||
st_foreach(rb_class_tbl, sv_i, (st_data_t)tbl);
|
||||
}
|
||||
return tbl;
|
||||
}
|
||||
|
||||
|
@ -1500,8 +1483,6 @@ rb_const_defined(klass, id)
|
|||
if (BUILTIN_TYPE(klass) == T_MODULE) {
|
||||
return rb_const_defined(rb_cObject, id);
|
||||
}
|
||||
if (st_lookup(rb_class_tbl, id, 0))
|
||||
return Qtrue;
|
||||
return Qfalse;
|
||||
}
|
||||
|
||||
|
@ -1523,8 +1504,7 @@ mod_av_set(klass, id, val, isconst)
|
|||
else if (isconst) {
|
||||
VALUE value = Qfalse;
|
||||
|
||||
if (st_lookup(RCLASS(klass)->iv_tbl, id, &value) ||
|
||||
(klass == rb_cObject && st_lookup(rb_class_tbl, id, 0))) {
|
||||
if (st_lookup(RCLASS(klass)->iv_tbl, id, &value)) {
|
||||
if (value == Qundef)
|
||||
autoload_delete(klass, id);
|
||||
else
|
||||
|
@ -1559,12 +1539,6 @@ rb_const_assign(klass, id, val)
|
|||
}
|
||||
tmp = RCLASS(tmp)->super;
|
||||
}
|
||||
/* pre-defined class */
|
||||
if (st_lookup(rb_class_tbl, id, 0)) {
|
||||
st_delete(rb_class_tbl, &id, 0);
|
||||
st_insert(RCLASS(rb_cObject)->iv_tbl, id, val);
|
||||
return;
|
||||
}
|
||||
|
||||
uninitialized_constant(klass, id);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue