Updates
[repair.git] / Repair / RepairCompiler / MCC / IR / Constraint.java
1 package MCC.IR;
2
3 import java.util.*;
4
5 public class Constraint {
6     
7     private static int count = 1;
8
9     String label = null;
10     boolean crash = false;
11     SymbolTable st = new SymbolTable();
12     Vector quantifiers = new Vector(); 
13     LogicStatement logicstatement = null;
14     DNFConstraint dnfconstraint;
15     int num;
16
17     public Constraint() {
18         num = count;
19         label = new String("c" + count++);
20     }
21
22     public int getNum() {
23         return num;
24     }
25
26     public String getLabel() {
27         return label;
28     }
29
30     public SymbolTable getSymbolTable() {
31         return st;
32     }
33
34     public void addQuantifier(Quantifier q) {
35         quantifiers.addElement(q);
36     }
37
38     public void setLogicStatement(LogicStatement ls) {
39         logicstatement = ls;
40         // Construct DNF form for analysis
41         dnfconstraint=logicstatement.constructDNF();
42     }
43
44     public LogicStatement getLogicStatement() {
45         return logicstatement;
46     }
47     
48     public void setCrash(boolean crash) {
49         this.crash = crash;
50     }
51
52     public ListIterator quantifiers() {
53         return quantifiers.listIterator();
54     }
55
56     public Set getRequiredDescriptorsFromQuantifiers() {
57
58         HashSet topdescriptors = new HashSet();
59
60         for (int i = 0; i < quantifiers.size(); i++) {            
61             Quantifier q = (Quantifier) quantifiers.elementAt(i);
62             topdescriptors.addAll(q.getRequiredDescriptors());                
63         }
64
65         return SetDescriptor.expand(topdescriptors);
66     }
67
68     public Set getRequiredDescriptorsFromLogicStatement() {
69         
70         HashSet topdescriptors = new HashSet();
71
72         topdescriptors.addAll(logicstatement.getRequiredDescriptors());
73
74         return SetDescriptor.expand(topdescriptors);
75     }
76    
77     public Set getRequiredDescriptors() {
78         Set set = getRequiredDescriptorsFromQuantifiers();
79         set.addAll(getRequiredDescriptorsFromLogicStatement());
80         return set;
81     }
82    
83 }
84