path: root/node.h
diff options
authorYusuke Endoh <>2021-11-18 03:40:49 +0900
committerYusuke Endoh <>2021-11-21 08:59:24 +0900
commitfeda058531c0bdd5b673180accb4407dcc798c79 (patch)
tree7a9e59021282949f551b690feee031919ddd8a5a /node.h
parent86ad878e6a0781749c73574112a0fac4f088e2c9 (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: Merged:
Diffstat (limited to 'node.h')
1 files changed, 10 insertions, 2 deletions
diff --git a/node.h b/node.h
index 8450455624..bd1c9d1fbf 100644
--- a/node.h
+++ b/node.h
@@ -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;
+} 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);