Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
d32aff7e9a
|
@ -65,6 +65,7 @@ import com.ibm.wala.ipa.cha.IClassHierarchy;
|
|||
import com.ibm.wala.shrikeCT.AnnotationsReader.ConstantElementValue;
|
||||
import com.ibm.wala.shrikeCT.AnnotationsReader.ElementValue;
|
||||
import com.ibm.wala.shrikeCT.ClassConstants;
|
||||
import com.ibm.wala.ssa.SSAInstruction;
|
||||
import com.ibm.wala.ssa.SSAThrowInstruction;
|
||||
import com.ibm.wala.ssa.SymbolTable;
|
||||
import com.ibm.wala.types.ClassLoaderReference;
|
||||
|
@ -170,7 +171,7 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
|
|||
}
|
||||
|
||||
private void addMethod(CAstEntity methodEntity, IClass owner, AbstractCFG cfg, SymbolTable symtab, boolean hasCatchBlock,
|
||||
Map<IBasicBlock, TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo, DebuggingInformation debugInfo) {
|
||||
Map<IBasicBlock<SSAInstruction>, TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo, DebuggingInformation debugInfo) {
|
||||
declaredMethods.put(Util.methodEntityToSelector(methodEntity), new ConcreteJavaMethod(methodEntity, owner, cfg, symtab,
|
||||
hasCatchBlock, caughtTypes, hasMonitorOp, lexicalInfo, debugInfo));
|
||||
}
|
||||
|
@ -251,7 +252,7 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
|
|||
private final TypeReference[] exceptionTypes;
|
||||
|
||||
public JavaEntityMethod(CAstEntity methodEntity, IClass owner, AbstractCFG cfg, SymbolTable symtab, boolean hasCatchBlock,
|
||||
Map<IBasicBlock, TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo, DebuggingInformation debugInfo) {
|
||||
Map<IBasicBlock<SSAInstruction>, TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo, DebuggingInformation debugInfo) {
|
||||
super(owner, methodEntity.getQualifiers(), cfg, symtab, MethodReference.findOrCreate(owner.getReference(), Util
|
||||
.methodEntityToSelector(methodEntity)), hasCatchBlock, caughtTypes, hasMonitorOp, lexicalInfo, debugInfo, JavaSourceLoaderImpl.this.getAnnotations(methodEntity));
|
||||
this.parameterTypes = computeParameterTypes(methodEntity);
|
||||
|
@ -369,7 +370,7 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
|
|||
*/
|
||||
public class ConcreteJavaMethod extends JavaEntityMethod {
|
||||
public ConcreteJavaMethod(CAstEntity methodEntity, IClass owner, AbstractCFG cfg, SymbolTable symtab, boolean hasCatchBlock,
|
||||
Map<IBasicBlock, TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo, DebuggingInformation debugInfo) {
|
||||
Map<IBasicBlock<SSAInstruction>, TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo, DebuggingInformation debugInfo) {
|
||||
super(methodEntity, owner, cfg, symtab, hasCatchBlock, caughtTypes, hasMonitorOp, lexicalInfo, debugInfo);
|
||||
}
|
||||
|
||||
|
@ -522,7 +523,7 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
|
|||
}
|
||||
|
||||
public void defineFunction(CAstEntity n, IClass owner, AbstractCFG cfg, SymbolTable symtab, boolean hasCatchBlock,
|
||||
Map<IBasicBlock, TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo, DebuggingInformation debugInfo) {
|
||||
Map<IBasicBlock<SSAInstruction>, TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo, DebuggingInformation debugInfo) {
|
||||
((JavaClass) owner).addMethod(n, owner, cfg, symtab, hasCatchBlock, caughtTypes, hasMonitorOp, lexicalInfo, debugInfo);
|
||||
}
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@ import com.ibm.wala.classLoader.CallSiteReference;
|
|||
import com.ibm.wala.classLoader.IClass;
|
||||
import com.ibm.wala.classLoader.ModuleEntry;
|
||||
import com.ibm.wala.classLoader.NewSiteReference;
|
||||
import com.ibm.wala.ssa.SSAInstruction;
|
||||
import com.ibm.wala.ssa.SymbolTable;
|
||||
import com.ibm.wala.types.FieldReference;
|
||||
import com.ibm.wala.types.TypeName;
|
||||
|
@ -244,8 +245,8 @@ public class JavaCAst2IRTranslator extends AstTranslator {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void defineFunction(CAstEntity N, WalkContext definingContext, AbstractCFG cfg, SymbolTable symtab,
|
||||
boolean hasCatchBlock, Map<IBasicBlock,TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo,
|
||||
protected void defineFunction(CAstEntity N, WalkContext definingContext, AbstractCFG<SSAInstruction, ? extends IBasicBlock<SSAInstruction>> cfg, SymbolTable symtab,
|
||||
boolean hasCatchBlock, Map<IBasicBlock<SSAInstruction>,TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo,
|
||||
DebuggingInformation debugInfo) {
|
||||
// N.B.: base class may actually ask to create a synthetic type to wrap
|
||||
// code bodies, so we may see other things than TYPE_ENTITY here.
|
||||
|
|
|
@ -46,6 +46,7 @@ import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
|
|||
import com.ibm.wala.ssa.DefUse;
|
||||
import com.ibm.wala.ssa.IR;
|
||||
import com.ibm.wala.ssa.SSAAbstractInvokeInstruction;
|
||||
import com.ibm.wala.ssa.SSAInstruction;
|
||||
import com.ibm.wala.ssa.SSAOptions;
|
||||
import com.ibm.wala.ssa.SymbolTable;
|
||||
import com.ibm.wala.types.TypeReference;
|
||||
|
@ -309,8 +310,8 @@ public class ArgumentSpecialization {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void defineFunction(CAstEntity N, WalkContext definingContext, AbstractCFG cfg, SymbolTable symtab,
|
||||
boolean hasCatchBlock, Map<IBasicBlock,TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation LI,
|
||||
protected void defineFunction(CAstEntity N, WalkContext definingContext, AbstractCFG<SSAInstruction, ? extends IBasicBlock<SSAInstruction>> cfg, SymbolTable symtab,
|
||||
boolean hasCatchBlock, Map<IBasicBlock<SSAInstruction>,TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation LI,
|
||||
DebuggingInformation debugInfo) {
|
||||
if (N == codeBodyEntity) {
|
||||
specializedCode = myloader.makeCodeBodyCode(cfg, symtab, hasCatchBlock, caughtTypes, hasMonitorOp, LI, debugInfo, method.getDeclaringClass());
|
||||
|
|
|
@ -57,6 +57,7 @@ import com.ibm.wala.ipa.callgraph.impl.ClassHierarchyMethodTargetSelector;
|
|||
import com.ibm.wala.ipa.cha.ClassHierarchyException;
|
||||
import com.ibm.wala.ipa.cha.ClassHierarchyFactory;
|
||||
import com.ibm.wala.ipa.cha.IClassHierarchy;
|
||||
import com.ibm.wala.ssa.SSAInstruction;
|
||||
import com.ibm.wala.ssa.SymbolTable;
|
||||
import com.ibm.wala.types.MethodReference;
|
||||
import com.ibm.wala.types.TypeName;
|
||||
|
@ -192,8 +193,8 @@ public class JSCallGraphUtil extends com.ibm.wala.cast.ipa.callgraph.CAstCallGra
|
|||
final Set<String> names = new HashSet<String>();
|
||||
JSAstTranslator toIR = new JSAstTranslator(cl) {
|
||||
@Override
|
||||
protected void defineFunction(CAstEntity N, WalkContext definingContext, AbstractCFG cfg, SymbolTable symtab,
|
||||
boolean hasCatchBlock, Map<IBasicBlock,TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation LI,
|
||||
protected void defineFunction(CAstEntity N, WalkContext definingContext, AbstractCFG<SSAInstruction, ? extends IBasicBlock<SSAInstruction>> cfg, SymbolTable symtab,
|
||||
boolean hasCatchBlock, Map<IBasicBlock<SSAInstruction>,TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation LI,
|
||||
DebuggingInformation debugInfo) {
|
||||
String fnName = "L" + composeEntityName(definingContext, N);
|
||||
names.add(fnName);
|
||||
|
|
|
@ -803,7 +803,7 @@ public class JavaScriptLoader extends CAstAbstractModuleLoader {
|
|||
private CAstEntity entity;
|
||||
|
||||
JavaScriptMethodObject(IClass cls, AbstractCFG cfg, SymbolTable symtab, boolean hasCatchBlock,
|
||||
Map<IBasicBlock, TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo, DebuggingInformation debugInfo) {
|
||||
Map<IBasicBlock<SSAInstruction>, TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo, DebuggingInformation debugInfo) {
|
||||
super(cls, functionQualifiers, cfg, symtab, AstMethodReference.fnReference(cls.getReference()), hasCatchBlock, caughtTypes,
|
||||
hasMonitorOp, lexicalInfo, debugInfo, null);
|
||||
|
||||
|
@ -917,14 +917,14 @@ public class JavaScriptLoader extends CAstAbstractModuleLoader {
|
|||
}
|
||||
|
||||
public IMethod defineCodeBodyCode(String clsName, AbstractCFG cfg, SymbolTable symtab, boolean hasCatchBlock,
|
||||
Map<IBasicBlock, TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo, DebuggingInformation debugInfo) {
|
||||
Map<IBasicBlock<SSAInstruction>, TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo, DebuggingInformation debugInfo) {
|
||||
JavaScriptCodeBody C = (JavaScriptCodeBody) lookupClass(clsName, cha);
|
||||
assert C != null : clsName;
|
||||
return C.setCodeBody(makeCodeBodyCode(cfg, symtab, hasCatchBlock, caughtTypes, hasMonitorOp, lexicalInfo, debugInfo, C));
|
||||
}
|
||||
|
||||
public JavaScriptMethodObject makeCodeBodyCode(AbstractCFG cfg, SymbolTable symtab, boolean hasCatchBlock,
|
||||
Map<IBasicBlock, TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo, DebuggingInformation debugInfo,
|
||||
Map<IBasicBlock<SSAInstruction>, TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo, DebuggingInformation debugInfo,
|
||||
IClass C) {
|
||||
return new JavaScriptMethodObject(C, cfg, symtab, hasCatchBlock, caughtTypes, hasMonitorOp, lexicalInfo,
|
||||
debugInfo);
|
||||
|
|
|
@ -168,8 +168,8 @@ public class JSAstTranslator extends AstTranslator {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void defineFunction(CAstEntity N, WalkContext definingContext, AbstractCFG cfg, SymbolTable symtab,
|
||||
boolean hasCatchBlock, Map<IBasicBlock,TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation LI,
|
||||
protected void defineFunction(CAstEntity N, WalkContext definingContext, AbstractCFG<SSAInstruction, ? extends IBasicBlock<SSAInstruction>> cfg, SymbolTable symtab,
|
||||
boolean hasCatchBlock, Map<IBasicBlock<SSAInstruction>,TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation LI,
|
||||
DebuggingInformation debugInfo) {
|
||||
if (DEBUG)
|
||||
System.err.println(("\n\nAdding code for " + N));
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
package com.ibm.wala.cast.ir.ssa;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.ibm.wala.cast.loader.AstMethod;
|
||||
import com.ibm.wala.cast.loader.AstMethod.LexicalInformation;
|
||||
|
@ -87,8 +88,8 @@ public class AstIRFactory<T extends IMethod> implements IRFactory<T> {
|
|||
}
|
||||
}
|
||||
|
||||
private void setupCatchTypes(SSACFG cfg, Map<IBasicBlock, TypeReference[]> map) {
|
||||
for(Map.Entry<IBasicBlock,TypeReference[]> e : map.entrySet()) {
|
||||
private void setupCatchTypes(SSACFG cfg, Map<IBasicBlock<SSAInstruction>, TypeReference[]> map) {
|
||||
for(Entry<IBasicBlock<SSAInstruction>, TypeReference[]> e : map.entrySet()) {
|
||||
if (e.getKey().getNumber() != -1) {
|
||||
ExceptionHandlerBasicBlock bb = (ExceptionHandlerBasicBlock) cfg.getNode(e.getKey().getNumber());
|
||||
for (int j = 0; j < e.getValue().length; j++) {
|
||||
|
|
|
@ -139,8 +139,8 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
|||
* fully define a function. invoked after all the code of the function has
|
||||
* been processed
|
||||
*/
|
||||
protected abstract void defineFunction(CAstEntity N, WalkContext definingContext, AbstractCFG cfg, SymbolTable symtab,
|
||||
boolean hasCatchBlock, Map<IBasicBlock, TypeReference[]> catchTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo,
|
||||
protected abstract void defineFunction(CAstEntity N, WalkContext definingContext, AbstractCFG<SSAInstruction, ? extends IBasicBlock<SSAInstruction>> cfg, SymbolTable symtab,
|
||||
boolean hasCatchBlock, Map<IBasicBlock<SSAInstruction>, TypeReference[]> catchTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo,
|
||||
DebuggingInformation debugInfo);
|
||||
|
||||
/**
|
||||
|
@ -2332,7 +2332,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
|||
|
||||
void setCatchType(CAstNode catchNode, TypeReference catchType);
|
||||
|
||||
Map<IBasicBlock,TypeReference[]> getCatchTypes();
|
||||
Map<IBasicBlock<SSAInstruction>, TypeReference[]> getCatchTypes();
|
||||
|
||||
void addEntityName(CAstEntity e, String name);
|
||||
|
||||
|
@ -2425,7 +2425,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
|||
}
|
||||
|
||||
@Override
|
||||
public Map<IBasicBlock, TypeReference[]> getCatchTypes() {
|
||||
public Map<IBasicBlock<SSAInstruction>, TypeReference[]> getCatchTypes() {
|
||||
return parent.getCatchTypes();
|
||||
}
|
||||
|
||||
|
@ -2530,7 +2530,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
|||
|
||||
private final IncipientCFG cfg;
|
||||
|
||||
private final Map<IBasicBlock,TypeReference[]> catchTypes = HashMapFactory.make();
|
||||
private final Map<IBasicBlock<SSAInstruction>, TypeReference[]> catchTypes = HashMapFactory.make();
|
||||
|
||||
Set<Pair<Pair<String, String>, Integer>> exposedReads;
|
||||
Set<Pair<Pair<String, String>, Integer>> exposedWrites;
|
||||
|
@ -2638,7 +2638,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
|||
}
|
||||
|
||||
@Override
|
||||
public Map<IBasicBlock,TypeReference[]> getCatchTypes() {
|
||||
public Map<IBasicBlock<SSAInstruction>, TypeReference[]> getCatchTypes() {
|
||||
return catchTypes;
|
||||
}
|
||||
|
||||
|
@ -3297,7 +3297,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
|||
|
||||
// create code entry stuff for this entity
|
||||
SymbolTable symtab = ((AbstractScope) functionContext.currentScope()).getUnderlyingSymtab();
|
||||
Map<IBasicBlock,TypeReference[]> catchTypes = functionContext.getCatchTypes();
|
||||
Map<IBasicBlock<SSAInstruction>,TypeReference[]> catchTypes = functionContext.getCatchTypes();
|
||||
AstCFG cfg = new AstCFG(n, functionContext.cfg(), symtab, insts);
|
||||
Position[] line = functionContext.cfg().getLinePositionMap();
|
||||
boolean katch = functionContext.cfg().hasCatchBlock();
|
||||
|
@ -4740,7 +4740,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
|||
}
|
||||
|
||||
@Override
|
||||
public Map<IBasicBlock, TypeReference[]> getCatchTypes() {
|
||||
public Map<IBasicBlock<SSAInstruction>, TypeReference[]> getCatchTypes() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ import com.ibm.wala.cfg.IBasicBlock;
|
|||
import com.ibm.wala.classLoader.IClass;
|
||||
import com.ibm.wala.classLoader.IMethod;
|
||||
import com.ibm.wala.shrikeCT.InvalidClassFileException;
|
||||
import com.ibm.wala.ssa.SSAInstruction;
|
||||
import com.ibm.wala.ssa.SymbolTable;
|
||||
import com.ibm.wala.types.Descriptor;
|
||||
import com.ibm.wala.types.MethodReference;
|
||||
|
@ -108,13 +109,13 @@ public abstract class AstMethod implements IMethod {
|
|||
private final MethodReference ref;
|
||||
private final boolean hasCatchBlock;
|
||||
private final boolean hasMonitorOp;
|
||||
private final Map<IBasicBlock, TypeReference[]> catchTypes;
|
||||
private final Map<IBasicBlock<SSAInstruction>, TypeReference[]> catchTypes;
|
||||
private final AstLexicalInformation lexicalInfo;
|
||||
private final DebuggingInformation debugInfo;
|
||||
private final Collection<Annotation> annotations;
|
||||
|
||||
protected AstMethod(IClass cls, Collection qualifiers, AbstractCFG cfg, SymbolTable symtab, MethodReference ref,
|
||||
boolean hasCatchBlock, Map<IBasicBlock, TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo,
|
||||
boolean hasCatchBlock, Map<IBasicBlock<SSAInstruction>, TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo,
|
||||
DebuggingInformation debugInfo, Collection<Annotation> annotations) {
|
||||
this.cls = cls;
|
||||
this.cfg = cfg;
|
||||
|
@ -158,7 +159,7 @@ public abstract class AstMethod implements IMethod {
|
|||
return symtab;
|
||||
}
|
||||
|
||||
public Map<IBasicBlock, TypeReference[]> catchTypes() {
|
||||
public Map<IBasicBlock<SSAInstruction>, TypeReference[]> catchTypes() {
|
||||
return catchTypes;
|
||||
}
|
||||
|
||||
|
|
|
@ -167,7 +167,7 @@
|
|||
<param name="destdir" value="${temp.folder}/dalvik/@dot"/>
|
||||
<param name="jsv" value="1.6"/>
|
||||
<param name="jtv" value="1.6"/>
|
||||
<param name="excludes" value="**/bak/,**/SortingExample.java,defaultMethods/*.java"/>
|
||||
<param name="excludes" value="**/bak/,**/SortingExample.java,defaultMethods/*.java,special/A.java"/>
|
||||
</antcall>
|
||||
</target>
|
||||
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
package special;
|
||||
|
||||
class A {
|
||||
String name;
|
||||
|
||||
A() {
|
||||
setX("silly");
|
||||
}
|
||||
|
||||
public void setX(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public
|
||||
String toString() {
|
||||
return name;
|
||||
}
|
||||
|
||||
interface Ctor<T> {
|
||||
T make();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Ctor<A> o = A::new;
|
||||
Object a = o.make();
|
||||
a.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -41,6 +41,26 @@ import com.ibm.wala.util.strings.Atom;
|
|||
*/
|
||||
public class LambdaTest extends WalaTestCase {
|
||||
|
||||
@Test public void testStreamExample_137() throws IOException, ClassHierarchyException, IllegalArgumentException, CancelException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA, CallGraphTestUtil.REGRESSION_EXCLUSIONS);
|
||||
ClassHierarchy cha = ClassHierarchyFactory.make(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
|
||||
"Lspecial/A");
|
||||
AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
|
||||
|
||||
CallGraph cg = CallGraphTestUtil.buildZeroCFA(options, new AnalysisCacheImpl(), cha, scope, false);
|
||||
|
||||
TypeReference A = TypeReference.findOrCreate(ClassLoaderReference.Application, "Lspecial/A");
|
||||
|
||||
MethodReference ct = MethodReference.findOrCreate(A, Atom.findOrCreateUnicodeAtom("<init>"), Descriptor.findOrCreateUTF8("()V"));
|
||||
Set<CGNode> ctnodes = cg.getNodes(ct);
|
||||
Assert.assertEquals(1, ctnodes.size());
|
||||
|
||||
MethodReference ts = MethodReference.findOrCreate(A, Atom.findOrCreateUnicodeAtom("toString"), Descriptor.findOrCreateUTF8("()Ljava/lang/String;"));
|
||||
Set<CGNode> tsnodes = cg.getNodes(ts);
|
||||
Assert.assertEquals(1, tsnodes.size());
|
||||
}
|
||||
|
||||
@Test public void testSortingExample() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA, CallGraphTestUtil.REGRESSION_EXCLUSIONS);
|
||||
|
|
|
@ -20,6 +20,7 @@ import com.ibm.wala.classLoader.CallSiteReference;
|
|||
import com.ibm.wala.classLoader.IClass;
|
||||
import com.ibm.wala.classLoader.IField;
|
||||
import com.ibm.wala.classLoader.IMethod;
|
||||
import com.ibm.wala.classLoader.NewSiteReference;
|
||||
import com.ibm.wala.classLoader.SyntheticClass;
|
||||
import com.ibm.wala.ipa.callgraph.CGNode;
|
||||
import com.ibm.wala.ipa.cha.IClassHierarchy;
|
||||
|
@ -257,27 +258,39 @@ public class LambdaSummaryClass extends SyntheticClass {
|
|||
MethodReference callee = MethodReference.findOrCreate(ClassLoaderReference.Application, getLambdaCalleeClass(), getLambdaCalleeName(), getLambdaCalleeSignature());
|
||||
|
||||
Dispatch code;
|
||||
boolean isNew = false;
|
||||
int new_v = -1;
|
||||
int kind = getLambdaCalleeKind();
|
||||
switch (kind) {
|
||||
case 5: code = Dispatch.VIRTUAL; break;
|
||||
case 6: code = Dispatch.STATIC; break;
|
||||
case 7: code = Dispatch.SPECIAL; break;
|
||||
case 8: code = Dispatch.SPECIAL; isNew = true; break;
|
||||
case 9: code = Dispatch.INTERFACE; break;
|
||||
default:
|
||||
throw new Error("unexpected dynamic invoke type " + kind);
|
||||
}
|
||||
|
||||
|
||||
int numParams = getClassHierarchy().resolveMethod(callee).getNumberOfParameters();
|
||||
int params[] = new int[ numParams ];
|
||||
for(int i = 0; i < invoke.getNumberOfParameters(); i++) {
|
||||
for(int i = isNew? 1: 0; i < invoke.getNumberOfParameters(); i++) {
|
||||
params[i] = args + i + 1;
|
||||
}
|
||||
for(int n = 2, i = invoke.getNumberOfParameters(); i < numParams; i++) {
|
||||
params[i] = n++;
|
||||
}
|
||||
|
||||
|
||||
if (isNew) {
|
||||
v++;
|
||||
summary.addStatement(insts.NewInstruction(inst++, new_v=v++, NewSiteReference.make(inst, callee.getDeclaringClass())));
|
||||
params[0] = new_v;
|
||||
}
|
||||
|
||||
if (callee.getReturnType().equals(TypeReference.Void)) {
|
||||
summary.addStatement(insts.InvokeInstruction(inst++, params, v++, CallSiteReference.make(inst, callee, code), null));
|
||||
if (isNew) {
|
||||
summary.addStatement(insts.ReturnInstruction(inst++, new_v, false));
|
||||
}
|
||||
} else {
|
||||
int ret = v++;
|
||||
summary.addStatement(insts.InvokeInstruction(inst++, ret, params, v++, CallSiteReference.make(inst, callee, code), null));
|
||||
|
|
Loading…
Reference in New Issue