diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-09-12 14:25:01 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-09-12 14:25:01 +0000 |
commit | 3889eaca02a641d5b5acf2f15bdf0d4dac4e3d00 (patch) | |
tree | 43c33edc50133d4bef4db944dbc5f31e28215b2a | |
parent | 4817ab23b31c2c71682c3d54e9da45f53fa7f154 (diff) | |
download | ruby-3889eaca02a641d5b5acf2f15bdf0d4dac4e3d00.tar.gz |
ruby/ruby.h: freeze singleton class
* include/ruby/ruby.h (rb_obj_freeze_inline): propagate freezing
to the singleton class if it is existing.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47557 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | eval.c | 4 | ||||
-rw-r--r-- | include/ruby/ruby.h | 14 |
2 files changed, 13 insertions, 5 deletions
@@ -409,10 +409,6 @@ rb_frozen_class_p(VALUE klass) noclass: Check_Type(klass, T_CLASS); } - if (FL_TEST(klass, FL_SINGLETON)) { - VALUE obj = rb_ivar_get(klass, id__attached__); - if (OBJ_FROZEN(obj)) OBJ_FREEZE(klass); - } if (OBJ_FROZEN(klass)) { const char *desc; diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h index c7ab5ef580..b198e65625 100644 --- a/include/ruby/ruby.h +++ b/include/ruby/ruby.h @@ -1105,7 +1105,19 @@ struct RStruct { RBASIC(x)->flags |= RBASIC(s)->flags & FL_TAINT : 0) #define OBJ_FROZEN(x) (FL_ABLE(x) ? !!(RBASIC(x)->flags&FL_FREEZE) : 1) -#define OBJ_FREEZE(x) FL_SET((x), FL_FREEZE) +#define OBJ_FREEZE(x) rb_obj_freeze_inline((VALUE)x) + +static inline void +rb_obj_freeze_inline(VALUE x) +{ + if (FL_ABLE(x)) { + VALUE klass = RBASIC_CLASS(x); + RBASIC(x)->flags |= FL_FREEZE; + if (FL_TEST(klass, (FL_SINGLETON|FL_FREEZE)) == FL_SINGLETON) { + RBASIC(klass)->flags |= FL_FREEZE; + } + } +} #if USE_RGENGC #define OBJ_PROMOTED_RAW(x) ((RBASIC(x)->flags & (FL_PROMOTED0|FL_PROMOTED1)) == (FL_PROMOTED0|FL_PROMOTED1)) |