this.dependency = dependency;
this.classSource = classSource;
}
public void apply(MethodHolder method) {
MethodDependencyInfo methodDep = dependency.getMethod(method.getReference());
if (methodDep == null) {
return;
}
Program program = method.getProgram();
for (int i = 0; i < program.basicBlockCount(); ++i) {
BasicBlock block = program.basicBlockAt(i);
for (Instruction insn : block.getInstructions()) {
if (!(insn instanceof InvokeInstruction)) {
continue;
}
InvokeInstruction invoke = (InvokeInstruction)insn;
if (invoke.getType() != InvocationType.VIRTUAL) {
continue;
}
ValueDependencyInfo var = methodDep.getVariable(invoke.getInstance().getIndex());
Set<MethodReference> implementations = getImplementations(var.getTypes(),
invoke.getMethod());
if (implementations.size() == 1) {
invoke.setType(InvocationType.SPECIAL);
invoke.setMethod(implementations.iterator().next());