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

@@ -80,6 +80,7 @@ int main(int argc, const char **argv, const char **envp) {
.input_file = nullptr,
.verbose = 0,
.output_file = nullptr,
.entry_point_symbol = nullptr,
.emit_ast = false,
.emit_ir = false,
.target_description = "x86_64-pc-windows-msvc",
@@ -243,6 +244,8 @@ sstream_drop:
scc_ir2mcode(&ir2mcode_ctx);
scc_ir2mcode_drop(&ir2mcode_ctx);
sccf_builder_set_entry_symbol_name(&sccf_builder,
config.entry_point_symbol);
const sccf_t *sccf = sccf_builder_to_sccf(&sccf_builder);
scc_pe_builder_t pe_builder;
sccf2pe(&pe_builder, sccf);