diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/ruby/ruby.h | 14 |
1 files changed, 13 insertions, 1 deletions
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)) |