*** empty log message ***
[repair.git] / Repair / RepairCompiler / MCC / IR / SetExpr.java
1 package MCC.IR;
2
3 import java.util.*;
4
5 public class SetExpr extends Expr {
6
7     SetDescriptor sd;
8
9     public SetExpr(SetDescriptor sd) {
10         this.sd = sd;
11     }
12
13     public String name() {
14         return sd.toString();
15     }
16
17     public boolean equals(Map remap, Expr e) {
18         if (e==null||!(e instanceof SetExpr))
19             return false;
20         SetExpr se=(SetExpr)e;
21         if (sd!=se.sd)
22             return false;
23         return true;
24     }
25
26     public boolean usesDescriptor(Descriptor s) {
27         return (s==sd);
28     }
29
30     public SetExpr() {
31         this.sd = null;
32     }
33
34     public Set getInversedRelations() {
35         return new HashSet();
36     }
37
38     public Descriptor getDescriptor() {
39         return sd;
40     }
41
42     public Set getRequiredDescriptors() {
43         HashSet v = new HashSet();
44         v.add(sd);
45         return v;
46     }
47
48     public void generate(CodeWriter writer, VarDescriptor dest) {
49         throw new IRException("unsupported");
50     }
51
52     public void generate_inclusion(CodeWriter writer, VarDescriptor dest, VarDescriptor element) {
53         writer.outputline("int " + dest.getSafeSymbol() + " = " + sd.getSafeSymbol() + "_hash->contains(" + element.getSafeSymbol() + ");");
54     }    
55
56     public void generate_size(CodeWriter writer, VarDescriptor dest) {
57         writer.outputline("int " + dest.getSafeSymbol() + " = " + sd.getSafeSymbol() + "_hash->count();");
58     }
59
60     public void prettyPrint(PrettyPrinter pp) {
61         pp.output(sd.getSafeSymbol());
62     }
63
64     public TypeDescriptor typecheck(SemanticAnalyzer sa) {
65         this.td = sd.getType();
66         return this.td;
67     }
68
69 }
70
71