More reachability set functionality, but not all there yet
authorjjenista <jjenista>
Tue, 1 Jul 2008 18:48:04 +0000 (18:48 +0000)
committerjjenista <jjenista>
Tue, 1 Jul 2008 18:48:04 +0000 (18:48 +0000)
Robust/src/Analysis/OwnershipAnalysis/ChangeTuple.java
Robust/src/Analysis/OwnershipAnalysis/ChangeTupleSet.java
Robust/src/Analysis/OwnershipAnalysis/ReachabilitySet.java
Robust/src/Analysis/OwnershipAnalysis/TokenTuple.java
Robust/src/Analysis/OwnershipAnalysis/TokenTupleSet.java

index 06dac9fc939ba25f066a93576c2fb2de1d50d8b2..9a1f8bdfda54fe8a4b2876354cb3bb6cc1436f93 100644 (file)
@@ -9,6 +9,9 @@ import java.io.*;
 // a change touple is a pair that indicates if the
 // first TokenTupleSet is found in a ReachabilitySet,
 // then the second TokenTupleSet should be added
+
+// THIS CLASS IS IMMUTABLE!
+
 public class ChangeTuple
 {
     private TokenTupleSet toMatch;
@@ -38,10 +41,6 @@ public class ChangeTuple
        return toMatch.hashCode() + toAdd.hashCode();
     }
 
-    public ChangeTuple copy() {
-       return new ChangeTuple( toMatch, toAdd );
-    }
-
     public String toString() {
        return new String( "<"+toMatch+" -> "+toAdd+">" );
     }
index 650716bccf9569682601ab53e70ddd728962cee8..c0d90104aa4f0131b1b8a730beadd1ae0f0c5356 100644 (file)
@@ -23,6 +23,10 @@ public class ChangeTupleSet {
        changeTuples = (HashSet<ChangeTuple>) cts.changeTuples.clone(); //COPY?!
     }
 
+    public Iterator iterator() {
+       return changeTuples.iterator();
+    }
+
     public ChangeTupleSet union( ChangeTupleSet ctsIn ) {
        ChangeTupleSet ctsOut = new ChangeTupleSet( this );
        ctsOut.changeTuples.addAll( ctsIn.changeTuples );
index ecb52ea69b3de800043fcfe5881c5339e6e2800d..6f612414bada4286e7a23e04ec364cf6a5270065 100644 (file)
@@ -18,6 +18,10 @@ public class ReachabilitySet {
        possibleReachabilities = (HashSet<TokenTupleSet>) rs.possibleReachabilities.clone(); // again, DEEP COPY?!
     }
 
+    public Iterator iterator() {
+       return possibleReachabilities.iterator();
+    }
+
     public ReachabilitySet union( ReachabilitySet rsIn ) {
        ReachabilitySet rsOut = new ReachabilitySet( this );
        rsOut.possibleReachabilities.addAll( rsIn.possibleReachabilities );
@@ -27,7 +31,7 @@ public class ReachabilitySet {
     public ReachabilitySet intersection( ReachabilitySet rsIn ) {
        ReachabilitySet rsOut = new ReachabilitySet();
 
-       Iterator i = this.possibleReachabilities.iterator();
+       Iterator i = this.iterator();
        while( i.hasNext() ) {
            TokenTupleSet tts = (TokenTupleSet) i.next();
            if( rsIn.possibleReachabilities.contains( tts ) ) {
@@ -38,9 +42,66 @@ public class ReachabilitySet {
        return rsOut;
     }
 
-    /*
     public ChangeTupleSet unionUpArity( ReachabilitySet rsIn ) {
-       
+       ChangeTupleSet ctsOut = new ChangeTupleSet();
+
+       Iterator itrO = this.iterator();
+       while( itrO.hasNext() ) {
+           TokenTupleSet o = (TokenTupleSet) itrO.next();
+
+           Iterator itrR = rsIn.iterator();
+           while( itrR.hasNext() ) {
+               TokenTupleSet r = (TokenTupleSet) itrR.next();
+
+               TokenTupleSet theUnion = new TokenTupleSet();
+
+               Iterator itrRelement = r.iterator();
+               while( itrRelement.hasNext() ) {
+                   TokenTuple e = (TokenTuple) itrRelement.next();
+
+                   if( o.contains( e ) ) {
+                       theUnion.union( new TokenTupleSet( e.increaseArity() ) );
+                   }
+               }
+           }
+       }
+
+       return ctsOut;
     }
-    */
 }
+
+/*
+Set specialUnion( Set O, Set R ) {
+  Set C = {}
+
+  foreach o in O {
+    foreach r in R {
+
+      Set theUnion = {}
+
+      foreach e in r {
+        if o.contains( e ) {
+          if e.isSummaryToken() { // wait, stronger condition?
+            theUnion.add( e.copy().increaseArity() )
+          } else {
+            theUnion.add( e.copy() )
+          }
+        }
+      }
+
+      foreach e in o {
+        if !theUnion.contains( e ) {
+           theUnion.add( e.copy() )
+        }
+      }
+
+      if !theUnion.isEmpty() {
+        C.add( <o, theUnion> )
+      }
+
+    }
+  }
+
+  return C
+}
+*/
index e9d3b400f1d2ba95d2b4c0bc4b039a5470d8ed9a..4d496987d89acb22ca0d30981395893a6bd851ac 100644 (file)
@@ -8,6 +8,9 @@ import java.io.*;
 
 // a token touple is a pair that indicates a
 // heap region node and an arity
+
+// THIS CLASS IS IMMUTABLE!
+
 public class TokenTuple
 {
     private Integer token;
@@ -35,10 +38,11 @@ public class TokenTuple
     public Integer getToken() { return token; }
     public int     getArity() {        return arity; }
 
-    public void increaseArity() {
+    public TokenTuple increaseArity() {
        if( isNewSummary ) {
-           arity = ARITY_MANY;
+           return new TokenTuple( token, isNewSummary, ARITY_MANY );
        }
+       return this;
     }
 
     public boolean equals( Object o ) {
@@ -56,12 +60,6 @@ public class TokenTuple
        return token.intValue();
     }
 
-    public TokenTuple copy() {
-       return new TokenTuple( token,
-                              isNewSummary,
-                              arity );
-    }
-
     public String toString() {
        String s = "";
        if( isNewSummary ) {
index a78943c9b94c12a59655fb84e406435b1868342b..626e5327fd9e679957b70373979e73d7c094a626 100644 (file)
@@ -23,19 +23,20 @@ public class TokenTupleSet {
        tokenTuples = (HashSet<TokenTuple>) tts.tokenTuples.clone(); //COPY?!
     }
 
+    public Iterator iterator() {
+       return tokenTuples.iterator();
+    }
+
     public TokenTupleSet union( TokenTupleSet ttsIn ) {
        TokenTupleSet ttsOut = new TokenTupleSet( this );
        ttsOut.tokenTuples.addAll( ttsIn.tokenTuples );
-       /*
-       Iterator i = ttsIn.tokenTuples.iterator();
-       while( i.hasNext() ) {
-           ttsOut.tokenTuples.add( (TokenTuple) i.next() );
-       }
-       */
-
        return ttsOut;
     }
 
+    public boolean contains( TokenTuple tt ) {
+       return tokenTuples.contains( tt );
+    }
+
     public String toString() {
        return tokenTuples.toString();
     }