worklist version
[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     int num;
19
20     public Rule () {
21         num = count;
22         label = new String("rule" + count++);
23     }
24     
25     public int getNum() {
26         return num;
27     }
28
29     public String getLabel() {
30         return label;
31     }
32
33     public void setStatic(boolean val) {
34         isstatic = val;
35     }
36
37     public void setDelay(boolean val) {
38         isdelay = val;
39     }
40
41     public void addQuantifier(Quantifier q) {
42         quantifiers.addElement(q);
43     }
44
45     public ListIterator quantifiers() {
46         return quantifiers.listIterator();
47     }
48
49     public void setGuardExpr(Expr guard) {
50         this.guard = guard;
51     }
52     
53     public Expr getGuardExpr() {
54         return guard;
55     }
56
57     public void setInclusion(Inclusion inclusion) {
58         this.inclusion = inclusion;
59     }
60
61     public Inclusion getInclusion() {
62         return inclusion;
63     }
64     
65     public SymbolTable getSymbolTable() {
66         return st;
67     }
68
69     public Set getRequiredDescriptors() {
70
71         HashSet topdescriptors = new HashSet();
72
73         for (int i = 0; i < quantifiers.size(); i++) {            
74             Quantifier q = (Quantifier) quantifiers.elementAt(i);
75             topdescriptors.addAll(q.getRequiredDescriptors());                
76         }
77
78         assert guard != null;            
79         topdescriptors.addAll(guard.getRequiredDescriptors());
80         
81         assert inclusion != null;
82         topdescriptors.addAll(inclusion.getRequiredDescriptors());
83         
84         return SetDescriptor.expand(topdescriptors);
85     }
86
87 }