From 34181f22cd6cec033a3136a7eb3c363c9e56d449 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Fri, 29 Aug 2025 22:20:36 +0900 Subject: fix: dangling pointer --- src/ast.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/ast.h') diff --git a/src/ast.h b/src/ast.h index 8940aee..108d436 100644 --- a/src/ast.h +++ b/src/ast.h @@ -22,13 +22,20 @@ typedef enum TypeKind TypeKind; const char* type_kind_stringify(TypeKind k); struct AstNode; +typedef struct AstNode AstNode; + +struct TypeRef { + struct AstNode* defs; + size_t index; +}; +typedef struct TypeRef TypeRef; struct Type { TypeKind kind; // Check `base` instead of `kind` to test if the type is an array or a pointer. struct Type* base; int array_size; - struct AstNode* def; + TypeRef ref; BOOL is_static; }; typedef struct Type Type; @@ -131,7 +138,6 @@ struct AstNode { int __i1; int __i2; }; -typedef struct AstNode AstNode; struct Program { AstNode* funcs; -- cgit v1.2.3-70-g09d2