From af07e3fba55ef98aabd54057c6e3433734b81111 Mon Sep 17 00:00:00 2001 From: mryouse Date: Thu, 1 Jun 2023 20:17:37 -0400 Subject: split concat/append into 2 ops --- vm.d | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'vm.d') diff --git a/vm.d b/vm.d index fbf874c..c5de28c 100644 --- a/vm.d +++ b/vm.d @@ -192,6 +192,14 @@ class VM { return value.as.seq; } + List asList(Value value) { + return cast(List)value.as.seq; + } + + String asNebString(Value value) { + return cast(String)value.as.seq; + } + double asNumber(Value value) { return value.as.number; } @@ -491,10 +499,15 @@ class VM { this.pushA(makeBooleanValue(areValuesEqual(a, b))); break; case OpCode.OP_CONCAT: - Seq b = asSeq(this.popA()); - Seq a = asSeq(this.popA()); + String b = asNebString(this.popA()); + String a = asNebString(this.popA()); this.pushA(makeSeqValue(a.concat(b))); break; + case OpCode.OP_APPEND: + Value b = this.popA(); + List a = asList(this.popA()); + this.pushA(makeSeqValue(a.append(b))); + break; case OpCode.OP_GREATER: Value b = this.popA(); Value a = this.popA(); -- cgit v1.2.3