use of jadx.core.dex.nodes.IMethodDetails in project jadx by skylot.
the class InlineMethods method processInvokeInsn.
private void processInvokeInsn(MethodNode mth, BlockNode block, InvokeNode insn) {
IMethodDetails callMthDetails = insn.get(AType.METHOD_DETAILS);
if (!(callMthDetails instanceof MethodNode)) {
return;
}
MethodNode callMth = (MethodNode) callMthDetails;
try {
// TODO: sort inner classes process order by dependencies!
MethodInlineAttr mia = MarkMethodsForInline.process(callMth);
if (mia == null) {
// method not yet loaded => will retry at codegen stage
callMth.getParentClass().reloadAtCodegenStage();
return;
}
if (mia.notNeeded()) {
return;
}
inlineMethod(mth, callMth, mia, block, insn);
} catch (Exception e) {
throw new JadxRuntimeException("Failed to process method for inline: " + callMth, e);
}
}
use of jadx.core.dex.nodes.IMethodDetails in project jadx by skylot.
the class OverrideMethodVisitor method processMth.
private void processMth(MethodNode mth, SuperTypesData superData) {
if (mth.isConstructor() || mth.getAccessFlags().isStatic() || mth.getAccessFlags().isPrivate()) {
return;
}
MethodOverrideAttr attr = processOverrideMethods(mth, superData);
if (attr != null) {
if (attr.getBaseMethods().isEmpty()) {
throw new JadxRuntimeException("No base methods for override attribute: " + attr.getOverrideList());
}
mth.addAttr(attr);
IMethodDetails baseMth = Utils.getOne(attr.getBaseMethods());
if (baseMth != null) {
boolean updated = fixMethodReturnType(mth, baseMth, superData);
updated |= fixMethodArgTypes(mth, baseMth, superData);
if (updated) {
// check if new signature cause method collisions
checkMethodSignatureCollisions(mth, mth.root().getArgs().isRenameValid());
}
}
}
}
use of jadx.core.dex.nodes.IMethodDetails in project jadx by skylot.
the class TypeUtils method getTypeVarMappingForInvoke.
public Map<ArgType, ArgType> getTypeVarMappingForInvoke(BaseInvokeNode invokeInsn) {
IMethodDetails mthDetails = root.getMethodUtils().getMethodDetails(invokeInsn);
if (mthDetails == null) {
return Collections.emptyMap();
}
Map<ArgType, ArgType> map = new HashMap<>(1 + invokeInsn.getArgsCount());
addTypeVarMapping(map, mthDetails.getReturnType(), invokeInsn.getResult());
int argCount = Math.min(mthDetails.getArgTypes().size(), invokeInsn.getArgsCount());
for (int i = 0; i < argCount; i++) {
addTypeVarMapping(map, mthDetails.getArgTypes().get(i), invokeInsn.getArg(i));
}
return map;
}
use of jadx.core.dex.nodes.IMethodDetails in project jadx by skylot.
the class TypeInferenceVisitor method makeInvokeUseBound.
private ITypeBound makeInvokeUseBound(RegisterArg regArg, BaseInvokeNode invoke) {
InsnArg instanceArg = invoke.getInstanceArg();
if (instanceArg == null) {
return null;
}
MethodUtils methodUtils = root.getMethodUtils();
IMethodDetails methodDetails = methodUtils.getMethodDetails(invoke);
if (methodDetails == null) {
return null;
}
if (instanceArg != regArg) {
int argIndex = invoke.getArgIndex(regArg) - invoke.getFirstArgOffset();
ArgType argType = methodDetails.getArgTypes().get(argIndex);
if (!argType.containsTypeVariable()) {
return null;
}
return new TypeBoundInvokeUse(root, invoke, regArg, argType);
}
// for override methods use origin declared class as type
if (methodDetails instanceof MethodNode) {
MethodNode callMth = (MethodNode) methodDetails;
ClassInfo declCls = methodUtils.getMethodOriginDeclClass(callMth);
return new TypeBoundConst(BoundEnum.USE, declCls.getType(), regArg);
}
return null;
}
Aggregations