Files
pork/vm/src/main/kotlin/gay/pizza/pork/vm/ops/JumpIfOpHandler.kt

16 lines
396 B
Kotlin
Raw Normal View History

2023-11-14 23:44:10 -08:00
package gay.pizza.pork.vm.ops
import gay.pizza.pork.bytecode.Op
import gay.pizza.pork.bytecode.Opcode
import gay.pizza.pork.vm.InternalMachine
import gay.pizza.pork.vm.OpHandler
object JumpIfOpHandler : OpHandler(Opcode.JumpIf) {
override fun handle(machine: InternalMachine, op: Op) {
val value = machine.pop<Boolean>()
2023-11-14 23:44:10 -08:00
if (value) {
machine.setNextInst(op.args[0])
}
}
}