зеркало из https://github.com/github/ruby.git
Remove `NODE_DASGN_CURR` [Feature #18406]
This `NODE` type was used in pre-YARV implementation, to improve the performance of assignment to dynamic local variable defined at the innermost scope. It has no longer any actual difference with `NODE_DASGN`, except for the node dump.
This commit is contained in:
Родитель
d3c8f7b1cd
Коммит
54f0e63a8c
1
ast.c
1
ast.c
|
@ -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:
|
||||
|
|
12
compile.c
12
compile.c
|
@ -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);
|
||||
|
@ -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:
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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));
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
9
node.c
9
node.c
|
@ -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)) {
|
||||
|
|
2
node.h
2
node.h
|
@ -48,7 +48,6 @@ enum node_type {
|
|||
NODE_MASGN,
|
||||
NODE_LASGN,
|
||||
NODE_DASGN,
|
||||
NODE_DASGN_CURR,
|
||||
NODE_GASGN,
|
||||
NODE_IASGN,
|
||||
NODE_CDECL,
|
||||
|
@ -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)
|
||||
|
|
12
parse.y
12
parse.y
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
|
Загрузка…
Ссылка в новой задаче