aboutsummaryrefslogtreecommitdiff
path: root/chunk.d
diff options
context:
space:
mode:
Diffstat (limited to 'chunk.d')
-rw-r--r--chunk.d18
1 files changed, 9 insertions, 9 deletions
diff --git a/chunk.d b/chunk.d
index ad5774c..0573687 100644
--- a/chunk.d
+++ b/chunk.d
@@ -3,6 +3,7 @@ import std.string;
import std.conv;
import parser;
+import dbg;
enum ObjType {
FUNCTION,
@@ -37,22 +38,19 @@ class Function : Obj {
}
class List : Obj {
- int[] addresses;
+ Value[] inner;
- this() {
+ this(int length) {
+ this.inner = new Value[length];
this.type = ObjType.LIST;
}
- void addItem(int addr) {
- addresses ~= addr;
- }
-
- int first() {
- return addresses[0]; // TODO this fails on empty lists
+ void addItemAtIndex(Value item, int idx) {
+ this.inner[idx] = item;
}
override string toString() {
- return format("list (%d)", addresses.length);
+ return format("list ('%s' + %d)", printableValue(this.inner[0]), this.inner.length - 1);
}
}
@@ -82,6 +80,8 @@ enum OpCode {
OP_CALL,
+ OP_LIST,
+
OP_CONCAT, // No?
OP_FIRST, // No?