use of jadx.core.dex.instructions.InvokeType in project jadx by skylot.
the class InsnGen method makeInvoke.
private void makeInvoke(InvokeNode insn, CodeWriter code) throws CodegenException {
MethodInfo callMth = insn.getCallMth();
// inline method
MethodNode callMthNode = mth.dex().deepResolveMethod(callMth);
if (callMthNode != null) {
if (inlineMethod(callMthNode, insn, code)) {
return;
}
callMth = callMthNode.getMethodInfo();
}
int k = 0;
InvokeType type = insn.getInvokeType();
switch(type) {
case DIRECT:
case VIRTUAL:
case INTERFACE:
InsnArg arg = insn.getArg(0);
// FIXME: add 'this' for equals methods in scope
if (!arg.isThis()) {
addArgDot(code, arg);
}
k++;
break;
case SUPER:
// use 'super' instead 'this' in 0 arg
code.add("super").add('.');
k++;
break;
case STATIC:
ClassInfo insnCls = mth.getParentClass().getAlias();
ClassInfo declClass = callMth.getDeclClass();
if (!insnCls.equals(declClass)) {
useClass(code, declClass);
code.add('.');
}
break;
}
if (callMthNode != null) {
code.attachAnnotation(callMthNode);
}
code.add(callMth.getAlias());
generateMethodArguments(code, insn, k, callMthNode);
}
use of jadx.core.dex.instructions.InvokeType in project jadx by skylot.
the class CustomLambdaCall method buildInvokeNode.
@NotNull
private static InvokeNode buildInvokeNode(MethodHandleType methodHandleType, InvokeCustomNode invokeCustomNode, MethodInfo callMthInfo) {
InvokeType invokeType = convertInvokeType(methodHandleType);
int callArgsCount = callMthInfo.getArgsCount();
boolean instanceCall = invokeType != InvokeType.STATIC;
if (instanceCall) {
callArgsCount++;
}
InvokeNode invokeNode = new InvokeNode(callMthInfo, invokeType, callArgsCount);
// copy insn args
int argsCount = invokeCustomNode.getArgsCount();
for (int i = 0; i < argsCount; i++) {
InsnArg arg = invokeCustomNode.getArg(i);
invokeNode.addArg(arg.duplicate());
}
if (callArgsCount > argsCount) {
// fill remaining args with NamedArg
int callArgNum = argsCount;
if (instanceCall) {
// start from instance type
callArgNum--;
}
List<ArgType> callArgTypes = callMthInfo.getArgumentsTypes();
for (int i = argsCount; i < callArgsCount; i++) {
ArgType argType;
if (callArgNum < 0) {
// instance arg type
argType = callMthInfo.getDeclClass().getType();
} else {
argType = callArgTypes.get(callArgNum++);
}
invokeNode.addArg(new NamedArg("v" + i, argType));
}
}
return invokeNode;
}
use of jadx.core.dex.instructions.InvokeType in project jadx by skylot.
the class InsnGen method makeInvoke.
private void makeInvoke(InvokeNode insn, ICodeWriter code) throws CodegenException {
InvokeType type = insn.getInvokeType();
if (type == InvokeType.CUSTOM) {
makeInvokeLambda(code, (InvokeCustomNode) insn);
return;
}
MethodInfo callMth = insn.getCallMth();
MethodNode callMthNode = mth.root().resolveMethod(callMth);
int k = 0;
switch(type) {
case DIRECT:
case VIRTUAL:
case INTERFACE:
InsnArg arg = insn.getArg(0);
if (needInvokeArg(arg)) {
addArgDot(code, arg);
}
k++;
break;
case SUPER:
ClassInfo superCallCls = getClassForSuperCall(code, callMth);
if (superCallCls != null) {
useClass(code, superCallCls);
code.add('.');
}
// use 'super' instead 'this' in 0 arg
code.add("super").add('.');
k++;
break;
case STATIC:
ClassInfo insnCls = mth.getParentClass().getClassInfo();
ClassInfo declClass = callMth.getDeclClass();
if (!insnCls.equals(declClass)) {
useClass(code, declClass);
code.add('.');
}
break;
}
if (callMthNode != null) {
code.attachAnnotation(callMthNode);
code.add(callMthNode.getAlias());
} else {
code.add(callMth.getAlias());
}
generateMethodArguments(code, insn, k, callMthNode);
}
use of jadx.core.dex.instructions.InvokeType in project jadx by skylot.
the class TypeInferenceVisitor method makeAssignInvokeBound.
private ITypeBound makeAssignInvokeBound(InvokeNode invokeNode) {
ArgType boundType = invokeNode.getCallMth().getReturnType();
ArgType genericReturnType = root.getMethodUtils().getMethodGenericReturnType(invokeNode);
if (genericReturnType != null) {
if (genericReturnType.containsTypeVariable()) {
InvokeType invokeType = invokeNode.getInvokeType();
if (invokeNode.getArgsCount() != 0 && invokeType != InvokeType.STATIC && invokeType != InvokeType.SUPER) {
return new TypeBoundInvokeAssign(root, invokeNode, genericReturnType);
}
} else {
boundType = genericReturnType;
}
}
return new TypeBoundConst(BoundEnum.ASSIGN, boundType);
}
Aggregations