feat(ast2ir): 添加数组初始化支持和AST转IR优化

添加了对未知长度数组的自动长度推导功能,支持字符串字面量和复合
初始化的数组长度计算。新增辅助函数resolve_array_length用于计算
数组实际长度,以及emit_array_initialization用于生成数组初始化
代码。

同时将AST转IR过程中的参数改为const引用,提高代码安全性。
新增IR构建器的借用检查机制,防止在借用期间进行重分配操作。

fix(ast): 为AST结构体添加详细注释说明字段用途
This commit is contained in:
zzy
2026-04-13 11:36:52 +08:00
parent 694778e4a0
commit ffb23afaf4
13 changed files with 480 additions and 220 deletions

View File

@@ -36,7 +36,7 @@ def run_test(test_file, expected):
exe_path = WORKSPACE / exe_filename
# 1. 编译
compile_cmd = [str(CC_PATH), str(test_file), "-o", exe_filename]
compile_cmd = [str(CC_PATH), str(test_file), "-o", exe_filename, "--entry-point-symbol", "main"]
# 编译时关注 stderr 和返回码
_, compile_err, compile_ret = run_command(compile_cmd)