1 19 20 package soot.jimple.spark.sets; 21 import soot.jimple.spark.*; 22 import soot.jimple.spark.pag.Node; 23 import soot.jimple.spark.pag.PAG; 24 import java.util.*; 25 import soot.Type; 26 27 30 public final class HashPointsToSet extends PointsToSetInternal { 31 public HashPointsToSet( Type type, PAG pag ) { 32 super( type ); 33 this.pag = pag; 34 } 35 36 public final boolean isEmpty() { 37 return s.isEmpty(); 38 } 39 41 public final boolean addAll( final PointsToSetInternal other, 42 final PointsToSetInternal exclude ) { 43 if( other instanceof HashPointsToSet 44 && exclude == null 45 && ( pag.getTypeManager().getFastHierarchy() == null || 46 type == null || type.equals( other.type ) ) ) { 47 return s.addAll( ((HashPointsToSet) other).s ); 48 } else { 49 return super.addAll( other, exclude ); 50 } 51 } 52 53 public final boolean forall( P2SetVisitor v ) { 54 for( Iterator it = new ArrayList(s).iterator(); it.hasNext(); ) { 55 v.visit( (Node) it.next() ); 56 } 57 return v.getReturnValue(); 58 } 59 60 public final boolean add( Node n ) { 61 if( pag.getTypeManager().castNeverFails( n.getType(), type ) ) { 62 63 return s.add( n ); 64 } 65 return false; 66 } 67 68 public final boolean contains( Node n ) { 69 return s.contains( n ); 70 } 71 public static P2SetFactory getFactory() { 72 return new P2SetFactory() { 73 public PointsToSetInternal newSet( Type type, PAG pag ) { 74 return new HashPointsToSet( type, pag ); 75 } 76 }; 77 } 78 79 80 81 82 private HashSet s = new HashSet(4); 83 private PAG pag = null; 84 } 85 86 | Popular Tags |