diff options
Diffstat (limited to 'internal/string.h')
-rw-r--r-- | internal/string.h | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/internal/string.h b/internal/string.h index cde81a1a25..fb37f73114 100644 --- a/internal/string.h +++ b/internal/string.h @@ -17,6 +17,7 @@ #define STR_NOEMBED FL_USER1 #define STR_SHARED FL_USER2 /* = ELTS_SHARED */ +#define STR_CHILLED FL_USER3 #ifdef rb_fstring_cstr # undef rb_fstring_cstr @@ -77,7 +78,7 @@ VALUE rb_id_quote_unprintable(ID); VALUE rb_sym_proc_call(ID mid, int argc, const VALUE *argv, int kw_splat, VALUE passed_proc); struct rb_execution_context_struct; -VALUE rb_ec_str_resurrect(struct rb_execution_context_struct *ec, VALUE str); +VALUE rb_ec_str_resurrect(struct rb_execution_context_struct *ec, VALUE str, bool chilled); #define rb_fstring_lit(str) rb_fstring_new((str), rb_strlen_lit(str)) #define rb_fstring_literal(str) rb_fstring_lit(str) @@ -109,6 +110,26 @@ STR_SHARED_P(VALUE str) } static inline bool +CHILLED_STRING_P(VALUE obj) +{ + return RB_TYPE_P(obj, T_STRING) && FL_TEST_RAW(obj, STR_CHILLED); +} + +static inline void +CHILLED_STRING_MUTATED(VALUE str) +{ + rb_category_warn(RB_WARN_CATEGORY_DEPRECATED, "literal string will be frozen in the future"); + FL_UNSET_RAW(str, STR_CHILLED | FL_FREEZE); +} + +static inline void +STR_CHILL_RAW(VALUE str) +{ + // Chilled strings are always also frozen + FL_SET_RAW(str, STR_CHILLED | RUBY_FL_FREEZE); +} + +static inline bool is_ascii_string(VALUE str) { return rb_enc_str_coderange(str) == ENC_CODERANGE_7BIT; |