From 9c5d50e5371cd26d7ae8fd896dc06fa9af684949 Mon Sep 17 00:00:00 2001 From: WormHeamer Date: Thu, 7 Aug 2025 00:50:01 -0400 Subject: add if statements --- ir.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'ir.h') diff --git a/ir.h b/ir.h index 251c198..ff75163 100644 --- a/ir.h +++ b/ir.h @@ -12,6 +12,7 @@ typedef enum { T_TOP, /* may or may not be a constant */ T_CONST, /* known compile-time constant */ T_BOT, /* known not a constant */ + T_CTRL /* bottom of control flow */ } TypeLevel; typedef enum { @@ -48,7 +49,7 @@ void type_err(struct Node *n, Lexer *l); typedef enum { N_NONE, - N_START, + N_START, N_IF_ELSE, N_REGION, N_PHI, N_STOP, N_PROJ, N_RETURN, N_KEEPALIVE, @@ -100,10 +101,17 @@ typedef struct { NameBinding *free_bind; } Scope; +typedef struct { + Str name; + Node *node; +} ScopeName; + +typedef DYNARR(ScopeName) ScopeNameList; + typedef struct { Arena arena; Str name; - Node *start, *stop, *keepalive; + Node *start, *stop, *ctrl, *keepalive; Node *free_list; Scope scope; } Proc; @@ -144,5 +152,6 @@ ScopeFrame *scope_pop(Scope *scope, Proc *proc); NameBinding *scope_find(Scope *scope, Str name); NameBinding *scope_bind(Scope *scope, Str name, Node *value, LexSpan pos, Proc *proc); NameBinding *scope_update(Scope *scope, Str name, Node *to, Proc *proc); +void scope_collect(Scope *scope, Proc *proc, ScopeNameList *nl, Arena *arena); #endif -- cgit v1.2.3