From a043f552ddca8d890b14bcddf555472ef69e9014 Mon Sep 17 00:00:00 2001 From: mryouse Date: Fri, 26 May 2023 21:04:49 +0000 Subject: bytecode compilation of map() --- vm.d | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'vm.d') diff --git a/vm.d b/vm.d index 75f6328..ba7fc50 100644 --- a/vm.d +++ b/vm.d @@ -311,7 +311,7 @@ class VM { // pop the next n-1 values Value[] inner; - for (int i = 0; i < n - 1; i++) { + for (int i = 0; i < (n - 1); i++) { inner ~= this.popA(); } @@ -319,7 +319,7 @@ class VM { this.pushA(top); // push the other values (preserve order) - for (int i = n - 1; i >= 0; i--) { + for (int i = (n - 2); i >= 0; i--) { this.pushA(inner[i]); } break; @@ -568,13 +568,16 @@ class VM { this.popA(); // throw this one away this.pushA(val); break; - + case OpCode.OP_JUMP_TO: + uint addr = this.readShort(); + //this.current.ip -= offset; + this.current.ip = to!ubyte(addr); + break; case OpCode.OP_JUMP: uint offset = this.readShort(); //ip += offset; this.current.ip += offset; break; - case OpCode.OP_JUMP_IF_FALSE: uint offset = this.readShort(); if (!isBoolean(this.peekA(0))) { -- cgit v1.2.3