stage1 修改部分测试 完成17-19测试

This commit is contained in:
zzy
2026-07-07 12:11:49 +08:00
parent 1df3e3bcb4
commit 463177d3be
7 changed files with 262 additions and 71 deletions

View File

@@ -76,10 +76,10 @@ static int spl_type_size(spl_type_t t) {
do { \
if (vm->sp >= vm->config.max_stack_depth) \
VM_ERROR("stack overflow"); \
vm->stacks.data[vm->sp++] = (spl_val_t)(v); \
vm->stacks.data[(vm->sp)++] = (spl_val_t)(v); \
} while (0)
#define POP() vm->stacks.data[--vm->sp]
#define POP() vm->stacks.data[--(vm->sp)]
/* ================================================================
* Type-dispatch macros for arithmetic / comparison
@@ -641,7 +641,7 @@ int spl_vm_run_once(spl_vm_t *vm) {
return -1;
prog = vm->prog;
if (vm->ip < 0 || vm->ip >= vec_size(prog->insns)) {
if (vm->ip >= vec_size(prog->insns)) {
fprintf(stderr, "vm: ip=%zd out of bounds\n", vm->ip);
vm->exit_code = 1;
return -1;
@@ -687,7 +687,7 @@ int spl_vm_run_once(spl_vm_t *vm) {
case SPL_PICK: {
isize _idx = ins->imm;
if (_idx >= vm->sp)
if ((usize)_idx >= vm->sp)
VM_ERROR("PICK: index out of range");
PUSH(vm->stacks.data[vm->sp - 1 - _idx]);
break;