summaryrefslogtreecommitdiff
path: root/variable.c
diff options
context:
space:
mode:
authorYukihiro Matsumoto <matz@ruby-lang.org>1994-10-14 06:19:03 +0900
committerTakashi Kokubun <takashikkbn@gmail.com>2019-08-17 22:09:30 +0900
commit29f237a8b1df650089b54447f070726c75706b6f (patch)
treee6ee836a39a5f2f1d433d6532de32471b655fb6d /variable.c
parent173976c97c9426aa8d96e53aef6c0e570c5fdfda (diff)
version 0.54v0_54
https://cache.ruby-lang.org/pub/ruby/1.0/ruby-0.54.tar.gz
Diffstat (limited to 'variable.c')
-rw-r--r--variable.c27
1 files changed, 11 insertions, 16 deletions
diff --git a/variable.c b/variable.c
index 70aa959..1a06def 100644
--- a/variable.c
+++ b/variable.c
@@ -260,8 +260,12 @@ rb_gvar_set(entry, val)
if (entry->set_hook)
(*entry->set_hook)(val, entry->id);
- if (entry->mode == GLOBAL_VAR && entry->v.var != Qnil)
+ if (entry->mode == GLOBAL_VAR) {
+ if (entry->v.var == Qnil) {
+ rb_readonly_hook(val, entry->id);
+ }
return *entry->v.var = val;
+ }
else {
if (entry->mode == GLOBAL_UNDEF)
entry->mode = GLOBAL_VAL;
@@ -319,8 +323,8 @@ const_bound(class, id)
return FALSE;
}
-static void
-rb_const_set_1(class, id, val)
+void
+rb_const_set(class, id, val)
struct RClass *class;
ID id;
VALUE val;
@@ -334,22 +338,13 @@ rb_const_set_1(class, id, val)
st_insert(class->c_tbl, id, val);
}
-VALUE
-rb_const_set(id, val)
- ID id;
- VALUE val;
-{
- rb_const_set_1(the_class, id, val);
- return val;
-}
-
void
rb_define_const(class, name, val)
struct RClass *class;
char *name;
VALUE val;
{
- rb_const_set_1(class, rb_intern(name), val);
+ rb_const_set(class, rb_intern(name), val);
}
VALUE
@@ -410,9 +405,9 @@ Fdefined(obj, name)
{
int i, max;
- if (the_env->local_tbl) {
- for (i=1, max=the_env->local_tbl[0]+1; i<max; i++) {
- if (the_env->local_tbl[i] == id) return TRUE;
+ if (the_scope->local_tbl) {
+ for (i=1, max=the_scope->local_tbl[0]+1; i<max; i++) {
+ if (the_scope->local_tbl[i] == id) return TRUE;
}
}
}