ruby-changes:2803
From: ko1@a...
Date: 18 Dec 2007 17:28:59 +0900
Subject: [ruby-changes:2803] matz - Ruby:r14294 (trunk): * object.c (rb_obj_freeze): preserve frozen state of immediate
matz 2007-12-18 17:28:39 +0900 (Tue, 18 Dec 2007) New Revision: 14294 Modified files: trunk/ChangeLog trunk/include/ruby/intern.h trunk/object.c trunk/variable.c Log: * 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. http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/variable.c?r1=14294&r2=14293 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=14294&r2=14293 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/object.c?r1=14294&r2=14293 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/include/ruby/intern.h?r1=14294&r2=14293 Index: include/ruby/intern.h =================================================================== --- include/ruby/intern.h (revision 14293) +++ include/ruby/intern.h (revision 14294) @@ -385,6 +385,7 @@ VALUE rb_obj_tainted(VALUE); VALUE rb_obj_untaint(VALUE); VALUE rb_obj_freeze(VALUE); +VALUE rb_obj_frozen_p(VALUE); VALUE rb_obj_id(VALUE); VALUE rb_obj_class(VALUE); VALUE rb_class_real(VALUE); Index: ChangeLog =================================================================== --- ChangeLog (revision 14293) +++ ChangeLog (revision 14294) @@ -1,3 +1,13 @@ +Tue Dec 18 17:27:12 2007 Yukihiro Matsumoto <matz@r...> + + * 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@r...> * transcode.c (rb_str_transcode_bang, rb_str_transcode): set new Index: variable.c =================================================================== --- variable.c (revision 14293) +++ variable.c (revision 14294) @@ -804,12 +804,12 @@ st_data_t data; if (rb_special_const_p(obj)) { + if (rb_obj_frozen_p(obj)) rb_error_frozen("object"); special_generic_ivar = 1; } if (!generic_iv_tbl) { generic_iv_tbl = st_init_numtable(); } - if (!st_lookup(generic_iv_tbl, obj, &data)) { FL_SET(obj, FL_EXIVAR); tbl = st_init_numtable(); Index: object.c =================================================================== --- object.c (revision 14293) +++ object.c (revision 14294) @@ -697,6 +697,7 @@ OBJ_INFECT(obj1, obj2); } +static st_table *immediate_frozen_tbl = 0; /* * call-seq: @@ -725,6 +726,12 @@ rb_raise(rb_eSecurityError, "Insecure: can't freeze object"); } 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; } @@ -740,10 +747,14 @@ * a.frozen? #=> true */ -static VALUE +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; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml