diff options
Diffstat (limited to 'compiler.d')
| -rw-r--r-- | compiler.d | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -662,6 +662,18 @@ class Compiler { this.func.chunk.writeOp(OpCode.OP_REST, args[0].line); } + void compileReverse(Form[] args) { + // TODO how do we identify/propagate errors? + if (args.length != 1) { + this.error("'reverse': expected [1] argument, received ?", -1); + return; + } + ValueType vt = this.resolve(args[0], ValueType.OBJ); // TODO need a new type + this.func.chunk.writeOp(OpCode.OP_TYPE_CHECK_SEQ, args[0].line); + + this.func.chunk.writeOp(OpCode.OP_REVERSE, args[0].line); + } + // TERMINAL void compilePrint(Form[] args) { if (args.length != 1) { @@ -843,6 +855,9 @@ class Compiler { case "rest": this.compileRest(cons.tail); break; + case "reverse": + this.compileReverse(cons.tail); + break; // OTHER case "print": |
