Parcourir la source

Add comments in Execution switch case

ApisNecros il y a 1 an
Parent
commit
44b5bfb757
1 fichiers modifiés avec 5 ajouts et 0 suppressions
  1. 5 0
      starfish.js

+ 5 - 0
starfish.js

@@ -152,8 +152,10 @@ class CodeBox {
     Execute(instruction) {
         let output = null;
         switch(instruction) {
+            // NOP
             case " ":
                 break;
+            // Numbers
             case "1":
             case "2":
             case "3":
@@ -172,6 +174,7 @@ class CodeBox {
             case "f":
                 this.stack.Push(parseInt(instruction, 16));
                 break;
+            // Operators
             case "+": {
                 const x = this.stack.Pop();
                 const y = this.stack.Pop();
@@ -202,12 +205,14 @@ class CodeBox {
                 this.stack.Push(y % x);
                 break;
             }
+            // Output
             case "n": 
                 output = this.stack.Pop();
                 break;
             case "o":
                 output = String.fromCharCode(this.stack.Pop());
                 break;
+            // End execution
             case ";":
                 output = true;
                 break;