From 6c4440ac1133bfaa7871d1049d174528a289ef30 Mon Sep 17 00:00:00 2001 From: hg Date: Sun, 17 Aug 2014 10:56:17 -0400 Subject: added support for automatic reconstruction of inner and anonymous classes also added class to restore bridge method flags taken out by the obfuscator --- src/cuchaz/enigma/analysis/TreeDumpVisitor.java | 45 +++++++++++++++++++++---- 1 file changed, 38 insertions(+), 7 deletions(-) (limited to 'src/cuchaz/enigma/analysis/TreeDumpVisitor.java') diff --git a/src/cuchaz/enigma/analysis/TreeDumpVisitor.java b/src/cuchaz/enigma/analysis/TreeDumpVisitor.java index 05d0e6b..ac3e92d 100644 --- a/src/cuchaz/enigma/analysis/TreeDumpVisitor.java +++ b/src/cuchaz/enigma/analysis/TreeDumpVisitor.java @@ -10,6 +10,11 @@ ******************************************************************************/ package cuchaz.enigma.analysis; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.Writer; + import com.strobel.componentmodel.Key; import com.strobel.decompiler.languages.java.ast.Annotation; import com.strobel.decompiler.languages.java.ast.AnonymousObjectCreationExpression; @@ -87,10 +92,42 @@ import com.strobel.decompiler.patterns.Pattern; public class TreeDumpVisitor implements IAstVisitor { + private File m_file; + private Writer m_out; + + public TreeDumpVisitor( File file ) + { + m_file = file; + m_out = null; + } + + @Override + public Void visitCompilationUnit( CompilationUnit node, Void ignored ) + { + try + { + m_out = new FileWriter( m_file ); + recurse( node, ignored ); + m_out.close(); + return null; + } + catch( IOException ex ) + { + throw new Error( ex ); + } + } + private Void recurse( AstNode node, Void ignored ) { // show the tree - System.out.println( getIndent( node ) + node.getClass().getSimpleName() + dumpUserData( node ) + " " + node.getRegion() ); + try + { + m_out.write( getIndent( node ) + node.getClass().getSimpleName() + dumpUserData( node ) + " " + node.getRegion() + "\n" ); + } + catch( IOException ex ) + { + throw new Error( ex ); + } // recurse for( final AstNode child : node.getChildren() ) @@ -378,12 +415,6 @@ public class TreeDumpVisitor implements IAstVisitor return recurse( node, ignored ); } - @Override - public Void visitCompilationUnit( CompilationUnit node, Void ignored ) - { - return recurse( node, ignored ); - } - @Override public Void visitPackageDeclaration( PackageDeclaration node, Void ignored ) { -- cgit v1.2.3