summaryrefslogtreecommitdiff
path: root/eval.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-11-21 14:26:25 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-11-21 14:26:25 +0000
commita122fce4768ab91c8aab8a4ca3734554c8f1d939 (patch)
tree92742b1be493679024a2e5987f1b9ca64df36efe /eval.c
parent6ffeed5c898cb5dd43d917d3f90459fbc31f8d3f (diff)
matz
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1051 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c41
1 files changed, 25 insertions, 16 deletions
diff --git a/eval.c b/eval.c
index 03ae377..6d300b6 100644
--- a/eval.c
+++ b/eval.c
@@ -1735,7 +1735,7 @@ is_defined(self, node, buf)
case NODE_GASGN:
case NODE_CDECL:
case NODE_CVDECL:
- case NODE_CVASGN2:
+ case NODE_CVASGN:
return "assignment";
case NODE_LVAR:
@@ -1768,9 +1768,10 @@ is_defined(self, node, buf)
}
break;
}
+ self = rb_iv_get(ruby_cbase, "__attached__");
/* fall through */
case NODE_CVAR2:
- if (rb_cvar_defined_singleton(self, node->nd_vid)) {
+ if (rb_cvar_defined(rb_cvar_singleton(self), node->nd_vid)) {
return "class variable";
}
break;
@@ -2255,6 +2256,7 @@ rb_eval(self, n)
if (state == TAG_RAISE) {
NODE * volatile resq = node->nd_resq;
+ ruby_sourceline = nd_line(node);
while (resq) {
if (handle_rescue(self, resq)) {
state = 0;
@@ -2598,15 +2600,18 @@ rb_eval(self, n)
if (NIL_P(ruby_cbase)) {
rb_raise(rb_eTypeError, "no class/module to define class variable");
}
- if (!FL_TEST(ruby_cbase, FL_SINGLETON)) {
- result = rb_eval(self, node->nd_value);
- rb_cvar_declare(ruby_cbase, node->nd_vid, result);
+ result = rb_eval(self, node->nd_value);
+ if (FL_TEST(ruby_cbase, FL_SINGLETON)) {
+ rb_cvar_declare(rb_cvar_singleton(rb_iv_get(ruby_cbase, "__attached__")),
+ node->nd_vid, result);
break;
}
- /* fall through */
- case NODE_CVASGN2:
+ rb_cvar_declare(ruby_cbase, node->nd_vid, result);
+ break;
+
+ case NODE_CVASGN:
result = rb_eval(self, node->nd_value);
- rb_cvar_set_singleton(self, node->nd_vid, result);
+ rb_cvar_set(rb_cvar_singleton(self), node->nd_vid, result);
break;
case NODE_LVAR:
@@ -2632,14 +2637,15 @@ rb_eval(self, n)
result = ev_const_get(RNODE(ruby_frame->cbase), node->nd_vid);
break;
- case NODE_CVAR:
+ case NODE_CVAR: /* normal method */
if (!FL_TEST(ruby_cbase, FL_SINGLETON)) {
result = rb_cvar_get(ruby_cbase, node->nd_vid);
break;
}
+ self = rb_iv_get(ruby_cbase, "__attached__");
/* fall through */
- case NODE_CVAR2:
- result = rb_cvar_get_singleton(self, node->nd_vid);
+ case NODE_CVAR2: /* singleton method */
+ result = rb_cvar_get(rb_cvar_singleton(self), node->nd_vid);
break;
case NODE_BLOCK_ARG:
@@ -3634,11 +3640,14 @@ assign(self, lhs, val, check)
break;
case NODE_CVDECL:
- rb_cvar_declare(ruby_cbase, lhs->nd_vid, val);
- break;
-
- case NODE_CVASGN2:
- rb_cvar_set(CLASS_OF(self), lhs->nd_vid, val);
+ if (!FL_TEST(ruby_cbase, FL_SINGLETON)) {
+ rb_cvar_declare(ruby_cbase, lhs->nd_vid, val);
+ break;
+ }
+ self = rb_iv_get(ruby_cbase, "__attached__");
+ /* fall through */
+ case NODE_CVASGN:
+ rb_cvar_set(rb_cvar_singleton(self), lhs->nd_vid, val);
break;
case NODE_MASGN: