feat(ast): 更新AST dump功能以使用新的树转储接口
- 将头文件中的tree_dump.h替换为scc_tree_dump.h - 修改函数签名将scc_tree_dump_ctx_t改为scc_tree_dump_t - 移除过时的宏定义和内联函数实现 - 使用新的scc_tree_dump_* API替代旧的PRINT_*宏 - 简化类型、表达式、语句和声明的转储逻辑 - 统一使用新的树转储接口进行节点和值的输出 feat(ast2ir): 实现逻辑运算符和一元运算符的IR转换 - 添加scc_ast2ir_logical_expr函数处理&&和||运算符 - 实现短路求值逻辑,包含分支控制流 - 添加对一元正号运算符的支持 - 实现取地址和间接寻址运算符 - 添加字符字面量解析支持转义序列 fix(ir): 修复字符串常量构建中的长度计算错误 - 修正数组长度计算从len+1改为len-1 - 调整字符串内容复制逻辑跳过引号边界 - 修正内存分配大小与实际数据长度匹配 refactor(ir): 更新IR转储模块使用统一的树转储接口 - 将IR转储上下文中的tree_dump_ctx_t替换为scc_tree_dump_t - 更新初始化函数签名以使用新的转储接口类型
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
#include <string.h>
|
||||
#include <utest/acutest.h>
|
||||
|
||||
static cbool process_input(const char *input, scc_cstring_t *output) {
|
||||
static cbool process_input(const char *input, scc_str_t *output) {
|
||||
int ret = 0;
|
||||
scc_sstream_t mem_stream;
|
||||
ret = scc_sstream_init_by_buffer(&mem_stream, input, strlen(input), false,
|
||||
@@ -17,14 +17,14 @@ static cbool process_input(const char *input, scc_cstring_t *output) {
|
||||
scc_pproc_init(&pp, scc_lexer_to_ring(&lexer, 8, true));
|
||||
|
||||
scc_lexer_tok_ring_t *tok_ring = scc_pproc_to_ring(&pp, 8, true, true);
|
||||
*output = scc_cstring_from_cstr("");
|
||||
*output = scc_str_from_cstr("");
|
||||
scc_lexer_tok_t tok;
|
||||
while (1) {
|
||||
scc_ring_next_consume(*tok_ring, tok, ret);
|
||||
if (!ret) {
|
||||
break;
|
||||
}
|
||||
scc_cstring_append(output, &tok.lexeme);
|
||||
scc_str_append(output, &tok.lexeme);
|
||||
scc_lexer_tok_drop(&tok);
|
||||
}
|
||||
|
||||
@@ -37,24 +37,24 @@ static cbool process_input(const char *input, scc_cstring_t *output) {
|
||||
|
||||
#define CHECK_PP_OUTPUT_EXACT(input, expect) \
|
||||
do { \
|
||||
scc_cstring_t output; \
|
||||
scc_str_t output; \
|
||||
process_input(input, &output); \
|
||||
assert(output.data != NULL); \
|
||||
TEST_CHECK(strcmp(output.data, expect) == 0); \
|
||||
TEST_MSG("Expected: %s", expect); \
|
||||
TEST_MSG("Produced: %s", output.data); \
|
||||
scc_cstring_free(&output); \
|
||||
scc_str_drop(&output); \
|
||||
} while (0)
|
||||
|
||||
#define CHECK_PP_OUTPUT_CONTAIN(input, expect) \
|
||||
do { \
|
||||
scc_cstring_t output; \
|
||||
scc_str_t output; \
|
||||
process_input(input, &output); \
|
||||
assert(output.data != NULL); \
|
||||
TEST_CHECK(strstr(output.data, expect) != NULL); \
|
||||
TEST_MSG("Expected: %s", expect); \
|
||||
TEST_MSG("Produced: %s", output.data); \
|
||||
scc_cstring_free(&output); \
|
||||
scc_str_drop(&output); \
|
||||
} while (0)
|
||||
|
||||
static void test_define_simple_no_macro(void) {
|
||||
|
||||
Reference in New Issue
Block a user