From 7f5349f8ce0cad85a83e9485b3d083296f9f7737 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Thu, 22 Apr 2004 20:55:30 +0000 Subject: [PATCH] Added code to correctly order checks... Added code to search through sets for bindings of size 1. --- .../MCC/IR/ConstraintDependence.java | 88 ++++++++++++++++--- Repair/RepairCompiler/MCC/IR/ExactSize.java | 9 +- .../MCC/IR/RepairGenerator.java | 9 +- Repair/RepairCompiler/MCC/IR/Termination.java | 27 ++++-- Repair/RepairCompiler/MCC/IR/UpdateNode.java | 30 ++++--- 5 files changed, 126 insertions(+), 37 deletions(-) diff --git a/Repair/RepairCompiler/MCC/IR/ConstraintDependence.java b/Repair/RepairCompiler/MCC/IR/ConstraintDependence.java index 49d4cb9..7ae89cb 100755 --- a/Repair/RepairCompiler/MCC/IR/ConstraintDependence.java +++ b/Repair/RepairCompiler/MCC/IR/ConstraintDependence.java @@ -18,10 +18,29 @@ public class ConstraintDependence { constonode=new Hashtable(); nodetonode=new Hashtable(); constructnodes(); - constructconjunctionnodes(); - constructconjunctionedges(); } + public Set computeOrdering() { + HashSet allnodes=new HashSet(); + allnodes.addAll(constnodes); + allnodes.addAll(nodes); + boolean acyclic=GraphNode.DFS.depthFirstSearch(allnodes); + if (!acyclic) { + throw new Error("Cylic dependency between constraints."); + } + TreeSet topologicalsort = new TreeSet(new Comparator() { + public boolean equals(Object obj) { return false; } + public int compare(Object o1, Object o2) { + GraphNode g1 = (GraphNode) o1; + GraphNode g2 = (GraphNode) o2; + return g1.getFinishingTime() - g2.getFinishingTime(); + } + }); + + topologicalsort.addAll(constnodes); + return topologicalsort; + } + public void addNode(GraphNode gn) { GraphNode gn2=new GraphNode(gn.getLabel(),gn.getTextLabel(),gn); nodes.add(gn2); @@ -29,6 +48,9 @@ public class ConstraintDependence { } public void associateWithConstraint(GraphNode gn, Constraint c) { + if (!nodetonode.containsKey(gn)) { + addNode(gn); + } GraphNode ggn=(GraphNode)nodetonode.get(gn); GraphNode gc=(GraphNode)constonode.get(c); GraphNode.Edge e=new GraphNode.Edge("associated",ggn); @@ -36,12 +58,49 @@ public class ConstraintDependence { } public void requiresConstraint(GraphNode gn, Constraint c) { + if (!nodetonode.containsKey(gn)) { + addNode(gn); + } GraphNode ggn=(GraphNode)nodetonode.get(gn); GraphNode gc=(GraphNode)constonode.get(c); GraphNode.Edge e=new GraphNode.Edge("requires",gc); ggn.addEdge(e); } + public void traversedependences(Termination termination) { + constructconjunctionnodes(termination); + constructconjunctionedges(termination); + Set removedset=termination.removedset; + + for(int i=0;i1 doesn't exist."); + if (b.getType()==Binding.SEARCH) { + VarDescriptor vd=b.getVar(); + cr.outputline(vd.getType().getGenerateType().getSafeSymbol()+" "+vd.getSafeSymbol()+"="+b.getSet().getSafeSymbol()+"->firstkey();"); + } else if (b.getType()==Binding.CREATE) { + throw new Error("Creation not supported"); + // source.generateSourceAlloc(cr,vd,b.getSet()); + } else { + VarDescriptor vd=b.getVar(); + switch(b.getPosition()) { + case 0: + cr.outputline(vd.getType().getGenerateType().getSafeSymbol()+" "+vd.getSafeSymbol()+"="+slot0+";"); + break; + case 1: + cr.outputline(vd.getType().getGenerateType().getSafeSymbol()+" "+vd.getSafeSymbol()+"="+slot1+";"); + break; + default: + throw new Error("Slot >1 doesn't exist."); + } } } } -- 2.34.1