()
| 72 | } |
| 73 | |
| 74 | private void buildStateMap() { |
| 75 | allStateVariables = new LinkedHashSet<>(); |
| 76 | objectLookup = new WeakHashMap<>(); |
| 77 | ObjectGraphNode emulator = new ObjectGraphNode(Emulator.instance); |
| 78 | emulator.name = "Emulator"; |
| 79 | Set visited = new HashSet(); |
| 80 | buildStateMap(emulator, visited); |
| 81 | |
| 82 | // Also track all softswitches |
| 83 | for (SoftSwitches s : SoftSwitches.values()) { |
| 84 | final SoftSwitches ss = s; |
| 85 | ObjectGraphNode switchNode = new ObjectGraphNode(s); |
| 86 | switchNode.name = s.toString(); |
| 87 | ObjectGraphNode switchVar = new ObjectGraphNode(s.getSwitch()) { |
| 88 | @Override |
| 89 | /** |
| 90 | * This is a more efficient way of updating the softswitch |
| 91 | * states And really in a way this works out much better to |
| 92 | * ensure that memory and graphics pages are set up correctly |
| 93 | * when resuming states. |
| 94 | */ |
| 95 | public void setCurrentValue(Object value) { |
| 96 | Boolean b = (Boolean) value; |
| 97 | ss.getSwitch().setState(b); |
| 98 | } |
| 99 | |
| 100 | @Override |
| 101 | public Object getCurrentValue() { |
| 102 | return ss.getSwitch().getState(); |
| 103 | } |
| 104 | }; |
| 105 | switchVar.name = "switch"; |
| 106 | switchVar.parent = switchNode; |
| 107 | allStateVariables.add(switchVar); |
| 108 | objectLookup.put(s, switchNode); |
| 109 | objectLookup.put(s.getSwitch(), switchVar); |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | private void buildStateMap(ObjectGraphNode node, Set visited) { |
| 114 | if (visited.contains(node)) { |
no test coverage detected