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