b084b8e47bdba6143b83000a240b61931b225b55
[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 SetExpr() {
14         this.sd = null;
15     }
16
17     public Set getInversedRelations() {
18         return new HashSet();
19     }
20
21     public Descriptor getDescriptor() {
22         return sd;
23     }
24
25     public Set getRequiredDescriptors() {
26         HashSet v = new HashSet();
27         v.add(sd);
28         return v;
29     }
30
31     public void generate(CodeWriter writer, VarDescriptor dest) {
32         throw new IRException("unsupported");
33     }
34
35     public void generate_inclusion(CodeWriter writer, VarDescriptor dest, VarDescriptor element) {
36         writer.outputline("int " + dest.getSafeSymbol() + " = " + sd.getSafeSymbol() + "_hash->contains(" + element.getSafeSymbol() + ");");
37     }    
38
39     public void generate_size(CodeWriter writer, VarDescriptor dest) {
40         writer.outputline("int " + dest.getSafeSymbol() + " = " + sd.getSafeSymbol() + "_hash->count();");
41     }
42
43     public void prettyPrint(PrettyPrinter pp) {
44         pp.output(sd.getSafeSymbol());
45     }
46
47     public TypeDescriptor typecheck(SemanticAnalyzer sa) {
48         this.td = sd.getType();
49         return this.td;
50     }
51
52 }
53
54