aboutsummaryrefslogtreecommitdiff
path: root/dbg.d
diff options
context:
space:
mode:
Diffstat (limited to 'dbg.d')
-rw-r--r--dbg.d24
1 files changed, 22 insertions, 2 deletions
diff --git a/dbg.d b/dbg.d
index 65c83af..64669ea 100644
--- a/dbg.d
+++ b/dbg.d
@@ -8,8 +8,8 @@ import parser;
//import dbg;
//import value;
-//bool DEBUG = true;
-bool DEBUG = false;
+bool DEBUG = true;
+//bool DEBUG = false;
void printForm(Form f, string prefix = "") {
@@ -85,11 +85,17 @@ string printableValue(Value val) {
return val.as.type;
case ValueType.NIL:
return "nil";
+ case ValueType.SEQ:
+ return printableSeq(val.as.seq);
default:
return "! unknown value type !";
}
}
+string printableSeq(Seq seq) {
+ return format("%s", seq);
+}
+
string printableFunction(Obj func) {
return format("%s", func);
}
@@ -119,6 +125,12 @@ int constantInstruction(string message, Chunk chunk, int offset) {
return offset + 2;
}
+int listInstruction(string message, Chunk chunk, int offset) {
+ ubyte idx = chunk.code[offset + 1];
+ writefln("%-16s %4d", message, idx);
+ return offset + 2;
+}
+
int simpleInstruction(string message, int offset) {
writeln(message);
return offset + 1;
@@ -147,6 +159,8 @@ int disassemble(Chunk chunk, int offset) {
return byteInstruction("OP_GET_LOCAL", chunk, offset);
case OpCode.OP_SET_LOCAL:
return byteInstruction("OP_SET_LOCAL", chunk, offset);
+ case OpCode.OP_LIST:
+ return listInstruction("OP_LIST", chunk, offset);
case OpCode.OP_ADD:
return simpleInstruction("OP_ADD", offset);
case OpCode.OP_LESS:
@@ -187,6 +201,12 @@ int disassemble(Chunk chunk, int offset) {
return simpleInstruction("OP_TYPE_CHECK_NUMBER", offset);
case OpCode.OP_TYPE_CHECK_BOOLEAN:
return simpleInstruction("OP_TYPE_CHECK_BOOLEAN", offset);
+ case OpCode.OP_TYPE_CHECK_SEQ:
+ return simpleInstruction("OP_TYPE_CHECK_SEQ", offset);
+ case OpCode.OP_FIRST:
+ return simpleInstruction("OP_FIRST", offset);
+ case OpCode.OP_REST:
+ return simpleInstruction("OP_REST", offset);
default:
writeln("unknown opcode?");
return offset + 1;