summaryrefslogtreecommitdiff
path: root/identifiers.c
diff options
context:
space:
mode:
Diffstat (limited to 'identifiers.c')
-rw-r--r--identifiers.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/identifiers.c b/identifiers.c
index e960a14..94d65f0 100644
--- a/identifiers.c
+++ b/identifiers.c
@@ -27,17 +27,25 @@ static int isident(int c) {
}
+static Identifier ident_new_anonymous(Identifiers *ids) {
+ IdentTree *node = block_arr_add(&ids->trees);
+ memset(node, 0, sizeof *node);
+ node->anonymous = true;
+ return node;
+}
+
/* used internally to allocate identifiers */
static Identifier ident_new(Identifiers *ids, Identifier parent, unsigned char index_in_parent) {
- IdentTree *tree = block_arr_add(&ids->trees);
- memset(tree, 0, sizeof *tree); /* use zero value of IdentTree */
- tree->parent = parent;
+ IdentTree *node = ident_new_anonymous(ids);
+ node->parent = parent;
if (parent)
- tree->depth = (uint16_t)(parent->depth + 1);
- tree->index_in_parent = index_in_parent;
- return tree;
+ node->depth = (uint16_t)(parent->depth + 1);
+ node->index_in_parent = index_in_parent;
+ node->anonymous = false;
+ return node;
}
+
/* Initialize Identifiers. */
static void idents_create(Identifiers *ids) {
block_arr_create(&ids->trees, 10, sizeof(IdentTree)); /* blocks of 1 << 10 = 1024 */