From 07ed21a88d15ab6d7c11858c597eb4fd6b8a76f2 Mon Sep 17 00:00:00 2001 From: adam Date: Sun, 25 Feb 2007 05:38:20 +0100 Subject: [PATCH] tweak box semantics in fleeterpreter to make them have no storage --- src/edu/berkeley/fleet/interpreter/Outbox.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/edu/berkeley/fleet/interpreter/Outbox.java b/src/edu/berkeley/fleet/interpreter/Outbox.java index 4c82c28..25b7f83 100644 --- a/src/edu/berkeley/fleet/interpreter/Outbox.java +++ b/src/edu/berkeley/fleet/interpreter/Outbox.java @@ -6,7 +6,8 @@ import edu.berkeley.fleet.api.Instruction; public class Outbox extends InstructionBenkoBox { /** are we ready to accept another item from the ship? */ - private boolean readyForItemFromShip = true; + private boolean readyForDataFromShip = false; + private boolean haveDataFromShip = false; /** data which has been presented by the ship and is waiting to depart */ private long itemPresentedByShip; @@ -29,14 +30,16 @@ public class Outbox extends InstructionBenkoBox { // check firing conditions if (instruction.tokenIn && triggersReceived <= 0) return false; - if (instruction.dataIn && readyForItemFromShip) return false; + if (instruction.dataIn) { + if (!haveDataFromShip) { readyForDataFromShip = true; return false; } + } // consume trigger if (instruction.tokenIn) triggersReceived--; // consume item if (instruction.dataIn) { - readyForItemFromShip = true; + haveDataFromShip = false; if (instruction.latch) register = itemPresentedByShip; } @@ -57,21 +60,21 @@ public class Outbox extends InstructionBenkoBox { return true; } - public final boolean readyForItemFromShip() { return readyForItemFromShip; } + public final boolean readyForDataFromShip() { return readyForDataFromShip; } public void addDataFromShip(long data) { addItemFromShip(data); } - public boolean readyForDataFromShip() { return readyForItemFromShip(); } public void addDataFromFabric(Packet packet) { triggersReceived++; } /** subclass invokes this to add an item from the ship */ protected final void addItemFromShip(long data) { - if (!readyForItemFromShip) + if (!readyForDataFromShip) throw new RuntimeException("tried to add an item to an outbox which was not ready! you have a buggy ship!"); - readyForItemFromShip = false; + readyForDataFromShip = false; + haveDataFromShip = true; itemPresentedByShip = data; } void shutdown() { - if (!readyForItemFromShip) + if (haveDataFromShip) Log.println(ANSI.red(" WARNING: you left a value ("+itemPresentedByShip+") on outbox port " + this)); if (triggersReceived > 0) Log.println(ANSI.red(" WARNING: you left a token on the trigger input to port " + this)); -- 1.7.10.4