diff options
author | Quinn Stephens <quinn@osmora.org> | 2024-11-03 09:24:06 -0500 |
---|---|---|
committer | Quinn Stephens <quinn@osmora.org> | 2024-11-03 09:24:06 -0500 |
commit | 774809f07cbbc8e5efdb30fbb7c06ed87d6c78ba (patch) | |
tree | 326314bcf01c3f78ce4285b21bb1d739e4825a83 /compiler/parser | |
parent | c0d1d67061cc0ac33a7c9add7fa4081e5e731360 (diff) |
[parser] Mini-refactor of type parsing
Removed type_new() since it was only used once.
Removed debug output from parse_type_ref().
Signed-off-by: Quinn Stephens <quinn@osmora.org>
Diffstat (limited to 'compiler/parser')
-rw-r--r-- | compiler/parser/type.c | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/compiler/parser/type.c b/compiler/parser/type.c index 5e161b4..4b961f0 100644 --- a/compiler/parser/type.c +++ b/compiler/parser/type.c @@ -14,19 +14,6 @@ #define HASHMAP_ROWS 8 -static struct type * -type_new(struct token *tok) -{ - struct type *typ; - - typ = malloc(sizeof(struct type)); - typ->hashmap_entry.hash = tok->hash; - typ->name = tok->pos; - typ->name_len = tok->len; - - return typ; -} - static void free_all(struct hashmap *map) { @@ -48,8 +35,6 @@ parse_type_ref(struct parser *ctx, struct type **typ_out, int *n_ptrs_out) struct type *typ; int n_ptrs; - debug("Parsing type reference...\n"); - /* Find type */ typ = (struct type*)hashmap_find(ctx->types, ctx->tok.hash); if (typ == NULL) { @@ -265,7 +250,10 @@ parse_type(struct parser *ctx) } /* Create type */ - typ = type_new(&ctx->tok); + typ = malloc(sizeof(struct type)); + typ->hashmap_entry.hash = ctx->tok.hash; + typ->name = ctx->tok.pos; + typ->name_len = ctx->tok.len; if (next_token(ctx)->kind != TK_COLON) { tok_error(&ctx->tok, "expected \":\" after type name\n"); |