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:
@@ -5,6 +5,7 @@
|
||||
#include "ast.h"
|
||||
#include "arena.h"
|
||||
#include "l_lang.h"
|
||||
#include "visit.h"
|
||||
#include <llvm-c/Analysis.h>
|
||||
#include <llvm-c/Types.h>
|
||||
#include <string.h>
|
||||
@@ -77,6 +78,7 @@ void cleanup_add(CgCtx* ctx, LLVMValueRef alloca);
|
||||
void cleanup_emit(CgCtx* ctx, size_t from_mark);
|
||||
|
||||
// === 代码生成函数 ===
|
||||
void codegen_expr_init(void);
|
||||
LLVMValueRef codegen_expr(CgCtx* ctx, AstNode* node);
|
||||
void codegen_stmt(CgCtx* ctx, AstNode* node);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user