1) Checking in filesystem example
[repair.git] / Repair / RepairCompiler / MCC / IR / SetInclusion.java
index 22ceb1d0a6e9333c306c474d35f0d92b3d5f7e78..51a5113844a1b3147cc6640c67c7679e623ae5af 100755 (executable)
@@ -1,5 +1,5 @@
 package MCC.IR;
-
+import MCC.Compiler;
 import java.util.*;
 
 public class SetInclusion extends Inclusion {
@@ -7,13 +7,38 @@ public class SetInclusion extends Inclusion {
     Expr elementexpr;
     SetDescriptor set;
 
-    static boolean worklist = true;
+    public String generatedresult = null;
+    public String generatedaddeditem = null;
+
+    public static boolean worklist = false;
+    public boolean dostore = true;
+
+    public String toString() {
+       String str="";
+       str+=elementexpr.name()+" in "+set;
+       return str;
+    }
 
     public SetInclusion(Expr elementexpr, SetDescriptor set) {
         this.elementexpr = elementexpr;
         this.set = set;
     }
 
+    public boolean usesDescriptor(Descriptor d) {
+       if (d==set)
+           return true;
+       else
+           return elementexpr.usesDescriptor(d);
+    }
+
+    public Expr getExpr() {
+       return elementexpr;
+    }
+
+    public SetDescriptor getSet() {
+        return set;
+    }
+
     public Set getTargetDescriptors() {
         HashSet v = new HashSet();
         v.add(set);
@@ -28,20 +53,33 @@ public class SetInclusion extends Inclusion {
         VarDescriptor vd = VarDescriptor.makeNew("element");
         elementexpr.generate(writer, vd);
 
+        // allows access to the value of this set addition later
+        generatedresult = vd.getSafeSymbol();
+
         String addeditem = (VarDescriptor.makeNew("addeditem")).getSafeSymbol();
-        writer.outputline("int " + addeditem + ";");
-        
-        writer.outputline(addeditem + " = " + set.getSafeSymbol() + "_hash->add((int)" + vd.getSafeSymbol() 
-                          +  ", (int)" + vd.getSafeSymbol() + ");");
+        generatedaddeditem = addeditem; // allows access to the result of the set addition later.
 
-        if (SetInclusion.worklist) {
-            writer.outputline("if (" + addeditem + ")");
-            writer.startblock(); {                
-                WorkList.generate_dispatch(writer, set, vd.getSafeSymbol());
+        // we set equal to one so that if dostore == false the guard in teh 
+        // metainclusion generation for the subrules and sub quantifiers will go on        
+
+
+        if (dostore) {
+           /*      if (!Compiler.REPAIR) {
+               writer.outputline("int " + addeditem + " = 1;");
+               writer.outputline(addeditem + " = " + set.getSafeSymbol() + "_hash->add((int)" + vd.getSafeSymbol() 
+                                 +  ", (int)" + vd.getSafeSymbol() + ");");
+                                 } else {*/
+               Repair.generate_dispatch(writer, set, vd.getSafeSymbol());
+               //          }
+           
+            if (SetInclusion.worklist) {
+                writer.outputline("if (" + addeditem + ")");
+                writer.startblock(); {                
+                    WorkList.generate_dispatch(writer, set, vd.getSafeSymbol());
+                }
+                writer.endblock();
             }
-            writer.endblock();
-        }
-        
+       }
     }
 
     public boolean typecheck(SemanticAnalyzer sa) {