stage1 整理代码 修复错误

This commit is contained in:
zzy
2026-07-21 20:00:19 +08:00
parent 7c5bb41e09
commit a2d5dd9ce8
9 changed files with 79 additions and 85 deletions

View File

@@ -99,7 +99,10 @@ static int parse_fn_body(spl_comp_t *ctx, const char *fn_name, int ret_type_idx,
spl_pop_scope(ctx);
emit_return(&ctx->emit, &ctx->tctx, ctx->current_ret_type_idx);
spl_prog_end_func(&ctx->prog, fi);
{
spl_func_info_t *f = &vec_at(ctx->funcs, fi);
spl_prog_end_func(&ctx->prog, f->func_idx);
}
ctx->current_func_idx = -1;
ctx->current_ret_type_idx = -1;
return fi;
@@ -293,7 +296,8 @@ static void parse_type_body(spl_comp_t *ctx, int container_type_idx, int is_enum
for (;;) {
advance(ctx); /* skip param name or type token */
skip_nl(ctx);
if (peek(ctx)->type == TOK_R_PAREN) break;
if (peek(ctx)->type == TOK_R_PAREN)
break;
if (peek(ctx)->type == TOK_COMMA) {
advance(ctx); /* , */
skip_nl(ctx);
@@ -365,9 +369,9 @@ static void parse_type_body(spl_comp_t *ctx, int container_type_idx, int is_enum
spl_tok_copy_name(vtok, vname, sizeof(vname));
spl_type_add_variant(&ctx->tctx, container_type_idx, vname,
dtype >= 0 ? dtype : -1);
} else if (tt == TOK_EOF) {
break;
} else {
} else if (tt == TOK_EOF) {
break;
} else {
char vname[256];
spl_tok_copy_name(vtok, vname, sizeof(vname));
spl_type_add_variant(&ctx->tctx, container_type_idx, vname, -1);