5 public class RelationQuantifier extends Quantifier {
7 RelationDescriptor relation;
8 VarDescriptor x, y; // y = x.relation
10 public RelationQuantifier() {}
12 public void setRelation(RelationDescriptor rd) {
16 public void setTuple(VarDescriptor x, VarDescriptor y) {
21 public Set getRequiredDescriptors() {
22 HashSet v = new HashSet();
27 public String toString() {
28 return "relation quantifier <" + x.getSymbol() + "," + y.getSymbol() + "> in " + relation.getSymbol();
31 public void generate_open(CodeWriter writer) {
32 writer.outputline("for (SimpleIterator* " + x.getSafeSymbol() + "_iterator = " + relation.getSafeSymbol() + "_hash->iterator(); " + x.getSafeSymbol() + "_iterator->hasNext(); )");
34 writer.outputline(y.getType().getSafeSymbol() + " " + y.getSafeSymbol() + " = (" + y.getType().getSafeSymbol() + ") " + x.getSafeSymbol() + "_iterator->next();");
35 // #ATTN#: key is called second because next() forwards ptr and key does not!
36 writer.outputline(x.getType().getSafeSymbol() + " " + x.getSafeSymbol() + " = (" + x.getType().getSafeSymbol() + ") " + x.getSafeSymbol() + "_iterator->key();");
39 public int generate_worklistload(CodeWriter writer, int offset) {
40 String varx = x.getSafeSymbol();
41 String vary = y.getSafeSymbol();
42 writer.outputline("int " + varx + " = wi->word" + offset + "; // r1");
43 writer.outputline("int " + vary + " = wi->word" + (offset + 1) + "; //r2");
47 public int generate_workliststore(CodeWriter writer, int offset) {
48 String varx = x.getSafeSymbol();
49 String vary = y.getSafeSymbol();
50 writer.outputline("wi->word" + offset + " = " + varx + "; // r1");
51 writer.outputline("wi->word" + (offset+1) + " = " + vary + "; // r2");