throw new RuntimeException("no more ships of type \""+shipType+"\"");
}
+ private long parseSSL(Tree t) {
+ String shipType = name(t.child(0));
+ String portName = name(t.child(1));
+ Ship chosenship = null;
+ for(Ship ship : fleet) {
+ if (ship.getType().equals(shipType)) {
+ chosenship = ship;
+ break;
+ }
+ }
+ Pump chosenport = chosenship.getPump(portName);
+ Tree specs = t.child(2);
+ long literal = 0;
+ for(int i=0; i<specs.size(); i++) {
+ Tree tt = specs.child(i);
+ literal |= chosenport.resolveLiteral(string(tt));
+ }
+ return literal;
+ }
+
void fillCodeBag(Tree<String> t, CodeBag cb) {
if (t.head()==null) return;
else if (t.head().equals("NamedCodeBag")) {
fillCodeBag(statement, cb2);
} else if (t.head().equals("ShipSpecificLiteral")) {
- String shipType = name(t.child(0).child(0));
- String portName = name(t.child(0).child(1));
- Ship chosenship = null;
- for(Ship ship : fleet) {
- if (ship.getType().equals(shipType)) {
- chosenship = ship;
- break;
- }
- }
- Pump chosenport = chosenship.getPump(portName);
- Tree specs = t.child(0).child(2);
- long literal = 0;
- for(int i=0; i<specs.size(); i++) {
- Tree tt = specs.child(i);
- literal |= chosenport.resolveLiteral(string(tt));
- }
+ long literal = parseSSL(t.child(0));
cb.add(new Instruction.Literal.Absolute(portReference(t.child(1)), literal));
} else if (t.head().equals("Literal")) {
else if ("Take".equals(ttt.head())) { dataIn = true; latch = true; }
else if ("SendTo".equals(ttt.head())) { dataOut = true; dest = portReference(ttt.child(0)); }
else if ("LocalLiteral".equals(ttt.head())) { localLiteral = true; literal = Long.parseLong(string(ttt.child(0))); }
+ else if ("LocalLiteralConst".equals(ttt.head())) {
+ localLiteral = true;
+ literal = parseSSL(ttt.child(0));
+ }
else if ("DataOutDest".equals(ttt.head())) { dataOutDest = true; }
else if ("Deliver".equals(ttt.head())) { dataOut = true; }
else if ("Ack".equals(ttt.head())) { tokenOut = true; dest = portReference(ttt.child(0)); }
| Kill:: "kill"
| KillStar:: "kill*"
| Wait:: "wait"
- | Discard:: "dismiss"
- | Take:: ("take"|"receive")
- | SendTo:: "sendto" ws! Port
- | DataOutDest:: "send"
- | Deliver:: "deliver"
- | LocalLiteral:: "literal" ws! int
- | Ack:: "notify" ws! Port
+ | Discard:: "dismiss"
+ | Take:: ("take"|"receive")
+ | SendTo:: "sendto" ws! Port
+ | DataOutDest:: "send"
+ | Deliver:: "deliver"
+ | LocalLiteral:: "literal" ws! int
+ | LocalLiteralConst:: "literal" ws! SSL
+ | Ack:: "notify" ws! Port
Source = Port
| ShipSpecific