Skip to content

Commit ddef48b

Browse files
committed
feat: add Virtual Machine (VM) implementation for bytecode interpretation and execution.
1 parent 7ca2375 commit ddef48b

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

src/runtime/vm.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,14 +1194,16 @@ static InterpretResult run(VM* vm) {
11941194
break;
11951195
}
11961196
case OP_RETURN: {
1197-
vm->frameCount--;
1198-
if (vm->frameCount == 0) {
1199-
pop(vm);
1200-
return INTERPRET_OK;
1201-
}
1202-
vm->stackTop = frame->slots;
1203-
frame = &vm->frames[vm->frameCount - 1];
1204-
break;
1197+
Value result = pop(vm);
1198+
vm->frameCount--;
1199+
if (vm->frameCount == 0) {
1200+
pop(vm);
1201+
return INTERPRET_OK;
1202+
}
1203+
vm->stackTop = frame->slots;
1204+
push(vm, result);
1205+
frame = &vm->frames[vm->frameCount - 1];
1206+
break;
12051207
}
12061208
default: return INTERPRET_COMPILE_ERROR;
12071209
}

0 commit comments

Comments
 (0)