From 3cdc850f2a7dbf1e170242417d67acf8d7e7b0d8 Mon Sep 17 00:00:00 2001 From: WormHeamer Date: Sun, 3 Aug 2025 20:59:53 -0400 Subject: expand and clarify type system, fix double-free of nodes --- ir.h | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'ir.h') diff --git a/ir.h b/ir.h index 9351864..72586f2 100644 --- a/ir.h +++ b/ir.h @@ -6,10 +6,32 @@ #include "lex.h" /* for error reporting only */ #include "str.h" +/* types */ + +typedef enum { + T_TOP, /* may or may not be a constant */ + T_CONST, /* known compile-time constant */ + T_BOT, /* known not a constant */ +} TypeLevel; + +typedef enum { + T_TUPLE, + T_INT +} BaseType; + +typedef struct Type { + BaseType t; + TypeLevel lvl; + struct Type *next; +} Type; + +int type_eql(Type *a, Type *b); + /* nodes */ typedef enum { N_START, + N_PROJ, N_RETURN, N_KEEPALIVE, N_LIT, @@ -22,13 +44,6 @@ typedef enum { const char *node_type_name(NodeType t); -typedef enum { - T_BOT, - T_TOP, - T_CONST, - T_INT -} Type; - typedef struct { Type type; union { -- cgit v1.2.3