diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-02-04 21:13:50 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-02-04 21:13:50 -0500 |
| commit | adde91636f04ae7544dba1ca5c6c1a40c074edb9 (patch) | |
| tree | dfeb8c0c16fda6a87ef30b048b070ee4cb175a78 /nextlang.c | |
| parent | b08a0d3e2bf45bae11c982dd24d0292d6436b993 (diff) | |
Builtins
Diffstat (limited to 'nextlang.c')
| -rw-r--r-- | nextlang.c | 16 |
1 files changed, 14 insertions, 2 deletions
@@ -29,8 +29,20 @@ int main(int argc, char *argv[]) fclose(out); } - // Predeclare funcs: CORD code = "#include \"nextlang.h\"\n\n"; + + // Predeclare types: + for (ast_list_t *stmt = Match(ast, Block)->statements; stmt; stmt = stmt->next) { + switch (stmt->ast->tag) { + case TypeDef: { + code = CORD_cat(code, compile(stmt->ast)); + break; + } + default: break; + } + } + + // Predeclare funcs: for (ast_list_t *stmt = Match(ast, Block)->statements; stmt; stmt = stmt->next) { switch (stmt->ast->tag) { case FunctionDef: { @@ -65,7 +77,7 @@ int main(int argc, char *argv[]) "GC_INIT();\n\n"); for (ast_list_t *stmt = Match(ast, Block)->statements; stmt; stmt = stmt->next) { switch (stmt->ast->tag) { - case FunctionDef: break; + case FunctionDef: case TypeDef: break; default: { code = CORD_cat(code, compile(stmt->ast)); code = CORD_cat(code, ";\n"); |
