Checking in changes that:
[repair.git] / Repair / RepairCompiler / MCC / IR / SetExpr.java
index deb9a1b37405f38784a462377435df4d834282aa..d166e6e9cce2554395bbc9c0bfa506210d7c9fdc 100755 (executable)
@@ -9,24 +9,60 @@ public class SetExpr extends Expr {
     public SetExpr(SetDescriptor sd) {
         this.sd = sd;
     }
-    
+
+    public String name() {
+       return sd.toString();
+    }
+
+    public boolean equals(Map remap, Expr e) {
+       if (e==null||!(e instanceof SetExpr))
+           return false;
+       SetExpr se=(SetExpr)e;
+       if (sd!=se.sd)
+           return false;
+       return true;
+    }
+
+    public boolean usesDescriptor(Descriptor s) {
+       return (s==sd);
+    }
+
+    public Set useDescriptor(Descriptor s) {
+       HashSet newset=new HashSet();
+       if (s==sd)
+           newset.add(this);
+       return newset;
+    }
+
     public SetExpr() {
         this.sd = null;
     }
 
+    public Set getInversedRelations() {
+        return new HashSet();
+    }
+
+    public Descriptor getDescriptor() {
+       return sd;
+    }
+
     public Set getRequiredDescriptors() {
         HashSet v = new HashSet();
         v.add(sd);
         return v;
     }
 
-    public void generate(CodeWriter writer, VarDescriptor vd) {
+    public void generate(CodeWriter writer, VarDescriptor dest) {
         throw new IRException("unsupported");
     }
 
-    public void generate_set(CodeWriter writer, VarDescriptor vd) {
-        writer.outputline("Set " + vd.getSafeSymbol() + " = " + sd.getSafeSymbol() + "_hash;");
-    }    
+    public void generate_inclusion(CodeWriter writer, VarDescriptor dest, VarDescriptor element) {
+        writer.outputline("int " + dest.getSafeSymbol() + " = SimpleHashcontainskey(" +sd.getSafeSymbol()+ "_hash, "+element.getSafeSymbol() + ");");
+    }
+
+    public void generate_size(CodeWriter writer, VarDescriptor dest) {
+        writer.outputline("int " + dest.getSafeSymbol() + " = SimpleHashcountset("+sd.getSafeSymbol()+"_hash);");
+    }
 
     public void prettyPrint(PrettyPrinter pp) {
         pp.output(sd.getSafeSymbol());