diff options
| author | 2019-07-08 11:18:46 -0400 | |
|---|---|---|
| committer | 2019-07-08 16:18:46 +0100 | |
| commit | d4229970e549b25139e3fb7348148f7deaab36c5 (patch) | |
| tree | f1c3bfae41bc8b799f655c3f583d567b50d11542 /src/main | |
| parent | 1AM coding (diff) | |
| download | enigma-fork-d4229970e549b25139e3fb7348148f7deaab36c5.tar.gz enigma-fork-d4229970e549b25139e3fb7348148f7deaab36c5.tar.xz enigma-fork-d4229970e549b25139e3fb7348148f7deaab36c5.zip | |
Fix compose-mappings not remapping descriptors of methods on the right side only (#154)
* Fix compose-mappings not remapping descriptors of methods on the right side only
* Update version
Diffstat (limited to 'src/main')
| -rw-r--r-- | src/main/java/cuchaz/enigma/command/MappingCommandsUtil.java | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/src/main/java/cuchaz/enigma/command/MappingCommandsUtil.java b/src/main/java/cuchaz/enigma/command/MappingCommandsUtil.java index 8384e4e..394d67b 100644 --- a/src/main/java/cuchaz/enigma/command/MappingCommandsUtil.java +++ b/src/main/java/cuchaz/enigma/command/MappingCommandsUtil.java | |||
| @@ -18,9 +18,7 @@ import cuchaz.enigma.translation.representation.entry.MethodEntry; | |||
| 18 | 18 | ||
| 19 | import java.io.IOException; | 19 | import java.io.IOException; |
| 20 | import java.nio.file.Path; | 20 | import java.nio.file.Path; |
| 21 | import java.util.HashMap; | ||
| 22 | import java.util.HashSet; | 21 | import java.util.HashSet; |
| 23 | import java.util.Map; | ||
| 24 | import java.util.Set; | 22 | import java.util.Set; |
| 25 | 23 | ||
| 26 | public final class MappingCommandsUtil { | 24 | public final class MappingCommandsUtil { |
| @@ -47,11 +45,9 @@ public final class MappingCommandsUtil { | |||
| 47 | return result; | 45 | return result; |
| 48 | } | 46 | } |
| 49 | 47 | ||
| 50 | @SuppressWarnings("unchecked") | ||
| 51 | public static EntryTree<EntryMapping> compose(EntryTree<EntryMapping> left, EntryTree<EntryMapping> right, boolean keepLeftOnly, boolean keepRightOnly) { | 48 | public static EntryTree<EntryMapping> compose(EntryTree<EntryMapping> left, EntryTree<EntryMapping> right, boolean keepLeftOnly, boolean keepRightOnly) { |
| 52 | Translator leftTranslator = new MappingTranslator(left, VoidEntryResolver.INSTANCE); | 49 | Translator leftTranslator = new MappingTranslator(left, VoidEntryResolver.INSTANCE); |
| 53 | EntryTree<EntryMapping> result = new HashEntryTree<>(); | 50 | EntryTree<EntryMapping> result = new HashEntryTree<>(); |
| 54 | Map<Entry<?>, Entry<?>> rightToLeft = new HashMap<>(); | ||
| 55 | Set<Entry<?>> addedMappings = new HashSet<>(); | 51 | Set<Entry<?>> addedMappings = new HashSet<>(); |
| 56 | 52 | ||
| 57 | for (EntryTreeNode<EntryMapping> node : left) { | 53 | for (EntryTreeNode<EntryMapping> node : left) { |
| @@ -59,7 +55,6 @@ public final class MappingCommandsUtil { | |||
| 59 | EntryMapping leftMapping = node.getValue(); | 55 | EntryMapping leftMapping = node.getValue(); |
| 60 | 56 | ||
| 61 | Entry<?> rightEntry = leftTranslator.translate(leftEntry); | 57 | Entry<?> rightEntry = leftTranslator.translate(leftEntry); |
| 62 | rightToLeft.put(rightEntry, leftEntry); | ||
| 63 | 58 | ||
| 64 | EntryMapping rightMapping = right.get(rightEntry); | 59 | EntryMapping rightMapping = right.get(rightEntry); |
| 65 | if (rightMapping != null) { | 60 | if (rightMapping != null) { |
| @@ -75,18 +70,9 @@ public final class MappingCommandsUtil { | |||
| 75 | Entry<?> rightEntry = node.getEntry(); | 70 | Entry<?> rightEntry = node.getEntry(); |
| 76 | EntryMapping rightMapping = node.getValue(); | 71 | EntryMapping rightMapping = node.getValue(); |
| 77 | 72 | ||
| 78 | if (addedMappings.contains(rightEntry)) { | 73 | if (!addedMappings.contains(rightEntry)) { |
| 79 | continue; | 74 | result.insert(leftTranslator.translate(rightEntry), rightMapping); |
| 80 | } | 75 | } |
| 81 | |||
| 82 | Entry<?> parent = rightEntry.getParent(); | ||
| 83 | Entry<?> correctEntry = rightEntry; | ||
| 84 | if (rightToLeft.containsKey(parent)) { | ||
| 85 | correctEntry = ((Entry<Entry<?>>) rightEntry).withParent(rightToLeft.get(parent)); | ||
| 86 | } | ||
| 87 | |||
| 88 | result.insert(correctEntry, rightMapping); | ||
| 89 | rightToLeft.put(rightEntry, correctEntry); | ||
| 90 | } | 76 | } |
| 91 | } | 77 | } |
| 92 | return result; | 78 | return result; |