From a26bfccdc52ab50a83b8f8d170c9e1a3be0164a5 Mon Sep 17 00:00:00 2001 From: Ben Winston Date: Sun, 21 May 2023 19:55:04 -0400 Subject: 'or' control statement --- vm.d | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'vm.d') diff --git a/vm.d b/vm.d index 45f3742..cc2b9ae 100644 --- a/vm.d +++ b/vm.d @@ -261,13 +261,23 @@ class VM { case OpCode.OP_JUMP_IF_FALSE: uint offset = readShort(); if (!isBoolean(peekA(0))) { - writeln("if expects a boolean condition"); + writeln("expecting a boolean condition"); return InterpretResult.RUNTIME_ERROR; // TODO error } if (!asBoolean(peekA(0))) { ip += offset; } break; + case OpCode.OP_JUMP_IF_TRUE: + uint offset = readShort(); + if (!isBoolean(peekA(0))) { + writeln("expecting a boolean condition"); + return InterpretResult.RUNTIME_ERROR; // TODO error + } + if (asBoolean(peekA(0))) { + ip += offset; + } + break; default: writeln("unknown opcode to run"); break; -- cgit v1.2.3