diff options
author | Yusuke Endoh <mame@ruby-lang.org> | 2021-11-18 03:40:49 +0900 |
---|---|---|
committer | Yusuke Endoh <mame@ruby-lang.org> | 2021-11-21 08:59:24 +0900 |
commit | feda058531c0bdd5b673180accb4407dcc798c79 (patch) | |
tree | 7a9e59021282949f551b690feee031919ddd8a5a /ast.c | |
parent | 86ad878e6a0781749c73574112a0fac4f088e2c9 (diff) |
Refactor hacky ID tables to struct rb_ast_id_table_t
The implementation of a local variable tables was represented as `ID*`,
but it was very hacky: the first element is not an ID but the size of
the table, and, the last element is (sometimes) a link to the next local
table only when the id tables are a linked list.
This change converts the hacky implementation to a normal struct.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/5136
Diffstat (limited to 'ast.c')
-rw-r--r-- | ast.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -600,11 +600,11 @@ node_children(rb_ast_t *ast, const NODE *node) } case NODE_SCOPE: { - ID *tbl = node->nd_tbl; - int i, size = tbl ? (int)*tbl++ : 0; + rb_ast_id_table_t *tbl = node->nd_tbl; + int i, size = tbl ? tbl->size : 0; VALUE locals = rb_ary_new_capa(size); for (i = 0; i < size; i++) { - rb_ary_push(locals, var_name(tbl[i])); + rb_ary_push(locals, var_name(tbl->ids[i])); } return rb_ary_new_from_args(3, locals, NEW_CHILD(ast, node->nd_args), NEW_CHILD(ast, node->nd_body)); } |