Broadening implementation for reachability in ownership analysis.
authorjjenista <jjenista>
Fri, 27 Jun 2008 20:24:54 +0000 (20:24 +0000)
committerjjenista <jjenista>
Fri, 27 Jun 2008 20:24:54 +0000 (20:24 +0000)
Robust/src/Analysis/OwnershipAnalysis/ChangeTuple.java [new file with mode: 0644]
Robust/src/Analysis/OwnershipAnalysis/ChangeTupleSet.java [new file with mode: 0644]
Robust/src/Analysis/OwnershipAnalysis/ReachabilitySet.java
Robust/src/Analysis/OwnershipAnalysis/TokenTupleSet.java
Robust/src/Makefile

diff --git a/Robust/src/Analysis/OwnershipAnalysis/ChangeTuple.java b/Robust/src/Analysis/OwnershipAnalysis/ChangeTuple.java
new file mode 100644 (file)
index 0000000..06dac9f
--- /dev/null
@@ -0,0 +1,48 @@
+package Analysis.OwnershipAnalysis;
+
+import IR.*;
+import IR.Flat.*;
+import java.util.*;
+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
+public class ChangeTuple
+{
+    private TokenTupleSet toMatch;
+    private TokenTupleSet toAdd;
+
+    public ChangeTuple( TokenTupleSet toMatch,
+                       TokenTupleSet toAdd ) {
+       this.toMatch = toMatch;
+       this.toAdd   = toAdd;
+    }
+
+    public TokenTupleSet getSetToMatch() { return toMatch; }
+    public TokenTupleSet getSetToAdd()   { return toAdd;   }
+
+    public boolean equals( Object o ) {
+       if( !(o instanceof ChangeTuple) ) {
+           return false;
+       }
+
+       ChangeTuple ct = (ChangeTuple) o;
+
+       return toMatch.equals( ct.getSetToMatch() ) &&
+                toAdd.equals( ct.getSetToAdd()   );
+    }
+
+    public int hashCode() {
+       return toMatch.hashCode() + toAdd.hashCode();
+    }
+
+    public ChangeTuple copy() {
+       return new ChangeTuple( toMatch, toAdd );
+    }
+
+    public String toString() {
+       return new String( "<"+toMatch+" -> "+toAdd+">" );
+    }
+}
diff --git a/Robust/src/Analysis/OwnershipAnalysis/ChangeTupleSet.java b/Robust/src/Analysis/OwnershipAnalysis/ChangeTupleSet.java
new file mode 100644 (file)
index 0000000..650716b
--- /dev/null
@@ -0,0 +1,39 @@
+package Analysis.OwnershipAnalysis;
+
+import IR.*;
+import IR.Flat.*;
+import java.util.*;
+import java.io.*;
+
+
+public class ChangeTupleSet {
+
+    public HashSet<ChangeTuple> changeTuples;
+
+    public ChangeTupleSet() {
+       changeTuples = new HashSet<ChangeTuple>();
+    }
+
+    public ChangeTupleSet( ChangeTuple ct ) {
+       this();
+       changeTuples.add( ct );
+    }
+
+    public ChangeTupleSet( ChangeTupleSet cts ) {
+       changeTuples = (HashSet<ChangeTuple>) cts.changeTuples.clone(); //COPY?!
+    }
+
+    public ChangeTupleSet union( ChangeTupleSet ctsIn ) {
+       ChangeTupleSet ctsOut = new ChangeTupleSet( this );
+       ctsOut.changeTuples.addAll( ctsIn.changeTuples );
+       return ctsOut;
+    }
+
+    public boolean isSubset( ChangeTupleSet ctsIn ) {
+       return ctsIn.changeTuples.containsAll( this.changeTuples );
+    }
+
+    public String toString() {
+       return changeTuples.toString();
+    }
+}
index 45dd8407db4a242752288ad0587e4300cbb57046..ecb52ea69b3de800043fcfe5881c5339e6e2800d 100644 (file)
@@ -10,6 +10,37 @@ public class ReachabilitySet {
 
     public HashSet<TokenTupleSet> possibleReachabilities;
 
-    
-    // this one has special union.
-}
\ No newline at end of file
+    public ReachabilitySet() {
+       possibleReachabilities = new HashSet<TokenTupleSet>();
+    }
+
+    public ReachabilitySet( ReachabilitySet rs ) {
+       possibleReachabilities = (HashSet<TokenTupleSet>) rs.possibleReachabilities.clone(); // again, DEEP COPY?!
+    }
+
+    public ReachabilitySet union( ReachabilitySet rsIn ) {
+       ReachabilitySet rsOut = new ReachabilitySet( this );
+       rsOut.possibleReachabilities.addAll( rsIn.possibleReachabilities );
+       return rsOut;
+    }
+
+    public ReachabilitySet intersection( ReachabilitySet rsIn ) {
+       ReachabilitySet rsOut = new ReachabilitySet();
+
+       Iterator i = this.possibleReachabilities.iterator();
+       while( i.hasNext() ) {
+           TokenTupleSet tts = (TokenTupleSet) i.next();
+           if( rsIn.possibleReachabilities.contains( tts ) ) {
+               rsOut.possibleReachabilities.add( tts );
+           }
+       }
+
+       return rsOut;
+    }
+
+    /*
+    public ChangeTupleSet unionUpArity( ReachabilitySet rsIn ) {
+       
+    }
+    */
+}
index 3ff84e385a70942a8b792decdf6a74e2c9744599..a78943c9b94c12a59655fb84e406435b1868342b 100644 (file)
@@ -25,11 +25,13 @@ public class TokenTupleSet {
 
     public TokenTupleSet union( TokenTupleSet ttsIn ) {
        TokenTupleSet ttsOut = new TokenTupleSet( this );
-       //ttsOut.tokenTuples.addAll( ttsIn.tokenTuples );
+       ttsOut.tokenTuples.addAll( ttsIn.tokenTuples );
+       /*
        Iterator i = ttsIn.tokenTuples.iterator();
        while( i.hasNext() ) {
            ttsOut.tokenTuples.add( (TokenTuple) i.next() );
        }
+       */
 
        return ttsOut;
     }
index 6efe1c0fafea1547085812c7763ef89cb360fcf6..e51d471789ee068ecaea15c53eabc342d55db9c6 100644 (file)
@@ -83,6 +83,8 @@ Analysis/OwnershipAnalysis/AllocationSite.class                         \
 Analysis/OwnershipAnalysis/TokenTuple.class                             \
 Analysis/OwnershipAnalysis/TokenTupleSet.class                          \
 Analysis/OwnershipAnalysis/ReachabilitySet.class                        \
+Analysis/OwnershipAnalysis/ChangeTuple.class                            \
+Analysis/OwnershipAnalysis/ChangeTupleSet.class                         \
 Util/GraphNode.class Util/Namer.class Util/Relation.class              \
 Interface/HTTPHeader.class Interface/HTTPResponse.class                        \
 Interface/HTTPServices.class Interface/HashStrings.class               \