提交 164123f5 编写于 作者: S Skylot

core: improve variable names after 'toString' invoke

上级 72c301dc
...@@ -4,6 +4,7 @@ import jadx.core.Consts; ...@@ -4,6 +4,7 @@ import jadx.core.Consts;
import jadx.core.deobf.NameMapper; import jadx.core.deobf.NameMapper;
import jadx.core.dex.attributes.nodes.LoopLabelAttr; import jadx.core.dex.attributes.nodes.LoopLabelAttr;
import jadx.core.dex.info.ClassInfo; import jadx.core.dex.info.ClassInfo;
import jadx.core.dex.info.MethodInfo;
import jadx.core.dex.instructions.InvokeNode; import jadx.core.dex.instructions.InvokeNode;
import jadx.core.dex.instructions.args.ArgType; import jadx.core.dex.instructions.args.ArgType;
import jadx.core.dex.instructions.args.InsnArg; import jadx.core.dex.instructions.args.InsnArg;
...@@ -187,14 +188,7 @@ public class NameGen { ...@@ -187,14 +188,7 @@ public class NameGen {
switch (insn.getType()) { switch (insn.getType()) {
case INVOKE: case INVOKE:
InvokeNode inv = (InvokeNode) insn; InvokeNode inv = (InvokeNode) insn;
String name = inv.getCallMth().getName(); return makeNameFromInvoke(inv.getCallMth());
if (name.startsWith("get") || name.startsWith("set")) {
return fromName(name.substring(3));
}
if ("iterator".equals(name)) {
return "it";
}
return name;
case CONSTRUCTOR: case CONSTRUCTOR:
ConstructorInsn co = (ConstructorInsn) insn; ConstructorInsn co = (ConstructorInsn) insn;
...@@ -222,4 +216,22 @@ public class NameGen { ...@@ -222,4 +216,22 @@ public class NameGen {
} }
return null; return null;
} }
private static String makeNameFromInvoke(MethodInfo callMth) {
String name = callMth.getName();
if (name.startsWith("get") || name.startsWith("set")) {
return fromName(name.substring(3));
}
ArgType declType = callMth.getDeclClass().getType();
if ("iterator".equals(name)) {
return "it";
}
if ("toString".equals(name)) {
return makeNameForType(declType);
}
if ("forName".equals(name) && declType.equals(ArgType.CLASS)) {
return OBJ_ALIAS.get(Consts.CLASS_CLASS);
}
return name;
}
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册