aboutsummaryrefslogtreecommitdiff
path: root/compiler.d
diff options
context:
space:
mode:
Diffstat (limited to 'compiler.d')
-rw-r--r--compiler.d18
1 files changed, 17 insertions, 1 deletions
diff --git a/compiler.d b/compiler.d
index ecd7785..992e36b 100644
--- a/compiler.d
+++ b/compiler.d
@@ -483,7 +483,7 @@ class Compiler {
ValueType vt = this.resolve(args[0], ValueType.STRING);
for (int i = 1; i < args.length; i++) {
vt = this.resolve(args[i], ValueType.STRING);
- this.func.chunk.writeOp(OpCode.OP_TYPE_CHECK_STRING, args[i].line);
+ this.func.chunk.writeOp(OpCode.OP_TYPE_CHECK_SEQ, args[i].line); // TODO wrong
this.func.chunk.writeOp(OpCode.OP_CONCAT, args[i].line);
}
return ValueType.STRING;
@@ -544,6 +544,22 @@ class Compiler {
this.func.chunk.writeOp(OpCode.OP_LENGTH, args[0].line);
}
+ void compileAppend(Form[] args) {
+ if (args.length != 2) {
+ this.error(format("'append': expected [2] arguments, received %d", args.length), -1);
+ this.advance();
+ return;
+ }
+
+ ValueType vt1 = this.resolve(args[0], ValueType.SEQ);
+ this.func.chunk.writeOp(OpCode.OP_TYPE_CHECK_SEQ, args[0].line);
+
+ // TODO if this is used for both string/list, should be able to typecheck second arg here
+ ValueType vt2 = this.resolve(args[1], ValueType.ANY);
+
+ this.func.chunk.writeOp(OpCode.OP_CONCAT, args[0].line);
+ }
+
void compileFirst(Form[] args) {
// TODO how do we identify/propagate errors?
if (args.length != 1) {