diff options
Diffstat (limited to 'compiler.d')
| -rw-r--r-- | compiler.d | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -596,6 +596,21 @@ class Compiler { this.func.chunk.writeOp(OpCode.OP_CONCAT, args[0].line); } + void compileIn(Form[] args) { + // TODO how do we identify/propagate errors? + if (args.length != 2) { + this.error(format("'in?': expected [2] arguments, received %d", args.length), -1); + this.advance(); + //writeln("COMPILE ERROR: 'first' expects exactly one argument"); + return; + } + ValueType vt1 = this.resolve(args[0], ValueType.ANY); + ValueType vt2 = this.resolve(args[1], ValueType.SEQ); + this.func.chunk.writeOp(OpCode.OP_TYPE_CHECK_SEQ, args[0].line); + + this.func.chunk.writeOp(OpCode.OP_MEMBER, args[0].line); + } + void compileFirst(Form[] args) { // TODO how do we identify/propagate errors? if (args.length != 1) { @@ -772,6 +787,9 @@ class Compiler { case "first": this.compileFirst(cons.tail); break; + case "in?": + this.compileIn(cons.tail); + break; case "length": this.compileLength(cons.tail); break; |
