model and checks
[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 getRequiredDescriptors() {
18         HashSet v = new HashSet();
19         v.add(sd);
20         return v;
21     }
22
23     public void generate(CodeWriter writer, VarDescriptor dest) {
24         throw new IRException("unsupported");
25     }
26
27     public void generate_inclusion(CodeWriter writer, VarDescriptor dest, VarDescriptor element) {
28         writer.outputline("int " + dest.getSafeSymbol() + " = " + sd.getSafeSymbol() + "_hash->contains(" + element.getSafeSymbol() + ");");
29     }    
30
31     public void generate_size(CodeWriter writer, VarDescriptor dest) {
32         writer.outputline("int " + dest.getSafeSymbol() + " = " + sd.getSafeSymbol() + "_hash->count();");
33     }
34
35     public void prettyPrint(PrettyPrinter pp) {
36         pp.output(sd.getSafeSymbol());
37     }
38
39     public TypeDescriptor typecheck(SemanticAnalyzer sa) {
40         this.td = sd.getType();
41         return this.td;
42     }
43
44 }
45
46