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;
}
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))
public String toString() {
return getDock()+(isInstructionDestination ? ":i" : "");
}
+
}
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))
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;
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() {
((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;
+ }
+
}