more type and method references; support for adding static fields to the FakeRootClass for analysis modelling purposes
git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@786 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
parent
24d290beb8
commit
8ad9a91582
|
@ -26,15 +26,7 @@ import com.ibm.wala.ipa.callgraph.propagation.rta.RTAContextInterpreter;
|
||||||
import com.ibm.wala.ipa.cha.ClassHierarchy;
|
import com.ibm.wala.ipa.cha.ClassHierarchy;
|
||||||
import com.ibm.wala.ipa.summaries.SyntheticIR;
|
import com.ibm.wala.ipa.summaries.SyntheticIR;
|
||||||
import com.ibm.wala.shrikeBT.IInvokeInstruction;
|
import com.ibm.wala.shrikeBT.IInvokeInstruction;
|
||||||
import com.ibm.wala.ssa.ConstantValue;
|
import com.ibm.wala.ssa.*;
|
||||||
import com.ibm.wala.ssa.IR;
|
|
||||||
import com.ibm.wala.ssa.SSAArrayStoreInstruction;
|
|
||||||
import com.ibm.wala.ssa.SSAGetInstruction;
|
|
||||||
import com.ibm.wala.ssa.SSAInstruction;
|
|
||||||
import com.ibm.wala.ssa.SSAInvokeInstruction;
|
|
||||||
import com.ibm.wala.ssa.SSANewInstruction;
|
|
||||||
import com.ibm.wala.ssa.SSAOptions;
|
|
||||||
import com.ibm.wala.ssa.SSAPhiInstruction;
|
|
||||||
import com.ibm.wala.types.FieldReference;
|
import com.ibm.wala.types.FieldReference;
|
||||||
import com.ibm.wala.types.MethodReference;
|
import com.ibm.wala.types.MethodReference;
|
||||||
import com.ibm.wala.types.TypeReference;
|
import com.ibm.wala.types.TypeReference;
|
||||||
|
@ -235,6 +227,12 @@ public abstract class AbstractRootMethod extends SyntheticMethod {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int addCheckcast(TypeReference type, int rv) {
|
||||||
|
int lv = nextLocal++;
|
||||||
|
statements.add(SSAInstructionFactory.CheckCastInstruction(lv, rv, type));
|
||||||
|
return lv;
|
||||||
|
}
|
||||||
|
|
||||||
public RTAContextInterpreter getInterpreter() {
|
public RTAContextInterpreter getInterpreter() {
|
||||||
return new RTAContextInterpreter() {
|
return new RTAContextInterpreter() {
|
||||||
|
|
||||||
|
|
|
@ -1,20 +1,18 @@
|
||||||
package com.ibm.wala.ipa.callgraph.impl;
|
package com.ibm.wala.ipa.callgraph.impl;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
import com.ibm.wala.classLoader.IClass;
|
import com.ibm.wala.classLoader.IClass;
|
||||||
import com.ibm.wala.classLoader.IField;
|
import com.ibm.wala.classLoader.IField;
|
||||||
import com.ibm.wala.classLoader.IMethod;
|
import com.ibm.wala.classLoader.IMethod;
|
||||||
import com.ibm.wala.classLoader.SyntheticClass;
|
import com.ibm.wala.classLoader.SyntheticClass;
|
||||||
import com.ibm.wala.ipa.cha.ClassHierarchy;
|
import com.ibm.wala.ipa.cha.ClassHierarchy;
|
||||||
import com.ibm.wala.ipa.cha.ClassHierarchyException;
|
import com.ibm.wala.ipa.cha.ClassHierarchyException;
|
||||||
import com.ibm.wala.types.ClassLoaderReference;
|
import com.ibm.wala.types.*;
|
||||||
import com.ibm.wala.types.Selector;
|
|
||||||
import com.ibm.wala.types.TypeName;
|
|
||||||
import com.ibm.wala.types.TypeReference;
|
|
||||||
import com.ibm.wala.util.Atom;
|
import com.ibm.wala.util.Atom;
|
||||||
import com.ibm.wala.util.debug.Assertions;
|
import com.ibm.wala.util.debug.Assertions;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* A synthetic class for the fake root method
|
* A synthetic class for the fake root method
|
||||||
|
@ -25,10 +23,64 @@ public class FakeRootClass extends SyntheticClass {
|
||||||
public static final TypeReference FAKE_ROOT_CLASS = TypeReference.findOrCreate(ClassLoaderReference.Primordial, TypeName
|
public static final TypeReference FAKE_ROOT_CLASS = TypeReference.findOrCreate(ClassLoaderReference.Primordial, TypeName
|
||||||
.string2TypeName("Lcom/ibm/wala/FakeRootClass"));
|
.string2TypeName("Lcom/ibm/wala/FakeRootClass"));
|
||||||
|
|
||||||
|
private Map fakeRootStaticFields = null;
|
||||||
|
|
||||||
FakeRootClass(ClassHierarchy cha) {
|
FakeRootClass(ClassHierarchy cha) {
|
||||||
super(FAKE_ROOT_CLASS, cha);
|
super(FAKE_ROOT_CLASS, cha);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addStaticField(final Atom name, final TypeReference fieldType) {
|
||||||
|
if (fakeRootStaticFields == null) {
|
||||||
|
fakeRootStaticFields = new HashMap(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
fakeRootStaticFields.put(name, new IField() {
|
||||||
|
public ClassHierarchy getClassHierarchy() {
|
||||||
|
return FakeRootClass.this.getClassHierarchy();
|
||||||
|
}
|
||||||
|
|
||||||
|
public TypeReference getFieldTypeReference() {
|
||||||
|
return fieldType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IClass getDeclaringClass() {
|
||||||
|
return FakeRootClass.this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Atom getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isStatic() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isVolatile() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FieldReference getFieldReference() {
|
||||||
|
return FieldReference.findOrCreate(FAKE_ROOT_CLASS, name, fieldType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFinal() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPrivate() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isProtected() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPublic() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
|
@ -99,9 +151,11 @@ public class FakeRootClass extends SyntheticClass {
|
||||||
* @see com.ibm.wala.classLoader.IClass#getMethod(com.ibm.wala.classLoader.Selector)
|
* @see com.ibm.wala.classLoader.IClass#getMethod(com.ibm.wala.classLoader.Selector)
|
||||||
*/
|
*/
|
||||||
public IField getField(Atom name) {
|
public IField getField(Atom name) {
|
||||||
// TODO Auto-generated method stub
|
if (fakeRootStaticFields != null) {
|
||||||
Assertions.UNREACHABLE();
|
return (IField) fakeRootStaticFields.get(name);
|
||||||
return null;
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -143,9 +197,11 @@ public class FakeRootClass extends SyntheticClass {
|
||||||
* @see com.ibm.wala.classLoader.IClass#getDeclaredStaticFields()
|
* @see com.ibm.wala.classLoader.IClass#getDeclaredStaticFields()
|
||||||
*/
|
*/
|
||||||
public Collection<IField> getDeclaredStaticFields() {
|
public Collection<IField> getDeclaredStaticFields() {
|
||||||
// TODO Auto-generated method stub
|
if (fakeRootStaticFields != null) {
|
||||||
Assertions.UNREACHABLE();
|
return fakeRootStaticFields.values();
|
||||||
return null;
|
} else {
|
||||||
|
return Collections.EMPTY_SET;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -185,8 +241,7 @@ public class FakeRootClass extends SyntheticClass {
|
||||||
* @see com.ibm.wala.classLoader.IClass#getAllStaticFields()
|
* @see com.ibm.wala.classLoader.IClass#getAllStaticFields()
|
||||||
*/
|
*/
|
||||||
public Collection<IField> getAllStaticFields() throws ClassHierarchyException {
|
public Collection<IField> getAllStaticFields() throws ClassHierarchyException {
|
||||||
Assertions.UNREACHABLE();
|
return getDeclaredStaticFields();
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -205,11 +260,10 @@ public class FakeRootClass extends SyntheticClass {
|
||||||
* @see com.ibm.wala.classLoader.IClass#getAllFields()
|
* @see com.ibm.wala.classLoader.IClass#getAllFields()
|
||||||
*/
|
*/
|
||||||
public Collection<IField> getAllFields() throws ClassHierarchyException {
|
public Collection<IField> getAllFields() throws ClassHierarchyException {
|
||||||
Assertions.UNREACHABLE();
|
return getDeclaredStaticFields();
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPublic() {
|
public boolean isPublic() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -815,6 +815,10 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
|
||||||
}
|
}
|
||||||
|
|
||||||
IField f = getClassHierarchy().resolveField(field);
|
IField f = getClassHierarchy().resolveField(field);
|
||||||
|
if (f == null && callGraph.getFakeRootNode().getMethod().getDeclaringClass().getReference().equals(field.getType())) {
|
||||||
|
f = callGraph.getFakeRootNode().getMethod().getDeclaringClass().getField(field.getName());
|
||||||
|
}
|
||||||
|
|
||||||
if (f == null) {
|
if (f == null) {
|
||||||
getWarnings().add(ResolutionFailure.create(node, field));
|
getWarnings().add(ResolutionFailure.create(node, field));
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -56,6 +56,10 @@ public final class MethodReference extends MemberReference {
|
||||||
public final static Descriptor runDesc = Descriptor.findOrCreateUTF8("()Ljava/lang/Object;");
|
public final static Descriptor runDesc = Descriptor.findOrCreateUTF8("()Ljava/lang/Object;");
|
||||||
public final static Selector runSelector = new Selector(runAtom, runDesc);
|
public final static Selector runSelector = new Selector(runAtom, runDesc);
|
||||||
|
|
||||||
|
public final static Atom equalsAtom = Atom.findOrCreateUnicodeAtom("equals");
|
||||||
|
public final static Descriptor equalsDesc = Descriptor.findOrCreateUTF8("(Ljava/lang/Object;)Z");
|
||||||
|
public final static Selector equalsSelector = new Selector(equalsAtom, equalsDesc);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* types of parameters to this method.
|
* types of parameters to this method.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -230,6 +230,14 @@ public final class TypeReference {
|
||||||
|
|
||||||
public final static TypeReference JavaLangCloneable = findOrCreate(ClassLoaderReference.Primordial, JavaLangCloneableName);
|
public final static TypeReference JavaLangCloneable = findOrCreate(ClassLoaderReference.Primordial, JavaLangCloneableName);
|
||||||
|
|
||||||
|
private final static TypeName JavaLangSystemName = TypeName.string2TypeName("Ljava/lang/System");
|
||||||
|
|
||||||
|
public final static TypeReference JavaLangSystem = findOrCreate(ClassLoaderReference.Primordial, JavaLangSystemName);
|
||||||
|
|
||||||
|
private final static TypeName JavaLangIntegerName = TypeName.string2TypeName("Ljava/lang/Integer");
|
||||||
|
|
||||||
|
public final static TypeReference JavaLangInteger = findOrCreate(ClassLoaderReference.Primordial, JavaLangIntegerName);
|
||||||
|
|
||||||
private final static TypeName JavaIoSerializableName = TypeName.string2TypeName("Ljava/io/Serializable");
|
private final static TypeName JavaIoSerializableName = TypeName.string2TypeName("Ljava/io/Serializable");
|
||||||
|
|
||||||
public final static TypeReference JavaIoSerializable = findOrCreate(ClassLoaderReference.Primordial, JavaIoSerializableName);
|
public final static TypeReference JavaIoSerializable = findOrCreate(ClassLoaderReference.Primordial, JavaIoSerializableName);
|
||||||
|
|
Loading…
Reference in New Issue