diff options
| author | 2014-08-21 01:10:37 -0400 | |
|---|---|---|
| committer | 2014-08-21 01:10:37 -0400 | |
| commit | 237b2ed2a6b6f537cdbdf9fc9c6d0c7743f34375 (patch) | |
| tree | ebad059c7fa0bc7723858cb25eed0bb6e95fe42a /src/cuchaz/enigma/analysis | |
| parent | fixed recognition of inner class tokens (diff) | |
| download | enigma-fork-237b2ed2a6b6f537cdbdf9fc9c6d0c7743f34375.tar.gz enigma-fork-237b2ed2a6b6f537cdbdf9fc9c6d0c7743f34375.tar.xz enigma-fork-237b2ed2a6b6f537cdbdf9fc9c6d0c7743f34375.zip | |
fixed call graph searching
added system to navigate multiple tokens for the same entry in a behavior
Diffstat (limited to 'src/cuchaz/enigma/analysis')
| -rw-r--r-- | src/cuchaz/enigma/analysis/EntryReference.java | 13 | ||||
| -rw-r--r-- | src/cuchaz/enigma/analysis/JarIndex.java | 30 | ||||
| -rw-r--r-- | src/cuchaz/enigma/analysis/SourceIndex.java | 37 | ||||
| -rw-r--r-- | src/cuchaz/enigma/analysis/SourceIndexBehaviorVisitor.java | 16 | ||||
| -rw-r--r-- | src/cuchaz/enigma/analysis/SourceIndexClassVisitor.java | 23 |
5 files changed, 64 insertions, 55 deletions
diff --git a/src/cuchaz/enigma/analysis/EntryReference.java b/src/cuchaz/enigma/analysis/EntryReference.java index 869e08c..768c113 100644 --- a/src/cuchaz/enigma/analysis/EntryReference.java +++ b/src/cuchaz/enigma/analysis/EntryReference.java | |||
| @@ -18,14 +18,13 @@ public class EntryReference<E extends Entry, C extends Entry> | |||
| 18 | { | 18 | { |
| 19 | public E entry; | 19 | public E entry; |
| 20 | public C context; | 20 | public C context; |
| 21 | public int pos; | ||
| 22 | 21 | ||
| 23 | public EntryReference( E entry ) | 22 | public EntryReference( E entry ) |
| 24 | { | 23 | { |
| 25 | this( entry, null, -1 ); | 24 | this( entry, null ); |
| 26 | } | 25 | } |
| 27 | 26 | ||
| 28 | public EntryReference( E entry, C context, int pos ) | 27 | public EntryReference( E entry, C context ) |
| 29 | { | 28 | { |
| 30 | if( entry == null ) | 29 | if( entry == null ) |
| 31 | { | 30 | { |
| @@ -34,7 +33,6 @@ public class EntryReference<E extends Entry, C extends Entry> | |||
| 34 | 33 | ||
| 35 | this.entry = entry; | 34 | this.entry = entry; |
| 36 | this.context = context; | 35 | this.context = context; |
| 37 | this.pos = pos; | ||
| 38 | } | 36 | } |
| 39 | 37 | ||
| 40 | public ClassEntry getClassEntry( ) | 38 | public ClassEntry getClassEntry( ) |
| @@ -51,7 +49,7 @@ public class EntryReference<E extends Entry, C extends Entry> | |||
| 51 | { | 49 | { |
| 52 | if( context != null ) | 50 | if( context != null ) |
| 53 | { | 51 | { |
| 54 | return Util.combineHashesOrdered( entry.hashCode(), context.hashCode(), Integer.valueOf( pos ).hashCode() ); | 52 | return Util.combineHashesOrdered( entry.hashCode(), context.hashCode() ); |
| 55 | } | 53 | } |
| 56 | return entry.hashCode(); | 54 | return entry.hashCode(); |
| 57 | } | 55 | } |
| @@ -82,7 +80,7 @@ public class EntryReference<E extends Entry, C extends Entry> | |||
| 82 | } | 80 | } |
| 83 | else if( context != null && other.context != null ) | 81 | else if( context != null && other.context != null ) |
| 84 | { | 82 | { |
| 85 | return context.equals( other.context ) && pos == other.pos; | 83 | return context.equals( other.context ); |
| 86 | } | 84 | } |
| 87 | return false; | 85 | return false; |
| 88 | } | 86 | } |
| @@ -96,9 +94,6 @@ public class EntryReference<E extends Entry, C extends Entry> | |||
| 96 | { | 94 | { |
| 97 | buf.append( " called from " ); | 95 | buf.append( " called from " ); |
| 98 | buf.append( context ); | 96 | buf.append( context ); |
| 99 | buf.append( " (" ); | ||
| 100 | buf.append( pos ); | ||
| 101 | buf.append( ")" ); | ||
| 102 | } | 97 | } |
| 103 | return buf.toString(); | 98 | return buf.toString(); |
| 104 | } | 99 | } |
diff --git a/src/cuchaz/enigma/analysis/JarIndex.java b/src/cuchaz/enigma/analysis/JarIndex.java index f408d93..315a286 100644 --- a/src/cuchaz/enigma/analysis/JarIndex.java +++ b/src/cuchaz/enigma/analysis/JarIndex.java | |||
| @@ -146,10 +146,15 @@ public class JarIndex | |||
| 146 | } | 146 | } |
| 147 | else if( behavior instanceof CtConstructor ) | 147 | else if( behavior instanceof CtConstructor ) |
| 148 | { | 148 | { |
| 149 | thisEntry = new ConstructorEntry( | 149 | boolean isStatic = behavior.getName().equals( "<clinit>" ); |
| 150 | new ClassEntry( className ), | 150 | if( isStatic ) |
| 151 | behavior.getSignature() | 151 | { |
| 152 | ); | 152 | thisEntry = new ConstructorEntry( new ClassEntry( className ) ); |
| 153 | } | ||
| 154 | else | ||
| 155 | { | ||
| 156 | thisEntry = new ConstructorEntry( new ClassEntry( className ), behavior.getSignature() ); | ||
| 157 | } | ||
| 153 | } | 158 | } |
| 154 | else | 159 | else |
| 155 | { | 160 | { |
| @@ -159,7 +164,6 @@ public class JarIndex | |||
| 159 | // index method calls | 164 | // index method calls |
| 160 | try | 165 | try |
| 161 | { | 166 | { |
| 162 | final Multiset<Entry> callNumbers = HashMultiset.create(); | ||
| 163 | behavior.instrument( new ExprEditor( ) | 167 | behavior.instrument( new ExprEditor( ) |
| 164 | { | 168 | { |
| 165 | @Override | 169 | @Override |
| @@ -171,11 +175,9 @@ public class JarIndex | |||
| 171 | call.getMethodName(), | 175 | call.getMethodName(), |
| 172 | call.getSignature() | 176 | call.getSignature() |
| 173 | ); | 177 | ); |
| 174 | callNumbers.add( calledMethodEntry ); | ||
| 175 | EntryReference<BehaviorEntry,BehaviorEntry> reference = new EntryReference<BehaviorEntry,BehaviorEntry>( | 178 | EntryReference<BehaviorEntry,BehaviorEntry> reference = new EntryReference<BehaviorEntry,BehaviorEntry>( |
| 176 | calledMethodEntry, | 179 | calledMethodEntry, |
| 177 | thisEntry, | 180 | thisEntry |
| 178 | callNumbers.count( calledMethodEntry ) - 1 | ||
| 179 | ); | 181 | ); |
| 180 | m_behaviorReferences.put( calledMethodEntry, reference ); | 182 | m_behaviorReferences.put( calledMethodEntry, reference ); |
| 181 | } | 183 | } |
| @@ -188,11 +190,9 @@ public class JarIndex | |||
| 188 | new ClassEntry( className ), | 190 | new ClassEntry( className ), |
| 189 | call.getFieldName() | 191 | call.getFieldName() |
| 190 | ); | 192 | ); |
| 191 | callNumbers.add( calledFieldEntry ); | ||
| 192 | EntryReference<FieldEntry,BehaviorEntry> reference = new EntryReference<FieldEntry,BehaviorEntry>( | 193 | EntryReference<FieldEntry,BehaviorEntry> reference = new EntryReference<FieldEntry,BehaviorEntry>( |
| 193 | calledFieldEntry, | 194 | calledFieldEntry, |
| 194 | thisEntry, | 195 | thisEntry |
| 195 | callNumbers.count( calledFieldEntry ) - 1 | ||
| 196 | ); | 196 | ); |
| 197 | m_fieldReferences.put( calledFieldEntry, reference ); | 197 | m_fieldReferences.put( calledFieldEntry, reference ); |
| 198 | } | 198 | } |
| @@ -208,11 +208,9 @@ public class JarIndex | |||
| 208 | new ClassEntry( className ), | 208 | new ClassEntry( className ), |
| 209 | call.getSignature() | 209 | call.getSignature() |
| 210 | ); | 210 | ); |
| 211 | callNumbers.add( calledConstructorEntry ); | ||
| 212 | EntryReference<BehaviorEntry,BehaviorEntry> reference = new EntryReference<BehaviorEntry,BehaviorEntry>( | 211 | EntryReference<BehaviorEntry,BehaviorEntry> reference = new EntryReference<BehaviorEntry,BehaviorEntry>( |
| 213 | calledConstructorEntry, | 212 | calledConstructorEntry, |
| 214 | thisEntry, | 213 | thisEntry |
| 215 | callNumbers.count( calledConstructorEntry ) - 1 | ||
| 216 | ); | 214 | ); |
| 217 | m_behaviorReferences.put( calledConstructorEntry, reference ); | 215 | m_behaviorReferences.put( calledConstructorEntry, reference ); |
| 218 | } | 216 | } |
| @@ -225,11 +223,9 @@ public class JarIndex | |||
| 225 | new ClassEntry( className ), | 223 | new ClassEntry( className ), |
| 226 | call.getSignature() | 224 | call.getSignature() |
| 227 | ); | 225 | ); |
| 228 | callNumbers.add( calledConstructorEntry ); | ||
| 229 | EntryReference<BehaviorEntry,BehaviorEntry> reference = new EntryReference<BehaviorEntry,BehaviorEntry>( | 226 | EntryReference<BehaviorEntry,BehaviorEntry> reference = new EntryReference<BehaviorEntry,BehaviorEntry>( |
| 230 | calledConstructorEntry, | 227 | calledConstructorEntry, |
| 231 | thisEntry, | 228 | thisEntry |
| 232 | callNumbers.count( calledConstructorEntry ) - 1 | ||
| 233 | ); | 229 | ); |
| 234 | m_behaviorReferences.put( calledConstructorEntry, reference ); | 230 | m_behaviorReferences.put( calledConstructorEntry, reference ); |
| 235 | } | 231 | } |
diff --git a/src/cuchaz/enigma/analysis/SourceIndex.java b/src/cuchaz/enigma/analysis/SourceIndex.java index bf890e3..960ec36 100644 --- a/src/cuchaz/enigma/analysis/SourceIndex.java +++ b/src/cuchaz/enigma/analysis/SourceIndex.java | |||
| @@ -10,13 +10,15 @@ | |||
| 10 | ******************************************************************************/ | 10 | ******************************************************************************/ |
| 11 | package cuchaz.enigma.analysis; | 11 | package cuchaz.enigma.analysis; |
| 12 | 12 | ||
| 13 | import java.util.HashMap; | 13 | import java.util.Collection; |
| 14 | import java.util.List; | 14 | import java.util.List; |
| 15 | import java.util.Map; | 15 | import java.util.Map; |
| 16 | import java.util.TreeMap; | 16 | import java.util.TreeMap; |
| 17 | 17 | ||
| 18 | import com.google.common.collect.HashMultimap; | ||
| 18 | import com.google.common.collect.Lists; | 19 | import com.google.common.collect.Lists; |
| 19 | import com.google.common.collect.Maps; | 20 | import com.google.common.collect.Maps; |
| 21 | import com.google.common.collect.Multimap; | ||
| 20 | import com.strobel.decompiler.languages.Region; | 22 | import com.strobel.decompiler.languages.Region; |
| 21 | import com.strobel.decompiler.languages.java.ast.Identifier; | 23 | import com.strobel.decompiler.languages.java.ast.Identifier; |
| 22 | 24 | ||
| @@ -26,7 +28,7 @@ public class SourceIndex | |||
| 26 | { | 28 | { |
| 27 | private String m_source; | 29 | private String m_source; |
| 28 | private TreeMap<Token,EntryReference<Entry,Entry>> m_tokenToReference; | 30 | private TreeMap<Token,EntryReference<Entry,Entry>> m_tokenToReference; |
| 29 | private HashMap<EntryReference<Entry,Entry>,Token> m_referenceToToken; | 31 | private Multimap<EntryReference<Entry,Entry>,Token> m_referenceToTokens; |
| 30 | private Map<Entry,Token> m_declarationToToken; | 32 | private Map<Entry,Token> m_declarationToToken; |
| 31 | private List<Integer> m_lineOffsets; | 33 | private List<Integer> m_lineOffsets; |
| 32 | 34 | ||
| @@ -34,7 +36,7 @@ public class SourceIndex | |||
| 34 | { | 36 | { |
| 35 | m_source = source; | 37 | m_source = source; |
| 36 | m_tokenToReference = Maps.newTreeMap(); | 38 | m_tokenToReference = Maps.newTreeMap(); |
| 37 | m_referenceToToken = Maps.newHashMap(); | 39 | m_referenceToTokens = HashMultimap.create(); |
| 38 | m_declarationToToken = Maps.newHashMap(); | 40 | m_declarationToToken = Maps.newHashMap(); |
| 39 | m_lineOffsets = Lists.newArrayList(); | 41 | m_lineOffsets = Lists.newArrayList(); |
| 40 | 42 | ||
| @@ -96,7 +98,7 @@ public class SourceIndex | |||
| 96 | if( token != null ) | 98 | if( token != null ) |
| 97 | { | 99 | { |
| 98 | m_tokenToReference.put( token, deobfReference ); | 100 | m_tokenToReference.put( token, deobfReference ); |
| 99 | m_referenceToToken.put( deobfReference, token ); | 101 | m_referenceToTokens.put( deobfReference, token ); |
| 100 | } | 102 | } |
| 101 | } | 103 | } |
| 102 | 104 | ||
| @@ -107,7 +109,7 @@ public class SourceIndex | |||
| 107 | { | 109 | { |
| 108 | EntryReference<Entry,Entry> reference = new EntryReference<Entry,Entry>( deobfEntry ); | 110 | EntryReference<Entry,Entry> reference = new EntryReference<Entry,Entry>( deobfEntry ); |
| 109 | m_tokenToReference.put( token, reference ); | 111 | m_tokenToReference.put( token, reference ); |
| 110 | m_referenceToToken.put( reference, token ); | 112 | m_referenceToTokens.put( reference, token ); |
| 111 | m_declarationToToken.put( deobfEntry, token ); | 113 | m_declarationToToken.put( deobfEntry, token ); |
| 112 | } | 114 | } |
| 113 | } | 115 | } |
| @@ -122,9 +124,9 @@ public class SourceIndex | |||
| 122 | return null; | 124 | return null; |
| 123 | } | 125 | } |
| 124 | 126 | ||
| 125 | public Token getReferenceToken( EntryReference<Entry,Entry> deobfReference ) | 127 | public Collection<Token> getReferenceTokens( EntryReference<Entry,Entry> deobfReference ) |
| 126 | { | 128 | { |
| 127 | return m_referenceToToken.get( deobfReference ); | 129 | return m_referenceToTokens.get( deobfReference ); |
| 128 | } | 130 | } |
| 129 | 131 | ||
| 130 | public EntryReference<Entry,Entry> getDeobfReference( Token token ) | 132 | public EntryReference<Entry,Entry> getDeobfReference( Token token ) |
| @@ -151,6 +153,27 @@ public class SourceIndex | |||
| 151 | return m_declarationToToken.get( deobfEntry ); | 153 | return m_declarationToToken.get( deobfEntry ); |
| 152 | } | 154 | } |
| 153 | 155 | ||
| 156 | public int getLineNumber( int pos ) | ||
| 157 | { | ||
| 158 | // line number is 1-based | ||
| 159 | int line = 0; | ||
| 160 | for( Integer offset : m_lineOffsets ) | ||
| 161 | { | ||
| 162 | if( offset > pos ) | ||
| 163 | { | ||
| 164 | break; | ||
| 165 | } | ||
| 166 | line++; | ||
| 167 | } | ||
| 168 | return line; | ||
| 169 | } | ||
| 170 | |||
| 171 | public int getColumnNumber( int pos ) | ||
| 172 | { | ||
| 173 | // column number is 1-based | ||
| 174 | return pos - m_lineOffsets.get( getLineNumber( pos ) - 1 ) + 1; | ||
| 175 | } | ||
| 176 | |||
| 154 | private int toPos( int line, int col ) | 177 | private int toPos( int line, int col ) |
| 155 | { | 178 | { |
| 156 | // line and col are 1-based | 179 | // line and col are 1-based |
diff --git a/src/cuchaz/enigma/analysis/SourceIndexBehaviorVisitor.java b/src/cuchaz/enigma/analysis/SourceIndexBehaviorVisitor.java index d3386c5..a943858 100644 --- a/src/cuchaz/enigma/analysis/SourceIndexBehaviorVisitor.java +++ b/src/cuchaz/enigma/analysis/SourceIndexBehaviorVisitor.java | |||
| @@ -10,8 +10,6 @@ | |||
| 10 | ******************************************************************************/ | 10 | ******************************************************************************/ |
| 11 | package cuchaz.enigma.analysis; | 11 | package cuchaz.enigma.analysis; |
| 12 | 12 | ||
| 13 | import com.google.common.collect.HashMultiset; | ||
| 14 | import com.google.common.collect.Multiset; | ||
| 15 | import com.strobel.assembler.metadata.MemberReference; | 13 | import com.strobel.assembler.metadata.MemberReference; |
| 16 | import com.strobel.assembler.metadata.MethodDefinition; | 14 | import com.strobel.assembler.metadata.MethodDefinition; |
| 17 | import com.strobel.assembler.metadata.ParameterDefinition; | 15 | import com.strobel.assembler.metadata.ParameterDefinition; |
| @@ -36,12 +34,10 @@ import cuchaz.enigma.mapping.MethodEntry; | |||
| 36 | public class SourceIndexBehaviorVisitor extends SourceIndexVisitor | 34 | public class SourceIndexBehaviorVisitor extends SourceIndexVisitor |
| 37 | { | 35 | { |
| 38 | private BehaviorEntry m_behaviorEntry; | 36 | private BehaviorEntry m_behaviorEntry; |
| 39 | private Multiset<Entry> m_indices; | ||
| 40 | 37 | ||
| 41 | public SourceIndexBehaviorVisitor( BehaviorEntry behaviorEntry ) | 38 | public SourceIndexBehaviorVisitor( BehaviorEntry behaviorEntry ) |
| 42 | { | 39 | { |
| 43 | m_behaviorEntry = behaviorEntry; | 40 | m_behaviorEntry = behaviorEntry; |
| 44 | m_indices = HashMultiset.create(); | ||
| 45 | } | 41 | } |
| 46 | 42 | ||
| 47 | @Override | 43 | @Override |
| @@ -64,10 +60,9 @@ public class SourceIndexBehaviorVisitor extends SourceIndexVisitor | |||
| 64 | MethodEntry methodEntry = new MethodEntry( classEntry, ref.getName(), ref.getSignature() ); | 60 | MethodEntry methodEntry = new MethodEntry( classEntry, ref.getName(), ref.getSignature() ); |
| 65 | if( node.getTarget() instanceof MemberReferenceExpression ) | 61 | if( node.getTarget() instanceof MemberReferenceExpression ) |
| 66 | { | 62 | { |
| 67 | m_indices.add( methodEntry ); | ||
| 68 | index.addReference( | 63 | index.addReference( |
| 69 | ((MemberReferenceExpression)node.getTarget()).getMemberNameToken(), | 64 | ((MemberReferenceExpression)node.getTarget()).getMemberNameToken(), |
| 70 | new EntryReference<Entry,Entry>( methodEntry, m_behaviorEntry, m_indices.count( methodEntry ) ) | 65 | new EntryReference<Entry,Entry>( methodEntry, m_behaviorEntry ) |
| 71 | ); | 66 | ); |
| 72 | } | 67 | } |
| 73 | 68 | ||
| @@ -82,10 +77,9 @@ public class SourceIndexBehaviorVisitor extends SourceIndexVisitor | |||
| 82 | { | 77 | { |
| 83 | ClassEntry classEntry = new ClassEntry( ref.getDeclaringType().getInternalName() ); | 78 | ClassEntry classEntry = new ClassEntry( ref.getDeclaringType().getInternalName() ); |
| 84 | FieldEntry fieldEntry = new FieldEntry( classEntry, ref.getName() ); | 79 | FieldEntry fieldEntry = new FieldEntry( classEntry, ref.getName() ); |
| 85 | m_indices.add( fieldEntry ); | ||
| 86 | index.addReference( | 80 | index.addReference( |
| 87 | node.getMemberNameToken(), | 81 | node.getMemberNameToken(), |
| 88 | new EntryReference<Entry,Entry>( fieldEntry, m_behaviorEntry, m_indices.count( fieldEntry ) ) | 82 | new EntryReference<Entry,Entry>( fieldEntry, m_behaviorEntry ) |
| 89 | ); | 83 | ); |
| 90 | } | 84 | } |
| 91 | 85 | ||
| @@ -99,10 +93,9 @@ public class SourceIndexBehaviorVisitor extends SourceIndexVisitor | |||
| 99 | if( node.getIdentifierToken().getStartLocation() != TextLocation.EMPTY ) | 93 | if( node.getIdentifierToken().getStartLocation() != TextLocation.EMPTY ) |
| 100 | { | 94 | { |
| 101 | ClassEntry classEntry = new ClassEntry( ref.getInternalName() ); | 95 | ClassEntry classEntry = new ClassEntry( ref.getInternalName() ); |
| 102 | m_indices.add( classEntry ); | ||
| 103 | index.addReference( | 96 | index.addReference( |
| 104 | node.getIdentifierToken(), | 97 | node.getIdentifierToken(), |
| 105 | new EntryReference<Entry,Entry>( classEntry, m_behaviorEntry, m_indices.count( classEntry ) ) | 98 | new EntryReference<Entry,Entry>( classEntry, m_behaviorEntry ) |
| 106 | ); | 99 | ); |
| 107 | } | 100 | } |
| 108 | 101 | ||
| @@ -130,10 +123,9 @@ public class SourceIndexBehaviorVisitor extends SourceIndexVisitor | |||
| 130 | { | 123 | { |
| 131 | ClassEntry classEntry = new ClassEntry( ref.getDeclaringType().getInternalName() ); | 124 | ClassEntry classEntry = new ClassEntry( ref.getDeclaringType().getInternalName() ); |
| 132 | FieldEntry fieldEntry = new FieldEntry( classEntry, ref.getName() ); | 125 | FieldEntry fieldEntry = new FieldEntry( classEntry, ref.getName() ); |
| 133 | m_indices.add( fieldEntry ); | ||
| 134 | index.addReference( | 126 | index.addReference( |
| 135 | node.getIdentifierToken(), | 127 | node.getIdentifierToken(), |
| 136 | new EntryReference<Entry,Entry>( fieldEntry, m_behaviorEntry, m_indices.count( fieldEntry ) ) | 128 | new EntryReference<Entry,Entry>( fieldEntry, m_behaviorEntry ) |
| 137 | ); | 129 | ); |
| 138 | } | 130 | } |
| 139 | 131 | ||
diff --git a/src/cuchaz/enigma/analysis/SourceIndexClassVisitor.java b/src/cuchaz/enigma/analysis/SourceIndexClassVisitor.java index 5257088..a1c8271 100644 --- a/src/cuchaz/enigma/analysis/SourceIndexClassVisitor.java +++ b/src/cuchaz/enigma/analysis/SourceIndexClassVisitor.java | |||
| @@ -10,8 +10,6 @@ | |||
| 10 | ******************************************************************************/ | 10 | ******************************************************************************/ |
| 11 | package cuchaz.enigma.analysis; | 11 | package cuchaz.enigma.analysis; |
| 12 | 12 | ||
| 13 | import com.google.common.collect.HashMultiset; | ||
| 14 | import com.google.common.collect.Multiset; | ||
| 15 | import com.strobel.assembler.metadata.FieldDefinition; | 13 | import com.strobel.assembler.metadata.FieldDefinition; |
| 16 | import com.strobel.assembler.metadata.MethodDefinition; | 14 | import com.strobel.assembler.metadata.MethodDefinition; |
| 17 | import com.strobel.assembler.metadata.TypeDefinition; | 15 | import com.strobel.assembler.metadata.TypeDefinition; |
| @@ -26,6 +24,7 @@ import com.strobel.decompiler.languages.java.ast.SimpleType; | |||
| 26 | import com.strobel.decompiler.languages.java.ast.TypeDeclaration; | 24 | import com.strobel.decompiler.languages.java.ast.TypeDeclaration; |
| 27 | import com.strobel.decompiler.languages.java.ast.VariableInitializer; | 25 | import com.strobel.decompiler.languages.java.ast.VariableInitializer; |
| 28 | 26 | ||
| 27 | import cuchaz.enigma.mapping.BehaviorEntry; | ||
| 29 | import cuchaz.enigma.mapping.ClassEntry; | 28 | import cuchaz.enigma.mapping.ClassEntry; |
| 30 | import cuchaz.enigma.mapping.ConstructorEntry; | 29 | import cuchaz.enigma.mapping.ConstructorEntry; |
| 31 | import cuchaz.enigma.mapping.Entry; | 30 | import cuchaz.enigma.mapping.Entry; |
| @@ -35,12 +34,10 @@ import cuchaz.enigma.mapping.MethodEntry; | |||
| 35 | public class SourceIndexClassVisitor extends SourceIndexVisitor | 34 | public class SourceIndexClassVisitor extends SourceIndexVisitor |
| 36 | { | 35 | { |
| 37 | private ClassEntry m_classEntry; | 36 | private ClassEntry m_classEntry; |
| 38 | private Multiset<Entry> m_indices; | ||
| 39 | 37 | ||
| 40 | public SourceIndexClassVisitor( ClassEntry classEntry ) | 38 | public SourceIndexClassVisitor( ClassEntry classEntry ) |
| 41 | { | 39 | { |
| 42 | m_classEntry = classEntry; | 40 | m_classEntry = classEntry; |
| 43 | m_indices = HashMultiset.create(); | ||
| 44 | } | 41 | } |
| 45 | 42 | ||
| 46 | @Override | 43 | @Override |
| @@ -68,7 +65,7 @@ public class SourceIndexClassVisitor extends SourceIndexVisitor | |||
| 68 | ClassEntry classEntry = new ClassEntry( ref.getInternalName() ); | 65 | ClassEntry classEntry = new ClassEntry( ref.getInternalName() ); |
| 69 | index.addReference( | 66 | index.addReference( |
| 70 | node.getIdentifierToken(), | 67 | node.getIdentifierToken(), |
| 71 | new EntryReference<Entry,Entry>( classEntry, m_classEntry, m_indices.count( classEntry ) ) | 68 | new EntryReference<Entry,Entry>( classEntry, m_classEntry ) |
| 72 | ); | 69 | ); |
| 73 | } | 70 | } |
| 74 | 71 | ||
| @@ -80,11 +77,17 @@ public class SourceIndexClassVisitor extends SourceIndexVisitor | |||
| 80 | { | 77 | { |
| 81 | MethodDefinition def = node.getUserData( Keys.METHOD_DEFINITION ); | 78 | MethodDefinition def = node.getUserData( Keys.METHOD_DEFINITION ); |
| 82 | ClassEntry classEntry = new ClassEntry( def.getDeclaringType().getInternalName() ); | 79 | ClassEntry classEntry = new ClassEntry( def.getDeclaringType().getInternalName() ); |
| 83 | MethodEntry methodEntry = new MethodEntry( classEntry, def.getName(), def.getSignature() ); | 80 | BehaviorEntry behaviorEntry; |
| 84 | index.addDeclaration( node.getNameToken(), methodEntry ); | 81 | if( def.getName().equals( "<clinit>" ) ) |
| 85 | //if( !def.getName().equals( "<clinit>" ) ) | 82 | { |
| 86 | 83 | behaviorEntry = new ConstructorEntry( classEntry ); | |
| 87 | return node.acceptVisitor( new SourceIndexBehaviorVisitor( methodEntry ), index ); | 84 | } |
| 85 | else | ||
| 86 | { | ||
| 87 | behaviorEntry = new MethodEntry( classEntry, def.getName(), def.getSignature() ); | ||
| 88 | } | ||
| 89 | index.addDeclaration( node.getNameToken(), behaviorEntry ); | ||
| 90 | return node.acceptVisitor( new SourceIndexBehaviorVisitor( behaviorEntry ), index ); | ||
| 88 | } | 91 | } |
| 89 | 92 | ||
| 90 | @Override | 93 | @Override |