}
insList.append(InstructionFactory.createStore(type, i));
}
}
InvokeInstruction inv = (InvokeInstruction) handle.getInstruction();
Type returnType = getReturnType(method.getConstantPool().getConstantPool(), inv.getIndex());
boolean skipFirst = returnType.getSize() > 0;
// restore stack
OperandStack os = frame.getStack();
for (int i = os.size() - 1; i >= (skipFirst ? 1 : 0); i--) {
Type type = os.peek(i);
if (type instanceof BasicType) {
if (type.getSize() < 2 && !type.equals(Type.FLOAT)) {
type = Type.INT;
}
insList.append(InstructionFactory.createLoad(STACK_TYPE, method.getMaxLocals()+1));
insList.append(insFactory.createInvoke(STACK_CLASS, getPopMethod(type), type, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
} else if (type == null) {
insList.append(new ACONST_NULL());
} else if (type instanceof UninitializedObjectType) {
// After the remove of new, there shouldn't be a
// uninitialized object on the stack
} else if (type instanceof ReferenceType) {
insList.append(InstructionFactory.createLoad(STACK_TYPE, method.getMaxLocals()+1));
insList.append(insFactory.createInvoke(STACK_CLASS, getPopMethod(Type.OBJECT), Type.OBJECT, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
if (!type.equals(Type.OBJECT))
insList.append(insFactory.createCast(Type.OBJECT, type));
}
}
// retrieve current object
if (!(inv instanceof INVOKESTATIC)) {
insList.append(InstructionFactory.createLoad(STACK_TYPE, method.getMaxLocals()+1));
insList.append(insFactory.createInvoke(STACK_CLASS, POP_METHOD + "Reference", Type.OBJECT, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
insList.append(insFactory.createCast(Type.OBJECT, objecttype));
}
// Create null types for the parameters of the method invocation
Type[] paramTypes = getParamTypes(method.getConstantPool().getConstantPool(), inv.getIndex());
for (int j = 0; j < paramTypes.length; j++) {
insList.append(InstructionFactory.createNull(paramTypes[j]));
}
// go to last invocation
insList.append(new GOTO(handle));