diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-10-09 23:06:13 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-12-14 19:19:16 +0900 |
commit | f43c71abe07b4b2b0f8f9a69c567fcd0f38faef6 (patch) | |
tree | 5174f18c9bd83ed60537a44c455a1b3369f49c88 /parse.y | |
parent | b1bd223085d7b97d8de8679894a81b7993c26b28 (diff) |
Implemented shareable_constant_value
It does shallow freeze only for now.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3681
Diffstat (limited to 'parse.y')
-rw-r--r-- | parse.y | 16 |
1 files changed, 15 insertions, 1 deletions
@@ -10926,18 +10926,32 @@ mark_lvar_used(struct parser_params *p, NODE *rhs) } static NODE * +shareable_constant_value(struct parser_params *p, NODE *value, const YYLTYPE *loc) +{ + if (p->ctxt.shareable_constant_value) { + NODE *ractor = NEW_COLON3(rb_intern("Ractor"), loc); + value = NEW_CALL(ractor, rb_intern("make_shareable"), + NEW_LIST(value, loc), loc); + } + return value; +} + +static NODE * node_assign(struct parser_params *p, NODE *lhs, NODE *rhs, const YYLTYPE *loc) { if (!lhs) return 0; switch (nd_type(lhs)) { + case NODE_CDECL: + rhs = shareable_constant_value(p, rhs, loc); + /* fallthru */ + case NODE_GASGN: case NODE_IASGN: case NODE_LASGN: case NODE_DASGN: case NODE_DASGN_CURR: case NODE_MASGN: - case NODE_CDECL: case NODE_CVASGN: lhs->nd_value = rhs; nd_set_loc(lhs, loc); |