add global to field-based pointer analysis
This commit is contained in:
parent
afb113efb9
commit
339de954ea
|
@ -19,6 +19,7 @@ import org.junit.Assert;
|
|||
import org.junit.Test;
|
||||
|
||||
import com.ibm.wala.analysis.pointers.HeapGraph;
|
||||
import com.ibm.wala.cast.ir.ssa.AstGlobalWrite;
|
||||
import com.ibm.wala.cast.js.callgraph.fieldbased.flowgraph.vertices.GlobalVertex;
|
||||
import com.ibm.wala.cast.js.callgraph.fieldbased.flowgraph.vertices.ObjectVertex;
|
||||
import com.ibm.wala.cast.js.html.JSSourceExtractor;
|
||||
|
@ -34,7 +35,6 @@ import com.ibm.wala.cast.js.types.JavaScriptTypes;
|
|||
import com.ibm.wala.cast.loader.AstDynamicField;
|
||||
import com.ibm.wala.cast.types.AstMethodReference;
|
||||
import com.ibm.wala.classLoader.CallSiteReference;
|
||||
import com.ibm.wala.classLoader.IField;
|
||||
import com.ibm.wala.classLoader.NewSiteReference;
|
||||
import com.ibm.wala.ipa.callgraph.CGNode;
|
||||
import com.ibm.wala.ipa.callgraph.CallGraph;
|
||||
|
@ -264,7 +264,13 @@ public abstract class TestPointerAnalyses {
|
|||
|
||||
System.err.println("heap graph models instruction " + inst);
|
||||
}
|
||||
}
|
||||
} else if (inst instanceof AstGlobalWrite) {
|
||||
String propName = ((AstGlobalWrite) inst).getGlobalName();
|
||||
propName = propName.substring("global ".length());
|
||||
PointerKey propKey = fbPA.getHeapModel().getPointerKeyForInstanceField(null, new AstDynamicField(false, null, Atom.findOrCreateUnicodeAtom(propName), JavaScriptTypes.Root));
|
||||
Assert.assertTrue("global " + propName + " should exist", hg.hasEdge(GlobalVertex.instance(), propKey));
|
||||
|
||||
System.err.println("heap graph models instruction " + inst);}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ import java.util.Iterator;
|
|||
import java.util.Set;
|
||||
|
||||
import com.ibm.wala.analysis.pointers.HeapGraph;
|
||||
import com.ibm.wala.cast.ir.ssa.AstGlobalWrite;
|
||||
import com.ibm.wala.cast.js.callgraph.fieldbased.flowgraph.vertices.AbstractVertexVisitor;
|
||||
import com.ibm.wala.cast.js.callgraph.fieldbased.flowgraph.vertices.CreationSiteVertex;
|
||||
import com.ibm.wala.cast.js.callgraph.fieldbased.flowgraph.vertices.FuncVertex;
|
||||
|
@ -355,6 +356,8 @@ public class FlowGraph implements Iterable<Vertex> {
|
|||
for(ObjectVertex o : getPointsToSet(object)) {
|
||||
addEdge(ensureNode(o), ensureNode(property));
|
||||
}
|
||||
} else if (inst instanceof AstGlobalWrite) {
|
||||
addEdge(ensureNode(factory.global()), ensureNode(property));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,16 @@ import com.ibm.wala.util.collections.Pair;
|
|||
|
||||
public class GlobalVertex extends Vertex implements ObjectVertex {
|
||||
|
||||
private GlobalVertex() {
|
||||
|
||||
}
|
||||
|
||||
public static final GlobalVertex global = new GlobalVertex();
|
||||
|
||||
public static GlobalVertex instance() {
|
||||
return global;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IClass getConcreteType() {
|
||||
return null;
|
||||
|
|
|
@ -128,7 +128,7 @@ public class VertexFactory {
|
|||
return value;
|
||||
}
|
||||
|
||||
private GlobalVertex global = new GlobalVertex();
|
||||
private GlobalVertex global = GlobalVertex.instance();
|
||||
|
||||
public GlobalVertex global() {
|
||||
return global;
|
||||
|
|
Loading…
Reference in New Issue