#ifndef PROC_H #define PROC_H #include "ir.h" #include "xar.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 { Str name; Value *from, *to; LexSpan from_pos, to_pos; } ScopeChange; typedef XAR(ScopeChange) ScopeChangeList; typedef struct { Str name; Value *from, *to; LexSpan from_pos, to_pos; } ScopeChange; typedef struct { Arena *arena; XAR(ScopeChange); } ScopeChangeList; typedef struct { Arena *arena; ScopeFrame *tail, *free_scope; NameBinding *free_bind; } Scope; 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); 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); #endif