diff options
| author | Ben Winston | 2023-05-21 20:26:59 -0400 |
|---|---|---|
| committer | Ben Winston | 2023-05-21 20:26:59 -0400 |
| commit | 8e1f84b1369909745859777d07a5e8e74b5df334 (patch) | |
| tree | 460f42755407e9ddf1b3e6dfabea6a09b3d1585d /dbg.d | |
| parent | a26bfccdc52ab50a83b8f8d170c9e1a3be0164a5 (diff) | |
move disassembly into compiler, preparing for functions
Diffstat (limited to 'dbg.d')
| -rw-r--r-- | dbg.d | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -80,6 +80,10 @@ string printableValue(Value val) { } } +string printableFunction(Function func) { + return format("%s", func); +} + string atomAsString(Atom a) { return printableValue(a.value); } @@ -110,6 +114,18 @@ int simpleInstruction(string message, int offset) { return offset + 1; } +void disassembleChunk(Chunk chunk, string name) { + writefln("== %s ==", name); + int cnt = 0; + while(true) { + if (cnt >= chunk.code.length) { + break; + } + cnt = disassemble(chunk, cnt); + } + +} + int disassemble(Chunk chunk, int offset) { writef("%04d %4d ", offset, chunk.lines[offset]); |
