Browse Source

Add most stack manipulation operators

ApisNecros 1 year ago
parent
commit
030fdb709e
1 changed files with 35 additions and 0 deletions
  1. 35 0
      starfish.js

+ 35 - 0
starfish.js

@@ -270,6 +270,41 @@ class CodeBox {
             case "#":
                 this.OmniMirror();
                 break;
+            // Stack manipulation
+            case ":":
+                this.stack.Duplicate();
+                break;
+            case "~":
+                this.stack.Remove();
+                break;
+            case "$":
+                this.stack.SwapTwo();
+                break;
+            // case "@":
+            //     this.stack.SwapThree();
+            //     break;
+            case "{":
+                this.stack.ShiftLeft();
+                break;
+            case "}":
+                this.stack.ShiftRight();
+                break;
+            case "r":
+                this.stack.Reverse();
+                break;
+            case "l":
+                this.stack.PushLength();
+                break;
+            // case "[":
+            //     break;
+            // case "]":
+            //     break;
+            // case "I":
+            //     this.curr_stack++;
+            //     break;
+            // case "D":
+            //     this.curr_stack--;
+            //     break;
             // Output
             case "n": 
                 output = this.stack.Pop();