From 774809f07cbbc8e5efdb30fbb7c06ed87d6c78ba Mon Sep 17 00:00:00 2001 From: Quinn Stephens Date: Sun, 3 Nov 2024 09:24:06 -0500 Subject: [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 --- compiler/parser/type.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) (limited to 'compiler/parser') 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"); -- cgit v1.2.3