From 46a9b83a118207f414f2f7e4c0391785dc440fa4 Mon Sep 17 00:00:00 2001 From: mryouse Date: Fri, 26 May 2023 02:24:35 +0000 Subject: make 'concat' work for sequences --- vm.d | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'vm.d') diff --git a/vm.d b/vm.d index 40877b8..c14c746 100644 --- a/vm.d +++ b/vm.d @@ -153,7 +153,8 @@ class VM { bool isString(Value value) { return value.type == ValueType.STRING || - value.type == ValueType.TYPE; + value.type == ValueType.TYPE || + value.type == ValueType.SEQ; // WRONG } bool isType(Value value) { @@ -195,6 +196,9 @@ class VM { string asString(Value value) { if (value.type == ValueType.TYPE) { return value.as.type; + } else if (value.type == ValueType.SEQ) { + String str = cast(String)value.as.seq; + return str.str; } else { return value.as.str; } @@ -443,11 +447,9 @@ class VM { this.pushA(makeBooleanValue(!bval)); break; case OpCode.OP_CONCAT: - Value b = this.popA(); - Value a = this.popA(); - string bstr = asString(b); - string astr = asString(a); - this.pushA(makeStringValue(astr ~ bstr)); + Seq b = asSeq(this.popA()); + Seq a = asSeq(this.popA()); + this.pushA(makeSeqValue(a.concat(b))); break; case OpCode.OP_GREATER: Value b = this.popA(); -- cgit v1.2.3