/** Resets the stack machine to the state it was in before it started running the stack program */ public void reset() { this.programCounter = 0; this.stack.clear(); this.numInstructions = 0; this.store = new StackValue<?>[STORE_SIZE]; this.inputIndex = 0; this.output = new ArrayList<StackValue<?>>(); for (int i = 0; i < STORE_SIZE; i++) { store[i] = new IntStackValue(0); for (StackMachineListener l : listeners) l.storeChanged(i); } for (StackMachineListener l : listeners) l.machineReset(); }