diff options
author | yui-knk <[email protected]> | 2024-07-25 14:57:14 +0900 |
---|---|---|
committer | Yuichiro Kaneko <[email protected]> | 2024-07-26 07:29:32 +0900 |
commit | f2728c3393d7571f681accd9c887dcd5bad65950 () | |
tree | 6f6d6f061516255d122b898f3661809cbf9ce2aa /compile.c | |
parent | a4563be05c1e7c6031e6fde613f7e874f41fe06c (diff) |
Change RESBODY Node structure
Extracrt exception variable into `nd_exc_var` field to keep the original grammar structure. For example: ``` begin rescue Error => e1 end ``` Before: ``` @ NODE_RESBODY (id: 8, line: 2, location: (2,0)-(2,18)) +- nd_args: | @ NODE_LIST (id: 2, line: 2, location: (2,7)-(2,12)) | +- as.nd_alen: 1 | +- nd_head: | | @ NODE_CONST (id: 1, line: 2, location: (2,7)-(2,12)) | | +- nd_vid: :Error | +- nd_next: | (null node) +- nd_body: | @ NODE_BLOCK (id: 6, line: 2, location: (2,13)-(2,18)) | +- nd_head (1): | | @ NODE_LASGN (id: 3, line: 2, location: (2,13)-(2,18)) | | +- nd_vid: :e1 | | +- nd_value: | | @ NODE_ERRINFO (id: 5, line: 2, location: (2,13)-(2,18)) | +- nd_head (2): | @ NODE_BEGIN (id: 4, line: 2, location: (2,18)-(2,18)) | +- nd_body: | (null node) +- nd_next: (null node) ``` After: ``` @ NODE_RESBODY (id: 6, line: 2, location: (2,0)-(2,18)) +- nd_args: | @ NODE_LIST (id: 2, line: 2, location: (2,7)-(2,12)) | +- as.nd_alen: 1 | +- nd_head: | | @ NODE_CONST (id: 1, line: 2, location: (2,7)-(2,12)) | | +- nd_vid: :Error | +- nd_next: | (null node) +- nd_exc_var: | @ NODE_LASGN (id: 3, line: 2, location: (2,13)-(2,18)) | +- nd_vid: :e1 | +- nd_value: | @ NODE_ERRINFO (id: 5, line: 2, location: (2,13)-(2,18)) +- nd_body: | @ NODE_BEGIN (id: 4, line: 2, location: (2,18)-(2,18)) | +- nd_body: | (null node) +- nd_next: (null node) ```
Notes: Merged: https://.com/ruby/ruby/pull/11243
-rw-r--r-- | compile.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -8396,7 +8396,11 @@ compile_resbody(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, ADD_LABEL(ret, label_hit); ADD_TRACE(ret, RUBY_EVENT_RESCUE); - if (nd_type(RNODE_RESBODY(resq)->nd_body) == NODE_BEGIN && RNODE_BEGIN(RNODE_RESBODY(resq)->nd_body)->nd_body == NULL) { // empty body ADD_SYNTHETIC_INSN(ret, nd_line(RNODE_RESBODY(resq)->nd_body), -1, putnil); } |