summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-09-02 12:45:11 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-09-02 13:30:16 +0900
commit93b78abd774109d1333d59eaf439b2e69ed0fe00 (patch)
treefce0a2c152ca6df4611942e5b9ac2df1bf8970b3 /parse.y
parent6321330461a31126d92314d379faf62d0f0ea46a (diff)
new_dstr: hoisted out from literal_concat and evstr2dstr
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y18
1 files changed, 12 insertions, 6 deletions
diff --git a/parse.y b/parse.y
index 83e6d20ea6..2a7d985356 100644
--- a/parse.y
+++ b/parse.y
@@ -481,6 +481,7 @@ static NODE *last_arg_append(struct parser_params *p, NODE *args, NODE *last_arg
static NODE *rest_arg_append(struct parser_params *p, NODE *args, NODE *rest_arg, const YYLTYPE *loc);
static NODE *literal_concat(struct parser_params*,NODE*,NODE*,const YYLTYPE*);
static NODE *new_evstr(struct parser_params*,NODE*,const YYLTYPE*);
+static NODE *new_dstr(struct parser_params*,NODE*,const YYLTYPE*);
static NODE *evstr2dstr(struct parser_params*,NODE*);
static NODE *splat_array(NODE*);
static void mark_lvar_used(struct parser_params *p, NODE *rhs);
@@ -9882,9 +9883,7 @@ literal_concat(struct parser_params *p, NODE *head, NODE *tail, const YYLTYPE *l
htype = nd_type(head);
if (htype == NODE_EVSTR) {
- NODE *node = NEW_DSTR(STR_NEW0(), loc);
- RB_OBJ_WRITTEN(p->ast, Qnil, node->nd_lit);
- head = list_append(p, node, head);
+ head = new_dstr(p, head, loc);
htype = NODE_DSTR;
}
if (p->heredoc_indent > 0) {
@@ -9964,9 +9963,7 @@ static NODE *
evstr2dstr(struct parser_params *p, NODE *node)
{
if (nd_type(node) == NODE_EVSTR) {
- NODE * dstr = NEW_DSTR(STR_NEW0(), &node->nd_loc);
- RB_OBJ_WRITTEN(p->ast, Qnil, dstr->nd_lit);
- node = list_append(p, dstr, node);
+ node = new_dstr(p, node, &node->nd_loc);
}
return node;
}
@@ -9986,6 +9983,15 @@ new_evstr(struct parser_params *p, NODE *node, const YYLTYPE *loc)
}
static NODE *
+new_dstr(struct parser_params *p, NODE *node, const YYLTYPE *loc)
+{
+ VALUE lit = STR_NEW0();
+ NODE *dstr = NEW_DSTR(lit, loc);
+ RB_OBJ_WRITTEN(p->ast, Qnil, lit);
+ return list_append(p, dstr, node);
+}
+
+static NODE *
call_bin_op(struct parser_params *p, NODE *recv, ID id, NODE *arg1,
const YYLTYPE *op_loc, const YYLTYPE *loc)
{