diff options
| author | Ben Winston | 2023-05-23 22:49:42 -0400 |
|---|---|---|
| committer | Ben Winston | 2023-05-23 22:49:52 -0400 |
| commit | 277f7110b01a510e42fd8a75682ebe3c4daa3d40 (patch) | |
| tree | 3f504df1daeea1350b4b68cf9107ec617628cacd /chunk.d | |
| parent | aafe90221e9f8e8bf15ebc87814a1bb67e5a4dce (diff) | |
first crack at lists (rather naive)
Diffstat (limited to 'chunk.d')
| -rw-r--r-- | chunk.d | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -7,6 +7,7 @@ import parser; enum ObjType { FUNCTION, SCRIPT, + LIST, } abstract class Obj { @@ -35,6 +36,26 @@ class Function : Obj { } } +class List : Obj { + int[] addresses; + + this() { + this.type = ObjType.LIST; + } + + void addItem(int addr) { + addresses ~= addr; + } + + int first() { + return addresses[0]; // TODO this fails on empty lists + } + + override string toString() { + return format("list (%d)", addresses.length); + } +} + enum OpCode { OP_ADD, OP_LESS, @@ -61,8 +82,14 @@ enum OpCode { OP_CALL, + OP_CONCAT, // No? + + OP_FIRST, // No? + OP_TYPE_CHECK_NUMBER, OP_TYPE_CHECK_BOOLEAN, + OP_TYPE_CHECK_STRING, + OP_TYPE_CHECK_LIST, } class Chunk { |
