diff options
Diffstat (limited to 'dbg.d')
| -rw-r--r-- | dbg.d | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -51,6 +51,10 @@ void printForm(Form f, string prefix = "") { Def def = cast(Def)f; writefln("%s var: %s", prefix, def.name.name); break; + case FormType.BLOCK: + Block block = cast(Block)f; + writefln("%s block of %d", prefix, block.blockBody.length); + break; default: writeln("printFormDefault"); break; @@ -79,6 +83,12 @@ string atomAsString(Atom a) { return printableValue(a.value); } +int byteInstruction(string message, Chunk chunk, int offset) { + ubyte slot = chunk.code[offset + 1]; + writefln("%-16s %4d", message, slot); + return offset + 2; +} + int constantInstruction(string message, Chunk chunk, int offset) { ubyte idx = chunk.code[offset + 1]; //writeln("dunno how to write a constant"); @@ -97,6 +107,10 @@ int disassemble(Chunk chunk, int offset) { ubyte inst = chunk.code[offset]; switch (inst) { + case OpCode.OP_GET_LOCAL: + return byteInstruction("OP_GET_LOCAL", chunk, offset); + case OpCode.OP_SET_LOCAL: + return byteInstruction("OP_SET_LOCAL", chunk, offset); case OpCode.OP_ADD: return simpleInstruction("OP_ADD", offset); case OpCode.OP_LESS: @@ -111,6 +125,8 @@ int disassemble(Chunk chunk, int offset) { return simpleInstruction("OP_NEGATE", offset); case OpCode.OP_POP: return simpleInstruction("OP_POP", offset); + case OpCode.OP_POP_SCOPE: + return simpleInstruction("OP_POP_SCOPE", offset); case OpCode.OP_RETURN: return simpleInstruction("OP_RETURN", offset); case OpCode.OP_NIL: |
