1 package Analysis.OwnershipAnalysis;
9 public class ReachabilitySet {
11 private HashSet<TokenTupleSet> possibleReachabilities;
13 public ReachabilitySet() {
14 possibleReachabilities = new HashSet<TokenTupleSet>();
17 public ReachabilitySet( TokenTupleSet tts ) {
18 possibleReachabilities = new HashSet<TokenTupleSet>();
19 possibleReachabilities.add( tts );
22 public ReachabilitySet( ReachabilitySet rs ) {
23 possibleReachabilities = (HashSet<TokenTupleSet>) rs.possibleReachabilities.clone(); // again, DEEP COPY?!
26 public Iterator iterator() {
27 return possibleReachabilities.iterator();
30 public ReachabilitySet union( ReachabilitySet rsIn ) {
31 ReachabilitySet rsOut = new ReachabilitySet( this );
32 rsOut.possibleReachabilities.addAll( rsIn.possibleReachabilities );
36 public ReachabilitySet intersection( ReachabilitySet rsIn ) {
37 ReachabilitySet rsOut = new ReachabilitySet();
39 Iterator i = this.iterator();
40 while( i.hasNext() ) {
41 TokenTupleSet tts = (TokenTupleSet) i.next();
42 if( rsIn.possibleReachabilities.contains( tts ) ) {
43 rsOut.possibleReachabilities.add( tts );
50 public ChangeTupleSet unionUpArity( ReachabilitySet rsIn ) {
51 ChangeTupleSet ctsOut = new ChangeTupleSet();
53 Iterator itrO = this.iterator();
54 while( itrO.hasNext() ) {
55 TokenTupleSet o = (TokenTupleSet) itrO.next();
57 Iterator itrR = rsIn.iterator();
58 while( itrR.hasNext() ) {
59 TokenTupleSet r = (TokenTupleSet) itrR.next();
61 TokenTupleSet theUnion = new TokenTupleSet();
63 Iterator itrRelement = r.iterator();
64 while( itrRelement.hasNext() ) {
65 TokenTuple e = (TokenTuple) itrRelement.next();
67 if( o.containsToken( e.getToken() ) ) {
68 theUnion = theUnion.union( new TokenTupleSet( e.increaseArity() ) );
70 theUnion = theUnion.union( new TokenTupleSet( e ) );
74 Iterator itrOelement = o.iterator();
75 while( itrOelement.hasNext() ) {
76 TokenTuple e = (TokenTuple) itrOelement.next();
78 if( !theUnion.containsToken( e.getToken() ) ) {
79 theUnion = theUnion.union( new TokenTupleSet( e ) );
83 if( !theUnion.isEmpty() ) {
84 ctsOut = ctsOut.union(
86 new ChangeTuple( o, theUnion )
96 public String toString() {
99 Iterator i = this.iterator();
100 while( i.hasNext() ) {