feat(ast): 修改函数调用表达式的结构定义

在AST定义中将函数调用表达式的name字段替换为callee字段,
以支持更复杂的函数调用场景。同时更新了相关的初始化函数、
转储函数和解析逻辑,使函数调用表达式能够正确处理callee节点。

BREAKING CHANGE: 函数调用表达式的结构发生了改变,从使用name字符串
改为使用callee表达式节点。
This commit is contained in:
zzy
2026-03-10 14:33:32 +08:00
parent 2e331ee016
commit 742bede02f
7 changed files with 102 additions and 23 deletions

View File

@@ -269,6 +269,7 @@ struct scc_ast_expr {
// 函数调用
struct {
const char *name;
scc_ast_expr_t *callee;
scc_ast_expr_t *_target;
scc_ast_expr_vec_t args;
} call;

View File

@@ -293,12 +293,12 @@ static inline void scc_ast_expr_cond_init(scc_ast_expr_t *expr,
// args can be null
static inline void scc_ast_expr_call_init(scc_ast_expr_t *expr,
const char *name,
scc_ast_expr_t *callee,
scc_ast_expr_vec_t *args) {
Assert(expr != null && name != null);
Assert(expr != null && callee != null);
expr->base.loc = scc_pos_create();
expr->base.type = SCC_AST_EXPR_CALL;
expr->call.name = name;
expr->call.callee = callee;
expr->call._target = null;
if (args == null) {
scc_vec_init(expr->call.args);

View File

@@ -440,8 +440,7 @@ static void dump_expr_impl(scc_ast_expr_t *expr, scc_tree_dump_ctx_t *ctx) {
break;
case SCC_AST_EXPR_CALL:
// dump_child_node((scc_ast_node_t *)expr->call._target, ctx, false);
PRINT_NODE(ctx, "%s", expr->call.name);
dump_child_node((scc_ast_node_t *)expr->call.callee, ctx, false);
// 转储参数
for (size_t i = 0; i < expr->call.args.size; i++) {
dump_child_node((scc_ast_node_t *)expr->call.args.data[i], ctx,