use of jadx.core.dex.info.FieldInfo in project jadx by skylot.
the class EnumVisitor method removeEnumMethods.
private void removeEnumMethods(ClassNode cls, ArgType clsType, FieldNode valuesField) {
String valuesMethod = "values()" + TypeGen.signature(ArgType.array(clsType));
FieldInfo valuesFieldInfo = valuesField.getFieldInfo();
// remove compiler generated methods
for (MethodNode mth : cls.getMethods()) {
MethodInfo mi = mth.getMethodInfo();
if (mi.isClassInit()) {
continue;
}
String shortId = mi.getShortId();
if (mi.isConstructor()) {
if (isDefaultConstructor(mth, shortId)) {
mth.add(AFlag.DONT_GENERATE);
}
markArgsForSkip(mth);
} else if (shortId.equals(valuesMethod) || usesValuesField(mth, valuesFieldInfo) || simpleValueOfMth(mth, clsType)) {
mth.add(AFlag.DONT_GENERATE);
}
}
}
use of jadx.core.dex.info.FieldInfo in project jadx by skylot.
the class EnumVisitor method createFakeField.
private FieldNode createFakeField(ClassNode cls, String name) {
FieldNode enumFieldNode;
FieldInfo fldInfo = FieldInfo.from(cls.root(), cls.getClassInfo(), name, cls.getType());
enumFieldNode = new FieldNode(cls, fldInfo, 0);
enumFieldNode.add(AFlag.SYNTHETIC);
enumFieldNode.addInfoComment("Fake field, exist only in values array");
return enumFieldNode;
}
use of jadx.core.dex.info.FieldInfo in project jadx by skylot.
the class EnumVisitor method processEnumFieldByField.
@Nullable
private EnumField processEnumFieldByField(ClassNode cls, InsnNode sgetInsn, BlockNode staticBlock, List<InsnNode> toRemove) {
if (sgetInsn.getType() != InsnType.SGET) {
return null;
}
FieldInfo fieldInfo = (FieldInfo) ((IndexInsnNode) sgetInsn).getIndex();
FieldNode enumFieldNode = cls.searchField(fieldInfo);
if (enumFieldNode == null) {
return null;
}
InsnNode sputInsn = searchFieldPutInsn(cls, staticBlock, enumFieldNode);
if (sputInsn == null) {
return null;
}
ConstructorInsn co = getConstructorInsn(sputInsn);
if (co == null) {
return null;
}
RegisterArg sgetResult = sgetInsn.getResult();
if (sgetResult == null || sgetResult.getSVar().getUseCount() == 1) {
toRemove.add(sgetInsn);
}
toRemove.add(sputInsn);
return createEnumFieldByConstructor(cls, enumFieldNode, co);
}
use of jadx.core.dex.info.FieldInfo in project jadx by skylot.
the class EnumVisitor method searchEnumField.
@Nullable
private FieldNode searchEnumField(ClassNode cls, SSAVar ssaVar, List<InsnNode> toRemove) {
InsnNode sputInsn = ssaVar.getUseList().get(0).getParentInsn();
if (sputInsn == null || sputInsn.getType() != InsnType.SPUT) {
return null;
}
FieldInfo fieldInfo = (FieldInfo) ((IndexInsnNode) sputInsn).getIndex();
FieldNode enumFieldNode = cls.searchField(fieldInfo);
if (enumFieldNode == null) {
return null;
}
toRemove.add(sputInsn);
return enumFieldNode;
}
use of jadx.core.dex.info.FieldInfo in project jadx by skylot.
the class EnumVisitor method searchFieldPutInsn.
@Nullable
private InsnNode searchFieldPutInsn(ClassNode cls, BlockNode staticBlock, FieldNode enumFieldNode) {
for (InsnNode sputInsn : staticBlock.getInstructions()) {
if (sputInsn != null && sputInsn.getType() == InsnType.SPUT) {
FieldInfo f = (FieldInfo) ((IndexInsnNode) sputInsn).getIndex();
FieldNode fieldNode = cls.searchField(f);
if (Objects.equals(fieldNode, enumFieldNode)) {
return sputInsn;
}
}
}
return null;
}
Aggregations