diff options
| author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-10-05 11:26:48 +0900 |
|---|---|---|
| committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-10-05 14:23:42 +0900 |
| commit | 696022a0cb8938c23e5297dd3b6acdec30f2f045 (patch) | |
| tree | d4a3f8cbb58342441fc627ffcbd04a25c5666d1b | |
| parent | f5f3b35b9320e0dfaf3c40f00d866dcb595d54ef (diff) | |
Differentiate `NODE_BREAK`/`NODE_NEXT`/`NODE_RETURN`
| -rw-r--r-- | ast.c | 4 | ||||
| -rw-r--r-- | node_dump.c | 11 | ||||
| -rw-r--r-- | rubyparser.h | 4 |
3 files changed, 12 insertions, 7 deletions
@@ -416,9 +416,11 @@ node_children(rb_ast_t *ast, const NODE *node) case NODE_FOR_MASGN: return rb_ary_new_from_node_args(ast, 1, RNODE_FOR_MASGN(node)->nd_var); case NODE_BREAK: + return rb_ary_new_from_node_args(ast, 1, RNODE_BREAK(node)->nd_stts); case NODE_NEXT: + return rb_ary_new_from_node_args(ast, 1, RNODE_NEXT(node)->nd_stts); case NODE_RETURN: - return rb_ary_new_from_node_args(ast, 1, RNODE_BREAK(node)->nd_stts); + return rb_ary_new_from_node_args(ast, 1, RNODE_RETURN(node)->nd_stts); case NODE_REDO: return rb_ary_new_from_node_args(ast, 0); case NODE_RETRY: diff --git a/node_dump.c b/node_dump.c index d6ccfa84ac..e9e5c950c7 100644 --- a/node_dump.c +++ b/node_dump.c @@ -294,19 +294,22 @@ dump_node(VALUE buf, VALUE indent, int comment, const NODE * node) ANN("break statement"); ANN("format: break [nd_stts]"); ANN("example: break 1"); - goto jump; + LAST_NODE; + F_NODE(nd_stts, RNODE_BREAK, "value"); + return; case NODE_NEXT: ANN("next statement"); ANN("format: next [nd_stts]"); ANN("example: next 1"); - goto jump; + LAST_NODE; + F_NODE(nd_stts, RNODE_NEXT, "value"); + return; case NODE_RETURN: ANN("return statement"); ANN("format: return [nd_stts]"); ANN("example: return 1"); - jump: LAST_NODE; - F_NODE(nd_stts, RNODE_BREAK, "value"); + F_NODE(nd_stts, RNODE_RETURN, "value"); return; case NODE_REDO: diff --git a/rubyparser.h b/rubyparser.h index 4a52ad9ace..b1b3423bdd 100644 --- a/rubyparser.h +++ b/rubyparser.h @@ -281,16 +281,16 @@ typedef struct RNode_FOR_MASGN { typedef struct RNode_BREAK { NODE node; - struct RNode *nd_stts; VALUE not_used; + struct RNode *nd_stts; VALUE not_used2; } rb_node_break_t; typedef struct RNode_NEXT { NODE node; - struct RNode *nd_stts; VALUE not_used; + struct RNode *nd_stts; VALUE not_used2; } rb_node_next_t; |
