diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2020-01-11 22:40:21 -0500 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2020-01-11 22:40:21 -0500 |
commit | 2069b22cbcbbf293151db0c7c2a3e29f8c29c977 (patch) | |
tree | 7ded0128f3e5673d3905cc850622703a52eefb2b /identifiers.c | |
parent | b4ece566e3625e5de6cec6b4773e05a07485da0d (diff) |
eval for imported stuff
Diffstat (limited to 'identifiers.c')
-rw-r--r-- | identifiers.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/identifiers.c b/identifiers.c index de8a106..c562d52 100644 --- a/identifiers.c +++ b/identifiers.c @@ -9,7 +9,7 @@ #endif /* can this character be used in an identifier? */ -static int isident(int c) { +static int is_ident(int c) { if (c >= 'a' && c <= 'z') return 1; if (c >= 'A' && c <= 'Z') @@ -71,7 +71,7 @@ static void idents_create(Identifiers *ids) { static Identifier ident_insert(Identifiers *ids, char **s) { IdentTree *tree = ids->root; while (1) { - if (!isident(**s)) { + if (!is_ident(**s)) { return tree; } int c = ident_char_to_uchar(**s); @@ -117,6 +117,7 @@ static char *ident_to_str(Identifier i) { return str; } + static void fprint_ident(FILE *out, Identifier id) { char *str = ident_to_str(id); fprintf(out, "%s", str); @@ -172,6 +173,15 @@ static Identifier ident_get(Identifiers *ids, const char *s) { return tree; } +static Identifier ident_translate(Identifier i, Identifiers *to_idents) { + /* OPTIM */ + if (!i || i->anonymous) return NULL; + char *s = ident_to_str(i); + Identifier new_ident = ident_get(to_idents, s); + free(s); + return new_ident; +} + static IdentDecl *ident_add_decl(Identifier i, struct Declaration *d, struct Block *b) { IdentDecl *id_decl = arr_add(&i->decls); id_decl->decl = d; |