summaryrefslogtreecommitdiff
path: root/variable.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-09-25 07:07:43 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-09-25 07:07:43 +0000
commitf33958990a43b8a20ad7ed7eb1d30ec211b46f85 (patch)
treef962530dd96d7c293cba9d8f4bd6318d688c33f2 /variable.c
parentd65fac5daa6838c9c56c6b6dd2f3127fe229d4e8 (diff)
* eval.c (ruby_run): should set toplevel visibility again here.
* eval.c (rb_eval): should not rely on ruby_class == rb_cObject check. Besides allow implicit publicity for attribute set methods. * parse.y (primary): need not to check class_nest, just set whether method is an attrset or not. * string.c (rb_str_each_line): p might be at the top of the string. * variable.c (rb_path2class): should not use rb_eval_string(). * parse.y (str_extend): expression substitution can contain string terminator again. * parse.y (yylex): the warning message "invalid character syntax" was never issued. * file.c (rb_find_file): $LOAD_PATH must not be empty. * file.c (rb_find_file_ext): ditto. * range.c (range_eq): class check should be based on range.class, instead of Range to work with Range.dup. * range.c (range_eql): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_6@2888 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'variable.c')
-rw-r--r--variable.c37
1 files changed, 29 insertions, 8 deletions
diff --git a/variable.c b/variable.c
index 29dc1edb8a..95c03cd3fc 100644
--- a/variable.c
+++ b/variable.c
@@ -221,19 +221,40 @@ VALUE
rb_path2class(path)
const char *path;
{
- VALUE c;
+ const char *pbeg, *p;
+ ID id;
+ VALUE c = rb_cObject;
if (path[0] == '#') {
rb_raise(rb_eArgError, "can't retrieve anonymous class %s", path);
}
- c = rb_eval_string(path);
- switch (TYPE(c)) {
- case T_MODULE:
- case T_CLASS:
- break;
- default:
- rb_raise(rb_eTypeError, "class path %s does not point class", path);
+ pbeg = p = path;
+ while (*p) {
+ VALUE str;
+
+ while (*p && *p != ':') p++;
+ str = rb_str_new(pbeg, p-pbeg);
+ id = rb_intern(RSTRING(str)->ptr);
+ if (p[0] == ':') {
+ if (p[1] != ':') goto undefined_class;
+ p += 2;
+ pbeg = p;
+ }
+ if (!rb_const_defined(c, id)) {
+ undefined_class:
+ rb_raise(rb_eArgError, "undefined class/module %s", rb_id2name(id));
+ rb_raise(rb_eArgError, "undefined class/module %s", path);
+ }
+ c = rb_const_get_at(c, id);
+ switch (TYPE(c)) {
+ case T_MODULE:
+ case T_CLASS:
+ break;
+ default:
+ rb_raise(rb_eTypeError, "%s does not refer class/module %d", path, TYPE(c));
+ }
}
+
return c;
}