add support for shortcuts in FleetDoc
authoradam <adam@megacz.com>
Fri, 13 Jul 2007 07:47:41 +0000 (08:47 +0100)
committeradam <adam@megacz.com>
Fri, 13 Jul 2007 07:47:41 +0000 (08:47 +0100)
ships/Alu3.ship
ships/BitFifo.ship
src/edu/berkeley/fleet/api/BenkoBox.java
src/edu/berkeley/fleet/doc/BenkoBoxDescription.java
src/edu/berkeley/fleet/doc/ShipDescription.java

index 9a9d95b..40ed9cc 100644 (file)
@@ -6,7 +6,11 @@ data  in:   in2
 data  in:   in3
 
 data  out:  out1
+  shortcut to: in1
 data  out:  out2
+  shortcut to: in2
+data  out:  out3
+  shortcut to: in3
 
 == Constants ========================================================
 == TeX ==============================================================
index feb2c72..90f21ef 100644 (file)
@@ -2,6 +2,7 @@ ship: BitFifo
 
 == Ports ===========================================================
 in:   inEnqueue
+
 in:   inEnqueueOp
   constant rev:      .......................1.............
   constant inv:      ........................1............
@@ -11,6 +12,9 @@ in:   inEnqueueOp
 out:  outDequeue
 in:   inDequeueOp
   
+== Sample Code ======================================================
+
+
 == Constants ========================================================
 
 == TeX ==============================================================
index 7f6cf8e..693087b 100644 (file)
@@ -27,4 +27,7 @@ public abstract class BenkoBox {
     /** default implementation: the empty string */
     public String getDestinationName() { return ""; }
 
+    /** return the BenkoBox which is the destination of this Box's shortcut (if any) */
+    public BenkoBox getShortcut() { return null; }
+
 }            
index 6a01297..990555d 100644 (file)
@@ -9,21 +9,27 @@ public class BenkoBoxDescription implements Iterable<String> {
     public boolean isInbox() { return inbox; }
     public boolean isOutbox() { return !inbox; }
     public boolean tokensOnly() { return tokenOnly; }
+    public String  getShortcut() { return shortcut; }
     public Iterator<String> iterator() { return destinations.iterator(); }
 
     // private //////////////////////////////////////////////////////////////////////////////
 
     private final ShipDescription ship;
+    private final String shortcut;
     private final String name;
     private final boolean inbox;
     private final boolean tokenOnly;
     private ArrayList<String> destinations = new ArrayList<String>();
 
     BenkoBoxDescription(ShipDescription ship, String name, boolean tokenOnly, boolean inbox) {
+        this(ship, name, tokenOnly, inbox, null);
+    }
+    BenkoBoxDescription(ShipDescription ship, String name, boolean tokenOnly, boolean inbox, String shortcut) {
         this.ship = ship;
         this.name = name;
         this.inbox = inbox;
         this.tokenOnly = tokenOnly;
+        this.shortcut = shortcut;
         ship.add(this);
     }
 
index 238128a..4031ce1 100644 (file)
@@ -56,6 +56,7 @@ public class ShipDescription implements Iterable<BenkoBoxDescription> {
         } else if (section.equals("ports")) {
             BufferedReader br = new BufferedReader(new StringReader(sections.get(section)));
             boolean rightSide = false;
+            BenkoBoxDescription p = null;
             for(String s = br.readLine(); s != null; s = br.readLine()) {
                 if (s.trim().length()==0) { rightSide = true; continue; }
 
@@ -71,10 +72,12 @@ public class ShipDescription implements Iterable<BenkoBoxDescription> {
                 else if (key.equals("out"))       { tokenOnly = false;  inbox = false; }
                 else if (key.startsWith("constant")) {
                     continue;
+                } else if (key.startsWith("shortcut to")) {
+                    continue;
                 }
                 else throw new RuntimeException("unknown port type: \""+key+"\"");
 
-                BenkoBoxDescription p = null;
+                p = null;
                 String val = s.substring(s.indexOf(':')+1).trim();
                 String boxname = val.indexOf('.') != -1 ? val.substring(0, val.indexOf('.')) : val;
                 String dest    = val.indexOf('.') != -1 ? val.substring(val.indexOf('.')+1)  : "";