diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2023-11-19 18:41:55 +0200 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2023-11-19 18:41:55 +0200 |
| commit | 8f754f8b13e55e4bb92d72f105c5aaaba1754b7d (patch) | |
| tree | b70b813c091691d6645f8cb82295f41f24f3be93 /src/compiler.c | |
| parent | 5304dbcf4df1fc211b5099f4d6eb7f23dfa8c454 (diff) | |
| download | ek-8f754f8b13e55e4bb92d72f105c5aaaba1754b7d.tar.gz ek-8f754f8b13e55e4bb92d72f105c5aaaba1754b7d.zip | |
start working on instruction lowering
Diffstat (limited to 'src/compiler.c')
| -rw-r--r-- | src/compiler.c | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/src/compiler.c b/src/compiler.c index 5ad67c3..8801c7f 100644 --- a/src/compiler.c +++ b/src/compiler.c @@ -22,6 +22,7 @@ #include <ek/debug.h> #include <ek/scope.h> #include <ek/path.h> +#include <ek/ops.h> #include <ek/res.h> /** @@ -163,18 +164,40 @@ out: return res; } -int compile(const char *file) { +int compile(const char *input, const char *output) { int ret = -1; struct scope *root = NULL; - if (process_file(&root, 0, file)) { + if (process_file(&root, 0, input)) { destroy_scope(root); - error("compilation of %s stopped due to errors", file); + error("compilation of %s stopped due to errors", input); return ret; } ret = actualize_main(root); - /** @todo backend */ + if (ret) { + destroy_scope(root); + destroy_ast_nodes(); + error("compilation of %s stopped due to errors", input); + return ret; + } + + struct ops *ops = create_ops(); + ret = lower_ops(root, ops); destroy_scope(root); destroy_ast_nodes(); - return ret; + + if (ret) { + destroy_ops(ops); + error("compilation of %s stopped due to errors", input); + return ret; + } + + ret = analyze_lifetime(ops); + if (ret) { + destroy_ops(ops); + error("compilation of %s stopped due to errors", input); + return ret; + } + + return print_asm(ops, output); } |
