* object.c (rb_obj_freeze): preserve frozen state of immediate
values in internal hash table, a la generic_ivar. * object.c (rb_obj_frozen_p): check immediate values too. * variable.c (generic_ivar_set): add frozen check fro immediate values. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14294 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
98da73bc96
commit
2521b33ed7
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
|||||||
|
Tue Dec 18 17:27:12 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* object.c (rb_obj_freeze): preserve frozen state of immediate
|
||||||
|
values in internal hash table, a la generic_ivar.
|
||||||
|
|
||||||
|
* object.c (rb_obj_frozen_p): check immediate values too.
|
||||||
|
|
||||||
|
* variable.c (generic_ivar_set): add frozen check fro immediate
|
||||||
|
values.
|
||||||
|
|
||||||
Tue Dec 18 17:04:25 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Tue Dec 18 17:04:25 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* transcode.c (rb_str_transcode_bang, rb_str_transcode): set new
|
* transcode.c (rb_str_transcode_bang, rb_str_transcode): set new
|
||||||
|
@ -385,6 +385,7 @@ VALUE rb_obj_taint(VALUE);
|
|||||||
VALUE rb_obj_tainted(VALUE);
|
VALUE rb_obj_tainted(VALUE);
|
||||||
VALUE rb_obj_untaint(VALUE);
|
VALUE rb_obj_untaint(VALUE);
|
||||||
VALUE rb_obj_freeze(VALUE);
|
VALUE rb_obj_freeze(VALUE);
|
||||||
|
VALUE rb_obj_frozen_p(VALUE);
|
||||||
VALUE rb_obj_id(VALUE);
|
VALUE rb_obj_id(VALUE);
|
||||||
VALUE rb_obj_class(VALUE);
|
VALUE rb_obj_class(VALUE);
|
||||||
VALUE rb_class_real(VALUE);
|
VALUE rb_class_real(VALUE);
|
||||||
|
13
object.c
13
object.c
@ -697,6 +697,7 @@ rb_obj_infect(VALUE obj1, VALUE obj2)
|
|||||||
OBJ_INFECT(obj1, obj2);
|
OBJ_INFECT(obj1, obj2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static st_table *immediate_frozen_tbl = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
@ -725,6 +726,12 @@ rb_obj_freeze(VALUE obj)
|
|||||||
rb_raise(rb_eSecurityError, "Insecure: can't freeze object");
|
rb_raise(rb_eSecurityError, "Insecure: can't freeze object");
|
||||||
}
|
}
|
||||||
OBJ_FREEZE(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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
@ -740,10 +747,14 @@ rb_obj_freeze(VALUE obj)
|
|||||||
* a.frozen? #=> true
|
* a.frozen? #=> true
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static VALUE
|
VALUE
|
||||||
rb_obj_frozen_p(VALUE obj)
|
rb_obj_frozen_p(VALUE obj)
|
||||||
{
|
{
|
||||||
if (OBJ_FROZEN(obj)) return Qtrue;
|
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 Qfalse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -804,12 +804,12 @@ generic_ivar_set(VALUE obj, ID id, VALUE val)
|
|||||||
st_data_t data;
|
st_data_t data;
|
||||||
|
|
||||||
if (rb_special_const_p(obj)) {
|
if (rb_special_const_p(obj)) {
|
||||||
|
if (rb_obj_frozen_p(obj)) rb_error_frozen("object");
|
||||||
special_generic_ivar = 1;
|
special_generic_ivar = 1;
|
||||||
}
|
}
|
||||||
if (!generic_iv_tbl) {
|
if (!generic_iv_tbl) {
|
||||||
generic_iv_tbl = st_init_numtable();
|
generic_iv_tbl = st_init_numtable();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!st_lookup(generic_iv_tbl, obj, &data)) {
|
if (!st_lookup(generic_iv_tbl, obj, &data)) {
|
||||||
FL_SET(obj, FL_EXIVAR);
|
FL_SET(obj, FL_EXIVAR);
|
||||||
tbl = st_init_numtable();
|
tbl = st_init_numtable();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user