diff options
Diffstat (limited to 'compiler.d')
| -rw-r--r-- | compiler.d | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -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); |
