1 package edu.berkeley.fleet.interpreter;
2 import edu.berkeley.sbp.util.ANSI;
3 import edu.berkeley.fleet.api.*;
8 public static PrintWriter log = new PrintWriter(new OutputStreamWriter(System.out));
9 public static boolean quiet = false;
11 public static void print(Object o) {
12 if (log==null || quiet) return;
15 } catch (Exception e) { throw new RuntimeException(e); }
17 public static void println() { println(""); }
18 public static void println(Object o) {
19 if (log==null || quiet) return;
23 } catch (Exception e) { throw new RuntimeException(e); }
26 public static void packet(Packet p) {
27 BitVector data = p.getValue();
28 Dock source = p.getSource();
29 Destination dest = p.getDestination();
30 if (dest.getDock().getInstructionDestination()==dest) {
32 println(ANSI.yellow(ANSI.bold(" torpedo: ")) + (source + " -> " + ANSI.yellow(ANSI.bold(dest+""))));
34 Instruction d = source.getShip().getFleet().decodeInstruction(data, source);
35 println(ANSI.red("dispatch: " + indent(d+"", " ")));
39 println(ANSI.blue(ANSI.bold(" token: ")) + (source + " -> " + ANSI.blue(ANSI.bold(dest+""))));
41 println(indent(ANSI.cyan(" data: "+data) +
43 (" : " + source))+(" -> "+ANSI.cyan(""+dest)), " "));
48 public static void error(Object o) { println(ANSI.red(o)); }
50 public static String indent(String s, String indent) {
51 StringBuffer ret = new StringBuffer();
52 for(int i=0; i<s.length(); i++) {
54 if (!(c=='\n' && i==s.length()-1))
56 if (c=='\n' && i<s.length()-1)
59 return ret.toString();