diff options
| author | WormHeamer | 2025-08-30 23:20:51 -0400 |
|---|---|---|
| committer | WormHeamer | 2025-08-30 23:20:51 -0400 |
| commit | cbca8b454309122632615f0bcb787bc898503df9 (patch) | |
| tree | 5b888ba81858df7f45baffe4a760d816cd59cd08 /proc.h | |
| parent | 6e419a23faf6550c3d3e986796ccf33bdec79c74 (diff) | |
separate IR graph parts of Proc into a Graph struct
Diffstat (limited to 'proc.h')
| -rw-r--r-- | proc.h | 51 |
1 files changed, 51 insertions, 0 deletions
@@ -0,0 +1,51 @@ +#ifndef PROC_H +#define PROC_H + +#include "ir.h" + +typedef struct NameBinding { + struct NameBinding *prev; + LexSpan src_pos; + Str name; + Node *node; +} NameBinding; + +typedef struct ScopeFrame { + struct ScopeFrame *prev; + NameBinding *latest; +} ScopeFrame; + +typedef struct { + Arena *arena; + ScopeFrame *tail, *free_scope; + NameBinding *free_bind; +} Scope; + +typedef struct { + Str name; + Node *node; +} ScopeName; + +typedef DYNARR(ScopeName) ScopeNameList; + +typedef struct { + Str name; + Type ret_type; + Arena perm, scratch; + NodePool pool; + Graph graph; + Scope scope; +} Proc; + +void proc_init(Proc *proc, Str name); +void proc_free(Proc *proc); + +ScopeFrame *scope_push(Scope *scope); +ScopeFrame *scope_pop(Scope *scope, Graph *g); +NameBinding *scope_find(Scope *scope, Str name); +NameBinding *scope_bind(Scope *scope, Str name, Node *value, LexSpan pos, Graph *g); +NameBinding *scope_update(NameBinding *b, Node *to, Graph *g); +void scope_collect(Scope *scope, Graph *g, ScopeNameList *nl, Arena *arena); +void scope_uncollect(Scope *scope, Graph *g, ScopeNameList *nl); + +#endif |
