diff options
| author | Zuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian> | 2026-01-11 17:16:40 +0000 |
|---|---|---|
| committer | Zuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian> | 2026-01-11 17:17:04 +0000 |
| commit | d2461482caf9e93d6e2bc7ff17567102f635211a (patch) | |
| tree | c302d1a2e7cb829b6ed006c905db0b8bbf45f57a /src/codegen/codegen_utils.c | |
| parent | f9b1992795142a073cd5dc1794350fc64e9aa695 (diff) | |
Fixed some things. Next thing will be tests.
Diffstat (limited to 'src/codegen/codegen_utils.c')
| -rw-r--r-- | src/codegen/codegen_utils.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/codegen/codegen_utils.c b/src/codegen/codegen_utils.c index fac6c6d..5dcbf19 100644 --- a/src/codegen/codegen_utils.c +++ b/src/codegen/codegen_utils.c @@ -1,12 +1,12 @@ -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <ctype.h> -#include "codegen.h" -#include "../zprep.h" #include "../ast/ast.h" #include "../parser/parser.h" +#include "../zprep.h" +#include "codegen.h" +#include <ctype.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> // Global state ASTNode *global_user_structs = NULL; @@ -44,7 +44,7 @@ ASTNode *find_struct_def_codegen(ParserContext *ctx, const char *name) ASTNode *s = global_user_structs; while (s) { - if (s->type == NODE_STRUCT && strcmp(s->strct.name, name) == 0) + if (s->type == NODE_STRUCT && strcmp(s->strct.name, name) == 0 && !s->strct.is_incomplete) { return s; } @@ -55,7 +55,8 @@ ASTNode *find_struct_def_codegen(ParserContext *ctx, const char *name) StructRef *sr = ctx->parsed_structs_list; while (sr) { - if (sr->node && sr->node->type == NODE_STRUCT && strcmp(sr->node->strct.name, name) == 0) + if (sr->node && sr->node->type == NODE_STRUCT && strcmp(sr->node->strct.name, name) == 0 && + !sr->node->strct.is_incomplete) { return sr->node; } @@ -64,7 +65,7 @@ ASTNode *find_struct_def_codegen(ParserContext *ctx, const char *name) s = ctx->instantiated_structs; while (s) { - if (s->type == NODE_STRUCT && strcmp(s->strct.name, name) == 0) + if (s->type == NODE_STRUCT && strcmp(s->strct.name, name) == 0 && !s->strct.is_incomplete) { return s; } |
