From d0cc93fb75919256c617501584fdbd8cd6bfd35e Mon Sep 17 00:00:00 2001 From: bdemsky Date: Sun, 2 Oct 2005 06:20:16 +0000 Subject: [PATCH] Quantifier bugs. --- .../MCC/IR/RelationQuantifier.java | 12 ++--- .../MCC/IR/RepairGenerator.java | 45 +++++++++++++++++++ 2 files changed, 52 insertions(+), 5 deletions(-) diff --git a/Repair/RepairCompiler/MCC/IR/RelationQuantifier.java b/Repair/RepairCompiler/MCC/IR/RelationQuantifier.java index 858f338..fb1291a 100755 --- a/Repair/RepairCompiler/MCC/IR/RelationQuantifier.java +++ b/Repair/RepairCompiler/MCC/IR/RelationQuantifier.java @@ -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(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) { @@ -64,8 +66,8 @@ public class RelationQuantifier extends Quantifier { 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(); } diff --git a/Repair/RepairCompiler/MCC/IR/RepairGenerator.java b/Repair/RepairCompiler/MCC/IR/RepairGenerator.java index cf2b98d..1902bf6 100755 --- a/Repair/RepairCompiler/MCC/IR/RepairGenerator.java +++ b/Repair/RepairCompiler/MCC/IR/RepairGenerator.java @@ -638,6 +638,51 @@ public class RepairGenerator { 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\");"); } -- 2.34.1