feat(ast): 重构AST节点类型定义并实现数组下标访问
- 将scc_ast_node_type_t重命名为scc_ast_node_kind_t以提高语义清晰度 - 为scc_ast_node结构体添加名称定义 - 更新所有相关头文件中的类型引用 - 实现数组下标表达式的IR转换逻辑 - 添加对sizeof和alignof表达式的基本支持 fix(ast2ir): 修复表达式求值和类型处理问题 - 修复数组类型退化为指针的逻辑 - 修复变量声明初始化值检查条件 - 添加结构体和枚举类型的IR生成支持 - 移除未使用的代码段 refactor(ir): 完善IR上下文错误处理 - 为未处理的类型标签添加恐慌处理 - 修复联合类型的哈希计算 chore(build): 更新依赖项配置 - 修正lexer模块中的依赖项名称 style(parser): 清理解析器代码 - 移除未使用的类型哈希表 - 更新语义分析回调函数签名 - 添加属性语法的占位符实现 - 完善内存清理逻辑 test: 添加数组下标和枚举测试用例 - 新增15_array_subscript.c测试数组下标访问 - 新增16_enum.c测试枚举类型功能 - 更新期望结果配置文件
This commit is contained in:
@@ -79,10 +79,10 @@ typedef enum {
|
||||
scc_ast_translation_unit_t_BEGIN,
|
||||
SCC_AST_TRANSLATION_UNIT, // 翻译单元(根节点)
|
||||
scc_ast_translation_unit_t_END,
|
||||
} scc_ast_node_type_t;
|
||||
} scc_ast_node_kind_t;
|
||||
|
||||
typedef struct {
|
||||
scc_ast_node_type_t type;
|
||||
typedef struct scc_ast_node {
|
||||
scc_ast_node_kind_t type;
|
||||
scc_pos_t loc;
|
||||
} scc_ast_node_t;
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ static inline void scc_ast_decl_param_init(scc_ast_decl_t *decl,
|
||||
}
|
||||
|
||||
static inline void _scc_ast_decl_record_init(scc_ast_decl_t *decl,
|
||||
scc_ast_node_type_t type,
|
||||
scc_ast_node_kind_t type,
|
||||
const char *name,
|
||||
scc_ast_decl_vec_t *fields_move,
|
||||
scc_pos_t loc) {
|
||||
@@ -352,7 +352,7 @@ static inline void scc_ast_expr_array_subscript_init(scc_ast_expr_t *expr,
|
||||
}
|
||||
|
||||
static inline void _scc_ast_expr_member_init(scc_ast_expr_t *expr,
|
||||
scc_ast_node_type_t type,
|
||||
scc_ast_node_kind_t type,
|
||||
scc_ast_expr_t *object,
|
||||
const char *member,
|
||||
scc_pos_t loc) {
|
||||
@@ -441,7 +441,7 @@ static inline void scc_ast_expr_compound_init(scc_ast_expr_t *expr,
|
||||
}
|
||||
|
||||
static inline void scc_ast_expr_literal_init(scc_ast_expr_t *expr,
|
||||
scc_ast_node_type_t type,
|
||||
scc_ast_node_kind_t type,
|
||||
const char *value, cbool owned,
|
||||
scc_pos_t loc) {
|
||||
Assert(expr != nullptr && value != nullptr);
|
||||
@@ -550,7 +550,7 @@ static inline void scc_ast_type_function_init(scc_ast_type_t *type,
|
||||
}
|
||||
|
||||
static inline void _scc_ast_type_record_init(scc_ast_type_t *type,
|
||||
scc_ast_node_type_t type_kind,
|
||||
scc_ast_node_kind_t type_kind,
|
||||
const char *name,
|
||||
scc_ast_decl_t *decl,
|
||||
scc_pos_t loc) {
|
||||
|
||||
@@ -68,7 +68,7 @@ static const char *node_type_names[] = {
|
||||
[scc_ast_translation_unit_t_END] = "ERROR",
|
||||
};
|
||||
|
||||
static const char *get_node_type_str(scc_ast_node_type_t type) {
|
||||
static const char *get_node_type_str(scc_ast_node_kind_t type) {
|
||||
return node_type_names[type];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user