diff options
author | yui-knk <[email protected]> | 2023-08-22 10:26:38 +0900 |
---|---|---|
committer | Yuichiro Kaneko <[email protected]> | 2023-09-28 11:58:10 +0900 |
commit | 74c67811537c0c1840668c218dc0e2510d00b473 (patch) | |
tree | 1f387a71cf9f797217721345e85e098b790187e5 /ruby_parser.c | |
parent | 684686a1e14d923b43cfd6c1d5a80222281a4070 (diff) |
Change RNode structure from union to struct
All kind of AST nodes use same struct RNode, which has u1, u2, u3 union members
for holding different kind of data.
This has two problems.
1. Low flexibility of data structure
Some nodes, for example NODE_TRUE, don’t use u1, u2, u3. On the other hand,
NODE_OP_ASGN2 needs more than three union members. However they use same
structure definition, need to allocate three union members for NODE_TRUE and
need to separate NODE_OP_ASGN2 into another node.
This change removes the restriction so make it possible to
change data structure by each node type.
2. No compile time check for union member access
It’s developer’s responsibility for using correct member for each node type when it’s union.
This change clarifies which node has which type of fields and enables compile time check.
This commit also changes node_buffer_elem_struct buf management to handle
different size data with alignment.
Diffstat (limited to 'ruby_parser.c')
-rw-r--r-- | ruby_parser.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/ruby_parser.c b/ruby_parser.c index da89968a74..b239494886 100644 --- a/ruby_parser.c +++ b/ruby_parser.c @@ -356,7 +356,7 @@ reg_named_capture_assign(struct parser_params* p, VALUE regexp, const rb_code_lo onig_foreach_name(RREGEXP_PTR(regexp), reg_named_capture_assign_iter, &arg); if (!arg.succ_block) return 0; - return arg.succ_block->nd_next; + return RNODE_BLOCK(arg.succ_block)->nd_next; } static VALUE |