aboutsummaryrefslogtreecommitdiff
path: root/compiler.d
diff options
context:
space:
mode:
Diffstat (limited to 'compiler.d')
-rw-r--r--compiler.d27
1 files changed, 27 insertions, 0 deletions
diff --git a/compiler.d b/compiler.d
index a9d3c3d..5b06f4c 100644
--- a/compiler.d
+++ b/compiler.d
@@ -205,6 +205,25 @@ class Compiler {
//advance();
}
+ void compileIsAny(Form[] args) {
+ if (args.length != 1) {
+ this.error(format("'any?': expecting [1] argument, received %d", args.length), -1);
+ this.advance();
+ return;
+ }
+ this.compileAtom(new Atom(true, args[0].line), ValueType.ANY);
+ }
+
+ void compileIsNil(Form[] args) {
+ if (args.length != 1) {
+ this.error(format("'nil?': expecting [1] argument, received %d", args.length), -1);
+ this.advance();
+ return;
+ }
+ ValueType vt = this.resolve(args[0], ValueType.ANY);
+ this.func.chunk.writeOp(OpCode.OP_IS_NIL, args[0].line);
+ }
+
void compileAdd(Form[] args, ValueType expecting) {
int line = args[0].line;
this.resolve(args[0], expecting);
@@ -897,6 +916,14 @@ class Compiler {
case "concat":
return this.compileConcat(cons.tail);
+ // TYPES
+ case "any?":
+ this.compileIsAny(cons.tail);
+ break;
+ case "nil?":
+ this.compileIsNil(cons.tail);
+ break;
+
// LISTS
case "append":
this.compileAppend(cons.tail);