* eval.c (ev_const_defined): add new parameter self for special

const fallback.

* eval.c (ev_const_get): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1250 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2001-03-13 09:00:01 +00:00
parent 037dacc510
commit a22cbaa697
4 changed files with 16 additions and 30 deletions

View File

@ -1,3 +1,10 @@
Tue Mar 13 17:51:09 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (ev_const_defined): add new parameter self for special
const fallback.
* eval.c (ev_const_get): ditto.
Tue Mar 13 16:39:45 2001 WATANABE Hirofumi <eban@ruby-lang.org> Tue Mar 13 16:39:45 2001 WATANABE Hirofumi <eban@ruby-lang.org>
* dir.c (rb_glob_helper): fix drive letter handling on DOSISH. * dir.c (rb_glob_helper): fix drive letter handling on DOSISH.

35
eval.c
View File

@ -1422,16 +1422,17 @@ superclass(self, node)
#define ruby_cbase (RNODE(ruby_frame->cbase)->nd_clss) #define ruby_cbase (RNODE(ruby_frame->cbase)->nd_clss)
static VALUE static VALUE
ev_const_defined(cref, id) ev_const_defined(cref, id, self)
NODE *cref; NODE *cref;
ID id; ID id;
VALUE self;
{ {
NODE *cbase = cref; NODE *cbase = cref;
while (cbase && cbase->nd_clss != rb_cObject) { while (cbase && cbase->nd_clss != rb_cObject) {
struct RClass *klass = RCLASS(cbase->nd_clss); struct RClass *klass = RCLASS(cbase->nd_clss);
if (NIL_P(klass)) return rb_const_defined(rb_cObject, id); if (NIL_P(klass)) return rb_const_defined(CLASS_OF(self), id);
if (klass->iv_tbl && st_lookup(klass->iv_tbl, id, 0)) { if (klass->iv_tbl && st_lookup(klass->iv_tbl, id, 0)) {
return Qtrue; return Qtrue;
} }
@ -1441,9 +1442,10 @@ ev_const_defined(cref, id)
} }
static VALUE static VALUE
ev_const_get(cref, id) ev_const_get(cref, id, self)
NODE *cref; NODE *cref;
ID id; ID id;
VALUE self;
{ {
NODE *cbase = cref; NODE *cbase = cref;
VALUE result; VALUE result;
@ -1451,7 +1453,7 @@ ev_const_get(cref, id)
while (cbase && cbase->nd_clss != rb_cObject) { while (cbase && cbase->nd_clss != rb_cObject) {
struct RClass *klass = RCLASS(cbase->nd_clss); struct RClass *klass = RCLASS(cbase->nd_clss);
if (NIL_P(klass)) return rb_const_get(rb_cObject, id); if (NIL_P(klass)) return rb_const_get(CLASS_OF(self), id);
if (klass->iv_tbl && st_lookup(klass->iv_tbl, id, &result)) { if (klass->iv_tbl && st_lookup(klass->iv_tbl, id, &result)) {
return result; return result;
} }
@ -1460,27 +1462,6 @@ ev_const_get(cref, id)
return rb_const_get(cref->nd_clss, id); return rb_const_get(cref->nd_clss, id);
} }
static VALUE
ev_const_set(cref, id, val)
NODE *cref;
ID id;
VALUE val;
{
NODE *cbase = cref;
while (cbase && cbase->nd_clss != rb_cObject) {
struct RClass *klass = RCLASS(cbase->nd_clss);
if (klass->iv_tbl && st_lookup(klass->iv_tbl, id, 0)) {
st_insert(klass->iv_tbl, id, val);
return val;
}
cbase = cbase->nd_next;
}
rb_const_assign(cbase->nd_clss, id, val);
return val;
}
static VALUE static VALUE
rb_mod_nesting() rb_mod_nesting()
{ {
@ -1826,7 +1807,7 @@ is_defined(self, node, buf)
break; break;
case NODE_CONST: case NODE_CONST:
if (ev_const_defined(RNODE(ruby_frame->cbase), node->nd_vid)) { if (ev_const_defined(RNODE(ruby_frame->cbase), node->nd_vid, self)) {
return "constant"; return "constant";
} }
break; break;
@ -2738,7 +2719,7 @@ rb_eval(self, n)
break; break;
case NODE_CONST: case NODE_CONST:
result = ev_const_get(RNODE(ruby_frame->cbase), node->nd_vid); result = ev_const_get(RNODE(ruby_frame->cbase), node->nd_vid, self);
break; break;
case NODE_CVAR: /* normal method */ case NODE_CVAR: /* normal method */

2
io.c
View File

@ -3183,8 +3183,6 @@ argf_seek_m(argc, argv, self)
VALUE *argv; VALUE *argv;
VALUE self; VALUE self;
{ {
VALUE args[2];
if (!next_argv()) { if (!next_argv()) {
rb_raise(rb_eArgError, "no stream to seek"); rb_raise(rb_eArgError, "no stream to seek");
} }

View File

@ -4522,7 +4522,7 @@ cond0(node, logop)
if (type == NODE_DOT2) nd_set_type(node,NODE_FLIP2); if (type == NODE_DOT2) nd_set_type(node,NODE_FLIP2);
else if (type == NODE_DOT3) nd_set_type(node, NODE_FLIP3); else if (type == NODE_DOT3) nd_set_type(node, NODE_FLIP3);
node->nd_cnt = local_append(0); node->nd_cnt = local_append(0);
warn_unless_e_option("range literal in condition"); warning_unless_e_option("range literal in condition");
break; break;
case NODE_LIT: case NODE_LIT: