better error reporting on invalid instructions
authoradam <adam@megacz.com>
Tue, 28 Aug 2007 00:25:09 +0000 (01:25 +0100)
committeradam <adam@megacz.com>
Tue, 28 Aug 2007 00:25:09 +0000 (01:25 +0100)
src/edu/berkeley/fleet/api/Instruction.java

index 55e2b52..0e03bf1 100644 (file)
@@ -73,6 +73,12 @@ public abstract class Instruction {
             this.ignoreUntilLast = ignoreUntilLast;
             if (count < 0)
                 throw new RuntimeException("count field of an instruction must be >=0");
+            if (pump.isInbox() && tokenIn && dataIn)
+                throw new RuntimeException("cannot have both \"wait\" and \"take\"/\"recieve\" on an inbox: " + this);
+            if (pump.isOutbox() && tokenOut && dataOut)
+                throw new RuntimeException("cannot have both \"sendto\" and \"notify\" on an outbox: " + this);
+            if (latch && !dataIn)
+                throw new RuntimeException("cannot have latch bit set without dataIn bit: " + this);
         }
 
         public boolean isStanding() {