aboutsummaryrefslogtreecommitdiff
path: root/compiler.d
diff options
context:
space:
mode:
Diffstat (limited to 'compiler.d')
-rw-r--r--compiler.d19
1 files changed, 19 insertions, 0 deletions
diff --git a/compiler.d b/compiler.d
index 8a00547..08b916b 100644
--- a/compiler.d
+++ b/compiler.d
@@ -325,6 +325,14 @@ class Compiler {
return ValueType.BOOLEAN;
}
+ void compilePrint(Form[] args) {
+ if (args.length != 1) {
+ this.error(format("'print': expected [1] argument, received %d", to!int(args.length)), -1);
+ }
+ ValueType vt1 = this.resolve(args[0], ValueType.ANY);
+ this.func.chunk.writeOp(OpCode.OP_PRINT, args[0].line);
+ }
+
int parseVariable(Symbol sym) {
this.declareVariable(sym);
@@ -856,6 +864,10 @@ class Compiler {
case "nil?":
this.compileIsNil(cons.tail);
break;
+ case "->string":
+ // does nothing at the moment, as primarily used for printing
+ // and everything can be printed
+ break;
// LISTS
case "append":
@@ -877,10 +889,17 @@ class Compiler {
case "rest":
this.compileRest(cons.tail);
break;
+
+ // OTHER
+ case "print":
+ this.compilePrint(cons.tail);
+ break;
+
default:
this.resolve(head);
this.call(cons.tail);
break;
+
}
return ValueType.NIL;