harec

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

commit b95dcfd0ca8d599c406415236329020fb31c72e4
parent 2c52a02a5bcd9867ef4e3c7fba2ace3828a1bfcf
Author: Armin Weigl <tb46305@gmail.com>
Date:   Sun, 19 Feb 2023 10:55:14 +0100

scan_enum_field: store type directly in scope_object

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

Diffstat:
Minclude/check.h | 1-
Msrc/check.c | 7+++----
2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/include/check.h b/include/check.h @@ -104,7 +104,6 @@ enum idecl_type { // Keeps track of enum specific context required for enum field resolution struct incomplete_enum_field { struct ast_enum_field *field; - const struct type *type; struct scope *enum_scope; }; diff --git a/src/check.c b/src/check.c @@ -3558,7 +3558,6 @@ scan_enum_field(struct context *ctx, struct scope *imports, xcalloc(1, sizeof(struct incomplete_enum_field)); *field = (struct incomplete_enum_field){ .field = f, - .type = etype, .enum_scope = enum_scope, }; @@ -3574,6 +3573,7 @@ scan_enum_field(struct context *ctx, struct scope *imports, &name, &localname); fld->type = IDECL_ENUM_FLD; fld->imports = imports; + fld->obj.type = etype, fld->field = field; } @@ -3723,7 +3723,7 @@ resolve_enum_field(struct context *ctx, struct incomplete_declaration *idecl) { assert(idecl->type == IDECL_ENUM_FLD); - const struct type *type = idecl->field->type; + const struct type *type = idecl->obj.type; struct identifier localname = { .name = idecl->obj.ident.name @@ -3783,7 +3783,6 @@ resolve_enum_field(struct context *ctx, struct incomplete_declaration *idecl) } idecl->obj.otype = O_CONST; - idecl->obj.type = type; idecl->obj.value = value; } @@ -3878,13 +3877,13 @@ scan_enum_field_aliases(struct context *ctx, const struct scope_object *obj) (struct incomplete_declaration *)val; *field = (struct incomplete_enum_field){ .field = afield, - .type = obj->type, .enum_scope = idecl->field->enum_scope, }; idecl = incomplete_declaration_create(ctx, (struct location){0}, ctx->scope, &ident, &name); idecl->type = IDECL_ENUM_FLD; + idecl->obj.type = obj->type; idecl->field = field; }; }