diff options
Diffstat (limited to 'compiler.d')
| -rw-r--r-- | compiler.d | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -304,6 +304,20 @@ class Compiler { return ValueType.BOOLEAN; } + ValueType compileEq(Form[] args) { + if (args.length != 2) { + this.error(format("'eq?': expected [1] argument, received %d", to!int(args.length)), -1); + this.advance(); + return ValueType.NIL; + } + ValueType vt1 = this.resolve(args[0], ValueType.ANY); + ValueType vt2 = this.resolve(args[1], ValueType.ANY); + + this.func.chunk.writeOp(OpCode.OP_EQUAL, args[1].line); + + return ValueType.BOOLEAN; + } + //int parseVariable(Def def) { int parseVariable(Symbol sym) { @@ -726,6 +740,8 @@ class Compiler { return this.compileSubtract(cons.tail, ValueType.NUMBER); } break; + + // BOOLEAN case "<": return this.compileLess(cons.tail, ValueType.NUMBER); break; @@ -742,6 +758,8 @@ class Compiler { return vt; case "not": return this.compileNot(cons.tail); + case "eq?": + return this.compileEq(cons.tail); // STRINGS case "concat": |
