make fields of interpreter.Packet private, add access methods
authormegacz <adam@megacz.com>
Thu, 8 Jan 2009 02:54:07 +0000 (18:54 -0800)
committermegacz <adam@megacz.com>
Thu, 8 Jan 2009 02:54:07 +0000 (18:54 -0800)
src/edu/berkeley/fleet/interpreter/DebugDock.java
src/edu/berkeley/fleet/interpreter/InterpreterDestination.java
src/edu/berkeley/fleet/interpreter/InterpreterDock.java
src/edu/berkeley/fleet/interpreter/Packet.java

index 4323a24..e286ea5 100644 (file)
@@ -31,9 +31,9 @@ public class DebugDock {
     public Queue<BitVector> getDataDestPackets() {
         Queue<BitVector> values = new LinkedList<BitVector>();
         for (Packet p : dock.dataDestination.packets) {
-            if (p.isToken)
+            if (p.isToken())
                 continue;
-            values.add(p.value);
+            values.add(p.getValue());
         }
         return values;
     }
@@ -41,10 +41,10 @@ public class DebugDock {
         Queue<Instruction> instr = new LinkedList<Instruction>();
 
         for (Packet p : dock.instructionDestination.packets) {
-            if (p.isToken)
+            if (p.isToken())
                 continue;
 
-            BitVector bv = p.value;
+            BitVector bv = p.getValue();
             long val = 0;
             for(int i=0; i<bv.length(); i++)
                 if (bv.get(i))
index 0646c7b..e30a161 100644 (file)
@@ -29,4 +29,5 @@ class InterpreterDestination extends Destination {
     public String toString() {
         return getDock()+(isInstructionDestination ? ":i" : "");
     }
+
 }
index 296be98..c8a9002 100644 (file)
@@ -94,11 +94,11 @@ class InterpreterDock extends FleetTwoDock {
 
         if (instructionDestination.packets.size() > 0) {
             Packet p = instructionDestination.packets.remove();
-            if (p.isToken) {
+            if (p.isToken()) {
                 if (torpedoWaiting) throw new RuntimeException("two torpedoes collided!");
                 torpedoWaiting = true;
             } else {
-                BitVector bv = p.value;
+                BitVector bv = p.getValue();
                 long val = 0;
                 for(int i=0; i<bv.length(); i++)
                     if (bv.get(i))
@@ -274,14 +274,14 @@ class InterpreterDock extends FleetTwoDock {
         Packet p = null;
         if (move.tokenIn) {
             p = dataDestination.packets.remove();
-            if (p.path.signal != null) flag_c = p.path.signal.get(0);
+            if (p.getSignal() != null) flag_c = p.getSignal().get(0);
         }
         if (move.dataIn) {
             BitVector bv = null;
             if (isInputDock()) {
                 p = dataDestination.packets.remove();
-                bv = new BitVector(p.value);
-                if (p.path.signal != null) flag_c = p.path.signal.get(0);
+                bv = new BitVector(p.getValue());
+                if (p.getSignal() != null) flag_c = p.getSignal().get(0);
             } else {
                 bv = new BitVector(getInterpreter().getWordWidth()).set(dataFromShip);
                 readyForDataFromShip = true;
index 60a69e7..5f44da2 100644 (file)
@@ -3,14 +3,15 @@ import edu.berkeley.fleet.api.*;
 
 class Packet {
 
-    InterpreterPath path;
-    BitVector value;
-    boolean isToken;
+    private final InterpreterPath path;
+    private final BitVector value;
+    private final boolean isToken;
 
     public Packet(InterpreterPath path, BitVector value, boolean isToken) {
         this.value = value;
         this.path = path;
         this.isToken = isToken;
+        this.value.setImmutable();
     }
 
     public void send() {
@@ -22,4 +23,20 @@ class Packet {
         ((InterpreterDestination)path.getDestination()).addDataFromFabric(this);
     }
 
+    public Destination getDestination() {
+        return path.getDestination();
+    }
+
+    public BitVector getSignal() {
+        return path.getSignal();
+    }
+
+    public BitVector getValue() {
+        return value;
+    }
+
+    public boolean isToken() {
+        return isToken;
+    }
+
 }