diff options
author | yui-knk <[email protected]> | 2024-07-22 16:28:00 +0900 |
---|---|---|
committer | Yuichiro Kaneko <[email protected]> | 2024-07-23 14:35:23 +0900 |
commit | 57b11be15ae518288b719fb36068ceb23da6e050 (patch) | |
tree | 9a772e11ab2a75c86a3df1f83e67247751b1679e /node_dump.c | |
parent | f23485a8d693cb69fd7b84c1ab93cb4198ecfe4a (diff) |
Implement UNLESS NODE keyword locations
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/11227
Diffstat (limited to 'node_dump.c')
-rw-r--r-- | node_dump.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/node_dump.c b/node_dump.c index 5656f1d812..9d718ff293 100644 --- a/node_dump.c +++ b/node_dump.c @@ -27,6 +27,10 @@ #define A_INT(val) rb_str_catf(buf, "%d", (val)) #define A_LONG(val) rb_str_catf(buf, "%ld", (val)) #define A_LIT(lit) AR(rb_dump_literal(lit)) +#define A_LOC(loc) \ + rb_str_catf(buf, "(%d,%d)-(%d,%d)", \ + loc.beg_pos.lineno, loc.beg_pos.column, \ + loc.end_pos.lineno, loc.end_pos.column) #define A_NODE_HEADER(node, term) \ rb_str_catf(buf, "@ %s (id: %d, line: %d, location: (%d,%d)-(%d,%d))%s"term, \ ruby_node_name(nd_type(node)), nd_node_id(node), nd_line(node), \ @@ -84,6 +88,7 @@ #define F_LIT(name, type, ann) SIMPLE_FIELD1(#name, ann) A_LIT(type(node)->name) #define F_VALUE(name, val, ann) SIMPLE_FIELD1(#name, ann) A_LIT(val) #define F_MSG(name, ann, desc) SIMPLE_FIELD1(#name, ann) A(desc) +#define F_LOC(name, type) SIMPLE_FIELD1(#name, "") A_LOC(type(node)->name) #define F_SHAREABILITY(name, type, ann) SIMPLE_FIELD1(#name, ann) A_SHAREABILITY(type(node)->name) #define F_NODE(name, type, ann) \ @@ -244,8 +249,11 @@ dump_node(VALUE buf, VALUE indent, int comment, const NODE * node) ANN("example: unless x == 1 then foo else bar end"); F_NODE(nd_cond, RNODE_UNLESS, "condition expr"); F_NODE(nd_body, RNODE_UNLESS, "then clause"); - LAST_NODE; F_NODE(nd_else, RNODE_UNLESS, "else clause"); + F_LOC(keyword_loc, RNODE_UNLESS); + F_LOC(then_keyword_loc, RNODE_UNLESS); + LAST_NODE; + F_LOC(end_keyword_loc, RNODE_UNLESS); return; case NODE_CASE: |