* eval.c (rb_eval): singleton chech should be moved from yycompile

to here.

* eval.c (is_defined): check should be added here too.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2060 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2002-02-09 14:47:52 +00:00
parent 3d44db882b
commit f2f74e91bf
3 changed files with 30 additions and 21 deletions

View File

@ -1,3 +1,10 @@
Fri Feb 8 23:07:23 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (rb_eval): singleton chech should be moved from yycompile
to here.
* eval.c (is_defined): check should be added here too.
Fri Feb 8 05:31:48 2002 Minero Aoki <aamine@loveruby.net> Fri Feb 8 05:31:48 2002 Minero Aoki <aamine@loveruby.net>
* lib/net/http.rb: HTTP.Proxy should use self for proxy-class's * lib/net/http.rb: HTTP.Proxy should use self for proxy-class's

40
eval.c
View File

@ -1899,19 +1899,21 @@ is_defined(self, node, buf)
break; break;
case NODE_CVAR: case NODE_CVAR:
if (NIL_P(ruby_cbase)) { if (!ruby_frame || !ruby_frame->last_class ||
if (rb_cvar_defined(CLASS_OF(self), node->nd_vid)) { !FL_TEST(ruby_frame->last_class, FL_SINGLETON)) {
return "class variable"; if (NIL_P(ruby_cbase)) {
if (rb_cvar_defined(CLASS_OF(self), node->nd_vid)) {
return "class variable";
}
break;
} }
break; if (!FL_TEST(ruby_cbase, FL_SINGLETON)) {
} if (rb_cvar_defined(ruby_cbase, node->nd_vid)) {
if (!FL_TEST(ruby_cbase, FL_SINGLETON)) { return "class variable";
if (rb_cvar_defined(ruby_cbase, node->nd_vid)) { }
return "class variable"; break;
} }
break;
} }
self = rb_iv_get(ruby_cbase, "__attached__");
/* fall through */ /* fall through */
case NODE_CVAR2: case NODE_CVAR2:
if (rb_cvar_defined(rb_cvar_singleton(self), node->nd_vid)) { if (rb_cvar_defined(rb_cvar_singleton(self), node->nd_vid)) {
@ -2901,13 +2903,17 @@ rb_eval(self, n)
break; break;
case NODE_CVAR: /* normal method */ case NODE_CVAR: /* normal method */
if (NIL_P(ruby_cbase)) { if (!ruby_frame || !ruby_frame->last_class ||
result = rb_cvar_get(CLASS_OF(self), node->nd_vid); !FL_TEST(ruby_frame->last_class, FL_SINGLETON)) {
break; /* non singleton method */
} if (NIL_P(ruby_cbase)) {
if (!FL_TEST(ruby_cbase, FL_SINGLETON)) { result = rb_cvar_get(CLASS_OF(self), node->nd_vid);
result = rb_cvar_get(ruby_cbase, node->nd_vid); break;
break; }
if (!FL_TEST(ruby_cbase, FL_SINGLETON)) {
result = rb_cvar_get(ruby_cbase, node->nd_vid);
break;
}
} }
/* fall through */ /* fall through */
case NODE_CVAR2: /* singleton method */ case NODE_CVAR2: /* singleton method */

View File

@ -2145,10 +2145,6 @@ yycompile(f, line)
heredoc_end = 0; heredoc_end = 0;
ruby_sourcefile = strdup(f); ruby_sourcefile = strdup(f);
ruby_in_compile = 1; ruby_in_compile = 1;
if (ruby_frame && ruby_frame->last_class &&
FL_TEST(ruby_frame->last_class, FL_SINGLETON)) {
in_single = 1;
}
n = yyparse(); n = yyparse();
ruby_debug_lines = 0; ruby_debug_lines = 0;
compile_for_eval = 0; compile_for_eval = 0;