1 package edu.berkeley.fleet.api;
5 public abstract class Fleet implements Iterable<Ship> {
7 /** read a machine-formatted instruction from a file (into a Java object) */
8 public abstract Instruction readInstruction(DataInputStream is) throws IOException;
10 /** write a machine-formatted instruction to a file (from a Java object) */
11 public abstract void writeInstruction(DataOutputStream os, Instruction instr) throws IOException;
13 /** ships must be returned in the same order every time -- ordering may be significant */
14 public abstract Iterator<Ship> iterator();
17 * Compute the value that should go in the MACHINE-addressed
18 * "offset" field of a literal given BYTE-addressed origin and
21 public abstract int computeOffset(int origin, int target);
24 * Compute the value that should go in the "offset" field of a
25 * literal given BYTE-addressed origin and MACHINE-addressed
28 public abstract int computeTarget(int origin, int offset);
31 * This interface marks Fleets which can create ships on the fly, like the fleeterpreter;
32 * if available, the parser will use this interface to create ships out of #ship definitions.
34 public static interface WithDynamicShips {
35 public Ship createShip(String shiptype, String shipname);