(int stackNum)
| 102 | } |
| 103 | |
| 104 | static int pop(int stackNum) throws Exception { |
| 105 | StackData stack = stacks[stackNum]; |
| 106 | if (stack.size == 0) { |
| 107 | throw new Exception("Trying to pop an empty stack."); |
| 108 | } |
| 109 | int value = buffer[stack.pointer]; |
| 110 | buffer[stack.pointer] = 0; |
| 111 | stack.pointer = previousElement(stack.pointer); |
| 112 | stack.size--; |
| 113 | return value; |
| 114 | } |
| 115 | |
| 116 | static int peek(int stackNum) { |
| 117 | StackData stack = stacks[stackNum]; |