Removed complete listing support from simulator.

Listing functions are moved to the assembler IDE.
This commit is contained in:
hneemann 2016-12-17 10:56:48 +01:00
parent 0213a358b0
commit e9af552d91
4 changed files with 55 additions and 39 deletions

View File

@ -432,15 +432,6 @@ public class Model implements Iterable<Node> {
return n;
}
public void addProgRom(ROM rom) {
progRoms.add(rom);
}
public ArrayList<ROM> getProgRoms() {
return progRoms;
}
/**
* fires a model changed event to all listeners
*/
@ -463,13 +454,41 @@ public class Model implements Iterable<Node> {
* @return the list, not null, but maybe empty
*/
public <NODE extends Node> List<NODE> findNode(Class<NODE> nodeClass) {
return findNode(nodeClass, n -> true);
}
/**
* Returns all nodes of the given class.
* A filter cann be used to narrow down the amount of nodes found.
*
* @param nodeClass the class
* @param filter filter to filter the nodes
* @param <NODE> the node type
* @return the list, not null, but maybe empty
*/
public <NODE extends Node> List<NODE> findNode(Class<NODE> nodeClass, NodeFilter<NODE> filter) {
ArrayList<NODE> found = new ArrayList<>();
for (Node n : nodes)
if (n.getClass() == nodeClass)
if (n.getClass() == nodeClass && filter.accept((NODE) n))
found.add((NODE) n);
return found;
}
/**
* A filter for nodes
*
* @param <NODE>
*/
public interface NodeFilter<NODE extends Node> {
/**
* Accepts the node
*
* @param n the node
* @return true if accepted
*/
boolean accept(NODE n);
}
@Override
public Iterator<Node> iterator() {
return nodes.iterator();

View File

@ -101,9 +101,6 @@ public class ROM extends Node implements Element {
@Override
public void init(Model model) throws NodeException {
if (isProgramMemory) {
model.addProgRom(this);
}
if (autoLoad) {
try {
data = new DataField(hexFile);

View File

@ -986,7 +986,7 @@ public class Main extends JFrame implements ClosingWindowListener.ConfirmSave, E
private long addr;
private void getProgRomAddr(Model model) {
ArrayList<ROM> roms = model.getProgRoms();
List<ROM> roms = model.findNode(ROM.class, ROM::isProgramMemory);
if (roms.size() == 1)
addr = roms.get(0).getRomAddress();
else
@ -1001,6 +1001,29 @@ public class Main extends JFrame implements ClosingWindowListener.ConfirmSave, E
}
}
private void setDebug(boolean debug) throws RemoteException {
settings.set(Keys.SHOW_DATA_TABLE, debug);
}
@Override
public void start(File romHex) throws RemoteException {
setDebug(false);
SwingUtilities.invokeLater(() -> {
windowPosManager.closeAll();
runModelState.enter(true, new RomLoader(romHex));
circuitComponent.hasChanged();
});
}
@Override
public void debug(File romHex) throws RemoteException {
setDebug(true);
SwingUtilities.invokeLater(() -> {
runModelState.enter(false, new RomLoader(romHex));
circuitComponent.hasChanged();
});
}
@Override
public String doSingleStep() throws RemoteException {
if (model != null && !realtimeClockRunning) {
@ -1047,29 +1070,6 @@ public class Main extends JFrame implements ClosingWindowListener.ConfirmSave, E
}
}
private void setDebug(boolean debug) throws RemoteException {
settings.set(Keys.SHOW_DATA_TABLE, debug);
}
@Override
public void debug(File romHex) throws RemoteException {
setDebug(true);
SwingUtilities.invokeLater(() -> {
runModelState.enter(false, new RomLoader(romHex));
circuitComponent.hasChanged();
});
}
@Override
public void start(File romHex) throws RemoteException {
setDebug(false);
SwingUtilities.invokeLater(() -> {
windowPosManager.closeAll();
runModelState.enter(true, new RomLoader(romHex));
circuitComponent.hasChanged();
});
}
@Override
public void stop() {
SwingUtilities.invokeLater(() -> {

View File

@ -8,7 +8,7 @@ import de.neemann.digital.lang.Lang;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/**
* A Modifier that loads a given rom file to the program memory of the model.
@ -28,7 +28,7 @@ public class RomLoader implements ModelModifier {
@Override
public void preInit(Model model) throws NodeException {
ArrayList<ROM> roms = model.getProgRoms();
List<ROM> roms = model.findNode(ROM.class, ROM::isProgramMemory);
if (roms.isEmpty())
throw new NodeException(Lang.get("msg_noRomFound"));
if (roms.size() > 1)