337c5697d963bf2f93f6143df67653143bd96709
[repair.git] / Repair / RepairCompiler / MCC / IR / TermNode.java
1 package MCC.IR;
2
3 class TermNode {
4     public final static int CONJUNCTION=1;
5     public final static int ABSTRACT=2;
6     public final static int UPDATE=3;
7     public final static int RULESCOPE=4;
8     public final static int CONSEQUENCE=5;
9
10     ConsequenceNode conseqnode;
11     Constraint constr;
12     Conjunction conj;
13     int type;
14     AbstractRepair repair;
15     ScopeNode scope;
16     MultUpdateNode update;
17
18     public int getType() {
19         return type;
20     }
21
22     public TermNode(Constraint constr, Conjunction conj) {
23         this.constr=constr;
24         this.conj=conj;
25         type=CONJUNCTION;
26     }
27
28     public TermNode(AbstractRepair ar) {
29         repair=ar;
30         type=ABSTRACT;
31     }
32
33     public TermNode(ConsequenceNode cn) {
34         conseqnode=cn;
35         type=CONSEQUENCE;
36     }
37
38     public TermNode(ScopeNode sn) {
39         scope=sn;
40         type=RULESCOPE;
41     }
42
43     public TermNode(MultUpdateNode un) {
44         update=un;
45         type=UPDATE;
46     }
47
48     public ConsequenceNode getConsequence() {
49         if (type!=CONSEQUENCE)
50             throw new Error("Not Consequence Node!");
51         else
52             return conseqnode;
53     }
54
55     public Conjunction getConjunction() {
56         if (type!=CONJUNCTION)
57             throw new Error("Not Conjunction Node!");
58         else
59             return conj;
60     }
61
62     public Constraint getConstraint() {
63         if (type!=CONJUNCTION)
64             throw new Error("Not Conjunction Node!");
65         else
66             return constr;
67     }
68
69     public MultUpdateNode getUpdate() {
70         if (type!=UPDATE)
71             throw new Error("Not Update Node!");
72         else
73             return update;
74     }
75
76     public ScopeNode getScope() {
77         if (type!=RULESCOPE)
78             throw new Error("Not Scope Node!");
79         else
80             return scope;
81     }
82
83     public AbstractRepair getAbstract() {
84         if (type!=ABSTRACT)
85             throw new Error("Not Abstract Repair Node!");
86         else
87             return repair;
88     }
89 }
90