1 19 20 package soot.jimple.spark.pag; 21 import soot.jimple.spark.*; 22 import soot.*; 23 import java.util.*; 24 25 28 public abstract class VarNode extends ValNode implements Comparable { 29 public Context context() { return null; } 30 31 public Collection getAllFieldRefs() { 32 if( fields == null ) return Collections.EMPTY_LIST; 33 return fields.values(); 34 } 35 37 public FieldRefNode dot( SparkField field ) 38 { return fields == null ? null : (FieldRefNode) fields.get( field ); } 39 public int compareTo( Object o ) { 40 VarNode other = (VarNode) o; 41 if( other.finishingNumber == finishingNumber && other != this ) { 42 G.v().out.println( "This is: "+this+" with id "+getNumber()+" and number "+finishingNumber ); 43 G.v().out.println( "Other is: "+other+" with id "+other.getNumber()+" and number "+other.finishingNumber ); 44 throw new RuntimeException ("Comparison error" ); 45 } 46 return other.finishingNumber - finishingNumber; 47 } 48 public void setFinishingNumber( int i ) { 49 finishingNumber = i; 50 if( i > pag.maxFinishNumber ) pag.maxFinishNumber = i; 51 } 52 53 public Object getVariable() { 54 return variable; 55 } 56 57 60 public void setInterProcTarget() { 61 interProcTarget = true; 62 } 63 66 public boolean isInterProcTarget() { 67 return interProcTarget; 68 } 69 70 73 public void setInterProcSource() { 74 interProcSource = true; 75 } 76 79 public boolean isInterProcSource() { 80 return interProcSource; 81 } 82 83 84 85 VarNode( PAG pag, Object variable, Type t ) { 86 super( pag, t ); 87 if( !(t instanceof RefLikeType) || t instanceof AnySubType ) { 88 throw new RuntimeException ( "Attempt to create VarNode of type "+t ); 89 } 90 this.variable = variable; 91 pag.getVarNodeNumberer().add(this); 92 setFinishingNumber( ++pag.maxFinishNumber ); 93 } 94 95 void addField( FieldRefNode frn, SparkField field ) { 96 if( fields == null ) fields = new HashMap(); 97 fields.put( field, frn ); 98 } 99 100 101 102 protected Object variable; 103 protected Map fields; 104 protected int finishingNumber = 0; 105 protected boolean interProcTarget = false; 106 protected boolean interProcSource = false; 107 protected int numDerefs = 0; 108 } 109 110 | Popular Tags |