diff options
-rw-r--r-- | rules.js | 17 |
1 files changed, 16 insertions, 1 deletions
@@ -2068,7 +2068,22 @@ function vm_if() { } function vm_else() { - vm_goto(vm_endif, vm_if, 1, 1) + vm_jump(vm_endif, vm_if, 1, 1) +} + +function vm_jump(op, nop, dir, step) { + let balance = 1 + while (balance > 0) { + game.vm.ip += dir + if (vm_inst(0) === op) + --balance + if (vm_inst(0) === nop) + ++balance + if (game.vm.ip < 0 || game.vm.ip > CODE[game.vm.fp].length) + throw "ERROR" + } + game.vm.ip += step + vm_exec() } function vm_endif() { |