* eval.c (rb_eval): replace rb_cvar_declare() by rb_cvar_set().
* eval.c (assign): ditto. * variable.c (rb_cvar_set): 4th argument (warn) added; define new class variable if it's not defined yet. * variable.c (rb_cvar_declare): removed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2073 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
289430e8ec
commit
1e5d404935
11
ChangeLog
11
ChangeLog
@ -1,3 +1,14 @@
|
|||||||
|
Fri Feb 15 14:40:38 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* eval.c (rb_eval): replace rb_cvar_declare() by rb_cvar_set().
|
||||||
|
|
||||||
|
* eval.c (assign): ditto.
|
||||||
|
|
||||||
|
* variable.c (rb_cvar_set): 4th argument (warn) added; define new
|
||||||
|
class variable if it's not defined yet.
|
||||||
|
|
||||||
|
* variable.c (rb_cvar_declare): removed.
|
||||||
|
|
||||||
Fri Feb 15 13:36:58 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
|
Fri Feb 15 13:36:58 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* bignum.c (rb_big_rshift): should properly convert the nagative
|
* bignum.c (rb_big_rshift): should properly convert the nagative
|
||||||
|
8
eval.c
8
eval.c
@ -2864,12 +2864,12 @@ rb_eval(self, n)
|
|||||||
if (ruby_verbose && FL_TEST(ruby_cbase, FL_SINGLETON)) {
|
if (ruby_verbose && FL_TEST(ruby_cbase, FL_SINGLETON)) {
|
||||||
rb_warn("declaring singleton class variable");
|
rb_warn("declaring singleton class variable");
|
||||||
}
|
}
|
||||||
rb_cvar_declare(ruby_cbase, node->nd_vid, result);
|
rb_cvar_set(ruby_cbase, node->nd_vid, result, Qtrue);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NODE_CVASGN:
|
case NODE_CVASGN:
|
||||||
result = rb_eval(self, node->nd_value);
|
result = rb_eval(self, node->nd_value);
|
||||||
rb_cvar_set(ruby_cbase, node->nd_vid, result);
|
rb_cvar_set(ruby_cbase, node->nd_vid, result, Qfalse);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NODE_LVAR:
|
case NODE_LVAR:
|
||||||
@ -3915,11 +3915,11 @@ assign(self, lhs, val, pcall)
|
|||||||
if (ruby_verbose && FL_TEST(ruby_cbase, FL_SINGLETON)) {
|
if (ruby_verbose && FL_TEST(ruby_cbase, FL_SINGLETON)) {
|
||||||
rb_warn("declaring singleton class variable");
|
rb_warn("declaring singleton class variable");
|
||||||
}
|
}
|
||||||
rb_cvar_declare(ruby_cbase, lhs->nd_vid, val);
|
rb_cvar_set(ruby_cbase, lhs->nd_vid, val, Qtrue);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NODE_CVASGN:
|
case NODE_CVASGN:
|
||||||
rb_cvar_set(ruby_cbase, lhs->nd_vid, val);
|
rb_cvar_set(ruby_cbase, lhs->nd_vid, val, Qfalse);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NODE_MASGN:
|
case NODE_MASGN:
|
||||||
|
3
intern.h
3
intern.h
@ -422,9 +422,8 @@ void rb_const_set _((VALUE, ID, VALUE));
|
|||||||
void rb_const_assign _((VALUE, ID, VALUE));
|
void rb_const_assign _((VALUE, ID, VALUE));
|
||||||
VALUE rb_mod_constants _((VALUE));
|
VALUE rb_mod_constants _((VALUE));
|
||||||
void rb_autoload_load _((ID));
|
void rb_autoload_load _((ID));
|
||||||
void rb_cvar_declare _((VALUE, ID, VALUE));
|
|
||||||
VALUE rb_cvar_defined _((VALUE, ID));
|
VALUE rb_cvar_defined _((VALUE, ID));
|
||||||
void rb_cvar_set _((VALUE, ID, VALUE));
|
void rb_cvar_set _((VALUE, ID, VALUE, int));
|
||||||
VALUE rb_cvar_get _((VALUE, ID));
|
VALUE rb_cvar_get _((VALUE, ID));
|
||||||
void rb_cv_set _((VALUE, const char *, VALUE));
|
void rb_cv_set _((VALUE, const char *, VALUE));
|
||||||
VALUE rb_cv_get _((VALUE, const char *));
|
VALUE rb_cv_get _((VALUE, const char *));
|
||||||
|
36
variable.c
36
variable.c
@ -1440,10 +1440,11 @@ cvar_override_check(id, a)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
rb_cvar_set(klass, id, val)
|
rb_cvar_set(klass, id, val, warn)
|
||||||
VALUE klass;
|
VALUE klass;
|
||||||
ID id;
|
ID id;
|
||||||
VALUE val;
|
VALUE val;
|
||||||
|
int warn;
|
||||||
{
|
{
|
||||||
VALUE tmp;
|
VALUE tmp;
|
||||||
|
|
||||||
@ -1453,34 +1454,7 @@ rb_cvar_set(klass, id, val)
|
|||||||
if (OBJ_FROZEN(tmp)) rb_error_frozen("class/module");
|
if (OBJ_FROZEN(tmp)) rb_error_frozen("class/module");
|
||||||
if (!OBJ_TAINTED(tmp) && rb_safe_level() >= 4)
|
if (!OBJ_TAINTED(tmp) && rb_safe_level() >= 4)
|
||||||
rb_raise(rb_eSecurityError, "Insecure: can't modify class variable");
|
rb_raise(rb_eSecurityError, "Insecure: can't modify class variable");
|
||||||
st_insert(RCLASS(tmp)->iv_tbl,id,val);
|
if (warn && ruby_verbose && klass != tmp) {
|
||||||
if (ruby_verbose) {
|
|
||||||
cvar_override_check(id, tmp);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
tmp = RCLASS(tmp)->super;
|
|
||||||
}
|
|
||||||
|
|
||||||
rb_name_error(id,"uninitialized class variable %s in %s",
|
|
||||||
rb_id2name(id), rb_class2name(klass));
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
rb_cvar_declare(klass, id, val)
|
|
||||||
VALUE klass;
|
|
||||||
ID id;
|
|
||||||
VALUE val;
|
|
||||||
{
|
|
||||||
VALUE tmp;
|
|
||||||
|
|
||||||
tmp = klass;
|
|
||||||
while (tmp) {
|
|
||||||
if (RCLASS(tmp)->iv_tbl && st_lookup(RCLASS(tmp)->iv_tbl,id,0)) {
|
|
||||||
if (OBJ_FROZEN(tmp)) rb_error_frozen("class/module");
|
|
||||||
if (!OBJ_TAINTED(tmp) && rb_safe_level() >= 4)
|
|
||||||
rb_raise(rb_eSecurityError, "Insecure: can't modify class variable");
|
|
||||||
if (ruby_verbose && klass != tmp) {
|
|
||||||
rb_warning("already initialized class variable %s", rb_id2name(id));
|
rb_warning("already initialized class variable %s", rb_id2name(id));
|
||||||
}
|
}
|
||||||
st_insert(RCLASS(tmp)->iv_tbl,id,val);
|
st_insert(RCLASS(tmp)->iv_tbl,id,val);
|
||||||
@ -1549,7 +1523,7 @@ rb_cv_set(klass, name, val)
|
|||||||
if (!rb_is_class_id(id)) {
|
if (!rb_is_class_id(id)) {
|
||||||
rb_name_error(id, "wrong class variable name %s", name);
|
rb_name_error(id, "wrong class variable name %s", name);
|
||||||
}
|
}
|
||||||
rb_cvar_set(klass, id, val);
|
rb_cvar_set(klass, id, val, Qfalse);
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
@ -1575,7 +1549,7 @@ rb_define_class_variable(klass, name, val)
|
|||||||
if (!rb_is_class_id(id)) {
|
if (!rb_is_class_id(id)) {
|
||||||
rb_name_error(id, "wrong class variable name %s", name);
|
rb_name_error(id, "wrong class variable name %s", name);
|
||||||
}
|
}
|
||||||
rb_cvar_declare(klass, id, val);
|
rb_cvar_set(klass, id, val, Qtrue);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#define RUBY_VERSION "1.7.2"
|
#define RUBY_VERSION "1.7.2"
|
||||||
#define RUBY_RELEASE_DATE "2002-02-14"
|
#define RUBY_RELEASE_DATE "2002-02-15"
|
||||||
#define RUBY_VERSION_CODE 172
|
#define RUBY_VERSION_CODE 172
|
||||||
#define RUBY_RELEASE_CODE 20020214
|
#define RUBY_RELEASE_CODE 20020215
|
||||||
|
Loading…
x
Reference in New Issue
Block a user