model and checks
[repair.git] / Repair / RepairCompiler / MCC / IR / ImageSetExpr.java
1 package MCC.IR;
2
3 import java.util.*;
4
5 public class ImageSetExpr extends SetExpr {
6     
7     public static final boolean INVERSE = true;
8
9     VarDescriptor vd;
10     RelationDescriptor rd;
11     boolean inverse;
12
13     public ImageSetExpr(VarDescriptor vd, RelationDescriptor rd) {
14         this.vd = vd;
15         this.rd = rd;
16         this.inverse = false;
17     }
18
19     public ImageSetExpr(boolean inverse, VarDescriptor vd, RelationDescriptor rd) {
20         this.vd = vd;
21         this.rd = rd;
22         this.inverse = inverse;
23     }
24
25     public Set getRequiredDescriptors() {
26         HashSet v = new HashSet();
27         v.add(rd);
28         return v;
29     }
30
31     public void generate(CodeWriter writer, VarDescriptor dest) {
32         throw new IRException("not supported");
33     }
34
35     public void generate_inclusion(CodeWriter writer, VarDescriptor dest, VarDescriptor element) {
36         String hash = inverse ? "_hashinv->contains(" : "_hash->contains(" ;
37         writer.outputline("int " + dest.getSafeSymbol() + " = " + rd.getSafeSymbol() + hash + vd.getSafeSymbol() + ", " + element.getSafeSymbol() + ");");
38     }    
39
40     public void generate_size(CodeWriter writer, VarDescriptor dest) {
41         assert dest != null;
42         assert vd != null;
43         assert rd != null;
44         String hash = inverse ? "_hashinv->count(" : "_hash->count(" ;
45         writer.outputline("int " + dest.getSafeSymbol() + " = " + rd.getSafeSymbol() + hash + vd.getSafeSymbol() + ");");
46     }
47
48     public void prettyPrint(PrettyPrinter pp) {
49         throw new IRException("not supported");
50     }
51
52     public TypeDescriptor typecheck(SemanticAnalyzer sa) {
53         throw new IRException("not supported");
54     }
55
56 }