16087e2d5553a44d9ad0147342146b5f17ea925f
[repair.git] / Repair / RepairCompiler / MCC / IR / Rule.java
1 package MCC.IR;
2
3 import java.util.*;
4
5 public class Rule {
6     
7     static int count = 1;
8
9     Vector quantifiers = new Vector();
10     boolean isstatic = false;
11     boolean isdelay = false;
12     Expr guard = null;
13     Inclusion inclusion = null;    
14     SymbolTable st = new SymbolTable();
15     
16     String label;
17
18     public Rule () {
19         label = new String("rule" + count++);
20     }
21
22     public String getLabel() {
23         return label;
24     }
25
26     public void setStatic(boolean val) {
27         isstatic = val;
28     }
29
30     public void setDelay(boolean val) {
31         isdelay = val;
32     }
33
34     public void addQuantifier(Quantifier q) {
35         quantifiers.addElement(q);
36     }
37
38     public ListIterator quantifiers() {
39         return quantifiers.listIterator();
40     }
41
42     public void setGuardExpr(Expr guard) {
43         this.guard = guard;
44     }
45     
46     public Expr getGuardExpr() {
47         return guard;
48     }
49
50     public void setInclusion(Inclusion inclusion) {
51         this.inclusion = inclusion;
52     }
53
54     public Inclusion getInclusion() {
55         return inclusion;
56     }
57     
58     public SymbolTable getSymbolTable() {
59         return st;
60     }
61
62     public Set getRequiredDescriptors() {
63
64         HashSet topdescriptors = new HashSet();
65
66         for (int i = 0; i < quantifiers.size(); i++) {            
67             Quantifier q = (Quantifier) quantifiers.elementAt(i);
68             topdescriptors.addAll(q.getRequiredDescriptors());                
69         }
70
71         assert guard != null;            
72         topdescriptors.addAll(guard.getRequiredDescriptors());
73         
74         assert inclusion != null;
75         topdescriptors.addAll(inclusion.getRequiredDescriptors());
76         
77         return SetDescriptor.expand(topdescriptors);
78     }
79
80 }