Updates
[repair.git] / Repair / RepairCompiler / MCC / IR / Termination.java
1 package MCC.IR;
2 import java.util.*;
3
4 class Termination {
5     HashSet conjunctions;
6     Hashtable conjunctionmap;
7
8     HashSet abstractrepair;
9
10     State state;
11
12     public Termination(State state) {
13         this.state=state;
14         generateconjunctionnodes();
15         generaterepairnodes();
16     }
17     
18     void generateconjunctionnodes() {
19         Vector constraints=state.vConstraints;
20         for(int i=0;i<constraints.size();i++) {
21             Constraint c=(Constraint)constraints.get(i);
22             DNFConstraint dnf=c.dnfconstraint;
23             for(int j=0;j<dnf.size();j++) {
24                 TermNode tn=new TermNode(c,dnf.get(j));
25                 GraphNode gn=new GraphNode("Conjunction"+i+","+j,tn);
26                 conjunctions.add(gn);
27                 conjunctionmap.put(c,gn);
28             }
29         }
30     }
31
32     void generaterepairnodes() {
33         for(Iterator conjiterator=conjunctions.iterator();conjiterator.hasNext();) {
34             GraphNode gn=(GraphNode)conjiterator.next();
35             TermNode tn=(TermNode)gn.getOwner();
36             Conjunction conj=tn.getConjunction();
37             for(int i=0;i<conj.size();i++) {
38                 DNFPredicate dp=conj.get(i);
39                 int[] array=dp.getPredicate().getRepairs();
40                 for {int j=0;j<array.length;j++) {
41                     AbstractRepair ar=new AbstractRepair(dp,array[j]);
42                     TermNode tn=new TermNode(ar);
43                     GraphNode gn2=new GraphNode(gn.getLabel()+"-"+i+","+j,tn);
44                     Edge e=new Edge("abstract",gn2);
45                     gn.addEdge(e);
46                     abstractrepair.add(gn2);
47                 }
48             }
49         }
50     }
51 }
52
53 class AbstractRepair {
54     public final static int ADDTOSET=1;
55     public final static int REMOVEFROMSET=2;
56     public final static int ADDTORELATION=3;
57     public final static int REMOVEFROMRELATION=4;
58     public final static int MODIFYRELATION=5;
59
60     DNFPredicate torepair;
61     int type;
62
63     public AbstractRepair(DNFPredicate dp,int typ) {
64         torepair=dp;
65         type=typ;
66     }
67 }
68
69 class TermNode {
70     public final static int CONJUNCTION=1;
71     public final static int ABSTRACT=2;
72
73     Constraint constr;
74     Conjunction conj;
75     int type;
76     AbstractRepair repair;
77
78     public TermNode(Constraint constr, Conjunction conj) {
79         this.constr=constr;
80         this.conj=conj;
81         type=CONJUNCTION;
82     }
83
84     public TermNode(AbstractRepair ar) {
85         repair=ar;
86         type=ABSTRACT;
87     }
88
89     public Conjunction getConjunction() {
90         return conj;
91     }
92 }
93