From: Daniel Kirschten Date: Sun, 15 Sep 2019 11:39:53 +0000 (+0200) Subject: Renamed some methods and parameters for clarity; removed debug code X-Git-Url: https://mograsim.net/gitweb/?a=commitdiff_plain;h=0e506ec1b95fb65d5cb85412b59e528f9a996038;p=Mograsim.git Renamed some methods and parameters for clarity; removed debug code --- diff --git a/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/machine/Am2900Machine.java b/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/machine/Am2900Machine.java index 5aa348ca..2d6c70bd 100644 --- a/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/machine/Am2900Machine.java +++ b/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/machine/Am2900Machine.java @@ -5,8 +5,6 @@ import net.mograsim.logic.core.timeline.Timeline; import net.mograsim.logic.core.types.BitVector; import net.mograsim.logic.model.model.LogicModel; import net.mograsim.logic.model.model.LogicModelModifiable; -import net.mograsim.logic.model.model.components.atomic.ModelClock; -import net.mograsim.logic.model.model.components.atomic.ModelManualSwitch; import net.mograsim.logic.model.modeladapter.CoreModelParameters; import net.mograsim.logic.model.modeladapter.LogicCoreAdapter; import net.mograsim.logic.model.serializing.IndirectModelComponentCreator; @@ -39,7 +37,6 @@ public class Am2900Machine implements Machine mainMemory = new WordAddressableMemory(am2900MachineDefinition.getMainMemoryDefinition()); instMemory = new StandardMicroInstructionMemory(am2900MachineDefinition.getMicroInstructionMemoryDefinition()); timeline = LogicCoreAdapter.convert(logicModel, params); - logicModel.getComponentByPath("Am2900.@c", ModelManualSwitch.class).getManualSwitch(); } @Override diff --git a/net.mograsim.logic.model/src/net/mograsim/logic/model/model/LogicModel.java b/net.mograsim.logic.model/src/net/mograsim/logic/model/model/LogicModel.java index 33cc22e2..f9eef5db 100644 --- a/net.mograsim.logic.model/src/net/mograsim/logic/model/model/LogicModel.java +++ b/net.mograsim.logic.model/src/net/mograsim/logic/model/model/LogicModel.java @@ -117,9 +117,9 @@ public class LogicModel return wiresUnmodifiable; } - public T getComponentByName(String name, Class modelClass) + public T getComponentByName(String name, Class expectedComponentClass) { - return getByName(name, modelClass, components); + return getByName(name, expectedComponentClass, components); } public ModelWire getWireByName(String name) @@ -128,33 +128,33 @@ public class LogicModel } @SuppressWarnings("unchecked") - private static T getByName(String name, Class modelClass, Map map) + private static T getByName(String name, Class expectedClass, Map map) { Object comp = map.get(name); Objects.requireNonNull(comp, "Invaild path, component " + name + " not found"); - if (modelClass.isInstance(comp)) + if (expectedClass.isInstance(comp)) return (T) comp; - throw new IllegalArgumentException("The component " + name + " is not an instance of " + modelClass); + throw new IllegalArgumentException("The component " + name + " is not an instance of " + expectedClass); } - public T getComponentByPath(String path, Class modelClass) + public T getComponentBySubmodelPath(String path, Class modelClass) { int firstDot = path.indexOf('.'); if (firstDot == -1) return getComponentByName(path, modelClass); String first = path.substring(0, firstDot); String rest = path.substring(firstDot + 1); - return getComponentByName(first, SubmodelComponent.class).submodel.getComponentByPath(rest, modelClass); + return getComponentByName(first, SubmodelComponent.class).submodel.getComponentBySubmodelPath(rest, modelClass); } - public ModelWire getWireByPath(String path) + public ModelWire getWireBySubmodelPath(String path) { int firstDot = path.indexOf('.'); if (firstDot == -1) return getWireByName(path); String first = path.substring(0, firstDot); String rest = path.substring(firstDot + 1); - return getComponentByName(first, SubmodelComponent.class).submodel.getWireByPath(rest); + return getComponentByName(first, SubmodelComponent.class).submodel.getWireBySubmodelPath(rest); } // @formatter:off @@ -162,19 +162,19 @@ public class LogicModel public void addComponentRemovedListener (Consumer listener) {componentRemovedListeners .add (listener);} public void addWireAddedListener (Consumer listener) {wireAddedListeners .add (listener);} public void addWireRemovedListener (Consumer listener) {wireRemovedListeners .add (listener);} - public void addRedrawHandlerChangedListener (Consumer listener) {redrawHandlerChangedListeners.add (listener);} + public void addRedrawHandlerChangedListener (Consumer listener) {redrawHandlerChangedListeners.add (listener);} public void removeComponentAddedListener (Consumer listener) {componentAddedListeners .remove(listener);} public void removeComponentRemovedListener (Consumer listener) {componentRemovedListeners .remove(listener);} public void removeWireAddedListener (Consumer listener) {wireAddedListeners .remove(listener);} public void removeWireRemovedListener (Consumer listener) {wireRemovedListeners .remove(listener);} - public void removeRedrawHandlerChangedListener(Consumer listener) {redrawHandlerChangedListeners.remove(listener);} + public void removeRedrawHandlerChangedListener(Consumer listener) {redrawHandlerChangedListeners.remove(listener);} private void callComponentAddedListeners (ModelComponent c) {componentAddedListeners .forEach(l -> l.accept(c));} private void callComponentRemovedListeners (ModelComponent c) {componentRemovedListeners .forEach(l -> l.accept(c));} private void callWireAddedListeners (ModelWire w) {wireAddedListeners .forEach(l -> l.accept(w));} private void callWireRemovedListeners (ModelWire w) {wireRemovedListeners .forEach(l -> l.accept(w));} - private void callRedrawHandlerChangedListener(Runnable r) {redrawHandlerChangedListeners.forEach(l -> l.accept(r));} + private void callRedrawHandlerChangedListener(Runnable r) {redrawHandlerChangedListeners.forEach(l -> l.accept(r));} // @formatter:on public void setRedrawHandler(Runnable handler)