summaryrefslogtreecommitdiff
path: root/object.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-09-11 05:37:32 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-09-11 05:37:32 +0000
commitcc3088ea519efa279e4aa71fb994328a9080483f (patch)
tree45b5736589c617e0fff1848094c3c7d74663d0e7 /object.c
parentd2d4017d8099c22dec6913b0f0b938dd8ef21850 (diff)
* include/ruby/ruby.h: freeze nil/true/false.
* gc.c (should_be_finalizable): check frozen after checkin FL_ABLE. * object.c (rb_obj_taint): check OBJ_TAINTABLE(obj). * object.c (rb_obj_freeze): remove immediate_frozen_tbl because all of immediate values are frozen. YAY! * object.c (rb_obj_frozen_p): ditto. * test/ruby/test_eval.rb: skip instance_variable_set for frozen objects. * test/ruby/test_weakmap.rb: check ArgumentError instead of RuntimeError. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47523 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'object.c')
-rw-r--r--object.c16
1 files changed, 3 insertions, 13 deletions
diff --git a/object.c b/object.c
index 98f0fe6..5b0f7df 100644
--- a/object.c
+++ b/object.c
@@ -980,7 +980,7 @@ rb_obj_tainted(VALUE obj)
VALUE
rb_obj_taint(VALUE obj)
{
- if (!OBJ_TAINTED(obj)) {
+ if (!OBJ_TAINTED(obj) && OBJ_TAINTABLE(obj)) {
rb_check_frozen(obj);
OBJ_TAINT(obj);
}
@@ -1057,8 +1057,6 @@ rb_obj_infect(VALUE obj1, VALUE obj2)
OBJ_INFECT(obj1, obj2);
}
-static st_table *immediate_frozen_tbl = 0;
-
/*
* call-seq:
* obj.freeze -> obj
@@ -1089,10 +1087,7 @@ rb_obj_freeze(VALUE obj)
if (!OBJ_FROZEN(obj)) {
OBJ_FREEZE(obj);
if (SPECIAL_CONST_P(obj)) {
- if (!immediate_frozen_tbl) {
- immediate_frozen_tbl = st_init_numtable();
- }
- st_insert(immediate_frozen_tbl, obj, (st_data_t)Qtrue);
+ rb_bug("special consts should be frozen.");
}
}
return obj;
@@ -1112,12 +1107,7 @@ rb_obj_freeze(VALUE obj)
VALUE
rb_obj_frozen_p(VALUE obj)
{
- if (OBJ_FROZEN(obj)) return Qtrue;
- if (SPECIAL_CONST_P(obj)) {
- if (!immediate_frozen_tbl) return Qfalse;
- if (st_lookup(immediate_frozen_tbl, obj, 0)) return Qtrue;
- }
- return Qfalse;
+ return OBJ_FROZEN(obj) ? Qtrue : Qfalse;
}