stage1 重构语义分析 ast2ir ir部分

This commit is contained in:
zzy
2026-08-18 11:22:15 +08:00
parent 4d9509c167
commit 994a35a942
7 changed files with 970 additions and 3659 deletions

View File

@@ -11,7 +11,7 @@
#include <string.h>
#include "spl_ast.h"
// #include "spl_ast2ir.h"
#include "spl_ast2ir.h"
// #include "spl_ir2vm.h"
#include "spl_lexer.h"
#include "spl_sema.h"
@@ -107,16 +107,25 @@ static int compile_spl(const char *src, const char *fname, const char *outpath,
// memory leak
return 0;
}
// spl_ast2ir_t a2ir;
// spl_ast2ir_init(&a2ir, &sema);
// spl_ast2ir_run(&a2ir);
// if (a2ir.err_count) {
// printf("ast2ir errors=%d, no output\n", a2ir.err_count);
// spl_ast2ir_drop(&a2ir);
// spl_sema_drop(&sema);
// spl_ast_drop(&ast);
// return 1;
// }
spl_ast2ir_t a2ir;
spl_ir_builder_t ir_builder;
spl_ir_builder_init(&ir_builder);
spl_ast2ir_init(&a2ir, &ir_builder, &sema);
spl_ast2ir_run(&a2ir);
if (a2ir.err_count) {
printf("ast2ir errors=%d, no output\n", a2ir.err_count);
spl_ast2ir_drop(&a2ir);
spl_sema_drop(&sema);
spl_ast_drop(&ast);
return 1;
}
if (dump == DUMP_IR) {
spl_ir_dump(&ir_builder.ir, &type);
// memory leak
return 0;
}
// spl_ir2vm_t ir2vm;
// spl_ir2vm_init(&ir2vm, &a2ir.ir, &sema.type);
// int rc = spl_ir2vm_run(&ir2vm, outpath);