diff options
| author | 2014-08-19 00:25:32 -0400 | |
|---|---|---|
| committer | 2014-08-19 00:25:32 -0400 | |
| commit | c4e35f2d516ade27e8e1a863b4bc356f182f43c2 (patch) | |
| tree | 6711cde39dcfaea30520b8ccabb6236872e0d756 /src/cuchaz/enigma/gui/GuiController.java | |
| parent | fixed type caching after rename (diff) | |
| download | enigma-fork-c4e35f2d516ade27e8e1a863b4bc356f182f43c2.tar.gz enigma-fork-c4e35f2d516ade27e8e1a863b4bc356f182f43c2.tar.xz enigma-fork-c4e35f2d516ade27e8e1a863b4bc356f182f43c2.zip | |
started new reference navigation system
Diffstat (limited to 'src/cuchaz/enigma/gui/GuiController.java')
| -rw-r--r-- | src/cuchaz/enigma/gui/GuiController.java | 65 |
1 files changed, 29 insertions, 36 deletions
diff --git a/src/cuchaz/enigma/gui/GuiController.java b/src/cuchaz/enigma/gui/GuiController.java index f305e34..f80bec7 100644 --- a/src/cuchaz/enigma/gui/GuiController.java +++ b/src/cuchaz/enigma/gui/GuiController.java | |||
| @@ -20,14 +20,15 @@ import java.util.Stack; | |||
| 20 | import com.google.common.collect.Lists; | 20 | import com.google.common.collect.Lists; |
| 21 | 21 | ||
| 22 | import cuchaz.enigma.Deobfuscator; | 22 | import cuchaz.enigma.Deobfuscator; |
| 23 | import cuchaz.enigma.analysis.BehaviorReferenceTreeNode; | ||
| 23 | import cuchaz.enigma.analysis.ClassInheritanceTreeNode; | 24 | import cuchaz.enigma.analysis.ClassInheritanceTreeNode; |
| 24 | import cuchaz.enigma.analysis.FieldCallsTreeNode; | 25 | import cuchaz.enigma.analysis.EntryReference; |
| 25 | import cuchaz.enigma.analysis.MethodCallsTreeNode; | 26 | import cuchaz.enigma.analysis.FieldReferenceTreeNode; |
| 26 | import cuchaz.enigma.analysis.MethodInheritanceTreeNode; | 27 | import cuchaz.enigma.analysis.MethodInheritanceTreeNode; |
| 27 | import cuchaz.enigma.analysis.SourceIndex; | 28 | import cuchaz.enigma.analysis.SourceIndex; |
| 28 | import cuchaz.enigma.analysis.Token; | 29 | import cuchaz.enigma.analysis.Token; |
| 30 | import cuchaz.enigma.mapping.BehaviorEntry; | ||
| 29 | import cuchaz.enigma.mapping.ClassEntry; | 31 | import cuchaz.enigma.mapping.ClassEntry; |
| 30 | import cuchaz.enigma.mapping.ConstructorEntry; | ||
| 31 | import cuchaz.enigma.mapping.Entry; | 32 | import cuchaz.enigma.mapping.Entry; |
| 32 | import cuchaz.enigma.mapping.EntryPair; | 33 | import cuchaz.enigma.mapping.EntryPair; |
| 33 | import cuchaz.enigma.mapping.FieldEntry; | 34 | import cuchaz.enigma.mapping.FieldEntry; |
| @@ -44,7 +45,7 @@ public class GuiController | |||
| 44 | private SourceIndex m_index; | 45 | private SourceIndex m_index; |
| 45 | private ClassEntry m_currentClass; | 46 | private ClassEntry m_currentClass; |
| 46 | private boolean m_isDirty; | 47 | private boolean m_isDirty; |
| 47 | private Stack<Entry> m_entryStack; | 48 | private Stack<Entry> m_locationStack; // TODO: make a location class, can be either Entry or EntryReference |
| 48 | 49 | ||
| 49 | public GuiController( Gui gui ) | 50 | public GuiController( Gui gui ) |
| 50 | { | 51 | { |
| @@ -53,7 +54,7 @@ public class GuiController | |||
| 53 | m_index = null; | 54 | m_index = null; |
| 54 | m_currentClass = null; | 55 | m_currentClass = null; |
| 55 | m_isDirty = false; | 56 | m_isDirty = false; |
| 56 | m_entryStack = new Stack<Entry>(); | 57 | m_locationStack = new Stack<Entry>(); |
| 57 | } | 58 | } |
| 58 | 59 | ||
| 59 | public boolean isDirty( ) | 60 | public boolean isDirty( ) |
| @@ -157,9 +158,9 @@ public class GuiController | |||
| 157 | return MethodInheritanceTreeNode.findNode( rootNode, obfMethodEntry ); | 158 | return MethodInheritanceTreeNode.findNode( rootNode, obfMethodEntry ); |
| 158 | } | 159 | } |
| 159 | 160 | ||
| 160 | public FieldCallsTreeNode getFieldCalls( FieldEntry obfFieldEntry ) | 161 | public FieldReferenceTreeNode getFieldReferences( FieldEntry obfFieldEntry ) |
| 161 | { | 162 | { |
| 162 | FieldCallsTreeNode rootNode = new FieldCallsTreeNode( | 163 | FieldReferenceTreeNode rootNode = new FieldReferenceTreeNode( |
| 163 | m_deobfuscator.getTranslator( TranslationDirection.Deobfuscating ), | 164 | m_deobfuscator.getTranslator( TranslationDirection.Deobfuscating ), |
| 164 | obfFieldEntry | 165 | obfFieldEntry |
| 165 | ); | 166 | ); |
| @@ -167,27 +168,12 @@ public class GuiController | |||
| 167 | return rootNode; | 168 | return rootNode; |
| 168 | } | 169 | } |
| 169 | 170 | ||
| 170 | public MethodCallsTreeNode getMethodCalls( Entry obfEntry ) | 171 | public BehaviorReferenceTreeNode getMethodReferences( BehaviorEntry obfEntry ) |
| 171 | { | 172 | { |
| 172 | MethodCallsTreeNode rootNode; | 173 | BehaviorReferenceTreeNode rootNode = new BehaviorReferenceTreeNode( |
| 173 | if( obfEntry instanceof MethodEntry ) | 174 | m_deobfuscator.getTranslator( TranslationDirection.Deobfuscating ), |
| 174 | { | 175 | obfEntry |
| 175 | rootNode = new MethodCallsTreeNode( | 176 | ); |
| 176 | m_deobfuscator.getTranslator( TranslationDirection.Deobfuscating ), | ||
| 177 | (MethodEntry)obfEntry | ||
| 178 | ); | ||
| 179 | } | ||
| 180 | else if( obfEntry instanceof ConstructorEntry ) | ||
| 181 | { | ||
| 182 | rootNode = new MethodCallsTreeNode( | ||
| 183 | m_deobfuscator.getTranslator( TranslationDirection.Deobfuscating ), | ||
| 184 | (ConstructorEntry)obfEntry | ||
| 185 | ); | ||
| 186 | } | ||
| 187 | else | ||
| 188 | { | ||
| 189 | throw new IllegalArgumentException( "entry must be a MethodEntry or a ConstructorEntry!" ); | ||
| 190 | } | ||
| 191 | rootNode.load( m_deobfuscator.getJarIndex(), true ); | 177 | rootNode.load( m_deobfuscator.getJarIndex(), true ); |
| 192 | return rootNode; | 178 | return rootNode; |
| 193 | } | 179 | } |
| @@ -200,7 +186,7 @@ public class GuiController | |||
| 200 | refreshCurrentClass( obfEntry ); | 186 | refreshCurrentClass( obfEntry ); |
| 201 | } | 187 | } |
| 202 | 188 | ||
| 203 | public void openEntry( Entry entry ) | 189 | public void openDeclaration( Entry entry ) |
| 204 | { | 190 | { |
| 205 | // go to the entry | 191 | // go to the entry |
| 206 | Entry obfEntry = m_deobfuscator.obfuscateEntry( entry ); | 192 | Entry obfEntry = m_deobfuscator.obfuscateEntry( entry ); |
| @@ -214,25 +200,32 @@ public class GuiController | |||
| 214 | m_gui.showToken( m_index.getDeclarationToken( m_deobfuscator.deobfuscateEntry( obfEntry ) ) ); | 200 | m_gui.showToken( m_index.getDeclarationToken( m_deobfuscator.deobfuscateEntry( obfEntry ) ) ); |
| 215 | } | 201 | } |
| 216 | 202 | ||
| 217 | if( m_entryStack.isEmpty() || !m_entryStack.peek().equals( obfEntry ) ) | 203 | if( m_locationStack.isEmpty() || !m_locationStack.peek().equals( obfEntry ) ) |
| 218 | { | 204 | { |
| 219 | // update the stack | 205 | // update the stack |
| 220 | m_entryStack.push( obfEntry ); | 206 | m_locationStack.push( obfEntry ); |
| 221 | } | 207 | } |
| 222 | } | 208 | } |
| 223 | 209 | ||
| 224 | public void openPreviousEntry( ) | 210 | public void openReference( EntryReference<Entry> reference ) |
| 211 | { | ||
| 212 | // TODO: find out how to load the n-th reference in a caller | ||
| 213 | // TEMP: just go to the caller for now | ||
| 214 | openDeclaration( reference.caller ); | ||
| 215 | } | ||
| 216 | |||
| 217 | public void openPreviousLocation( ) | ||
| 225 | { | 218 | { |
| 226 | if( hasPreviousEntry() ) | 219 | if( hasPreviousLocation() ) |
| 227 | { | 220 | { |
| 228 | m_entryStack.pop(); | 221 | m_locationStack.pop(); |
| 229 | openEntry( m_entryStack.peek() ); | 222 | openDeclaration( m_locationStack.peek() ); |
| 230 | } | 223 | } |
| 231 | } | 224 | } |
| 232 | 225 | ||
| 233 | public boolean hasPreviousEntry( ) | 226 | public boolean hasPreviousLocation( ) |
| 234 | { | 227 | { |
| 235 | return m_entryStack.size() > 1; | 228 | return m_locationStack.size() > 1; |
| 236 | } | 229 | } |
| 237 | 230 | ||
| 238 | private void refreshClasses( ) | 231 | private void refreshClasses( ) |