Fix some of Dan's bugs (code generation for relation quantifiers misstyped), didn...
[repair.git] / Repair / RepairCompiler / MCC / IR / Constraint.java
index ec216b6a0f523c2aa7662c7a1865915703a7ce64..f3fdceced94091e5b52edd2180bf7cef0504afec 100755 (executable)
@@ -2,7 +2,7 @@ package MCC.IR;
 
 import java.util.*;
 
-public class Constraint {
+public class Constraint implements Quantifiers {
     
     private static int count = 1;
 
@@ -11,11 +11,35 @@ public class Constraint {
     SymbolTable st = new SymbolTable();
     Vector quantifiers = new Vector(); 
     LogicStatement logicstatement = null;
+    DNFConstraint dnfconstraint;
+    int num;
 
     public Constraint() {
+        num = count;
         label = new String("c" + count++);
     }
 
+    public String toString() {
+       String name="";
+       for(int i=0;i<numQuantifiers();i++) {
+           name+=getQuantifier(i).toString()+",";
+       }
+       name+=logicstatement.name();
+       return name;
+    }
+
+    public int getNum() {
+        return num;
+    }
+
+    public int numQuantifiers() {
+       return quantifiers.size();
+    }
+
+    public Quantifier getQuantifier(int i) {
+       return (Quantifier) quantifiers.get(i);
+    }
+
     public String getLabel() {
         return label;
     }
@@ -30,6 +54,8 @@ public class Constraint {
 
     public void setLogicStatement(LogicStatement ls) {
         logicstatement = ls;
+       // Construct DNF form for analysis
+       dnfconstraint=logicstatement.constructDNF();
     }
 
     public LogicStatement getLogicStatement() {
@@ -40,8 +66,8 @@ public class Constraint {
         this.crash = crash;
     }
 
-    public Iterator quantifiers() {
-        return quantifiers.iterator();
+    public ListIterator quantifiers() {
+        return quantifiers.listIterator();
     }
 
     public Set getRequiredDescriptorsFromQuantifiers() {
@@ -50,7 +76,7 @@ public class Constraint {
 
         for (int i = 0; i < quantifiers.size(); i++) {            
             Quantifier q = (Quantifier) quantifiers.elementAt(i);
-            topdescriptors.addAll(q.getRequiredDescriptors());                
+            topdescriptors.addAll(q.getRequiredDescriptors());
         }
 
         return SetDescriptor.expand(topdescriptors);