aboutsummaryrefslogtreecommitdiff
path: root/compiler.d
diff options
context:
space:
mode:
authormryouse2023-05-26 02:52:39 +0000
committermryouse2023-05-26 02:52:39 +0000
commitaab6510a0e59c26a31526ff303a9d581736815fc (patch)
tree4fed2a5fe5711f8e0e43b7386317183a162345a9 /compiler.d
parent11e9f1d854602aae7cb895cfb2f9fc5dd338e6f8 (diff)
eq? for many things
Diffstat (limited to 'compiler.d')
-rw-r--r--compiler.d18
1 files changed, 18 insertions, 0 deletions
diff --git a/compiler.d b/compiler.d
index eccc4ce..4fb37f2 100644
--- a/compiler.d
+++ b/compiler.d
@@ -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":