aboutsummaryrefslogtreecommitdiff
path: root/nextlang.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-02-04 21:13:50 -0500
committerBruce Hill <bruce@bruce-hill.com>2024-02-04 21:13:50 -0500
commitadde91636f04ae7544dba1ca5c6c1a40c074edb9 (patch)
treedfeb8c0c16fda6a87ef30b048b070ee4cb175a78 /nextlang.c
parentb08a0d3e2bf45bae11c982dd24d0292d6436b993 (diff)
Builtins
Diffstat (limited to 'nextlang.c')
-rw-r--r--nextlang.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/nextlang.c b/nextlang.c
index 333c4515..f3b8d88b 100644
--- a/nextlang.c
+++ b/nextlang.c
@@ -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");