refactor: codegen_expr switch→Visitor dispatch (12 handler)

cg_expr.c 440行: 12 表达式handler提取为独立函数 + AstDispatch 表
codegen_expr 从巨型 switch 改为 ast_visit() 查表调用
新增表达式节点: codegen_expr_init() 加一行即可
修复: to_llvm_type/type_info_to_llvm TYPE_ENUM/STR 完整映射

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-06-07 12:59:18 +08:00
parent bcf6508c4c
commit 82b0570869
3 changed files with 361 additions and 372 deletions
+1
View File
@@ -288,6 +288,7 @@ LLVMModuleRef codegen_module(AstNode* ast, Arena* codegen_arena,
}
ctx.module = LLVMModuleCreateWithNameInContext(name, ctx.context);
ctx.builder = LLVMCreateBuilderInContext(ctx.context);
codegen_expr_init();
// 声明 C 标准库 printf(内置 print 函数依赖它)
LLVMTypeRef printf_param_types[] = {