stage1 修复错误 提供类型检查

This commit is contained in:
zzy
2026-07-22 18:04:35 +08:00
parent a2d5dd9ce8
commit da9dae734c
5 changed files with 136 additions and 30 deletions

View File

@@ -90,8 +90,14 @@ static int parse_fn_body(spl_comp_t *ctx, const char *fn_name, int ret_type_idx,
if ((usize)ctx->emit.frame.peak_bytes < min_bytes)
ctx->emit.frame.peak_bytes = (int)min_bytes;
}
emit_patch(&ctx->emit, alloc_addr,
ctx->emit.frame.peak_bytes / (int)sizeof(spl_val_t) - total_phys_slots);
int alloc_slots = ctx->emit.frame.peak_bytes / (int)sizeof(spl_val_t) - total_phys_slots;
if (alloc_slots < 0 || alloc_slots > 65536) {
fprintf(
stderr,
"WARN: parse_fn_body: suspicious alloc_slots=%d (peak_bytes=%d, phys_slots=%d)\n",
alloc_slots, ctx->emit.frame.peak_bytes, total_phys_slots);
}
emit_patch(&ctx->emit, alloc_addr, alloc_slots);
expect(ctx, TOK_R_BRACE);
}