public Ship getShip(String type, int ordinal) {
for(Ship s : this)
if (s.getType().equals(type))
- if (ordinal-- < 0)
+ if (ordinal-- <= 0)
return s;
return null;
}
+ /** do not use this; it is going to go away */
+ public Interpreter() {
+ }
+
+ public Interpreter(String[] ships, boolean logging) {
+ int i=0;
+ Log.quiet = !logging;
+ for(String s : ships) {
+ createShip(ships[i], ships[i]+"_"+i);
+ i++;
+ }
+ }
+
void dispatch(Instruction i) {
Log.dispatch(i);
long il = writeInstruction(i, debugShip.getDock("in"));
new Packet((InterpreterPath)path, new BitVector(getWordWidth()).set(il), false).send();
}
+ /** do not use this; it is going to go away */
public Ship createShip(String shipType, String shipname) {
try {
Class c = Class.forName("edu.berkeley.fleet.interpreter."+shipType);
public static boolean ansi_color = true;
public static PrintWriter log = new PrintWriter(new OutputStreamWriter(System.out));
+ public static boolean quiet = false;
public static void print(Object o) {
- if (log==null) return;
+ if (log==null || quiet) return;
try {
log.print(o);
} catch (Exception e) {
}
public static void println() { println(""); }
public static void println(Object o) {
- if (log==null) return;
+ if (log==null || quiet) return;
try {
log.println(o);
log.flush();
}
public void send() {
+ if (isToken) {
+ Log.token(path.getSource(), path.getDestination());
+ } else {
+ Log.data(value+"", path.getSource(), path.getDestination());
+ }
((InterpreterDestination)path.getDestination()).addDataFromFabric(this);
}