diff options
| author | mryouse | 2023-05-26 03:15:51 +0000 |
|---|---|---|
| committer | mryouse | 2023-05-26 03:15:51 +0000 |
| commit | 2ffc9959f3324a234d8337f05643c8e531154081 (patch) | |
| tree | 70d8b066adc8e72c5c64e4eb71da68ced0ccd00d /compiler.d | |
| parent | aab6510a0e59c26a31526ff303a9d581736815fc (diff) | |
in? (lists and strings)
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; |
