diff options
| author | mryouse | 2023-05-25 20:27:36 +0000 |
|---|---|---|
| committer | mryouse | 2023-05-25 20:27:36 +0000 |
| commit | d95e4f6f988b16bbd95a9c78c0355d190390f003 (patch) | |
| tree | 88c47ec85d16ebc3654ebae64c5e9905702d3c49 /chunk.d | |
| parent | f90b882fe50d982293be5427457efea565173261 (diff) | |
make list creation simpler (and allow nesting)
Diffstat (limited to 'chunk.d')
| -rw-r--r-- | chunk.d | 18 |
1 files changed, 9 insertions, 9 deletions
@@ -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? |
