feat(ast2ir): 添加数组初始化支持和AST转IR优化
添加了对未知长度数组的自动长度推导功能,支持字符串字面量和复合 初始化的数组长度计算。新增辅助函数resolve_array_length用于计算 数组实际长度,以及emit_array_initialization用于生成数组初始化 代码。 同时将AST转IR过程中的参数改为const引用,提高代码安全性。 新增IR构建器的借用检查机制,防止在借用期间进行重分配操作。 fix(ast): 为AST结构体添加详细注释说明字段用途
This commit is contained in:
@@ -188,6 +188,7 @@ struct scc_ast_type {
|
||||
} record;
|
||||
struct {
|
||||
const char *name;
|
||||
/// @brief 指向typedef的声明(可以间接找到typedef的指向的类型)
|
||||
scc_ast_decl_t *decl;
|
||||
} typedef_type;
|
||||
};
|
||||
@@ -312,7 +313,9 @@ struct scc_ast_expr {
|
||||
// 复合字面量
|
||||
struct {
|
||||
scc_ast_expr_t *base;
|
||||
/// @brief 赋值语句的左值
|
||||
scc_ast_expr_vec_t lhs_exprs;
|
||||
/// @brief 赋值语句的右值
|
||||
scc_ast_expr_vec_t rhs_exprs;
|
||||
} compound;
|
||||
// 字面量
|
||||
@@ -429,10 +432,11 @@ struct scc_ast_decl {
|
||||
} param;
|
||||
// 结构体/联合/枚举声明
|
||||
struct {
|
||||
/// @brief 结构体/联合/枚举的字段
|
||||
scc_ast_decl_vec_t fields;
|
||||
} record;
|
||||
// typedef 声明
|
||||
struct {
|
||||
/// @brief 被 typedef 的类型
|
||||
scc_ast_type_t *type;
|
||||
} typedef_decl;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user