Changes:
[repair.git] / Repair / RepairCompiler / MCC / IR / ExprPredicate.java
1 package MCC.IR;
2
3 import java.util.*;
4
5 public class ExprPredicate extends Predicate {
6     
7     Expr expr;
8
9
10     public static final int SIZE=1;
11     public static final int COMPARISON=2;
12
13     public TypeDescriptor typecheck(SemanticAnalyzer sa) {
14         TypeDescriptor t=expr.typecheck(sa);
15         return t;
16     }
17
18     public String name() {
19         return expr.name();
20     }
21
22     public int getType() {
23         if (((OpExpr)expr).left instanceof SizeofExpr)
24             return SIZE;
25         else if (((OpExpr)expr).left instanceof RelationExpr)
26             return COMPARISON;
27         else throw new Error("Unidentifiable Type");
28     }
29
30     public Opcode getOp() {
31         return ((OpExpr)expr).opcode;
32     }
33
34     public int rightSize() {
35         assert isRightInt();
36         return OpExpr.getInt(((OpExpr)expr).right);
37     }
38
39     public boolean isRightInt() {
40         return OpExpr.isInt(((OpExpr)expr).right);
41     }
42
43     public ExprPredicate(Expr expr) {
44         if (expr == null) {
45             throw new NullPointerException();
46         }
47         this.expr = expr;
48     }
49
50     public Set getInversedRelations() {
51         return expr.getInversedRelations();
52     }
53
54     public int[] getRepairs(boolean negated, Termination t) {
55         return expr.getRepairs(negated,t);
56     }
57
58     public Descriptor getDescriptor() {
59         return expr.getDescriptor();
60     }
61
62     public boolean inverted() {
63         return expr.inverted();
64     }
65
66     public boolean usesDescriptor(RelationDescriptor rd) {
67         return expr.usesDescriptor(rd);
68     }
69
70     public Set getRequiredDescriptors() {
71         return expr.getRequiredDescriptors();
72     }
73
74     public void generate(CodeWriter writer, VarDescriptor dest) {
75         expr.generate(writer, dest);
76     }
77 }
78