1 19 20 package soot.jimple.toolkits.pointer; 21 import soot.*; 22 import java.util.*; 23 24 public class MemoryEfficientRasUnion extends Union { 25 HashSet subsets; 26 27 public boolean isEmpty() { 28 if( subsets == null ) return true; 29 for( Iterator subsetIt = subsets.iterator(); subsetIt.hasNext(); ) { 30 final PointsToSet subset = (PointsToSet) subsetIt.next(); 31 if( !subset.isEmpty() ) return false; 32 } 33 return true; 34 } 35 public boolean hasNonEmptyIntersection( PointsToSet other ) { 36 if( subsets == null ) return true; 37 for( Iterator subsetIt = subsets.iterator(); subsetIt.hasNext(); ) { 38 final PointsToSet subset = (PointsToSet) subsetIt.next(); 39 if( other instanceof Union ) { 40 if( other.hasNonEmptyIntersection( subset ) ) return true; 41 } else { 42 if( subset.hasNonEmptyIntersection( other ) ) return true; 43 } 44 } 45 return false; 46 } 47 public boolean addAll( PointsToSet s ) { 48 boolean ret = false; 49 if( subsets == null ) subsets = new HashSet(); 50 if( s instanceof Union ) { 51 MemoryEfficientRasUnion meru = (MemoryEfficientRasUnion) s; 52 if( meru.subsets == null || subsets.containsAll( meru.subsets ) ) { 53 return false; 54 } 55 return subsets.addAll( meru.subsets ); 56 } else { 57 PointsToSet r = (PointsToSet) s; 58 return subsets.add( s ); 59 } 60 } 61 public Object clone() { 62 MemoryEfficientRasUnion ret = new MemoryEfficientRasUnion(); 63 ret.addAll( this ); 64 return ret; 65 } 66 public Set possibleTypes() { 67 if( subsets == null ) { 68 return Collections.EMPTY_SET; 69 } 70 HashSet ret = new HashSet(); 71 for( Iterator subsetIt = subsets.iterator(); subsetIt.hasNext(); ) { 72 final PointsToSet subset = (PointsToSet) subsetIt.next(); 73 ret.addAll( subset.possibleTypes() ); 74 } 75 return ret; 76 } 77 public MemoryEfficientRasUnion() { 78 } 79 80 81 } 82 | Popular Tags |