[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: about reaching object of array
The special elements field is represented by
soot.jimple.spark.pag.ArrayElement.v().
The attached patch adds a reachingObjectsOfArrayElement() method to
PointsToAnalysis that should do what you need.
This patch will be included in future Soot releases.
Ondrej
On Fri, Sep 19, 2003 at 05:33:05PM +1000, Phung Hua Nguyen wrote:
> Hi All,
>
> I would like to know how to get objects reached through array.
> In PointsToAnalysis, there are methods like
> reachingObjects(PointsToSet, SootField) but I don't know what SootField
> is for array. In the document, you mentioned about special field
> "elements" to represent the elements of array. But I couldn't find the
> special field in Spark.
>
> Thanks,
>
> Nguyen Hua Phung
> University of New South Wales
Index: src/soot/jimple/spark/pag/PAG.java
===================================================================
--- src/soot/jimple/spark/pag/PAG.java (revision 1166)
+++ src/soot/jimple/spark/pag/PAG.java (working copy)
@@ -130,6 +130,17 @@
public PointsToSet reachingObjects( PointsToSet s, final SootField f ) {
if( f.isStatic() )
throw new RuntimeException( "The parameter f must be an *instance* field." );
+
+ return reachingObjectsInternal( s, f );
+ }
+
+ /** Returns the set of objects pointed to by elements of the arrays
+ * in the PointsToSet s. */
+ public PointsToSet reachingObjectsOfArrayElement( PointsToSet s ) {
+ return reachingObjectsInternal( s, ArrayElement.v() );
+ }
+
+ private PointsToSet reachingObjectsInternal( PointsToSet s, final SparkField f ) {
if( getOpts().field_based() || getOpts().vta() ) {
VarNode n = findGlobalVarNode( f );
if( n == null ) {
@@ -141,7 +152,8 @@
throw new RuntimeException( "The alias edge propagator does not compute points-to information for instance fields! Use a different propagator." );
}
PointsToSetInternal bases = (PointsToSetInternal) s;
- final PointsToSetInternal ret = setFactory.newSet( f.getType(), this );
+ final PointsToSetInternal ret = setFactory.newSet(
+ (f instanceof SootField) ? ((SootField)f).getType() : null, this );
bases.forall( new P2SetVisitor() {
public final void visit( Node n ) {
ret.addAll( ((AllocNode) n).dot( f ).getP2Set(), null );
Index: src/soot/jimple/spark/pag/BDDPAG.java
===================================================================
--- src/soot/jimple/spark/pag/BDDPAG.java (revision 1166)
+++ src/soot/jimple/spark/pag/BDDPAG.java (working copy)
@@ -63,6 +63,9 @@
public PointsToSet reachingObjects( PointsToSet ptset, SootField f ) {
throw new RuntimeException( "NYI" );
}
+ public PointsToSet reachingObjectsOfArrayElement( PointsToSet ptset ) {
+ throw new RuntimeException( "NYI" );
+ }
public Iterator simpleSourcesIterator() {
return edgeSet.projectDownTo( src ).iterator();
Index: src/soot/jimple/toolkits/pointer/DumbPointerAnalysis.java
===================================================================
--- src/soot/jimple/toolkits/pointer/DumbPointerAnalysis.java (revision 1166)
+++ src/soot/jimple/toolkits/pointer/DumbPointerAnalysis.java (working copy)
@@ -51,5 +51,11 @@
public PointsToSet reachingObjects( Local l, SootField f ) {
return reachingObjects(f);
}
+
+ /** Returns the set of objects pointed to by elements of the arrays
+ * in the PointsToSet s. */
+ public PointsToSet reachingObjectsOfArrayElement( PointsToSet s ) {
+ return FullObjectSet.v();
+ }
}
Index: src/soot/PointsToAnalysis.java
===================================================================
--- src/soot/PointsToAnalysis.java (revision 1166)
+++ src/soot/PointsToAnalysis.java (working copy)
@@ -38,6 +38,10 @@
* of the objects pointed to by l. */
public PointsToSet reachingObjects( Local l, SootField f );
+ /** Returns the set of objects pointed to by elements of the arrays
+ * in the PointsToSet s. */
+ public PointsToSet reachingObjectsOfArrayElement( PointsToSet s );
+
public static final Integer THIS_NODE = new Integer( -1 );
public static final int RETURN_NODE = -2;
public static final Integer THROW_NODE = new Integer( -3 );