projects
/
fleet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
add initial support for virtual destinations
[fleet.git]
/
src
/
edu
/
berkeley
/
fleet
/
api
/
Instruction.java
diff --git
a/src/edu/berkeley/fleet/api/Instruction.java
b/src/edu/berkeley/fleet/api/Instruction.java
index
9e7dc14
..
5b89965
100644
(file)
--- a/
src/edu/berkeley/fleet/api/Instruction.java
+++ b/
src/edu/berkeley/fleet/api/Instruction.java
@@
-6,16
+6,21
@@
public abstract class Instruction {
public final BenkoBox benkoBox;
public final int count;
public final BenkoBox benkoBox;
public final int count;
- public Kill(BenkoBox benkoBox, int count) { this.benkoBox=benkoBox; this.count=count; }
+ public final boolean killOnlyStandingInstructions;
+ public Kill(BenkoBox benkoBox, int count, boolean killOnlyStandingInstructions) {
+ this.benkoBox=benkoBox;
+ this.count=count;
+ this.killOnlyStandingInstructions = killOnlyStandingInstructions;
+ }
public String toString() { return (count>1 ? "["+count+"] " : "") + "kill"; }
}
public static class Executable extends Instruction {
public String toString() { return (count>1 ? "["+count+"] " : "") + "kill"; }
}
public static class Executable extends Instruction {
- public final BenkoBox benkoBox;
- public final BenkoBox dest;
- public final int count;
+ public final BenkoBox benkoBox;
+ public final Destination dest;
+ public final int count;
public final boolean tokenIn;
public final boolean dataIn;
public final boolean tokenIn;
public final boolean dataIn;
@@
-25,15
+30,15
@@
public abstract class Instruction {
public final boolean recycle;
/** count=0 denotes a standing move */
public final boolean recycle;
/** count=0 denotes a standing move */
- public Executable(BenkoBox benkoBox,
- BenkoBox dest,
- int count,
- boolean tokenIn,
- boolean dataIn,
- boolean latch,
- boolean dataOut,
- boolean tokenOut,
- boolean recycle) {
+ public Executable(BenkoBox benkoBox,
+ Destination dest,
+ int count,
+ boolean tokenIn,
+ boolean dataIn,
+ boolean latch,
+ boolean dataOut,
+ boolean tokenOut,
+ boolean recycle) {
this.benkoBox = benkoBox;
this.dest = dest;
this.count = count;
this.benkoBox = benkoBox;
this.dest = dest;
this.count = count;
@@
-47,24
+52,34
@@
public abstract class Instruction {
throw new RuntimeException("count field of an instruction must be >=0");
}
throw new RuntimeException("count field of an instruction must be >=0");
}
+ public boolean isStanding() {
+ return count==0;
+ }
+
public Instruction.Executable decrementCount() {
if (count==1) return null;
public Instruction.Executable decrementCount() {
if (count==1) return null;
- return new Executable(benkoBox, dest, count==0 ? 0 : count-0, tokenIn, dataIn, latch, dataOut, tokenOut, recycle);
+ return new Executable(benkoBox, dest, count==0 ? 0 : count-1,
+ tokenIn, dataIn, latch, dataOut, tokenOut, recycle);
}
public String toString() {
}
public String toString() {
- String ret = "";
+ String ret = benkoBox.toString() + ": ";
if (count==0 || count>1 || recycle) {
if (count==0 || count>1 || recycle) {
- ret += "[";
+ ret += recycle ? "(" : "[";
if (count>1) ret += count;
if (count==0) ret += "*";
if (count>1) ret += count;
if (count==0) ret += "*";
- if (recycle) ret += "r";
- ret += "] ";
+ ret += recycle ? ")" : "] ";
}
boolean needcomma = false;
if (tokenIn) { ret += (needcomma ? ", " : "") + "wait"; needcomma = true; }
}
boolean needcomma = false;
if (tokenIn) { ret += (needcomma ? ", " : "") + "wait"; needcomma = true; }
- if (dataIn && latch) { ret += (needcomma ? ", " : "") + "take"; needcomma = true; }
- if (dataIn && !latch) { ret += (needcomma ? ", " : "") + "discard"; needcomma = true; }
+ if (dataIn && latch) {
+ if (benkoBox instanceof BenkoBox.Inbox)
+ ret += (needcomma ? ", " : "") + "receive";
+ else
+ ret += (needcomma ? ", " : "") + "take";
+ needcomma = true;
+ }
+ if (dataIn && !latch) { ret += (needcomma ? ", " : "") + "dismiss"; needcomma = true; }
if (dataOut) {
if (benkoBox instanceof BenkoBox.Inbox || dest==null)
ret += (needcomma ? ", " : "") + "deliver";
if (dataOut) {
if (benkoBox instanceof BenkoBox.Inbox || dest==null)
ret += (needcomma ? ", " : "") + "deliver";
@@
-72,38
+87,46
@@
public abstract class Instruction {
ret += (needcomma ? ", " : "") + "sendto "+dest;
needcomma = true;
}
ret += (needcomma ? ", " : "") + "sendto "+dest;
needcomma = true;
}
- if (tokenOut) { ret += (needcomma ? ", " : "") + "ack "+dest; needcomma = true; }
+ if (tokenOut) { ret += (needcomma ? ", " : "") + "notify "+dest; needcomma = true; }
return ret;
}
}
public static class Literal extends Instruction {
return ret;
}
}
public static class Literal extends Instruction {
- public final BenkoBox dest;
- protected Literal(BenkoBox dest) { this.dest = dest; }
+ public final Destination dest;
+ protected Literal(Destination dest) { this.dest = dest; }
public static class Absolute extends Literal {
public final long value;
public static class Absolute extends Literal {
public final long value;
- public Absolute(BenkoBox dest, long value) { super(dest); this.value = value; }
- public String toString() { return value + ": sendto " + dest; }
+ public Absolute(Destination dest, long value) { super(dest); this.value = value; }
+ public String toString() {
+ return value + ": sendto " + dest;
+ }
}
public static class Relative extends Literal {
/** value transmitted will be offset plus the address from which this instruction was loaded */
public final long offset;
}
public static class Relative extends Literal {
/** value transmitted will be offset plus the address from which this instruction was loaded */
public final long offset;
- public Relative(BenkoBox dest, long offset) { super(dest); this.offset = offset; }
- // FIXME: not final form!
- public String toString() { return "(relative "+offset+"): sendto " + dest; }
+ public Relative(Destination dest, long offset) { super(dest); this.offset = offset; }
+ public String toString() {
+ String off = ""+offset;
+ if (offset > 0) off = "+"+off;
+ return "(@"+offset+"): sendto " + dest;
+ }
}
public static class CodeBagDescriptor extends Literal {
/** address of CBD, relative to address that this instruction was loaded from */
public final long offset;
public final long size;
}
public static class CodeBagDescriptor extends Literal {
/** address of CBD, relative to address that this instruction was loaded from */
public final long offset;
public final long size;
- public CodeBagDescriptor(BenkoBox dest, long offset, long size) {
+ public CodeBagDescriptor(Destination dest, long offset, long size) {
super(dest); this.offset = offset; this.size = size; }
super(dest); this.offset = offset; this.size = size; }
- // FIXME: not final form!
- public String toString() { return "(CBD "+offset+":"+size+"): sendto " + dest; }
+ public String toString() {
+ String off = ""+offset;
+ if (offset > 0) off = "+"+off;
+ return "(@"+off+":"+size+"): sendto " + dest;
+ }
}
}
}
}
}
}