ec216b6a0f523c2aa7662c7a1865915703a7ce64
[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
15     public Constraint() {
16         label = new String("c" + count++);
17     }
18
19     public String getLabel() {
20         return label;
21     }
22
23     public SymbolTable getSymbolTable() {
24         return st;
25     }
26
27     public void addQuantifier(Quantifier q) {
28         quantifiers.addElement(q);
29     }
30
31     public void setLogicStatement(LogicStatement ls) {
32         logicstatement = ls;
33     }
34
35     public LogicStatement getLogicStatement() {
36         return logicstatement;
37     }
38     
39     public void setCrash(boolean crash) {
40         this.crash = crash;
41     }
42
43     public Iterator quantifiers() {
44         return quantifiers.iterator();
45     }
46
47     public Set getRequiredDescriptorsFromQuantifiers() {
48
49         HashSet topdescriptors = new HashSet();
50
51         for (int i = 0; i < quantifiers.size(); i++) {            
52             Quantifier q = (Quantifier) quantifiers.elementAt(i);
53             topdescriptors.addAll(q.getRequiredDescriptors());                
54         }
55
56         return SetDescriptor.expand(topdescriptors);
57     }
58
59     public Set getRequiredDescriptorsFromLogicStatement() {
60         
61         HashSet topdescriptors = new HashSet();
62
63         topdescriptors.addAll(logicstatement.getRequiredDescriptors());
64
65         return SetDescriptor.expand(topdescriptors);
66     }
67    
68     public Set getRequiredDescriptors() {
69         Set set = getRequiredDescriptorsFromQuantifiers();
70         set.addAll(getRequiredDescriptorsFromLogicStatement());
71         return set;
72     }
73    
74 }
75