use of jadx.core.dex.visitors.IDexTreeVisitor in project jadx by skylot.
the class Jadx method getPassesList.
public static List<IDexTreeVisitor> getPassesList(IJadxArgs args, File outDir) {
List<IDexTreeVisitor> passes = new ArrayList<IDexTreeVisitor>();
if (args.isFallbackMode()) {
passes.add(new FallbackModeVisitor());
} else {
passes.add(new BlockSplitter());
passes.add(new BlockProcessor());
passes.add(new BlockExceptionHandler());
passes.add(new BlockFinallyExtract());
passes.add(new BlockFinish());
passes.add(new SSATransform());
passes.add(new DebugInfoVisitor());
passes.add(new TypeInference());
if (args.isRawCFGOutput()) {
passes.add(DotGraphVisitor.dumpRaw(outDir));
}
passes.add(new ConstInlineVisitor());
passes.add(new FinishTypeInference());
passes.add(new EliminatePhiNodes());
passes.add(new ModVisitor());
passes.add(new CodeShrinker());
passes.add(new ReSugarCode());
if (args.isCFGOutput()) {
passes.add(DotGraphVisitor.dump(outDir));
}
passes.add(new RegionMakerVisitor());
passes.add(new IfRegionVisitor());
passes.add(new ReturnVisitor());
passes.add(new CodeShrinker());
passes.add(new SimplifyVisitor());
passes.add(new CheckRegions());
if (args.isCFGOutput()) {
passes.add(DotGraphVisitor.dumpRegions(outDir));
}
passes.add(new MethodInlineVisitor());
passes.add(new ExtractFieldInit());
passes.add(new ClassModifier());
passes.add(new EnumVisitor());
passes.add(new PrepareForCodeGen());
passes.add(new LoopRegionVisitor());
passes.add(new ProcessVariables());
passes.add(new DependencyCollector());
passes.add(new RenameVisitor());
}
return passes;
}
use of jadx.core.dex.visitors.IDexTreeVisitor in project jadx by skylot.
the class JadxVisitorsOrderTest method check.
private static List<String> check(List<IDexTreeVisitor> passes) {
List<Class<?>> classList = new ArrayList<Class<?>>(passes.size());
for (IDexTreeVisitor pass : passes) {
classList.add(pass.getClass());
}
List<String> errors = new ArrayList<String>();
Set<String> names = new HashSet<String>();
for (int i = 0; i < passes.size(); i++) {
IDexTreeVisitor pass = passes.get(i);
JadxVisitor info = pass.getClass().getAnnotation(JadxVisitor.class);
if (info == null) {
LOG.warn("No JadxVisitor annotation for visitor: {}", pass.getClass().getName());
continue;
}
String passName = pass.getClass().getSimpleName();
if (!names.add(passName)) {
errors.add("Visitor name conflict: " + passName + ", class: " + pass.getClass().getName());
}
for (Class<? extends IDexTreeVisitor> cls : info.runBefore()) {
if (classList.indexOf(cls) < i) {
errors.add("Pass " + passName + " must be before " + cls.getSimpleName());
}
}
for (Class<? extends IDexTreeVisitor> cls : info.runAfter()) {
if (classList.indexOf(cls) > i) {
errors.add("Pass " + passName + " must be after " + cls.getSimpleName());
}
}
}
return errors;
}
use of jadx.core.dex.visitors.IDexTreeVisitor in project jadx by skylot.
the class IntegrationTest method decompile.
private void decompile(JadxDecompiler jadx, ClassNode cls) {
List<IDexTreeVisitor> passes = Jadx.getPassesList(jadx.getArgs(), new File(outDir));
ProcessClass.process(cls, passes, new CodeGen(jadx.getArgs()));
}
use of jadx.core.dex.visitors.IDexTreeVisitor in project jadx by skylot.
the class IntegrationTest method decompileWithoutUnload.
private void decompileWithoutUnload(JadxDecompiler d, ClassNode cls) {
cls.load();
List<IDexTreeVisitor> passes = Jadx.getPassesList(d.getArgs(), new File(outDir));
for (IDexTreeVisitor visitor : passes) {
DepthTraversal.visit(visitor, cls);
}
try {
new CodeGen(d.getArgs()).visit(cls);
} catch (CodegenException e) {
e.printStackTrace();
fail(e.getMessage());
}
// don't unload class
}
use of jadx.core.dex.visitors.IDexTreeVisitor in project jadx by skylot.
the class JadxVisitorsOrderTest method testOrder.
@Test
public void testOrder() {
List<IDexTreeVisitor> passes = Jadx.getPassesList(new JadxArgs(), new File("out"));
List<String> errors = check(passes);
for (String str : errors) {
LOG.error(str);
}
assertThat(errors, empty());
}
Aggregations