9e3dbe8b113a4d90af70b8aa0304869abef93b9e
[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 TermNode(Constraint constr, Conjunction conj) {
19         this.constr=constr;
20         this.conj=conj;
21         type=CONJUNCTION;
22     }
23
24     public TermNode(AbstractRepair ar) {
25         repair=ar;
26         type=ABSTRACT;
27     }
28
29     public TermNode(ConsequenceNode cn) {
30         conseqnode=cn;
31         type=CONSEQUENCE;
32     }
33
34     public TermNode(ScopeNode sn) {
35         scope=sn;
36         type=RULESCOPE;
37     }
38
39     public TermNode(MultUpdateNode un) {
40         update=un;
41         type=UPDATE;
42     }
43
44     public ConsequenceNode getConsequence() {
45         if (type!=CONSEQUENCE)
46             throw new Error("Not Consequence Node!");
47         else
48             return conseqnode;
49     }
50
51     public Conjunction getConjunction() {
52         if (type!=CONJUNCTION)
53             throw new Error("Not Conjunction Node!");
54         else
55             return conj;
56     }
57
58     public MultUpdateNode getUpdate() {
59         if (type!=UPDATE)
60             throw new Error("Not Update Node!");
61         else
62             return update;
63     }
64
65     public ScopeNode getScope() {
66         if (type!=RULESCOPE)
67             throw new Error("Not Scope Node!");
68         else
69             return scope;
70     }
71
72     public AbstractRepair getAbstract() {
73         if (type!=ABSTRACT)
74             throw new Error("Not Abstract Repair Node!");
75         else
76             return repair;
77     }
78 }
79