diff options
| author | mryouse | 2023-05-26 02:24:35 +0000 |
|---|---|---|
| committer | mryouse | 2023-05-26 02:24:35 +0000 |
| commit | 46a9b83a118207f414f2f7e4c0391785dc440fa4 (patch) | |
| tree | 1ac15aa353063302fe6b9f4759cc4a0c7fc199b7 /vm.d | |
| parent | 6b7b9d96fb26ba9d4616d2b839098b7c75f39c3f (diff) | |
make 'concat' work for sequences
Diffstat (limited to 'vm.d')
| -rw-r--r-- | vm.d | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -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(); |
