diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-02-08 05:20:34 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-02-08 05:20:34 +0000 |
commit | d4110a1e7150384ace36a42a9483d1772f12b8c8 (patch) | |
tree | 24f82ed966318b3bf512feec2aa15b164cc8fba1 | |
parent | ebd6cbda2fb3727a54735071ed9845765ffe5a06 (diff) |
* parse.y (yycompile): should inherit "in_single" if eval happened
in a singleton method.
* eval.c (rb_eval): class variables from singleton methods defined
within singleton class statement should work like ones defined
by sington def statements.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_6@2058 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | eval.c | 3 | ||||
-rw-r--r-- | parse.y | 4 | ||||
-rw-r--r-- | variable.c | 3 |
4 files changed, 17 insertions, 2 deletions
@@ -5,6 +5,15 @@ Fri Feb 8 05:39:15 2002 Minero Aoki <aamine@loveruby.net> * lib/net/http.rb: initialize HTTP.proxy_port by HTTP.port. +Fri Feb 8 01:27:33 2002 Yukihiro Matsumoto <matz@ruby-lang.org> + + * parse.y (yycompile): should inherit "in_single" if eval happened + in a singleton method. + + * eval.c (rb_eval): class variables from singleton methods defined + within singleton class statement should work like ones defined + by sington def statements. + Thu Feb 07 13:44:08 2002 akira yamada <akira@arika.org> * uri/common.rb (URI::join): new method. @@ -1847,7 +1847,6 @@ is_defined(self, node, buf) } break; } - self = rb_iv_get(ruby_cbase, "__attached__"); /* fall through */ case NODE_CVAR2: if (rb_cvar_defined(rb_cvar_singleton(self), node->nd_vid)) { @@ -4598,7 +4597,7 @@ rb_call(klass, recv, mid, argc, argv, scope) /* self must be kind of a specified form for private method */ if ((noex & NOEX_PROTECTED)) { VALUE defined_class = klass; - while (TYPE(defined_class) == T_ICLASS) + if (TYPE(defined_class) == T_ICLASS) defined_class = RBASIC(defined_class)->klass; if (!rb_obj_is_kind_of(ruby_frame->self, defined_class)) return rb_undefined(recv, mid, argc, argv, CSTAT_PROT); @@ -1974,6 +1974,10 @@ yycompile(f, line) heredoc_end = 0; ruby_sourcefile = strdup(f); ruby_in_compile = 1; + if (ruby_frame && ruby_frame->last_class && + FL_TEST(ruby_frame->last_class, FL_SINGLETON)) { + in_single = 1; + } n = yyparse(); ruby_debug_lines = 0; compile_for_eval = 0; diff --git a/variable.c b/variable.c index 878d858849..76bc8311a8 100644 --- a/variable.c +++ b/variable.c @@ -145,6 +145,9 @@ classname(klass) VALUE path = Qnil; ID classpath = rb_intern("__classpath__"); + if (TYPE(klass) == T_ICLASS) { + klass = RBASIC(klass)->klass; + } klass = rb_class_real(klass); if (!klass) klass = rb_cObject; if (ROBJECT(klass)->iv_tbl && |