1 19 20 package soot.jimple.spark.pag; 21 import soot.jimple.spark.*; 22 import soot.*; 23 import java.util.*; 24 25 28 public class AllocNode extends Node implements Context { 29 30 public Object getNewExpr() { return newExpr; } 31 32 public Collection getAllFieldRefs() { 33 if( fields == null ) return Collections.EMPTY_LIST; 34 return fields.values(); 35 } 36 38 public AllocDotField dot( SparkField field ) 39 { return fields == null ? null : (AllocDotField) fields.get( field ); } 40 public String toString() { 41 return "AllocNode "+getNumber()+" "+newExpr+" in method "+method; 42 } 43 44 45 46 AllocNode( PAG pag, Object newExpr, Type t, SootMethod m ) { 47 super( pag, t ); 48 this.method = m; 49 if( t instanceof RefType ) { 50 RefType rt = (RefType) t; 51 if( rt.getSootClass().isAbstract() ) { 52 throw new RuntimeException ( "Attempt to create allocnode with abstract type "+t ); 53 } 54 } 55 this.newExpr = newExpr; 56 if( newExpr instanceof ContextVarNode ) throw new RuntimeException (); 57 pag.getAllocNodeNumberer().add( this ); 58 } 59 60 void addField( AllocDotField adf, SparkField field ) { 61 if( fields == null ) fields = new HashMap(); 62 fields.put( field, adf ); 63 } 64 65 public Set getFields() { 66 if( fields == null ) return Collections.EMPTY_SET; 67 return new HashSet( fields.values() ); 68 } 69 70 71 72 protected Object newExpr; 73 protected Map fields; 74 75 private SootMethod method; 76 public SootMethod getMethod() { return method; } 77 } 78 79 | Popular Tags |