mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
matz
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@831 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ec9fbf3939
commit
1ad26ccf35
2 changed files with 24 additions and 18 deletions
|
@ -1,5 +1,9 @@
|
||||||
Wed Jul 12 15:32:57 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
|
Wed Jul 12 15:32:57 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||||
|
|
||||||
|
* variable.c (rb_const_get): constants for builtin classes must
|
||||||
|
have higher priority than constants from included modules at
|
||||||
|
Object class.
|
||||||
|
|
||||||
* bignum.c (bigdivrem): small embarrassing typo.
|
* bignum.c (bigdivrem): small embarrassing typo.
|
||||||
|
|
||||||
Wed Jul 12 15:06:28 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
|
Wed Jul 12 15:06:28 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||||
|
|
38
variable.c
38
variable.c
|
@ -1011,31 +1011,23 @@ rb_obj_remove_instance_variable(obj, name)
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static int
|
||||||
top_const_get(klass, id)
|
top_const_get(id, klassp)
|
||||||
VALUE klass;
|
|
||||||
ID id;
|
ID id;
|
||||||
|
VALUE *klassp;
|
||||||
{
|
{
|
||||||
VALUE value;
|
VALUE value;
|
||||||
|
|
||||||
/* pre-defined class */
|
/* pre-defined class */
|
||||||
if (st_lookup(rb_class_tbl, id, &value)) return value;
|
if (st_lookup(rb_class_tbl, id, klassp)) return Qtrue;
|
||||||
|
|
||||||
/* autoload */
|
/* autoload */
|
||||||
if (autoload_tbl && st_lookup(autoload_tbl, id, 0)) {
|
if (autoload_tbl && st_lookup(autoload_tbl, id, 0)) {
|
||||||
rb_autoload_load(id);
|
rb_autoload_load(id);
|
||||||
return rb_const_get(klass, id);
|
*klassp = rb_const_get(rb_cObject, id);
|
||||||
|
return Qtrue;
|
||||||
}
|
}
|
||||||
|
return Qfalse;
|
||||||
/* Uninitialized constant */
|
|
||||||
if (klass && klass != rb_cObject)
|
|
||||||
rb_raise(rb_eNameError, "uninitialized constant %s::%s",
|
|
||||||
RSTRING(rb_class_path(klass))->ptr,
|
|
||||||
rb_id2name(id));
|
|
||||||
else {
|
|
||||||
rb_raise(rb_eNameError, "uninitialized constant %s",rb_id2name(id));
|
|
||||||
}
|
|
||||||
return Qnil; /* not reached */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
|
@ -1048,8 +1040,8 @@ rb_const_get_at(klass, id)
|
||||||
if (RCLASS(klass)->iv_tbl && st_lookup(RCLASS(klass)->iv_tbl, id, &value)) {
|
if (RCLASS(klass)->iv_tbl && st_lookup(RCLASS(klass)->iv_tbl, id, &value)) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
if (klass == rb_cObject) {
|
if (klass == rb_cObject && top_const_get(id, &value)) {
|
||||||
return top_const_get(klass, id);
|
return value;
|
||||||
}
|
}
|
||||||
rb_raise(rb_eNameError, "uninitialized constant %s::%s",
|
rb_raise(rb_eNameError, "uninitialized constant %s::%s",
|
||||||
RSTRING(rb_class_path(klass))->ptr,
|
RSTRING(rb_class_path(klass))->ptr,
|
||||||
|
@ -1084,12 +1076,22 @@ rb_const_get(klass, id)
|
||||||
if (RCLASS(tmp)->iv_tbl && st_lookup(RCLASS(tmp)->iv_tbl,id,&value)) {
|
if (RCLASS(tmp)->iv_tbl && st_lookup(RCLASS(tmp)->iv_tbl,id,&value)) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
if (tmp == rb_cObject && top_const_get(id, &value)) return value;
|
||||||
tmp = RCLASS(tmp)->super;
|
tmp = RCLASS(tmp)->super;
|
||||||
}
|
}
|
||||||
if (BUILTIN_TYPE(klass) == T_MODULE) {
|
if (BUILTIN_TYPE(klass) == T_MODULE) {
|
||||||
return rb_const_get(rb_cObject, id);
|
return rb_const_get(rb_cObject, id);
|
||||||
}
|
}
|
||||||
return top_const_get(klass, id);
|
|
||||||
|
/* Uninitialized constant */
|
||||||
|
if (klass && klass != rb_cObject)
|
||||||
|
rb_raise(rb_eNameError, "uninitialized constant %s::%s",
|
||||||
|
RSTRING(rb_class_path(klass))->ptr,
|
||||||
|
rb_id2name(id));
|
||||||
|
else {
|
||||||
|
rb_raise(rb_eNameError, "uninitialized constant %s",rb_id2name(id));
|
||||||
|
}
|
||||||
|
return Qnil; /* not reached */
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue