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));
11 public static void print(Object o) {
12 if (log==null) return;
15 } catch (Exception e) {
16 throw new RuntimeException(e);
19 public static void println() { println(""); }
20 public static void println(Object o) {
21 if (log==null) return;
25 } catch (Exception e) {
26 throw new RuntimeException(e);
31 public static void dispatch(Dispatchable d) {
32 println(ANSI.green("dispatch: " + indent(d+"", " ")));
35 public static void dispatch(Instruction d) {
36 println(ANSI.green("dispatch: " + indent(d+"", " ")));
39 public static void data(String data, Pump source, Destination dest) {
40 println((" data: ") + indent(ANSI.purple(data) +
42 (" : " + source))+(" -> "+ANSI.purple(""+dest)), " "));
45 public static void token(Pump source, Destination dest) {
46 println(ANSI.purple(" token: ") + (source + " -> " + ANSI.purple(dest+"")));
49 public static String clreol() { return ""; }
50 public static void error(Object o) { println(ANSI.red(o)); }
52 public static String indent(String s, String indent) {
53 StringBuffer ret = new StringBuffer();
54 for(int i=0; i<s.length(); i++) {
56 if (!(c=='\n' && i==s.length()-1))
58 if (c=='\n' && i<s.length()-1)
61 return ret.toString();