diff options
Diffstat (limited to 'src/main/java/cuchaz/enigma/convert/MemberMatches.java')
| -rw-r--r-- | src/main/java/cuchaz/enigma/convert/MemberMatches.java | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/src/main/java/cuchaz/enigma/convert/MemberMatches.java b/src/main/java/cuchaz/enigma/convert/MemberMatches.java index 25af2f8..51cee85 100644 --- a/src/main/java/cuchaz/enigma/convert/MemberMatches.java +++ b/src/main/java/cuchaz/enigma/convert/MemberMatches.java | |||
| @@ -21,29 +21,29 @@ import java.util.Set; | |||
| 21 | 21 | ||
| 22 | public class MemberMatches<T extends Entry> { | 22 | public class MemberMatches<T extends Entry> { |
| 23 | 23 | ||
| 24 | private BiMap<T, T> m_matches; | 24 | private BiMap<T, T> matches; |
| 25 | private Multimap<ClassEntry, T> m_matchedSourceEntries; | 25 | private Multimap<ClassEntry, T> matchedSourceEntries; |
| 26 | private Multimap<ClassEntry, T> m_unmatchedSourceEntries; | 26 | private Multimap<ClassEntry, T> unmatchedSourceEntries; |
| 27 | private Multimap<ClassEntry, T> m_unmatchedDestEntries; | 27 | private Multimap<ClassEntry, T> unmatchedDestEntries; |
| 28 | private Multimap<ClassEntry, T> m_unmatchableSourceEntries; | 28 | private Multimap<ClassEntry, T> unmatchableSourceEntries; |
| 29 | 29 | ||
| 30 | public MemberMatches() { | 30 | public MemberMatches() { |
| 31 | m_matches = HashBiMap.create(); | 31 | matches = HashBiMap.create(); |
| 32 | m_matchedSourceEntries = HashMultimap.create(); | 32 | matchedSourceEntries = HashMultimap.create(); |
| 33 | m_unmatchedSourceEntries = HashMultimap.create(); | 33 | unmatchedSourceEntries = HashMultimap.create(); |
| 34 | m_unmatchedDestEntries = HashMultimap.create(); | 34 | unmatchedDestEntries = HashMultimap.create(); |
| 35 | m_unmatchableSourceEntries = HashMultimap.create(); | 35 | unmatchableSourceEntries = HashMultimap.create(); |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | public void addMatch(T srcEntry, T destEntry) { | 38 | public void addMatch(T srcEntry, T destEntry) { |
| 39 | boolean wasAdded = m_matches.put(srcEntry, destEntry) == null; | 39 | boolean wasAdded = matches.put(srcEntry, destEntry) == null; |
| 40 | assert (wasAdded); | 40 | assert (wasAdded); |
| 41 | wasAdded = m_matchedSourceEntries.put(srcEntry.getClassEntry(), srcEntry); | 41 | wasAdded = matchedSourceEntries.put(srcEntry.getClassEntry(), srcEntry); |
| 42 | assert (wasAdded); | 42 | assert (wasAdded); |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | public void addUnmatchedSourceEntry(T sourceEntry) { | 45 | public void addUnmatchedSourceEntry(T sourceEntry) { |
| 46 | boolean wasAdded = m_unmatchedSourceEntries.put(sourceEntry.getClassEntry(), sourceEntry); | 46 | boolean wasAdded = unmatchedSourceEntries.put(sourceEntry.getClassEntry(), sourceEntry); |
| 47 | assert (wasAdded); | 47 | assert (wasAdded); |
| 48 | } | 48 | } |
| 49 | 49 | ||
| @@ -56,7 +56,7 @@ public class MemberMatches<T extends Entry> { | |||
| 56 | public void addUnmatchedDestEntry(T destEntry) { | 56 | public void addUnmatchedDestEntry(T destEntry) { |
| 57 | if (destEntry.getName().equals("<clinit>") || destEntry.getName().equals("<init>")) | 57 | if (destEntry.getName().equals("<clinit>") || destEntry.getName().equals("<init>")) |
| 58 | return; | 58 | return; |
| 59 | boolean wasAdded = m_unmatchedDestEntries.put(destEntry.getClassEntry(), destEntry); | 59 | boolean wasAdded = unmatchedDestEntries.put(destEntry.getClassEntry(), destEntry); |
| 60 | assert (wasAdded); | 60 | assert (wasAdded); |
| 61 | } | 61 | } |
| 62 | 62 | ||
| @@ -67,63 +67,63 @@ public class MemberMatches<T extends Entry> { | |||
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | public void addUnmatchableSourceEntry(T sourceEntry) { | 69 | public void addUnmatchableSourceEntry(T sourceEntry) { |
| 70 | boolean wasAdded = m_unmatchableSourceEntries.put(sourceEntry.getClassEntry(), sourceEntry); | 70 | boolean wasAdded = unmatchableSourceEntries.put(sourceEntry.getClassEntry(), sourceEntry); |
| 71 | assert (wasAdded); | 71 | assert (wasAdded); |
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | public Set<ClassEntry> getSourceClassesWithUnmatchedEntries() { | 74 | public Set<ClassEntry> getSourceClassesWithUnmatchedEntries() { |
| 75 | return m_unmatchedSourceEntries.keySet(); | 75 | return unmatchedSourceEntries.keySet(); |
| 76 | } | 76 | } |
| 77 | 77 | ||
| 78 | public Collection<ClassEntry> getSourceClassesWithoutUnmatchedEntries() { | 78 | public Collection<ClassEntry> getSourceClassesWithoutUnmatchedEntries() { |
| 79 | Set<ClassEntry> out = Sets.newHashSet(); | 79 | Set<ClassEntry> out = Sets.newHashSet(); |
| 80 | out.addAll(m_matchedSourceEntries.keySet()); | 80 | out.addAll(matchedSourceEntries.keySet()); |
| 81 | out.removeAll(m_unmatchedSourceEntries.keySet()); | 81 | out.removeAll(unmatchedSourceEntries.keySet()); |
| 82 | return out; | 82 | return out; |
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | public Collection<T> getUnmatchedSourceEntries() { | 85 | public Collection<T> getUnmatchedSourceEntries() { |
| 86 | return m_unmatchedSourceEntries.values(); | 86 | return unmatchedSourceEntries.values(); |
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | public Collection<T> getUnmatchedSourceEntries(ClassEntry sourceClass) { | 89 | public Collection<T> getUnmatchedSourceEntries(ClassEntry sourceClass) { |
| 90 | return m_unmatchedSourceEntries.get(sourceClass); | 90 | return unmatchedSourceEntries.get(sourceClass); |
| 91 | } | 91 | } |
| 92 | 92 | ||
| 93 | public Collection<T> getUnmatchedDestEntries() { | 93 | public Collection<T> getUnmatchedDestEntries() { |
| 94 | return m_unmatchedDestEntries.values(); | 94 | return unmatchedDestEntries.values(); |
| 95 | } | 95 | } |
| 96 | 96 | ||
| 97 | public Collection<T> getUnmatchedDestEntries(ClassEntry destClass) { | 97 | public Collection<T> getUnmatchedDestEntries(ClassEntry destClass) { |
| 98 | return m_unmatchedDestEntries.get(destClass); | 98 | return unmatchedDestEntries.get(destClass); |
| 99 | } | 99 | } |
| 100 | 100 | ||
| 101 | public Collection<T> getUnmatchableSourceEntries() { | 101 | public Collection<T> getUnmatchableSourceEntries() { |
| 102 | return m_unmatchableSourceEntries.values(); | 102 | return unmatchableSourceEntries.values(); |
| 103 | } | 103 | } |
| 104 | 104 | ||
| 105 | public boolean hasSource(T sourceEntry) { | 105 | public boolean hasSource(T sourceEntry) { |
| 106 | return m_matches.containsKey(sourceEntry) || m_unmatchedSourceEntries.containsValue(sourceEntry); | 106 | return matches.containsKey(sourceEntry) || unmatchedSourceEntries.containsValue(sourceEntry); |
| 107 | } | 107 | } |
| 108 | 108 | ||
| 109 | public boolean hasDest(T destEntry) { | 109 | public boolean hasDest(T destEntry) { |
| 110 | return m_matches.containsValue(destEntry) || m_unmatchedDestEntries.containsValue(destEntry); | 110 | return matches.containsValue(destEntry) || unmatchedDestEntries.containsValue(destEntry); |
| 111 | } | 111 | } |
| 112 | 112 | ||
| 113 | public BiMap<T, T> matches() { | 113 | public BiMap<T, T> matches() { |
| 114 | return m_matches; | 114 | return matches; |
| 115 | } | 115 | } |
| 116 | 116 | ||
| 117 | public boolean isMatchedSourceEntry(T sourceEntry) { | 117 | public boolean isMatchedSourceEntry(T sourceEntry) { |
| 118 | return m_matches.containsKey(sourceEntry); | 118 | return matches.containsKey(sourceEntry); |
| 119 | } | 119 | } |
| 120 | 120 | ||
| 121 | public boolean isMatchedDestEntry(T destEntry) { | 121 | public boolean isMatchedDestEntry(T destEntry) { |
| 122 | return m_matches.containsValue(destEntry); | 122 | return matches.containsValue(destEntry); |
| 123 | } | 123 | } |
| 124 | 124 | ||
| 125 | public boolean isUnmatchableSourceEntry(T sourceEntry) { | 125 | public boolean isUnmatchableSourceEntry(T sourceEntry) { |
| 126 | return m_unmatchableSourceEntries.containsEntry(sourceEntry.getClassEntry(), sourceEntry); | 126 | return unmatchableSourceEntries.containsEntry(sourceEntry.getClassEntry(), sourceEntry); |
| 127 | } | 127 | } |
| 128 | public void makeMatch(T sourceEntry, T destEntry) { | 128 | public void makeMatch(T sourceEntry, T destEntry) { |
| 129 | makeMatch(sourceEntry, destEntry, null, null); | 129 | makeMatch(sourceEntry, destEntry, null, null); |
| @@ -136,15 +136,15 @@ public class MemberMatches<T extends Entry> { | |||
| 136 | sourceEntry = (T) sourceEntry.cloneToNewClass(sourceDeobfuscator.getJarIndex().getTranslationIndex().resolveEntryClass(sourceEntry, true)); | 136 | sourceEntry = (T) sourceEntry.cloneToNewClass(sourceDeobfuscator.getJarIndex().getTranslationIndex().resolveEntryClass(sourceEntry, true)); |
| 137 | destEntry = (T) destEntry.cloneToNewClass(destDeobfuscator.getJarIndex().getTranslationIndex().resolveEntryClass(destEntry, true)); | 137 | destEntry = (T) destEntry.cloneToNewClass(destDeobfuscator.getJarIndex().getTranslationIndex().resolveEntryClass(destEntry, true)); |
| 138 | } | 138 | } |
| 139 | boolean wasRemoved = m_unmatchedSourceEntries.remove(sourceEntry.getClassEntry(), sourceEntry); | 139 | boolean wasRemoved = unmatchedSourceEntries.remove(sourceEntry.getClassEntry(), sourceEntry); |
| 140 | assert (wasRemoved); | 140 | assert (wasRemoved); |
| 141 | wasRemoved = m_unmatchedDestEntries.remove(destEntry.getClassEntry(), destEntry); | 141 | wasRemoved = unmatchedDestEntries.remove(destEntry.getClassEntry(), destEntry); |
| 142 | assert (wasRemoved); | 142 | assert (wasRemoved); |
| 143 | addMatch(sourceEntry, destEntry); | 143 | addMatch(sourceEntry, destEntry); |
| 144 | } | 144 | } |
| 145 | 145 | ||
| 146 | public boolean isMatched(T sourceEntry, T destEntry) { | 146 | public boolean isMatched(T sourceEntry, T destEntry) { |
| 147 | T match = m_matches.get(sourceEntry); | 147 | T match = matches.get(sourceEntry); |
| 148 | return match != null && match.equals(destEntry); | 148 | return match != null && match.equals(destEntry); |
| 149 | } | 149 | } |
| 150 | 150 | ||
| @@ -159,9 +159,9 @@ public class MemberMatches<T extends Entry> { | |||
| 159 | destDeobfuscator.getJarIndex().getTranslationIndex().resolveEntryClass(destEntry, true)); | 159 | destDeobfuscator.getJarIndex().getTranslationIndex().resolveEntryClass(destEntry, true)); |
| 160 | } | 160 | } |
| 161 | 161 | ||
| 162 | boolean wasRemoved = m_matches.remove(sourceEntry) != null; | 162 | boolean wasRemoved = matches.remove(sourceEntry) != null; |
| 163 | assert (wasRemoved); | 163 | assert (wasRemoved); |
| 164 | wasRemoved = m_matchedSourceEntries.remove(sourceEntry.getClassEntry(), sourceEntry); | 164 | wasRemoved = matchedSourceEntries.remove(sourceEntry.getClassEntry(), sourceEntry); |
| 165 | assert (wasRemoved); | 165 | assert (wasRemoved); |
| 166 | addUnmatchedSourceEntry(sourceEntry); | 166 | addUnmatchedSourceEntry(sourceEntry); |
| 167 | addUnmatchedDestEntry(destEntry); | 167 | addUnmatchedDestEntry(destEntry); |
| @@ -175,7 +175,7 @@ public class MemberMatches<T extends Entry> { | |||
| 175 | sourceDeobfuscator.getJarIndex().getTranslationIndex().resolveEntryClass(sourceEntry, true)); | 175 | sourceDeobfuscator.getJarIndex().getTranslationIndex().resolveEntryClass(sourceEntry, true)); |
| 176 | } | 176 | } |
| 177 | assert (!isMatchedSourceEntry(sourceEntry)); | 177 | assert (!isMatchedSourceEntry(sourceEntry)); |
| 178 | boolean wasRemoved = m_unmatchedSourceEntries.remove(sourceEntry.getClassEntry(), sourceEntry); | 178 | boolean wasRemoved = unmatchedSourceEntries.remove(sourceEntry.getClassEntry(), sourceEntry); |
| 179 | assert (wasRemoved); | 179 | assert (wasRemoved); |
| 180 | addUnmatchableSourceEntry(sourceEntry); | 180 | addUnmatchableSourceEntry(sourceEntry); |
| 181 | } | 181 | } |