refactor(ast): 统一记录类型结构并移除成员访问操作符

- 移除了枚举类型的独立结构定义,统一使用record结构
- 移除了成员访问操作符SCC_AST_OP_MEMBER_ACCESS和SCC_AST_OP_PTR_MEMBER_ACCESS
- 更新了for循环语句中init字段的类型从scc_ast_type_t*到scc_ast_node_t*
- 修改了声明初始化函数以支持统一的记录类型处理

fix(ast2ir): 完善二元表达式处理和for循环代码生成

- 重构了赋值操作符的处理逻辑,通过临时表达式实现复合赋值
- 添加了对for循环语句的完整IR代码生成功能
- 修复了if-else语句中错误的基本块跳转问题
- 改进了标识符未找到时的错误提示信息

chore: 清理代码和修复潜在问题

- 移除了未使用的自动标签生成功能
- 统一了IR基本块标签格式化输出
- 修复了机器码生成中的寄存器存储控制流问题
- 改进了词法分析器中十六进制数字的处理逻辑
This commit is contained in:
zzy
2026-03-21 10:33:17 +08:00
parent a64e1f8330
commit 35a704a1cb
25 changed files with 1335 additions and 2095 deletions

View File

@@ -17,10 +17,13 @@ static void free_token(scc_lexer_tok_t *tok) { scc_cstring_free(&tok->lexeme); }
scc_lexer_init(&lexer, ref); \
scc_lexer_get_token(&lexer, &token); \
\
TEST_CHECK(token.type == expected_type); \
TEST_CHECK(token.type == expected_type && \
scc_strcmp(input, scc_cstring_as_cstr(&token.lexeme)) == \
0); \
TEST_MSG("Input: '%s'", input); \
TEST_MSG("Expected: %s", scc_get_tok_name(expected_type)); \
TEST_MSG("Got: %s", scc_get_tok_name(token.type)); \
TEST_MSG("Expected: %s `%s`", scc_get_tok_name(expected_type), input); \
TEST_MSG("Got: %s `%s`", scc_get_tok_name(token.type), \
scc_cstring_as_cstr(&token.lexeme)); \
\
free_token(&token); \
scc_sstream_drop_ring(ref); \
@@ -167,7 +170,7 @@ void test_literals() {
TEST_TOKEN("0x1A3F", SCC_TOK_INT_LITERAL);
TEST_TOKEN("0XABCDEF", SCC_TOK_INT_LITERAL);
TEST_TOKEN("0x123abc", SCC_TOK_INT_LITERAL);
TEST_TOKEN("0XFF", SCC_TOK_INT_LITERAL);
TEST_TOKEN("0xFF", SCC_TOK_INT_LITERAL);
TEST_CASE("Integer literals - octal");
TEST_TOKEN("0123", SCC_TOK_INT_LITERAL);