writer.addDeclaration("struct SimpleIterator",x.getSafeSymbol()+"_iterator");
writer.outputline("for (SimpleHashiterator("+relation.getSafeSymbol()+"_hash, &"+x.getSafeSymbol()+"_iterator); hasNext(&"+x.getSafeSymbol()+"_iterator); )");
writer.startblock();
- writer.addDeclaration(y.getType().getGenerateType().toString(), y.getSafeSymbol());
- writer.outputline(y.getSafeSymbol() + " = (" + y.getType().getGenerateType() + ") next(&"+x.getSafeSymbol()+"_iterator);");
- // #ATTN#: key is called second because next() forwards ptr and key does not!
- writer.addDeclaration(x.getType().getGenerateType().toString(), x.getSafeSymbol());
+ // #ATTN#: key is called first because next() forwards ptr and key does not!
+ writer.addDeclaration(x.getType().getGenerateType().toString(), x.getSafeSymbol());
writer.outputline(x.getSafeSymbol() + " = (" + x.getType().getGenerateType() + ") key(&"+x.getSafeSymbol()+"_iterator);");
+
+ writer.addDeclaration(y.getType().getGenerateType().toString(), y.getSafeSymbol());
+ writer.outputline(y.getSafeSymbol() + " = (" + y.getType().getGenerateType() + ") next(&"+x.getSafeSymbol()+"_iterator);");
+
}
public void generate_open(CodeWriter writer, String type,int number, String left,String right) {
writer.endblock();
writer.outputline("else");
writer.startblock();
- writer.outputline(y.getSafeSymbol() + " = (" + y.getType().getGenerateType() + ") next(&"+x.getSafeSymbol()+"_iterator);");
writer.outputline(x.getSafeSymbol() + " = (" + x.getType().getGenerateType() + ") key(&"+x.getSafeSymbol()+"_iterator);");
+ writer.outputline(y.getSafeSymbol() + " = (" + y.getType().getGenerateType() + ") next(&"+x.getSafeSymbol()+"_iterator);");
writer.endblock();
}
cr.endblock();
}
+ Iterator reliterator = state.stRelations.descriptors();
+ while (reliterator.hasNext()) {
+ RelationDescriptor rd = (RelationDescriptor) reliterator.next();
+
+
+ String relname = rd.getSafeSymbol();
+ if (rd.testUsage(RelationDescriptor.IMAGE)) {
+ cr.startblock();
+ cr.outputline("/* printing relation " + relname+"*/");
+ cr.outputline("printf(\"\\nPrinting relation " + rd.getSymbol() + " - %d elements \\n\", SimpleHashcountset("+relname+"_hash));");
+ cr.addDeclaration("struct SimpleIterator","__reliterator");
+ cr.outputline("SimpleHashiterator("+relname+"_hash,&__reliterator);");
+ cr.outputline("while (hasNext(&__reliterator))");
+ cr.startblock();
+ cr.addDeclaration("int","__relval");
+ cr.addDeclaration("int","__relval2");
+ cr.outputline("__relval2 = (int) key(&__reliterator);");
+ cr.outputline("__relval = (int) next(&__reliterator);");
+
+ cr.outputline("printf(\"<%ld,%ld> \", __relval2,__relval);");
+
+ cr.endblock();
+ cr.endblock();
+ } else if (rd.testUsage(RelationDescriptor.INVIMAGE)) {
+ cr.startblock();
+ cr.outputline("/* printing inv relation " + relname+"*/");
+ cr.outputline("printf(\"\\nPrinting relation using inv" + rd.getSymbol() + " - %d elements \\n\", SimpleHashcountset("+relname+"_hash));");
+ cr.addDeclaration("struct SimpleIterator","__reliterator");
+ cr.outputline("SimpleHashiterator("+relname+"_hashinv,&__reliterator);");
+ cr.outputline("while (hasNext(&__reliterator))");
+ cr.startblock();
+ cr.addDeclaration("int","__relval");
+ cr.addDeclaration("int","__relval2");
+ cr.outputline("__relval2 = (int) key(&__reliterator);");
+ cr.outputline("__relval = (int) next(&__reliterator);");
+
+
+ cr.outputline("printf(\"<%ld,%ld> \", __relval,__relval2);");
+
+ cr.endblock();
+ cr.endblock();
+ }
+
+ }
+
cr.outputline("printf(\"\\n\\n------------------- END PRINTING\\n\");");
}