}
}
- private long parseSSL(Tree t) {
+ private BitVector parseSSL(Tree t) {
String shipType = name(t.child(0));
String portName = name(t.child(1));
Ship chosenship = null;
Dock chosenport = chosenship.getDock(portName);
Tree specs = t.child(2);
long literal = 0;
- for(int i=0; i<specs.size(); i++) {
- Tree tt = specs.child(i);
- literal |= resolveLiteral(chosenport, stringBody(tt));
- }
- return literal;
+ if (specs.size() != 1) throw new RuntimeException("multiple constants not supported");
+ Tree tt = specs.child(0);
+ return resolveLiteral(chosenport, stringBody(tt));
}
- private static long resolveLiteral(Dock dd, String s) {
+ private static BitVector resolveLiteral(Dock dd, String s) {
long val = 0;
long ret = 0;
boolean hasval = false;
s = s.substring(0, s.indexOf('='));
hasval = true;
}
- ShipDescription.Constant c = ((FleetTwoDock)dd).getDockConstant(s);
- if (c==null) throw new RuntimeException("no constant " + s + " on dock " + dd);
- ret |= c.setbits;
- ret &= ~c.clearbits;
- if (hasval)
- ret |= ((~(0xffffffffffffffffL << c.numberWidth)) & val) << c.numberOffset;
- return ret;
+ return ((FleetTwoDock)dd).getDockConstant(s);
}
private static FlagFunction parseFlags(Tree<String> t) {
cb.add(new Abort(dock, predicate));
continue;
} else if ("word".equals(tt.head())) {
- long literal = 0;
+ BitVector literal = null;
if (tt.child(0).head().equals("CodeBagBody")) {
Tree<String> tq = tt;
CodeBag cb2 = getCodeBag("anon"+(anoncount++));
} else if (tt.child(0).head().equals("[")) {
literal = parseSSL(tt.child(0));
} else {
- literal = number(tt.child(0));
+ literal = new BitVector(dock.getShip().getFleet().getWordWidth()).set(number(tt.child(0)));
}
count = 1;
- /*
- if ("int".equals(tt.child(1).head())) {
- count = (int)number(tt.child(1));
- } else if ("forever".equals(tt.child(1).head())) {
- count = 0;
- }
- */
-
if (((FleetTwoFleet)fleet).isSmallEnoughToFit(literal)) {
- cb.add(new Set(dock, predicate, SetDest.DataLatch, (literal)));
+ cb.add(new Set(dock, predicate, SetDest.DataLatch, literal.toLong()));
} else {
int counter = 0;
while(counter < dock.getShip().getFleet().getWordWidth()) counter += fleet.getShiftWidth();
- while(counter > 0) {
- cb.add(new Shift(dock, predicate,
- new BitVector(dock.getShip().getFleet().getShiftWidth())
- .set(getField(counter-1, counter-fleet.getShiftWidth(), literal))));
+ while(true) {
counter -= fleet.getShiftWidth();
+ if (counter < 0) break;
+ BitVector bv = new BitVector(dock.getShip().getFleet().getShiftWidth());
+ for(int i=0; i<fleet.getShiftWidth(); i++)
+ bv.set(i, literal.get(counter+i));
+ cb.add(new Shift(dock, predicate, bv));
}
}