Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove NODE_DASGN_CURR [Feature #18406] #5251

Merged
merged 1 commit into from
Dec 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,6 @@ node_children(rb_ast_t *ast, const NODE *node)
}
case NODE_LASGN:
case NODE_DASGN:
case NODE_DASGN_CURR:
case NODE_IASGN:
case NODE_CVASGN:
case NODE_GASGN:
Expand Down
12 changes: 4 additions & 8 deletions compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -4928,7 +4928,6 @@ compile_massign_opt(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
MEMORY(ln->nd_vid);
break;
case NODE_DASGN:
case NODE_DASGN_CURR:
case NODE_IASGN:
case NODE_CVASGN:
MEMORY(ln->nd_vid);
Expand Down Expand Up @@ -5322,7 +5321,6 @@ defined_expr0(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
case NODE_MASGN:
case NODE_LASGN:
case NODE_DASGN:
case NODE_DASGN_CURR:
case NODE_GASGN:
case NODE_IASGN:
case NODE_CDECL:
Expand Down Expand Up @@ -6592,8 +6590,7 @@ iseq_compile_pattern_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *c
ADD_INSNL(ret, line_node, jump, matched);
break;
}
case NODE_DASGN:
case NODE_DASGN_CURR: {
case NODE_DASGN: {
int idx, lv, ls;
ID id = node->nd_vid;

Expand All @@ -6609,7 +6606,7 @@ iseq_compile_pattern_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *c
}

if (idx < 0) {
COMPILE_ERROR(ERROR_ARGS "NODE_DASGN(_CURR): unknown id (%"PRIsVALUE")",
COMPILE_ERROR(ERROR_ARGS "NODE_DASGN: unknown id (%"PRIsVALUE")",
rb_id2str(id));
return COMPILE_NG;
}
Expand Down Expand Up @@ -9199,8 +9196,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
ADD_SETLOCAL(ret, node, idx, get_lvar_level(iseq));
break;
}
case NODE_DASGN:
case NODE_DASGN_CURR:{
case NODE_DASGN: {
int idx, lv, ls;
ID id = node->nd_vid;
CHECK(COMPILE(ret, "dvalue", node->nd_value));
Expand All @@ -9213,7 +9209,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
idx = get_dyna_var_idx(iseq, id, &lv, &ls);

if (idx < 0) {
COMPILE_ERROR(ERROR_ARGS "NODE_DASGN(_CURR): unknown id (%"PRIsVALUE")",
COMPILE_ERROR(ERROR_ARGS "NODE_DASGN: unknown id (%"PRIsVALUE")",
rb_id2str(id));
goto ng;
}
Expand Down
1 change: 0 additions & 1 deletion ext/objspace/objspace.c
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,6 @@ count_nodes(int argc, VALUE *argv, VALUE os)
COUNT_NODE(NODE_MASGN);
COUNT_NODE(NODE_LASGN);
COUNT_NODE(NODE_DASGN);
COUNT_NODE(NODE_DASGN_CURR);
COUNT_NODE(NODE_GASGN);
COUNT_NODE(NODE_IASGN);
COUNT_NODE(NODE_CDECL);
Expand Down
9 changes: 1 addition & 8 deletions node.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,16 +407,9 @@ dump_node(VALUE buf, VALUE indent, int comment, const NODE * node)
}
return;
case NODE_DASGN:
ANN("dynamic variable assignment (out of current scope)");
ANN("dynamic variable assignment");
ANN("format: [nd_vid](dvar) = [nd_value]");
ANN("example: x = nil; 1.times { x = foo }");
F_ID(nd_vid, "local variable");
LAST_NODE;
F_NODE(nd_value, "rvalue");
return;
case NODE_DASGN_CURR:
ANN("dynamic variable assignment (in current scope)");
ANN("format: [nd_vid](current dvar) = [nd_value]");
ANN("example: 1.times { x = foo }");
F_ID(nd_vid, "local variable");
if (NODE_REQUIRED_KEYWORD_P(node)) {
Expand Down
2 changes: 0 additions & 2 deletions node.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ enum node_type {
NODE_MASGN,
NODE_LASGN,
NODE_DASGN,
NODE_DASGN_CURR,
NODE_GASGN,
NODE_IASGN,
NODE_CDECL,
Expand Down Expand Up @@ -327,7 +326,6 @@ typedef struct RNode {
#define NEW_GASGN(v,val,loc) NEW_NODE(NODE_GASGN,v,val,v,loc)
#define NEW_LASGN(v,val,loc) NEW_NODE(NODE_LASGN,v,val,0,loc)
#define NEW_DASGN(v,val,loc) NEW_NODE(NODE_DASGN,v,val,0,loc)
#define NEW_DASGN_CURR(v,val,loc) NEW_NODE(NODE_DASGN_CURR,v,val,0,loc)
#define NEW_IASGN(v,val,loc) NEW_NODE(NODE_IASGN,v,val,0,loc)
#define NEW_CDECL(v,val,path,loc) NEW_NODE(NODE_CDECL,v,val,path,loc)
#define NEW_CVASGN(v,val,loc) NEW_NODE(NODE_CVASGN,v,val,0,loc)
Expand Down
12 changes: 3 additions & 9 deletions parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -3177,8 +3177,7 @@ primary : literal

switch (nd_type($2)) {
case NODE_LASGN:
case NODE_DASGN:
case NODE_DASGN_CURR: /* e.each {|internal_var| a = internal_var; ... } */
case NODE_DASGN: /* e.each {|internal_var| a = internal_var; ... } */
$2->nd_value = internal_var;
id = 0;
m->nd_plen = 1;
Expand Down Expand Up @@ -10879,11 +10878,11 @@ assignable0(struct parser_params *p, ID id, const char **err)
NUMPARAM_ID_TO_IDX(id));
return -1;
}
if (dvar_curr(p, id)) return NODE_DASGN_CURR;
if (dvar_curr(p, id)) return NODE_DASGN;
if (dvar_defined(p, id)) return NODE_DASGN;
if (local_id(p, id)) return NODE_LASGN;
dyna_var(p, id);
return NODE_DASGN_CURR;
return NODE_DASGN;
}
else {
if (!local_id(p, id)) local_var(p, id);
Expand All @@ -10910,7 +10909,6 @@ assignable(struct parser_params *p, ID id, NODE *val, const YYLTYPE *loc)
const char *err = 0;
int node_type = assignable0(p, id, &err);
switch (node_type) {
case NODE_DASGN_CURR: return NEW_DASGN_CURR(id, val, loc);
case NODE_DASGN: return NEW_DASGN(id, val, loc);
case NODE_LASGN: return NEW_LASGN(id, val, loc);
case NODE_GASGN: return NEW_GASGN(id, val, loc);
Expand Down Expand Up @@ -11122,7 +11120,6 @@ mark_lvar_used(struct parser_params *p, NODE *rhs)
}
break;
case NODE_DASGN:
case NODE_DASGN_CURR:
if (dvar_defined_ref(p, rhs->nd_vid, &vidp)) {
if (vidp) *vidp |= LVAR_USED;
}
Expand Down Expand Up @@ -11397,7 +11394,6 @@ node_assign(struct parser_params *p, NODE *lhs, NODE *rhs, struct lex_context ct
case NODE_IASGN:
case NODE_LASGN:
case NODE_DASGN:
case NODE_DASGN_CURR:
case NODE_MASGN:
case NODE_CVASGN:
lhs->nd_value = rhs;
Expand Down Expand Up @@ -11477,7 +11473,6 @@ value_expr_check(struct parser_params *p, NODE *node)

case NODE_LASGN:
case NODE_DASGN:
case NODE_DASGN_CURR:
case NODE_MASGN:
mark_lvar_used(p, node);
return NULL;
Expand Down Expand Up @@ -11713,7 +11708,6 @@ assign_in_cond(struct parser_params *p, NODE *node)
case NODE_MASGN:
case NODE_LASGN:
case NODE_DASGN:
case NODE_DASGN_CURR:
case NODE_GASGN:
case NODE_IASGN:
break;
Expand Down