start of new file
[IRC.git] / Robust / src / IR / Tree / DNFFlag.java
index 67cdd3c28dd9342e5e2b001fc052337175c19dbd..980868876a3f6a9a1a666ef34c7453a8168efe89 100644 (file)
@@ -3,7 +3,7 @@ import java.util.Vector;
 import IR.*;
 
 public class DNFFlag {
-    Vector conjunctions;
+    private Vector conjunctions;
     public DNFFlag(FlagNode flag) {
        DNFFlagAtom dfa=new DNFFlagAtom(flag, false);
        conjunctions=new Vector();
@@ -15,6 +15,18 @@ public class DNFFlag {
        conjunctions=new Vector();
     }
 
+    /** Returns the number of conjunctions in the DNF form. */
+
+    public int size() {
+       return conjunctions.size();
+    }
+
+    /** Returns a Vector containing the terms in the n'th conjunction. */
+
+    public Vector get(int n) {
+       return (Vector) conjunctions.get(n);
+    }
+
     /** This method negates a DNFFlag expression. */
 
     public DNFFlag not() {
@@ -24,7 +36,7 @@ public class DNFFlag {
             DNFFlag newflag=null;
             for (int j=0;j<conj.size();j++) {
                 DNFFlagAtom dfa=(DNFFlagAtom) conj.get(j);
-               DNFFlagAtom negdfa=new DNFFlagAtom(dfa.flag,!dfa.negated);
+               DNFFlagAtom negdfa=new DNFFlagAtom(dfa.getFlagNode(),!dfa.getNegated());
                DNFFlag tmp=new DNFFlag();
                Vector v=new Vector();
                tmp.conjunctions.add(v);
@@ -72,7 +84,7 @@ public class DNFFlag {
        for(int i=0;i<conjunctions.size();i++) {
            for(int i2=0;i2<dnf2.conjunctions.size();i2++) {
                Vector conjunct=(Vector)conjunctions.get(i);
-               Vector conjunct2=(Vector)conjunctions.get(i2);
+               Vector conjunct2=(Vector)dnf2.conjunctions.get(i2);
                Vector newconjunct=new Vector();
                result.conjunctions.add(newconjunct);
                for(int j=0;j<conjunct.size();j++) {
@@ -85,4 +97,19 @@ public class DNFFlag {
        }
        return result;
     }
+
+    public String toString() {
+       String value="";
+       for(int i=0;i<conjunctions.size();i++) {
+           if (i!=0)
+               value+=" || ";
+           Vector conjunct=(Vector)conjunctions.get(i);
+           for(int j=0;j<conjunct.size();j++) {
+               if (j!=0)
+                   value+="&&";
+               value+=conjunct.get(j);
+           }
+       }
+       return value;
+    }
 }