implementing
[IRC.git] / Robust / src / Analysis / Disjoint / ExistPredSet.java
1 package Analysis.Disjoint;
2
3 import IR.*;
4 import IR.Flat.*;
5 import java.util.*;
6 import java.io.*;
7
8 // a set of existence predicates that are
9 // OR'ed terms, if any predicate is true
10 // then the set evaluates to true
11
12 public class ExistPredSet extends Canonical {
13
14   protected Set<ExistPred> preds;
15
16   public ExistPredSet() {
17     preds = new HashSet<ExistPred>();
18   }
19
20   public ExistPredSet makeCanonical() {
21     return (ExistPredSet) ExistPredSet.makeCanonical( this );
22   }
23
24
25   public void add( ExistPred pred ) {
26     preds.add( pred );
27   }
28
29   public boolean isSatisfiedBy( ReachGraph rg ) {
30     Iterator<ExistPred> predItr = preds.iterator();
31     while( predItr.hasNext() ) {
32       if( !predItr.next().isSatisfiedBy( rg ) ) {
33         return false;
34       }
35     }
36     return true;
37   }
38
39   public String toString() {
40     String s = "P[";
41     Iterator<ExistPred> predItr = preds.iterator();
42     while( predItr.hasNext() ) {
43       ExistPred pred = predItr.next();
44       s += pred.toString();
45       if( predItr.hasNext() ) {
46         s += " && ";
47       }
48     }
49     s += "]";
50     return s;
51   }
52
53 }