Halt to halt the VM
Some checks failed
Build / build (push) Failing after 6m4s
Publish Image / publish (push) Failing after 25s
Test / build (push) Failing after 5m49s

This commit is contained in:
Chuck Smith
2024-03-30 14:17:20 -04:00
parent 3b6df3e813
commit c8de195ac8
4 changed files with 74 additions and 19 deletions

View File

@@ -686,7 +686,7 @@ func (vm *VM) LastPoppedStackElem() object.Object {
return vm.stack[vm.sp]
}
func (vm *VM) Run() error {
func (vm *VM) Run() (err error) {
var n int
var ip int
var ins code.Instructions
@@ -699,9 +699,7 @@ func (vm *VM) Run() error {
}()
}
var err error
for vm.frame.ip < len(vm.frame.Instructions())-1 && err == nil {
for err == nil {
vm.frame.ip++
ip = vm.frame.ip
@@ -894,6 +892,9 @@ func (vm *VM) Run() error {
case code.OpMinus:
err = vm.executeMinus()
case code.OpHalt:
return
default:
err = fmt.Errorf("unhandled opcode: %s", op)
}