1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

new_dstr: hoisted out from literal_concat and evstr2dstr

This commit is contained in:
Nobuyoshi Nakada 2020-09-02 12:45:11 +09:00
parent 6321330461
commit 93b78abd77
No known key found for this signature in database
GPG key ID: 7CD2805BFA3770C6

18
parse.y
View file

@ -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 *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 *literal_concat(struct parser_params*,NODE*,NODE*,const YYLTYPE*);
static NODE *new_evstr(struct parser_params*,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 *evstr2dstr(struct parser_params*,NODE*);
static NODE *splat_array(NODE*); static NODE *splat_array(NODE*);
static void mark_lvar_used(struct parser_params *p, NODE *rhs); 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); htype = nd_type(head);
if (htype == NODE_EVSTR) { if (htype == NODE_EVSTR) {
NODE *node = NEW_DSTR(STR_NEW0(), loc); head = new_dstr(p, head, loc);
RB_OBJ_WRITTEN(p->ast, Qnil, node->nd_lit);
head = list_append(p, node, head);
htype = NODE_DSTR; htype = NODE_DSTR;
} }
if (p->heredoc_indent > 0) { if (p->heredoc_indent > 0) {
@ -9964,9 +9963,7 @@ static NODE *
evstr2dstr(struct parser_params *p, NODE *node) evstr2dstr(struct parser_params *p, NODE *node)
{ {
if (nd_type(node) == NODE_EVSTR) { if (nd_type(node) == NODE_EVSTR) {
NODE * dstr = NEW_DSTR(STR_NEW0(), &node->nd_loc); node = new_dstr(p, node, &node->nd_loc);
RB_OBJ_WRITTEN(p->ast, Qnil, dstr->nd_lit);
node = list_append(p, dstr, node);
} }
return node; return node;
} }
@ -9985,6 +9982,15 @@ new_evstr(struct parser_params *p, NODE *node, const YYLTYPE *loc)
return NEW_EVSTR(head, loc); return NEW_EVSTR(head, 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 * static NODE *
call_bin_op(struct parser_params *p, NODE *recv, ID id, NODE *arg1, call_bin_op(struct parser_params *p, NODE *recv, ID id, NODE *arg1,
const YYLTYPE *op_loc, const YYLTYPE *loc) const YYLTYPE *op_loc, const YYLTYPE *loc)