separated interpreter from assembler
[fleet.git] / src / edu / berkeley / fleet / api / Fleet.java
1 package edu.berkeley.fleet.api;
2 import java.io.*;
3 import java.util.*;
4
5 public abstract class Fleet implements Iterable<Ship> {
6
7     /** read a machine-formatted instruction from a file (into a Java object) */
8     public abstract Instruction readInstruction(DataInputStream is) throws IOException;
9
10     /** write a machine-formatted instruction to a file (from a Java object) */
11     public abstract void        writeInstruction(DataOutputStream os, Instruction instr) throws IOException;
12
13     /** ships must be returned in the same order every time -- ordering may be significant */
14     public abstract Iterator<Ship> iterator();
15
16     /**
17      *  Compute the value that should go in the MACHINE-addressed
18      *  "offset" field of a literal given BYTE-addressed origin and
19      *  target
20      */ 
21     public abstract int computeOffset(int origin, int target);
22
23     /**
24      *  Compute the value that should go in the "offset" field of a
25      *  literal given BYTE-addressed origin and MACHINE-addressed
26      *  target
27      */ 
28     public abstract int computeTarget(int origin, int offset);
29
30 }