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@827 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
beffb7f835
commit
b8e9c32d17
5 changed files with 81 additions and 58 deletions
50
variable.c
50
variable.c
|
@ -1011,6 +1011,33 @@ rb_obj_remove_instance_variable(obj, name)
|
|||
return val;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
top_const_get(klass, id)
|
||||
VALUE klass;
|
||||
ID id;
|
||||
{
|
||||
VALUE value;
|
||||
|
||||
/* pre-defined class */
|
||||
if (st_lookup(rb_class_tbl, id, &value)) return value;
|
||||
|
||||
/* autoload */
|
||||
if (autoload_tbl && st_lookup(autoload_tbl, id, 0)) {
|
||||
rb_autoload_load(id);
|
||||
return rb_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 */
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_const_get_at(klass, id)
|
||||
VALUE klass;
|
||||
|
@ -1022,7 +1049,7 @@ rb_const_get_at(klass, id)
|
|||
return value;
|
||||
}
|
||||
if (klass == rb_cObject) {
|
||||
return rb_const_get(klass, id);
|
||||
return top_const_get(klass, id);
|
||||
}
|
||||
rb_raise(rb_eNameError, "uninitialized constant %s::%s",
|
||||
RSTRING(rb_class_path(klass))->ptr,
|
||||
|
@ -1030,7 +1057,6 @@ rb_const_get_at(klass, id)
|
|||
return Qnil; /* not reached */
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
rb_autoload_load(id)
|
||||
ID id;
|
||||
|
@ -1063,25 +1089,7 @@ rb_const_get(klass, id)
|
|||
if (BUILTIN_TYPE(klass) == T_MODULE) {
|
||||
return rb_const_get(rb_cObject, id);
|
||||
}
|
||||
|
||||
/* pre-defined class */
|
||||
if (st_lookup(rb_class_tbl, id, &value)) return value;
|
||||
|
||||
/* autoload */
|
||||
if (autoload_tbl && st_lookup(autoload_tbl, id, 0)) {
|
||||
rb_autoload_load(id);
|
||||
return rb_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 */
|
||||
return top_const_get(klass, id);
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue