diff options
| author | Mel <mel@rnrd.eu> | 2025-08-05 22:49:40 +0200 |
|---|---|---|
| committer | Mel <mel@rnrd.eu> | 2025-08-05 22:49:40 +0200 |
| commit | c2c84f4d15d964fb663f390046b1d17441145c61 (patch) | |
| tree | a1724e49fefe143fd82404ffb1a0891ad6bc9755 /boot/transpile.c | |
| parent | 1d277d507498d8f3649684e7ff0ad2c3a19792a4 (diff) | |
| download | catskill-c2c84f4d15d964fb663f390046b1d17441145c61.tar.zst catskill-c2c84f4d15d964fb663f390046b1d17441145c61.zip | |
Add core library for catskill transpiled source, output defined types in transpiler
Signed-off-by: Mel <mel@rnrd.eu>
Diffstat (limited to 'boot/transpile.c')
| -rw-r--r-- | boot/transpile.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/boot/transpile.c b/boot/transpile.c index bebcbbc..25a3d79 100644 --- a/boot/transpile.c +++ b/boot/transpile.c @@ -65,13 +65,19 @@ transpiler_visit_type_node(struct Visit* visit, struct Type_Node* node) case TYPE_NODE_NAME: { struct String name = node->value.name.name; if (strcmp(name.data, "int") == 0) { - fprintf(transpiler->output, "int64_t"); + fprintf(transpiler->output, "integer"); } else if (strcmp(name.data, "string") == 0) { - fprintf(transpiler->output, "const char*"); + fprintf(transpiler->output, "struct String"); } else if (strcmp(name.data, "bool") == 0) { fprintf(transpiler->output, "bool"); } else if (strcmp(name.data, "float") == 0) { - fprintf(transpiler->output, "double"); + fprintf(transpiler->output, "real"); + } else if (strcmp(name.data, "uint") == 0) { + fprintf(transpiler->output, "uint"); + } else if (strcmp(name.data, "byte") == 0) { + fprintf(transpiler->output, "byte"); + } else if (strcmp(name.data, "ascii") == 0) { + fprintf(transpiler->output, "ascii"); } else { fprintf(transpiler->output, "%.*s", (int)name.length, name.data); } @@ -369,10 +375,9 @@ transpiler_visit_tree(struct Visit* visit, struct Tree* tree) { TRANSPILER_PREAMBLE - // include some standard c headers - // catskill should have it's own standard library, - // but until bootstrapping is complete, we will just use a - // normal libc (preferably musl). + // include the catskill runtime core library + // which provides all the necessary types and functions + // for transpiled catskill programs. // other headers can be included by the user // with the pragma `| c-header "header.h"`. fprintf(transpiler->output, "#include <stdio.h>\n"); |
