diff options
Diffstat (limited to 'identifiers.c')
-rw-r--r-- | identifiers.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/identifiers.c b/identifiers.c index ca6050f..ebf3f0d 100644 --- a/identifiers.c +++ b/identifiers.c @@ -13,6 +13,7 @@ typedef struct IdentTree { Array decls; /* array of declarations of this identifier */ unsigned long c_fn_reps; /* number of repetitions of this identifier in the C output--only used for functions */ size_t depth; + struct Type *type; } IdentTree; typedef IdentTree *Identifier; @@ -90,6 +91,22 @@ static bool ident_eq_str(Identifier i, const char *s) { return true; } +static char *ident_to_str(Identifier i) { + char *str = malloc(i->depth + 1); + str += i->depth; + *str = 0; + while (i->parent != NULL) { + str--; + *str = identifier_chars[i - i->parent->children]; + i = i->parent; + } + return str; +} + +static IdentDecl *ident_decl(Identifier i) { + return (IdentDecl*)i->decls.last; +} + static void idents_free_tree(IdentTree *tree) { if (!tree->children) return; for (int i = 0; i < NIDENTIFIER_CHARS; i++) |