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:
@@ -658,10 +658,14 @@ void scc_pproc_expand_macro(scc_pproc_expand_t *expand_ctx) {
|
||||
expand_ctx->need_rescan = true;
|
||||
|
||||
expand_ctx->call_pos = tok.loc;
|
||||
if (macro->type == SCC_PP_MACRO_OBJECT) {
|
||||
|
||||
switch (macro->type) {
|
||||
case SCC_PP_MACRO_OBJECT: {
|
||||
scc_lexer_tok_drop(&tok);
|
||||
expand_object_macro(expand_ctx, macro);
|
||||
} else if (macro->type == SCC_PP_MACRO_FUNCTION) {
|
||||
break;
|
||||
}
|
||||
case SCC_PP_MACRO_FUNCTION: {
|
||||
scc_lexer_tok_t expect_tok;
|
||||
scc_ring_peek(*expand_ctx->input, expect_tok, ok);
|
||||
if (ok == false || expect_tok.type != SCC_TOK_L_PAREN) {
|
||||
@@ -671,8 +675,30 @@ void scc_pproc_expand_macro(scc_pproc_expand_t *expand_ctx) {
|
||||
|
||||
scc_lexer_tok_drop(&tok);
|
||||
expand_function_macro(expand_ctx, macro);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
// FIXME 这可能不符合c语义
|
||||
case SCC_PP_MACRO_BUILTIN__FILE__:
|
||||
scc_cstring_free(&tok.lexeme);
|
||||
scc_cstring_append_ch(&tok.lexeme, '"');
|
||||
scc_cstring_append_cstr(&tok.lexeme, tok.loc.name,
|
||||
scc_strlen(tok.loc.name));
|
||||
scc_cstring_append_ch(&tok.lexeme, '"');
|
||||
tok.type = SCC_TOK_STRING_LITERAL;
|
||||
scc_vec_push(expand_ctx->output, tok);
|
||||
break;
|
||||
case SCC_PP_MACRO_BUILTIN__LINE__:
|
||||
scc_cstring_free(&tok.lexeme);
|
||||
char *buff = scc_malloc(32);
|
||||
scc_snprintf(buff, 32, "%zu", tok.loc.line);
|
||||
tok.lexeme = scc_cstring_from_cstr(buff);
|
||||
scc_free(buff);
|
||||
tok.type = SCC_TOK_INT_LITERAL;
|
||||
scc_vec_push(expand_ctx->output, tok);
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user