From 03b4987afc5e32ec560fac6f74c153d592f75259 Mon Sep 17 00:00:00 2001 From: Ben Winston Date: Sun, 21 May 2023 23:50:04 -0400 Subject: functionsgit add *.d! --- dbg.d | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'dbg.d') diff --git a/dbg.d b/dbg.d index b32c431..f131226 100644 --- a/dbg.d +++ b/dbg.d @@ -75,12 +75,14 @@ string printableValue(Value val) { } else { return "false"; } + case ValueType.OBJ: + return printableFunction(val.as.obj); default: return "! unknown value type !"; } } -string printableFunction(Function func) { +string printableFunction(Obj func) { return format("%s", func); } @@ -147,6 +149,8 @@ int disassemble(Chunk chunk, int offset) { return constantInstruction("OP_CONSTANT", chunk, offset); case OpCode.OP_DEF_GLOBAL: return constantInstruction("OP_DEF_GLOBAL", chunk, offset); + case OpCode.OP_GET_GLOBAL: + return constantInstruction("OP_GET_GLOBAL", chunk, offset); case OpCode.OP_NEGATE: return simpleInstruction("OP_NEGATE", offset); case OpCode.OP_POP: @@ -165,6 +169,8 @@ int disassemble(Chunk chunk, int offset) { return jumpInstruction("OP_JUMP_IF_FALSE", 1, chunk, offset); case OpCode.OP_JUMP_IF_TRUE: return jumpInstruction("OP_JUMP_IF_TRUE", 1, chunk, offset); + case OpCode.OP_CALL: + return byteInstruction("OP_CALL", chunk, offset); default: writeln("unknown opcode?"); -- cgit v1.2.3