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 /node.h | |
parent | 86ad878e6a0781749c73574112a0fac4f088e2c9 (diff) | |
download | ruby-feda058531c0bdd5b673180accb4407dcc798c79.tar.gz |
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.
Diffstat (limited to 'node.h')
-rw-r--r-- | node.h | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -11,6 +11,8 @@ **********************************************************************/ +#include "internal/compilers.h" + #if defined(__cplusplus) extern "C" { #if 0 @@ -146,13 +148,18 @@ code_loc_gen(const rb_code_location_t *loc1, const rb_code_location_t *loc2) return loc; } +typedef struct rb_ast_id_table { + int size; + ID ids[FLEX_ARY_LEN]; +} rb_ast_id_table_t; + typedef struct RNode { VALUE flags; union { struct RNode *node; ID id; VALUE value; - ID *tbl; + rb_ast_id_table_t *tbl; } u1; union { struct RNode *node; @@ -411,13 +418,14 @@ typedef struct rb_ast_struct { rb_ast_t *rb_ast_new(void); void rb_ast_mark(rb_ast_t*); void rb_ast_update_references(rb_ast_t*); -void rb_ast_add_local_table(rb_ast_t*, ID *buf); void rb_ast_dispose(rb_ast_t*); void rb_ast_free(rb_ast_t*); size_t rb_ast_memsize(const rb_ast_t*); void rb_ast_add_mark_object(rb_ast_t*, VALUE); NODE *rb_ast_newnode(rb_ast_t*, enum node_type type); void rb_ast_delete_node(rb_ast_t*, NODE *n); +rb_ast_id_table_t *rb_ast_new_local_table(rb_ast_t*, int); +rb_ast_id_table_t *rb_ast_resize_latest_local_table(rb_ast_t*, int); VALUE rb_parser_new(void); VALUE rb_parser_end_seen_p(VALUE); |