Quantifier bugs.
authorbdemsky <bdemsky>
Sun, 2 Oct 2005 06:20:16 +0000 (06:20 +0000)
committerbdemsky <bdemsky>
Sun, 2 Oct 2005 06:20:16 +0000 (06:20 +0000)
Repair/RepairCompiler/MCC/IR/RelationQuantifier.java
Repair/RepairCompiler/MCC/IR/RepairGenerator.java

index 858f338636f4fe07a158ef8c998f8373699b37fa..fb1291a2bfa3dcd91f088acefc35adb24ef4072c 100755 (executable)
@@ -36,11 +36,13 @@ public class RelationQuantifier extends Quantifier {
        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("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.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) {
     }
 
     public void generate_open(CodeWriter writer, String type,int number, String left,String right) {
@@ -64,8 +66,8 @@ public class RelationQuantifier extends Quantifier {
        writer.endblock();
        writer.outputline("else");
        writer.startblock();
        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(x.getSafeSymbol() + " = (" + x.getType().getGenerateType() + ") key(&"+x.getSafeSymbol()+"_iterator);");
+        writer.outputline(y.getSafeSymbol() + " = (" + y.getType().getGenerateType() + ") next(&"+x.getSafeSymbol()+"_iterator);");
        writer.endblock();
     }
 
        writer.endblock();
     }
 
index cf2b98d22604ef4cc0a10b788470315a9e9dca97..1902bf66941e1433f454ce491c8f66124c1d8db3 100755 (executable)
@@ -638,6 +638,51 @@ public class RepairGenerator {
            cr.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\");");
     }
 
        cr.outputline("printf(\"\\n\\n------------------- END PRINTING\\n\");");
     }