summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryui-knk <[email protected]>2023-09-27 21:58:16 +0900
committerYuichiro Kaneko <[email protected]>2023-09-29 08:36:39 +0900
commit37a783a30cbcc0f5381c955885e525cf702bb506 (patch)
tree5c8159666ba31b333a9ed0635a57ed8d27a70e9b
parent23bcdda37771bbc606535e0a6b0b428b5c26e847 (diff)
Merge RNode_OP_ASGN2 and RNode_OP_ASGN22
-rw-r--r--ast.c9
-rw-r--r--compile.c6
-rw-r--r--node_dump.c6
-rw-r--r--parse.y17
-rw-r--r--rubyparser.h8
5 files changed, 13 insertions, 33 deletions
diff --git a/ast.c b/ast.c
index cdd2269e64..a14cd5b2e3 100644
--- a/ast.c
+++ b/ast.c
@@ -474,13 +474,10 @@ node_children(rb_ast_t *ast, const NODE *node)
NEW_CHILD(ast, RNODE_ARGSCAT(RNODE_OP_ASGN1(node)->nd_args)->nd_head),
NEW_CHILD(ast, RNODE_ARGSCAT(RNODE_OP_ASGN1(node)->nd_args)->nd_body));
case NODE_OP_ASGN2:
- // NODE_OP_ASGN2 has NODE_OP_ASGN2 in its nd_next, however nd_next
- // has different structure, whose u1 is ID attr, u2 is ID op, u3 is bool.
- // See: NEW_OP_ASGN2
return rb_ary_new_from_args(5, NEW_CHILD(ast, RNODE_OP_ASGN2(node)->nd_recv),
- RBOOL(RNODE_OP_ASGN22(RNODE_OP_ASGN2(node)->nd_next)->nd_aid),
- ID2SYM(RNODE_OP_ASGN22(RNODE_OP_ASGN2(node)->nd_next)->nd_vid),
- ID2SYM(RNODE_OP_ASGN22(RNODE_OP_ASGN2(node)->nd_next)->nd_mid),
+ RBOOL(RNODE_OP_ASGN2(node)->nd_aid),
+ ID2SYM(RNODE_OP_ASGN2(node)->nd_vid),
+ ID2SYM(RNODE_OP_ASGN2(node)->nd_mid),
NEW_CHILD(ast, RNODE_OP_ASGN2(node)->nd_value));
case NODE_OP_ASGN_AND:
return rb_ary_new_from_args(3, NEW_CHILD(ast, RNODE_OP_ASGN_AND(node)->nd_head), ID2SYM(idANDOP),
diff --git a/compile.c b/compile.c
index 34113a4387..3b4624d0b4 100644
--- a/compile.c
+++ b/compile.c
@@ -8708,8 +8708,8 @@ static int
compile_op_asgn2(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int popped)
{
const int line = nd_line(node);
- ID atype = RNODE_OP_ASGN2(node)->nd_next->nd_mid;
- ID vid = RNODE_OP_ASGN2(node)->nd_next->nd_vid, aid = rb_id_attrset(vid);
+ ID atype = RNODE_OP_ASGN2(node)->nd_mid;
+ ID vid = RNODE_OP_ASGN2(node)->nd_vid, aid = rb_id_attrset(vid);
int asgnflag;
LABEL *lfin = NEW_LABEL(line);
LABEL *lcfin = NEW_LABEL(line);
@@ -8769,7 +8769,7 @@ compile_op_asgn2(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node
asgnflag = COMPILE_RECV(ret, "NODE_OP_ASGN2#recv", node, RNODE_OP_ASGN2(node)->nd_recv);
CHECK(asgnflag != -1);
- if (RNODE_OP_ASGN2(node)->nd_next->nd_aid) {
+ if (RNODE_OP_ASGN2(node)->nd_aid) {
lskip = NEW_LABEL(line);
ADD_INSN(ret, node, dup);
ADD_INSNL(ret, node, branchnil, lskip);
diff --git a/node_dump.c b/node_dump.c
index e4862da0eb..81fed547ac 100644
--- a/node_dump.c
+++ b/node_dump.c
@@ -479,10 +479,10 @@ dump_node(VALUE buf, VALUE indent, int comment, const NODE * node)
ANN("example: struct.field += foo");
F_NODE(nd_recv, RNODE_OP_ASGN2, "receiver");
F_CUSTOM1(nd_next->nd_vid, "attr") {
- if (RNODE_OP_ASGN2(node)->nd_next->nd_aid) A("? ");
- A_ID(RNODE_OP_ASGN2(node)->nd_next->nd_vid);
+ if (RNODE_OP_ASGN2(node)->nd_aid) A("? ");
+ A_ID(RNODE_OP_ASGN2(node)->nd_vid);
}
- F_ID(nd_next->nd_mid, RNODE_OP_ASGN2, "operator");
+ F_ID(nd_mid, RNODE_OP_ASGN2, "operator");
LAST_NODE;
F_NODE(nd_value, RNODE_OP_ASGN2, "rvalue");
return;
diff --git a/parse.y b/parse.y
index cfd7502d40..3b513d3ade 100644
--- a/parse.y
+++ b/parse.y
@@ -914,8 +914,7 @@ static rb_node_iasgn_t *rb_node_iasgn_new(struct parser_params *p, ID nd_vid, NO
static rb_node_cdecl_t *rb_node_cdecl_new(struct parser_params *p, ID nd_vid, NODE *nd_value, NODE *nd_else, const YYLTYPE *loc);
static rb_node_cvasgn_t *rb_node_cvasgn_new(struct parser_params *p, ID nd_vid, NODE *nd_value, const YYLTYPE *loc);
static rb_node_op_asgn1_t *rb_node_op_asgn1_new(struct parser_params *p, NODE *nd_recv, ID nd_mid, rb_node_argscat_t *nd_args, const YYLTYPE *loc);
-static rb_node_op_asgn2_t *rb_node_op_asgn2_new(struct parser_params *p, NODE *nd_recv, NODE *nd_value, rb_node_op_asgn22_t *nd_next, const YYLTYPE *loc);
-static rb_node_op_asgn22_t *rb_node_op_asgn22_new(struct parser_params *p, ID nd_vid, ID nd_mid, bool nd_aid, const YYLTYPE *loc);
+static rb_node_op_asgn2_t *rb_node_op_asgn2_new(struct parser_params *p, NODE *nd_recv, NODE *nd_value, ID nd_vid, ID nd_mid, bool nd_aid, const YYLTYPE *loc);
static rb_node_op_asgn_or_t *rb_node_op_asgn_or_new(struct parser_params *p, NODE *nd_head, NODE *nd_value, const YYLTYPE *loc);
static rb_node_op_asgn_and_t *rb_node_op_asgn_and_new(struct parser_params *p, NODE *nd_head, NODE *nd_value, const YYLTYPE *loc);
static rb_node_op_cdecl_t *rb_node_op_cdecl_new(struct parser_params *p, NODE *nd_head, NODE *nd_value, ID nd_aid, const YYLTYPE *loc);
@@ -1016,8 +1015,7 @@ static rb_node_error_t *rb_node_error_new(struct parser_params *p, const YYLTYPE
#define NEW_CDECL(v,val,path,loc) (NODE *)rb_node_cdecl_new(p,v,val,path,loc)
#define NEW_CVASGN(v,val,loc) (NODE *)rb_node_cvasgn_new(p,v,val,loc)
#define NEW_OP_ASGN1(r,id,a,loc) (NODE *)rb_node_op_asgn1_new(p,r,id,a,loc)
-#define NEW_OP_ASGN2(r,t,i,o,val,loc) (NODE *)rb_node_op_asgn2_new(p,r,val,NEW_OP_ASGN22(i,o,t,loc),loc)
-#define NEW_OP_ASGN22(i,o,t,loc) rb_node_op_asgn22_new(p,i,o,t,loc)
+#define NEW_OP_ASGN2(r,t,i,o,val,loc) (NODE *)rb_node_op_asgn2_new(p,r,val,i,o,t,loc)
#define NEW_OP_ASGN_OR(i,val,loc) (NODE *)rb_node_op_asgn_or_new(p,i,val,loc)
#define NEW_OP_ASGN_AND(i,val,loc) (NODE *)rb_node_op_asgn_and_new(p,i,val,loc)
#define NEW_OP_CDECL(v,op,val,loc) (NODE *)rb_node_op_cdecl_new(p,v,val,op,loc)
@@ -11619,20 +11617,11 @@ rb_node_op_asgn1_new(struct parser_params *p, NODE *nd_recv, ID nd_mid, rb_node_
}
static rb_node_op_asgn2_t *
-rb_node_op_asgn2_new(struct parser_params *p, NODE *nd_recv, NODE *nd_value, rb_node_op_asgn22_t *nd_next, const YYLTYPE *loc)
+rb_node_op_asgn2_new(struct parser_params *p, NODE *nd_recv, NODE *nd_value, ID nd_vid, ID nd_mid, bool nd_aid, const YYLTYPE *loc)
{
rb_node_op_asgn2_t *n = NODE_NEWNODE(NODE_OP_ASGN2, rb_node_op_asgn2_t, loc);
n->nd_recv = nd_recv;
n->nd_value = nd_value;
- n->nd_next = nd_next;
-
- return n;
-}
-
-static rb_node_op_asgn22_t *
-rb_node_op_asgn22_new(struct parser_params *p, ID nd_vid, ID nd_mid, bool nd_aid, const YYLTYPE *loc)
-{
- rb_node_op_asgn22_t *n = NODE_NEWNODE(NODE_OP_ASGN2, rb_node_op_asgn22_t, loc);
n->nd_vid = nd_vid;
n->nd_mid = nd_mid;
n->nd_aid = nd_aid;
diff --git a/rubyparser.h b/rubyparser.h
index 970965347c..6a8a6a2577 100644
--- a/rubyparser.h
+++ b/rubyparser.h
@@ -438,16 +438,10 @@ typedef struct RNode_OP_ASGN2 {
struct RNode *nd_recv;
struct RNode *nd_value;
- struct RNode_OP_ASGN22 *nd_next;
-} rb_node_op_asgn2_t;
-
-typedef struct RNode_OP_ASGN22 {
- NODE node;
-
ID nd_vid;
ID nd_mid;
bool nd_aid;
-} rb_node_op_asgn22_t;
+} rb_node_op_asgn2_t;
typedef struct RNode_OP_ASGN_AND {
NODE node;