diff options
| author | 2019-11-22 15:40:50 -0500 | |
|---|---|---|
| committer | 2019-11-22 20:40:50 +0000 | |
| commit | 37cafdb5a837cbe29e4cc9a34737e24f496bc94f (patch) | |
| tree | 413ec17d5593984465ffc6005f3fa3c096d7225f /src/main/java/cuchaz/enigma/analysis | |
| parent | Tweak runemoro's stats generator to be compatible with multiple services (#178) (diff) | |
| download | enigma-fork-37cafdb5a837cbe29e4cc9a34737e24f496bc94f.tar.gz enigma-fork-37cafdb5a837cbe29e4cc9a34737e24f496bc94f.tar.xz enigma-fork-37cafdb5a837cbe29e4cc9a34737e24f496bc94f.zip | |
Correctly decompile bridges, and add command to add bridges to mappings (#180)
Diffstat (limited to 'src/main/java/cuchaz/enigma/analysis')
| -rw-r--r-- | src/main/java/cuchaz/enigma/analysis/index/BridgeMethodIndex.java | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/main/java/cuchaz/enigma/analysis/index/BridgeMethodIndex.java b/src/main/java/cuchaz/enigma/analysis/index/BridgeMethodIndex.java index 8a9b459..a4b1aac 100644 --- a/src/main/java/cuchaz/enigma/analysis/index/BridgeMethodIndex.java +++ b/src/main/java/cuchaz/enigma/analysis/index/BridgeMethodIndex.java | |||
| @@ -1,7 +1,6 @@ | |||
| 1 | package cuchaz.enigma.analysis.index; | 1 | package cuchaz.enigma.analysis.index; |
| 2 | 2 | ||
| 3 | import com.google.common.collect.Maps; | 3 | import com.google.common.collect.Maps; |
| 4 | import com.google.common.collect.Sets; | ||
| 5 | import cuchaz.enigma.translation.representation.AccessFlags; | 4 | import cuchaz.enigma.translation.representation.AccessFlags; |
| 6 | import cuchaz.enigma.translation.representation.MethodDescriptor; | 5 | import cuchaz.enigma.translation.representation.MethodDescriptor; |
| 7 | import cuchaz.enigma.translation.representation.TypeDescriptor; | 6 | import cuchaz.enigma.translation.representation.TypeDescriptor; |
| @@ -17,7 +16,7 @@ public class BridgeMethodIndex implements JarIndexer { | |||
| 17 | private final InheritanceIndex inheritanceIndex; | 16 | private final InheritanceIndex inheritanceIndex; |
| 18 | private final ReferenceIndex referenceIndex; | 17 | private final ReferenceIndex referenceIndex; |
| 19 | 18 | ||
| 20 | private final Set<MethodEntry> bridgeToSpecialized = Sets.newHashSet(); | 19 | private final Map<MethodEntry, MethodEntry> bridgeToSpecialized = Maps.newHashMap(); |
| 21 | private final Map<MethodEntry, MethodEntry> specializedToBridge = Maps.newHashMap(); | 20 | private final Map<MethodEntry, MethodEntry> specializedToBridge = Maps.newHashMap(); |
| 22 | 21 | ||
| 23 | public BridgeMethodIndex(EntryIndex entryIndex, InheritanceIndex inheritanceIndex, ReferenceIndex referenceIndex) { | 22 | public BridgeMethodIndex(EntryIndex entryIndex, InheritanceIndex inheritanceIndex, ReferenceIndex referenceIndex) { |
| @@ -52,7 +51,6 @@ public class BridgeMethodIndex implements JarIndexer { | |||
| 52 | } | 51 | } |
| 53 | 52 | ||
| 54 | MethodEntry renamedSpecializedEntry = specializedEntry.withName(bridgeEntry.getName()); | 53 | MethodEntry renamedSpecializedEntry = specializedEntry.withName(bridgeEntry.getName()); |
| 55 | bridgeToSpecialized.add(renamedSpecializedEntry); | ||
| 56 | specializedToBridge.put(renamedSpecializedEntry, specializedToBridge.get(specializedEntry)); | 54 | specializedToBridge.put(renamedSpecializedEntry, specializedToBridge.get(specializedEntry)); |
| 57 | } | 55 | } |
| 58 | } | 56 | } |
| @@ -64,7 +62,7 @@ public class BridgeMethodIndex implements JarIndexer { | |||
| 64 | } | 62 | } |
| 65 | 63 | ||
| 66 | if (access.isBridge() || isPotentialBridge(syntheticMethod, specializedMethod)) { | 64 | if (access.isBridge() || isPotentialBridge(syntheticMethod, specializedMethod)) { |
| 67 | bridgeToSpecialized.add(syntheticMethod); | 65 | bridgeToSpecialized.put(syntheticMethod, specializedMethod); |
| 68 | specializedToBridge.put(specializedMethod, syntheticMethod); | 66 | specializedToBridge.put(specializedMethod, syntheticMethod); |
| 69 | } | 67 | } |
| 70 | } | 68 | } |
| @@ -130,7 +128,7 @@ public class BridgeMethodIndex implements JarIndexer { | |||
| 130 | } | 128 | } |
| 131 | 129 | ||
| 132 | public boolean isBridgeMethod(MethodEntry entry) { | 130 | public boolean isBridgeMethod(MethodEntry entry) { |
| 133 | return bridgeToSpecialized.contains(entry); | 131 | return bridgeToSpecialized.containsKey(entry); |
| 134 | } | 132 | } |
| 135 | 133 | ||
| 136 | public boolean isSpecializedMethod(MethodEntry entry) { | 134 | public boolean isSpecializedMethod(MethodEntry entry) { |
| @@ -142,7 +140,17 @@ public class BridgeMethodIndex implements JarIndexer { | |||
| 142 | return specializedToBridge.get(specialized); | 140 | return specializedToBridge.get(specialized); |
| 143 | } | 141 | } |
| 144 | 142 | ||
| 143 | public MethodEntry getSpecializedFromBridge(MethodEntry bridge) { | ||
| 144 | return bridgeToSpecialized.get(bridge); | ||
| 145 | } | ||
| 146 | |||
| 147 | /** Includes "renamed specialized -> bridge" entries. */ | ||
| 145 | public Map<MethodEntry, MethodEntry> getSpecializedToBridge() { | 148 | public Map<MethodEntry, MethodEntry> getSpecializedToBridge() { |
| 146 | return Collections.unmodifiableMap(specializedToBridge); | 149 | return Collections.unmodifiableMap(specializedToBridge); |
| 147 | } | 150 | } |
| 151 | |||
| 152 | /** Only "bridge -> original name" entries. **/ | ||
| 153 | public Map<MethodEntry, MethodEntry> getBridgeToSpecialized() { | ||
| 154 | return Collections.unmodifiableMap(bridgeToSpecialized); | ||
| 155 | } | ||
| 148 | } | 156 | } |