refactor(ast): 将AST类型系统重构为规范类型系统

- 将scc_ast_type_t替换为scc_ast_qual_type_t,引入规范类型概念
- 添加scc_ast_canonical_type_t联合体用于表示规范类型
- 修改头文件结构,移除大量内联初始化函数,改为使用AST上下文分配器
- 添加SCC_AST_ALLOC宏用于统一节点分配管理
- 更新builtin类型枚举定义,添加类型计数常量

feat(ast): 引入AST上下文管理器

- 创建scc_ast_ctx_t结构体用于管理AST节点生命周期
- 实现类型池化机制,支持内置类型的统一管理
- 添加canonical类型获取和分配接口

refactor(abi): 适配新的AST类型系统

- 更新头文件包含,从<scc_ir.h>改为<scc_hir.h>
- 适配函数参数类型,使用qual_type替代原始type
- 使用scc_ast_canon_type()函数获取规范类型进行处理

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
zzy
2026-04-27 20:40:03 +08:00
parent d7ac5fd30b
commit f6bc40ae4a
20 changed files with 1302 additions and 1045 deletions

View File

@@ -184,9 +184,11 @@ int main(int argc, const char **argv, const char **envp) {
scc_lexer_tok_ring_t *tok_ring =
scc_pproc_to_ring(&pproc, 1024, false, false);
scc_parser_t parser;
scc_sema_callbacks_t sema_callbacks;
scc_sema_init(&sema_callbacks);
scc_parser_init(&parser, tok_ring, &sema_callbacks);
scc_ast_ctx_t ast_ctx;
scc_ast_ctx_init(&ast_ctx);
scc_sema_ctx_t sema_callbacks;
scc_sema_init(&sema_callbacks, &ast_ctx);
scc_parser_init(&parser, tok_ring, &ast_ctx, &sema_callbacks);
scc_ast_translation_unit_t *translation_unit =
scc_parse_translation_unit(&parser);
@@ -221,7 +223,7 @@ sstream_drop:
scc_hir_cprog_t cprog;
scc_hir_cprog_init(&cprog);
scc_ast2ir_ctx_init(&ast2ir_ctx, &scc_ast_abi_impl, &cprog);
scc_ast2ir_translation_unit(&ast2ir_ctx, translation_unit);
scc_ast2ir_run(&ast2ir_ctx, translation_unit);
scc_ast2ir_ctx_drop(&ast2ir_ctx);
if (config.emit_hir) {