diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-02-17 16:56:19 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-02-17 16:56:19 -0500 |
| commit | de3eeacfa0151243e4ef52af3d6c2e2b731fc720 (patch) | |
| tree | 4bf2ee295698a89a6378701f6e1e7aecbc552da2 /environment.h | |
| parent | 60f3e91b80dee6fcd995066730058dd5bc29414d (diff) | |
Major cleanup
Diffstat (limited to 'environment.h')
| -rw-r--r-- | environment.h | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/environment.h b/environment.h index a03ccd42..64b59594 100644 --- a/environment.h +++ b/environment.h @@ -6,21 +6,30 @@ #include "builtins/table.h" typedef struct { - table_t globals, types; - table_t *locals; - CORD imports; - CORD typedefs; - CORD typecode; - CORD staticdefs; - CORD funcs; - CORD main; + CORD imports; + CORD typedefs; + CORD typecode; + CORD staticdefs; + CORD funcs; + CORD main; +} compilation_unit_t; + +typedef struct { + table_t *types, *globals, *locals; + compilation_unit_t *code; } env_t; typedef struct { - CORD code; - type_t *type; + CORD code; + type_t *type; } binding_t; -env_t *new_environment(void); +env_t *new_compilation_unit(void); +env_t *fresh_scope(env_t *env); +__attribute__((noreturn)) +void compiler_err(file_t *f, const char *start, const char *end, const char *fmt, ...); +binding_t *get_binding(env_t *env, const char *name); +void set_binding(env_t *env, const char *name, binding_t *binding); +#define code_err(ast, ...) compiler_err((ast)->file, (ast)->start, (ast)->end, __VA_ARGS__) // vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1,\:0 |
