From feda058531c0bdd5b673180accb4407dcc798c79 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Thu, 18 Nov 2021 03:40:49 +0900 Subject: 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. --- ast.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'ast.c') diff --git a/ast.c b/ast.c index 96116d43eb..8139fcd390 100644 --- a/ast.c +++ b/ast.c @@ -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)); } -- cgit v1.2.1