add kill*
[fleet.git] / src / edu / berkeley / fleet / api / Instruction.java
index f72fcec..263c40b 100644 (file)
@@ -6,7 +6,12 @@ public abstract class Instruction {
 
         public final BenkoBox benkoBox;
         public final int      count;
-        public Kill(BenkoBox benkoBox, int count) { this.benkoBox=benkoBox; this.count=count; }
+        public final boolean  killOnlyStandingInstructions;
+        public Kill(BenkoBox benkoBox, int count, boolean killOnlyStandingInstructions) {
+            this.benkoBox=benkoBox;
+            this.count=count;
+            this.killOnlyStandingInstructions = killOnlyStandingInstructions;
+        }
         public String toString() { return (count>1 ? "["+count+"] " : "") + "kill"; }
 
     }
@@ -47,6 +52,10 @@ public abstract class Instruction {
                 throw new RuntimeException("count field of an instruction must be >=0");
         }
 
+        public boolean isStanding() {
+            return count==0;
+        }
+
         public Instruction.Executable decrementCount() {
             if (count==1) return null;
             return new Executable(benkoBox, dest, count==0 ? 0 : count-1,
@@ -54,7 +63,7 @@ public abstract class Instruction {
         }
 
         public String toString() {
-            String ret = "";
+            String ret = benkoBox.toString() + ": ";
             if (count==0 || count>1 || recycle) {
                 ret += "[";
                 if (count>1) ret += count;
@@ -86,15 +95,20 @@ public abstract class Instruction {
         public static class Absolute extends Literal {
             public final long value;
             public Absolute(BenkoBox dest, long value) { super(dest); this.value = value; }
-            public String toString() { return value + ": sendto " + dest; }
+            public String toString() {
+                return value + ": sendto " + dest;
+            }
         }
 
         public static class Relative extends Literal {
             /** value transmitted will be offset plus the address from which this instruction was loaded */
             public final long offset;
             public Relative(BenkoBox dest, long offset) { super(dest); this.offset = offset; }
-            // FIXME: not final form!
-            public String toString() { return "(relative "+offset+"): sendto " + dest; }
+            public String toString() {
+                String off = ""+offset;
+                if (offset > 0) off = "+"+off;
+                return "(@"+offset+"): sendto " + dest;
+            }
         }
 
         public static class CodeBagDescriptor extends Literal {
@@ -103,8 +117,11 @@ public abstract class Instruction {
             public final long size;
             public CodeBagDescriptor(BenkoBox dest, long offset, long size) {
                 super(dest); this.offset = offset; this.size = size; }
-            // FIXME: not final form!
-            public String toString() { return "(CBD "+offset+":"+size+"): sendto " + dest; }
+            public String toString() {
+                String off = ""+offset;
+                if (offset > 0) off = "+"+off;
+                return "(@"+off+":"+size+"): sendto " + dest;
+            }
         }
     }
 }