harec

[hare] Hare compiler, written in C11 for POSIX OSs
Log | Files | Refs | README | LICENSE

commit 28fedb0d09847378162e06ea44304439dc8e0ebd
parent 38fd430c3982d182f3177c494a557a9dc32c492f
Author: Armin Weigl <tb46305@gmail.com>
Date:   Tue,  7 Feb 2023 05:32:04 +0100

check_type: reuse resolved type

Signed-off-by: Armin Weigl <tb46305@gmail.com>

Diffstat:
Msrc/check.c | 26++++----------------------
1 file changed, 4 insertions(+), 22 deletions(-)

diff --git a/src/check.c b/src/check.c @@ -3499,32 +3499,14 @@ check_global(struct context *ctx, static struct declaration * check_type(struct context *ctx, + const struct scope_object *obj, const struct ast_type_decl *adecl, bool exported) { struct declaration *decl = xcalloc(1, sizeof(struct declaration)); - mkident(ctx, &decl->ident, &adecl->ident, NULL); decl->type = DECL_TYPE; - if (adecl->type->storage == STORAGE_ENUM) { - decl->_type = - type_store_lookup_enum(ctx->store, adecl->type, exported); - } else { - const struct type *type = - type_store_lookup_atype(ctx->store, adecl->type); - struct type _alias = { - .storage = STORAGE_ALIAS, - .alias = { - .ident = decl->ident, - .name = adecl->ident, - .type = type, - .exported = exported, - }, - .size = type->size, - .align = type->align, - .flags = type->flags, - }; - decl->_type = type_store_lookup_alias(ctx->store, &_alias, NULL); - } + decl->ident = obj->ident; + decl->_type = obj->type; return decl; } @@ -3546,7 +3528,7 @@ check_declaration(struct context *ctx, decl = check_global(ctx, &adecl->global); break; case AST_DECL_TYPE: - decl = check_type(ctx, &adecl->type, adecl->exported); + decl = check_type(ctx, &idecl->obj, &adecl->type, adecl->exported); break; }