improve Instruction.toString() method
authoradam <adam@megacz.com>
Sun, 7 Sep 2008 06:10:23 +0000 (07:10 +0100)
committeradam <adam@megacz.com>
Sun, 7 Sep 2008 06:10:23 +0000 (07:10 +0100)
src/edu/berkeley/fleet/api/Instruction.java

index 5a8fd7a..014f4d8 100644 (file)
@@ -27,7 +27,7 @@ public abstract class Instruction {
     public String toString() {
         String s = predicate.toString();
         if (s.length()>0) s = "["+s+"] ";
-        if (looping) s += "[L] ";
+        if (looping) s += "[Rq] ";
         return dock+": "+s;
     }
 
@@ -193,28 +193,18 @@ public abstract class Instruction {
             switch(dest) {
                 case InnerLoopCounter:
                     switch(source) {
-                        /*
-                        case Infinity: return super.toString()+"set ilc=*";
-                        case DataLatch: return super.toString()+"set ilc=data";
-                        case Immediate: return super.toString()+"set ilc="+immediate;
-                        */
-                        case Infinity: return super.toString()+"load repeat counter with *;";
-                        case DataLatch: return super.toString()+"set ilc=data";
-                        case Immediate: return super.toString()+"load repeat counter with "+immediate+";";
+                        case Infinity: return super.toString()+"set ilc=*;";
+                        case DataLatch: return super.toString()+"set ilc=data;";
+                        case Immediate: return super.toString()+"set ilc="+immediate+";";
                     }
                 case OuterLoopCounter:
                     switch(source) {
-                        /*
-                        case Decrement: return super.toString()+"set olc--";
-                        case DataLatch: return super.toString()+"set olc=data";
-                        case Immediate: return super.toString()+"set olc="+immediate;
-                        */
-                        case Decrement: return super.toString()+"decrement loop counter;";
+                        case Decrement: return super.toString()+"set olc--;";
                         case DataLatch: return super.toString()+"set olc=data;";
-                        case Immediate: return super.toString()+"load loop counter with "+immediate+";";
+                        case Immediate: return super.toString()+"set olc="+immediate+";";
                     }
-                case Flags: return super.toString()+"set flags a="+newFlagA+" b="+newFlagB;
-                case DataLatch: return super.toString()+"literal "+immediate+";";
+                case Flags: return super.toString()+"set flags a="+newFlagA+", b="+newFlagB+";";
+                case DataLatch: return super.toString()+"set word="+immediate+";";
             }
             throw new Error("impossible");
         }
@@ -291,9 +281,9 @@ public abstract class Instruction {
             this.tokenOut = tokenOut;
             this.interruptible = interruptible;
             if (dock != null && dock.isInputDock() && tokenIn && dataIn)
-                throw new RuntimeException("cannot have both \"wait\" and \"take\"/\"recieve\" on an input dock: " + this);
+                throw new RuntimeException("cannot have two \"recv\"s: " + this);
             if (dock != null && dock.isOutputDock() && tokenOut && dataOut)
-                throw new RuntimeException("cannot have both \"sendto\" and \"notify\" on an output dock: " + this);
+                throw new RuntimeException("cannot have two \"send\"s: " + this);
             if (latchData && !dataIn)
                 throw new RuntimeException("cannot have latchData bit set without dataIn bit: " + this);
             if (latchPath && !dataIn)
@@ -304,15 +294,15 @@ public abstract class Instruction {
 
         public String toString() {
             StringBuffer ret = new StringBuffer();
-            if (tokenIn)                        ret.append(", wait");
+            if (tokenIn)                        ret.append(", recv token");
             if (dataIn) {
                 if (latchPath)                  ret.append(!dock.isInputDock() ? ", collect path" : ", recv path");
                 if (latchData)                  ret.append(!dock.isInputDock() ? ", collect"      : ", recv");
                 if (!latchPath && !latchData)   ret.append(", discard");
             }
             if (dataOut && dock.isInputDock())  ret.append(", deliver");
-            if (dataOut && !dock.isInputDock()) ret.append(path==null ? ", send"  : ", sendto "  + path.getDestination().getDock());
-            if (tokenOut)                       ret.append(path==null ? ", token" : ", notify " + path.getDestination().getDock());
+            if (dataOut && !dock.isInputDock()) ret.append(path==null ? ", send"  : ", send to "  + path.getDestination().getDock());
+            if (tokenOut)                       ret.append(path==null ? ", token" : ", send token to " + path.getDestination().getDock());
             String s = ret.toString();
             s = s.equals("") ? "nop" : s.substring(2);
             if (interruptible) s = "[T] " + s;
@@ -323,7 +313,7 @@ public abstract class Instruction {
     /** marks the end of a loop; closes the hatch */
     public static class Tail extends Instruction {
         public Tail(Dock dock) { super(dock, false, Predicate.IgnoreOLC); }
-        public String toString() { return super.toString() + "tail;"; }
+        public String toString() { return dock+": tail;"; }
     }
 
 }