Ver Fonte

Add printing of all stacks for debugging

ApisNecros há 1 ano atrás
pai
commit
9d4dbfcef6
1 ficheiros alterados com 18 adições e 1 exclusões
  1. 18 1
      starfish.js

+ 18 - 1
starfish.js

@@ -173,7 +173,9 @@ class CodeBox {
         }
     }
 
-    /** Prints the code box to the console */
+    /** 
+     * Prints the code box to the console
+     */
     PrintCodeBox() {
         let output = "";
         for (let y = 0; y < this.box.length; y++) {
@@ -190,6 +192,20 @@ class CodeBox {
         console.log(output);
     }
 
+    /**
+     * Prints all stacks to the console
+     */
+    PrintStacks() {
+        let output = "{\n";
+
+        for (let i = 0; i < this.stacks.length; i++) {
+            output += `\t${i}: ${JSON.stringify(this.stacks[i].stack)},\n`
+        }
+        output += "}";
+
+        console.log(output);
+    }
+
     /**
      * Make all the rows in the code box the same length
      *
@@ -458,6 +474,7 @@ class CodeBox {
 
     Swim() {
         if(this.debug.print.codeBox) { this.PrintCodeBox(); }
+        if(this.debug.print.stacks) { this.PrintStacks(); }
 
         const instruction = this.box[this.pointer.Y][this.pointer.X];
         this.datetime = new Date();