1 package edu.berkeley.fleet.interpreter;
2 import edu.berkeley.sbp.util.ANSI;
3 import edu.berkeley.fleet.api.*;
8 public static boolean ansi_color = true;
9 public static PrintWriter log = new PrintWriter(new OutputStreamWriter(System.out));
10 public static boolean quiet = false;
12 public static void print(Object o) {
13 if (log==null || quiet) return;
16 } catch (Exception e) {
17 throw new RuntimeException(e);
20 public static void println() { println(""); }
21 public static void println(Object o) {
22 if (log==null || quiet) return;
26 } catch (Exception e) {
27 throw new RuntimeException(e);
32 public static void dispatch(Dispatchable d) {
33 println(ANSI.green("dispatch: " + indent(d+"", " ")));
36 public static void dispatch(Instruction d) {
37 println(ANSI.green("dispatch: " + indent(d+"", " ")));
40 public static void data(String data, Dock source, Destination dest) {
41 println((" data: ") + indent(ANSI.purple(data) +
43 (" : " + source))+(" -> "+ANSI.purple(""+dest)), " "));
46 public static void token(Dock source, Destination dest) {
47 println(ANSI.purple(" token: ") + (source + " -> " + ANSI.purple(dest+"")));
50 public static String clreol() { return ""; }
51 public static void error(Object o) { println(ANSI.red(o)); }
53 public static String indent(String s, String indent) {
54 StringBuffer ret = new StringBuffer();
55 for(int i=0; i<s.length(); i++) {
57 if (!(c=='\n' && i==s.length()-1))
59 if (c=='\n' && i<s.length()-1)
62 return ret.toString();