import edu.berkeley.sbp.util.*;
import java.util.*;
import java.io.*;
-import static edu.berkeley.fleet.Instruction.IgnoreCopyTake.*;
/**
* @author Adam Megacz <megacz@cs.berkeley.edu>
dump_code = true;
continue;
- } else if (s[i].startsWith("--inboxes=")) {
- String val = s[i].substring(s[i].indexOf('=')+1);
- if (val.equals("configured")) {
- DataInbox.defaultInstruction =
- new Instruction(null, null, Integer.MAX_VALUE, TAKE, false, false, true);
- continue;
- } else if (val.equals("unconfigured")) {
- DataInbox.defaultInstruction = null;
- continue;
- }
} else if (s[i].startsWith("--memory=")) {
String val = s[i].substring(s[i].indexOf('=')+1);
if (val.equals("hide")) {
for(Tree<String> statement : t.child(1))
fillCodeBag(statement, cb2);
- } else if (t.head().equals("Instruction")) {
- Tree<String> opcode = t.child(0);
- boolean trigger = opcode != null && opcode.size()>0 && "Triggered".equals(opcode.child(0).head());
+ } else if (t.head().equals("Literal")) {
+ int literal = Integer.parseInt(string(t.child(0)));
+ PortReference benkobox = portReference(t.child(1));
+ cb.add(new Literal.LiteralDatum(literal, benkobox, false, 1));
- int count = 0;
- Tree arrow = t.child(2);
- if (arrow.head().equals("->")) count = 1;
- else if (arrow.head().equals("-[*]->")) count = Integer.MAX_VALUE;
- else if (arrow.head().equals("-[")) count = Integer.parseInt(string(arrow.child(0)));
-
- Tree opcodebody = opcode.size()==0 ? null : opcode.child(0).child(opcode.size()-1);
+ } else if (t.head().equals("Fiber")) {
+ PortReference benkobox = portReference(t.child(0));
- PortReference d = portReference(t.child(3));
+ for(Tree tt : t.child(1)) {
+ int count = 1;
+ Tree ttx = null;
+ if (tt.size() > 1 && tt.child(0).size()>0) {
+ System.out.println(tt.child(0));
+ if (tt.child(0).size() > 0 && "Star".equals(tt.child(0).child(0).head())) count=Integer.MAX_VALUE;
+ else count = Integer.parseInt(string(tt.child(0)));
+ }
+ ttx = tt.child(1);
+ boolean tokenIn = false;
+ boolean dataIn = false;
+ boolean latch = false;
+ boolean dataOut = false;
+ boolean tokenOut = false;
+ PortReference dest = null;
+ for(int i=0; i<ttx.size(); i++) {
+ Tree ttt = ttx.child(i);
+ if ("Wait".equals(ttt.head())) { tokenIn = true; }
+ else if ("Discard".equals(ttt.head())) { dataIn = true; latch = false; }
+ 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 ("Accept".equals(ttt.head())) { dataOut = true; }
+ else if ("Ack".equals(ttt.head())) { tokenOut = true; dest = portReference(ttt.child(0)); }
+ }
+ cb.add(new Instruction(benkobox, dest, count, dataIn, latch, tokenOut, tokenIn, dataOut));
+ }
+ }
+ /*
if (t.child(1).head() == null) {
int literal = Integer.parseInt(string(t.child(1)));
cb.add(new Literal.LiteralDatum(literal, d, false, count));
} else if ("ShipSpecific".equals(t.child(1).head())) {
cb.add(new Literal.ShipSpecific(string(t.child(1).child(0)), d, count));
-
- } else {
- PortReference s = portReference(t.child(1));
- Instruction inst = null;
- if (opcodebody==null) inst = new Instruction(s, d, count, TAKE, false, trigger, true);
- else if (opcodebody.head().equals("nop")) inst = new Instruction(s, d, count, IGNORE, false, trigger, false);
- else if (opcodebody.head().equals("synthesize")) inst = new Instruction(s, d, count, IGNORE, false, trigger, true);
- else if (opcodebody.head().equals("synthesize+ack")) inst = new Instruction(s, d, count, IGNORE, true, trigger, true);
- else if (opcodebody.head().equals("wait")) inst = new Instruction(s, d, count, COPY, false, trigger, false);
- else if (opcodebody.head().equals("discard")) inst = new Instruction(s, d, count, TAKE, false, trigger, false);
- else if (opcodebody.head().equals("nop+ack")) inst = new Instruction(s, d, count, IGNORE, true, trigger, false);
- else if (opcodebody.head().equals("wait+ack")) inst = new Instruction(s, d, count, COPY, true, trigger, false);
- else if (opcodebody.head().equals("discard+ack")) inst = new Instruction(s, d, count, TAKE, true, trigger, false);
- else if (opcodebody.head().equals("copy")) inst = new Instruction(s, d, count, COPY, false, trigger, true);
- else if (opcodebody.head().equals("copy+ack")) inst = new Instruction(s, d, count, COPY, true, trigger, true);
- else if (opcodebody.head().equals("move")) inst = new Instruction(s, d, count, TAKE, false, trigger, true);
- else if (opcodebody.head().equals("move+ack")) inst = new Instruction(s, d, count, TAKE, true, trigger, true);
- else if (opcodebody.head().equals("accept")) inst = new Instruction(s, d, count, TAKE, false, trigger, true);
- else if (opcodebody.head().equals("accept+ack")) inst = new Instruction(s, d, count, TAKE, true, trigger, true);
- cb.add(inst);
- }
- }
+ */
}
-
}