package edu.berkeley.fleet.api;
+import edu.berkeley.fleet.doc.*;
import java.io.*;
import java.util.*;
*/
public abstract int computeTarget(int origin, int offset);
+ /** if possible, run the given code and create a FleetProcess */
+ public FleetProcess run(byte[] code) {
+ throw new RuntimeException("class " + this.getClass().getName() + " does not implement method run()");
+ }
+
+ /** extract the portion of ShipDescription which is specific to this fleet and generate any source code necessary */
+ public void expand(ShipDescription sd) {
+ throw new RuntimeException("class " + this.getClass().getName() + " does not implement method expand()");
+ }
+
/**
* This interface marks Fleets which can create ships on the fly, like the fleeterpreter;
* if available, the parser will use this interface to create ships out of #ship definitions.
--- /dev/null
+package edu.berkeley.fleet.api;
+import java.io.*;
+import java.util.*;
+
+/** represents a <i>running</i> "slave" fleet with a debug connection */
+public abstract class FleetProcess {
+
+ private boolean terminated = false;
+
+ /** dumps an instruction into the fetch unit */
+ public abstract void invokeInstruction(Instruction i);
+
+ /** reads a word back from the debug port */
+ public abstract long readWord();
+
+ /** subclasses may be assured that this will be called exactly once */
+ protected abstract void _terminate();
+
+ public synchronized void terminate() {
+ if (terminated) return;
+ terminated = true;
+ _terminate();
+ }
+
+ public boolean isTerminated() {
+ return terminated;
+ }
+
+ public synchronized void finalize() {
+ if (!terminated)
+ terminate();
+ }
+
+}