Fix sythetic methods inline
This commit is contained in:
@@ -3,6 +3,7 @@ package jadx.dex.visitors;
|
||||
import jadx.dex.attributes.AttributeFlag;
|
||||
import jadx.dex.attributes.IAttribute;
|
||||
import jadx.dex.attributes.MethodInlineAttr;
|
||||
import jadx.dex.info.AccessInfo;
|
||||
import jadx.dex.instructions.InsnType;
|
||||
import jadx.dex.nodes.BlockNode;
|
||||
import jadx.dex.nodes.InsnNode;
|
||||
@@ -13,34 +14,30 @@ public class MethodInlinerVisitor extends AbstractVisitor {
|
||||
|
||||
@Override
|
||||
public void visit(MethodNode mth) throws JadxException {
|
||||
if (mth.getAccessFlags().isSynthetic() && mth.getAccessFlags().isStatic()) {
|
||||
if (mth.getBasicBlocks().size() == 1) {
|
||||
BlockNode block = mth.getBasicBlocks().get(0);
|
||||
// synthetic field getter
|
||||
if (block.getInstructions().size() == 1) {
|
||||
InsnNode insn = block.getInstructions().get(0);
|
||||
if (insn.getType() == InsnType.RETURN) {
|
||||
InsnNode inl = new InsnNode(InsnType.ARGS, 1);
|
||||
inl.addArg(insn.getArg(0));
|
||||
addInlineAttr(mth, inl);
|
||||
return;
|
||||
}
|
||||
AccessInfo accessFlags = mth.getAccessFlags();
|
||||
if (accessFlags.isSynthetic() && accessFlags.isStatic()) {
|
||||
if (mth.getBasicBlocks().size() == 2) {
|
||||
BlockNode block = mth.getBasicBlocks().get(1);
|
||||
if (block.getAttributes().contains(AttributeFlag.RETURN)) {
|
||||
inlineMth(mth);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// synthetic field setter
|
||||
if (block.getInstructions().size() == 2) {
|
||||
if (block.getInstructions().get(1).getType() == InsnType.RETURN) {
|
||||
InsnNode insn = block.getInstructions().get(0);
|
||||
addInlineAttr(mth, insn);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// synthetic method invoke
|
||||
if (block.getInstructions().size() == 1) {
|
||||
InsnNode insn = block.getInstructions().get(0);
|
||||
addInlineAttr(mth, insn);
|
||||
}
|
||||
private static void inlineMth(MethodNode mth) {
|
||||
BlockNode firstBlock = mth.getBasicBlocks().get(0);
|
||||
if (firstBlock.getInstructions().isEmpty()) {
|
||||
// synthetic field getter
|
||||
BlockNode block = mth.getBasicBlocks().get(1);
|
||||
InsnNode insn = block.getInstructions().get(0);
|
||||
InsnNode inl = new InsnNode(InsnType.ARGS, 1);
|
||||
inl.addArg(insn.getArg(0));
|
||||
addInlineAttr(mth, inl);
|
||||
} else {
|
||||
// synthetic field setter or method invoke
|
||||
if (firstBlock.getInstructions().size() == 1) {
|
||||
addInlineAttr(mth, firstBlock.getInstructions().get(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -50,5 +47,4 @@ public class MethodInlinerVisitor extends AbstractVisitor {
|
||||
mth.getAttributes().add(attr);
|
||||
mth.getAttributes().add(AttributeFlag.DONT_GENERATE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user