diff options
| author | mryouse | 2023-06-11 23:34:25 +0000 |
|---|---|---|
| committer | mryouse | 2023-06-11 23:34:25 +0000 |
| commit | 639e303f7ba2963e32295c4c60d6001e384868e3 (patch) | |
| tree | 7cb588605c3b93f79f01b1056bbf8be3232dfcad /compiler.d | |
| parent | 90bde7320c09c13bc2a2edbb89e58a62c13da8ff (diff) | |
Diffstat (limited to 'compiler.d')
| -rw-r--r-- | compiler.d | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -582,6 +582,19 @@ class Compiler { } // LISP-Y + void compileApply(Form[] args) { + if (args.length != 2) { + this.error(format("'apply?': expected [2] argument, received %d", to!int(args.length)), -1); + return; + } + ValueType vt1 = this.resolve(args[0], ValueType.ANY); // this should be a function + vt1 = this.resolve(args[1], ValueType.ANY); + + // ungroup the list and call the function + this.func.chunk.writeOp(OpCode.OP_UNGROUP, args[1].line); + this.func.chunk.writeOp(OpCode.OP_CALL_N, args[1].line); + } + void compileBlock(Form form) { Block block = cast(Block)form; this.beginScope(); @@ -1088,6 +1101,9 @@ class Compiler { break; // OTHER + case "apply": + this.compileApply(cons.tail); + break; case "print": this.compilePrint(cons.tail); break; @@ -1223,6 +1239,7 @@ class Compiler { this.globals["reverse"] = 1; // OTHER + this.globals["apply"] = 2; this.globals["print"] = 1; } |
