aboutsummaryrefslogtreecommitdiff
path: root/vm.d
diff options
context:
space:
mode:
Diffstat (limited to 'vm.d')
-rw-r--r--vm.d34
1 files changed, 18 insertions, 16 deletions
diff --git a/vm.d b/vm.d
index d2968a3..7e91de1 100644
--- a/vm.d
+++ b/vm.d
@@ -224,22 +224,25 @@ class VM {
InterpretResult run() {
writeln("== VM running ==");
while (true) {
- writeln(" Stacks:");
- write(" A> ");
- for (int i = 0; i < aTop; i++) {
- writef("[ %s ]", printableValue(aStack[i]));
+ if (DEBUG) {
+ writeln(" Stacks:");
+ write(" A> ");
+ for (int i = 0; i < aTop; i++) {
+ writef("[ %s ]", printableValue(aStack[i]));
+ }
+ write("\n B> ");
+ for (int i = 0; i < bTop; i++) {
+ //writef("[ %s ]", printableValue(bStack[i]));
+ writef("[ %s ]", printableValue(current.slots[i]));
+ }
+
+ write("\n constants> ");
+ for (int i = 0; i < current.func.chunk.constants.length; i++) {
+ writef("[ %s ]", printableValue(current.func.chunk.constants[i]));
+ }
+ writeln("\n--");
+ disassemble(current.func.chunk, current.ip);
}
- write("\n B> ");
- for (int i = 0; i < bTop; i++) {
- //writef("[ %s ]", printableValue(bStack[i]));
- writef("[ %s ]", printableValue(current.slots[i]));
- }
-
- write("\n constants> ");
- for (int i = 0; i < current.func.chunk.constants.length; i++) {
- writef("[ %s ]", printableValue(current.func.chunk.constants[i]));
- }
- writeln("\n--");
/*
write(" globals >");
@@ -250,7 +253,6 @@ class VM {
writeln("\n--");
*/
- disassemble(current.func.chunk, current.ip);
ubyte inst;
switch (inst = this.readByte()) {
case OpCode.OP_DEF_GLOBAL: