diff options
| author | mryouse | 2023-06-06 20:27:18 -0400 |
|---|---|---|
| committer | mryouse | 2023-06-06 20:27:18 -0400 |
| commit | 59d076f6dc179315b6dfc1c141dc9ee48cc66a54 (patch) | |
| tree | ec667f8146e12299404ab11d52fed2e8d79c62b3 /compiler.d | |
| parent | 87ee44163d0f7ec86963cefea51e721ce4eb156c (diff) | |
initial commit of reverse
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": |
