From: adam Date: Thu, 1 Mar 2007 13:15:15 +0000 (+0100) Subject: make api.Destination a class rather than an interface X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=cb691390d68a386e88e37d4c627eeec16d58cca2;p=fleet.git make api.Destination a class rather than an interface --- diff --git a/contrib/demo.f0 b/contrib/demo.f0 index a7946f5..824f9e6 100644 --- a/contrib/demo.f0 +++ b/contrib/demo.f0 @@ -11,6 +11,9 @@ main(x -> out) = ;; fifo2.out --> alu.inOp, alu.in1, alu.in2 alu.out --> debug.in + while alu.out > 3 { + 3 --> debug.in + } /* double(a -> out) = diff --git a/src/edu/berkeley/fleet/api/Destination.java b/src/edu/berkeley/fleet/api/Destination.java index c89ae92..3127836 100644 --- a/src/edu/berkeley/fleet/api/Destination.java +++ b/src/edu/berkeley/fleet/api/Destination.java @@ -1,14 +1,14 @@ package edu.berkeley.fleet.api; -public interface Destination { +public abstract class Destination { /** return the Ship to which this BenkoBox belongs */ - public Ship getShip(); + public abstract Ship getShip(); /** * this returns the third component of the name; that is in * "ship.port.foo", it returns "foo", and in "ship.port" it * returns "" */ - public String getDestinationName(); + public abstract String getDestinationName(); } diff --git a/src/edu/berkeley/fleet/interpreter/Inbox.java b/src/edu/berkeley/fleet/interpreter/Inbox.java index a1e4769..f7e5522 100644 --- a/src/edu/berkeley/fleet/interpreter/Inbox.java +++ b/src/edu/berkeley/fleet/interpreter/Inbox.java @@ -72,12 +72,12 @@ public class Inbox extends InstructionBenkoBox { // and make note of the fact that we need to send an ack (if requested) if (instruction.tokenOut) - bufferedAck = new Packet(getInterpreter(), this, 0, (InterpreterBenkoBox)instruction.dest); + bufferedAck = new Packet(getInterpreter(), this, 0, (InterpreterDestination)instruction.dest); } else if (instruction.tokenOut) { // if dataOut is not set, we can send the data immediately - new Packet(getInterpreter(), this, 0, (InterpreterBenkoBox)instruction.dest).send(); + new Packet(getInterpreter(), this, 0, (InterpreterDestination)instruction.dest).send(); } return true; } diff --git a/src/edu/berkeley/fleet/interpreter/InterpreterBenkoBox.java b/src/edu/berkeley/fleet/interpreter/InterpreterBenkoBox.java index f8525c8..88a8815 100644 --- a/src/edu/berkeley/fleet/interpreter/InterpreterBenkoBox.java +++ b/src/edu/berkeley/fleet/interpreter/InterpreterBenkoBox.java @@ -4,7 +4,7 @@ import edu.berkeley.fleet.api.BenkoBox; import java.util.*; /** anything that has a destination address on the switch fabric */ -public abstract class InterpreterBenkoBox extends BenkoBox implements InterpreterDestination { +public abstract class InterpreterBenkoBox extends BenkoBox { private final String name; private final InterpreterShip ship; @@ -17,9 +17,7 @@ public abstract class InterpreterBenkoBox extends BenkoBox implements Interprete this.ports = new Destination[ports.length]; for(int i=0; i getDestinations() { @@ -47,7 +45,7 @@ public abstract class InterpreterBenkoBox extends BenkoBox implements Interprete private static int max_addr; - private class InterpreterBenkoBoxDestination implements InterpreterDestination { + private class InterpreterBenkoBoxDestination extends InterpreterDestination { public String name; public long addr = max_addr++; public InterpreterBenkoBoxDestination(String name) { this.name = name; } diff --git a/src/edu/berkeley/fleet/interpreter/InterpreterDestination.java b/src/edu/berkeley/fleet/interpreter/InterpreterDestination.java index bde33bc..87748bd 100644 --- a/src/edu/berkeley/fleet/interpreter/InterpreterDestination.java +++ b/src/edu/berkeley/fleet/interpreter/InterpreterDestination.java @@ -2,8 +2,8 @@ package edu.berkeley.fleet.interpreter; import edu.berkeley.fleet.api.*; import java.util.*; -interface InterpreterDestination extends Destination { - public long getDestAddr(); - public void addDataFromFabric(Packet packet); - public String getDestinationName(); +abstract class InterpreterDestination extends Destination { + public abstract long getDestAddr(); + public abstract void addDataFromFabric(Packet packet); + public abstract String getDestinationName(); } \ No newline at end of file diff --git a/src/edu/berkeley/fleet/interpreter/Outbox.java b/src/edu/berkeley/fleet/interpreter/Outbox.java index 25b7f83..b6f76eb 100644 --- a/src/edu/berkeley/fleet/interpreter/Outbox.java +++ b/src/edu/berkeley/fleet/interpreter/Outbox.java @@ -54,7 +54,7 @@ public class Outbox extends InstructionBenkoBox { } else if (instruction.tokenOut) { // if no item was sent, we might still send an ack - new Packet(getInterpreter(), this, 0, (InterpreterBenkoBox)instruction.dest).send(); + new Packet(getInterpreter(), this, 0, (InterpreterDestination)instruction.dest).send(); } return true; diff --git a/src/edu/berkeley/fleet/slipway/Slipway.java b/src/edu/berkeley/fleet/slipway/Slipway.java index bd7d781..a27e165 100644 --- a/src/edu/berkeley/fleet/slipway/Slipway.java +++ b/src/edu/berkeley/fleet/slipway/Slipway.java @@ -423,14 +423,7 @@ public class Slipway extends Fleet { public void writeInstruction(DataOutputStream os, Instruction d) throws IOException { iie.writeInstruction(os, d); } private class SlipwayInstructionEncoder extends InstructionEncoder { - public long getDestAddr(Destination box) { - long ret; - if (box instanceof SlipwayBenkoBox) - ret = ((SlipwayBenkoBox)box).addr; - else - ret = ((SlipwayBenkoBox.VirtualPort)box).addr; - return ret; - } + public long getDestAddr(Destination box) { return ((SlipwayBenkoBox.VirtualPort)box).addr; } public long getBoxInstAddr(BenkoBox box) { return ((SlipwayBenkoBox)box).instr_addr; } public Destination getDestByAddr(long dest) { for(Ship ship : Slipway.this) diff --git a/src/edu/berkeley/fleet/slipway/SlipwayBenkoBox.java b/src/edu/berkeley/fleet/slipway/SlipwayBenkoBox.java index fb6082d..a43a659 100644 --- a/src/edu/berkeley/fleet/slipway/SlipwayBenkoBox.java +++ b/src/edu/berkeley/fleet/slipway/SlipwayBenkoBox.java @@ -59,7 +59,7 @@ public class SlipwayBenkoBox extends BenkoBox { ports = newports; } - public class VirtualPort implements Destination { + public class VirtualPort extends Destination { public String name; public VirtualPort(String name) { this.name = name; } public String getDestinationName() { return name; }