1 package Analysis.OwnershipAnalysis;
9 public class ReachabilitySet {
11 public HashSet<TokenTupleSet> possibleReachabilities;
13 public ReachabilitySet() {
14 possibleReachabilities = new HashSet<TokenTupleSet>();
17 public ReachabilitySet( ReachabilitySet rs ) {
18 possibleReachabilities = (HashSet<TokenTupleSet>) rs.possibleReachabilities.clone(); // again, DEEP COPY?!
21 public Iterator iterator() {
22 return possibleReachabilities.iterator();
25 public ReachabilitySet union( ReachabilitySet rsIn ) {
26 ReachabilitySet rsOut = new ReachabilitySet( this );
27 rsOut.possibleReachabilities.addAll( rsIn.possibleReachabilities );
31 public ReachabilitySet intersection( ReachabilitySet rsIn ) {
32 ReachabilitySet rsOut = new ReachabilitySet();
34 Iterator i = this.iterator();
35 while( i.hasNext() ) {
36 TokenTupleSet tts = (TokenTupleSet) i.next();
37 if( rsIn.possibleReachabilities.contains( tts ) ) {
38 rsOut.possibleReachabilities.add( tts );
45 public ChangeTupleSet unionUpArity( ReachabilitySet rsIn ) {
46 ChangeTupleSet ctsOut = new ChangeTupleSet();
48 Iterator itrO = this.iterator();
49 while( itrO.hasNext() ) {
50 TokenTupleSet o = (TokenTupleSet) itrO.next();
52 Iterator itrR = rsIn.iterator();
53 while( itrR.hasNext() ) {
54 TokenTupleSet r = (TokenTupleSet) itrR.next();
56 TokenTupleSet theUnion = new TokenTupleSet();
58 Iterator itrRelement = r.iterator();
59 while( itrRelement.hasNext() ) {
60 TokenTuple e = (TokenTuple) itrRelement.next();
62 if( o.contains( e ) ) {
63 theUnion.union( new TokenTupleSet( e.increaseArity() ) );
74 Set specialUnion( Set O, Set R ) {
84 if e.isSummaryToken() { // wait, stronger condition?
85 theUnion.add( e.copy().increaseArity() )
87 theUnion.add( e.copy() )
93 if !theUnion.contains( e ) {
94 theUnion.add( e.copy() )
98 if !theUnion.isEmpty() {
99 C.add( <o, theUnion> )