diff options
Diffstat (limited to 'src/main/java/cuchaz/enigma/command/MapSpecializedMethodsCommand.java')
| -rw-r--r-- | src/main/java/cuchaz/enigma/command/MapSpecializedMethodsCommand.java | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/src/main/java/cuchaz/enigma/command/MapSpecializedMethodsCommand.java b/src/main/java/cuchaz/enigma/command/MapSpecializedMethodsCommand.java deleted file mode 100644 index eb8d5dc..0000000 --- a/src/main/java/cuchaz/enigma/command/MapSpecializedMethodsCommand.java +++ /dev/null | |||
| @@ -1,69 +0,0 @@ | |||
| 1 | package cuchaz.enigma.command; | ||
| 2 | |||
| 3 | import cuchaz.enigma.ProgressListener; | ||
| 4 | import cuchaz.enigma.analysis.ClassCache; | ||
| 5 | import cuchaz.enigma.analysis.index.BridgeMethodIndex; | ||
| 6 | import cuchaz.enigma.analysis.index.JarIndex; | ||
| 7 | import cuchaz.enigma.throwables.MappingParseException; | ||
| 8 | import cuchaz.enigma.translation.MappingTranslator; | ||
| 9 | import cuchaz.enigma.translation.Translator; | ||
| 10 | import cuchaz.enigma.translation.mapping.*; | ||
| 11 | import cuchaz.enigma.translation.mapping.tree.EntryTree; | ||
| 12 | import cuchaz.enigma.translation.mapping.tree.EntryTreeNode; | ||
| 13 | import cuchaz.enigma.translation.mapping.tree.HashEntryTree; | ||
| 14 | import cuchaz.enigma.translation.representation.entry.MethodEntry; | ||
| 15 | import cuchaz.enigma.utils.Utils; | ||
| 16 | |||
| 17 | import java.io.IOException; | ||
| 18 | import java.nio.file.Path; | ||
| 19 | import java.nio.file.Paths; | ||
| 20 | import java.util.Map; | ||
| 21 | |||
| 22 | public class MapSpecializedMethodsCommand extends Command { | ||
| 23 | public MapSpecializedMethodsCommand() { | ||
| 24 | super("map-specialized-methods"); | ||
| 25 | } | ||
| 26 | |||
| 27 | @Override | ||
| 28 | public String getUsage() { | ||
| 29 | return "<jar> <source-format> <source> <result-format> <result>"; | ||
| 30 | } | ||
| 31 | |||
| 32 | @Override | ||
| 33 | public boolean isValidArgument(int length) { | ||
| 34 | return length == 5; | ||
| 35 | } | ||
| 36 | |||
| 37 | @Override | ||
| 38 | public void run(String... args) throws IOException, MappingParseException { | ||
| 39 | run(Paths.get(args[0]), args[1], Paths.get(args[2]), args[3], Paths.get(args[4])); | ||
| 40 | } | ||
| 41 | |||
| 42 | public static void run(Path jar, String sourceFormat, Path sourcePath, String resultFormat, Path output) throws IOException, MappingParseException { | ||
| 43 | MappingSaveParameters saveParameters = new MappingSaveParameters(MappingFileNameFormat.BY_DEOBF); | ||
| 44 | EntryTree<EntryMapping> source = MappingCommandsUtil.read(sourceFormat, sourcePath, saveParameters); | ||
| 45 | EntryTree<EntryMapping> result = new HashEntryTree<>(); | ||
| 46 | ClassCache classCache = ClassCache.of(jar); | ||
| 47 | JarIndex jarIndex = classCache.index(ProgressListener.none()); | ||
| 48 | BridgeMethodIndex bridgeMethodIndex = jarIndex.getBridgeMethodIndex(); | ||
| 49 | Translator translator = new MappingTranslator(source, jarIndex.getEntryResolver()); | ||
| 50 | |||
| 51 | // Copy all non-specialized methods | ||
| 52 | for (EntryTreeNode<EntryMapping> node : source) { | ||
| 53 | if (!(node.getEntry() instanceof MethodEntry) || !bridgeMethodIndex.isSpecializedMethod((MethodEntry) node.getEntry())) { | ||
| 54 | result.insert(node.getEntry(), node.getValue()); | ||
| 55 | } | ||
| 56 | } | ||
| 57 | |||
| 58 | // Add correct mappings for specialized methods | ||
| 59 | for (Map.Entry<MethodEntry, MethodEntry> entry : bridgeMethodIndex.getBridgeToSpecialized().entrySet()) { | ||
| 60 | MethodEntry bridge = entry.getKey(); | ||
| 61 | MethodEntry specialized = entry.getValue(); | ||
| 62 | String name = translator.translate(bridge).getName(); | ||
| 63 | result.insert(specialized, new EntryMapping(name)); | ||
| 64 | } | ||
| 65 | |||
| 66 | Utils.delete(output); | ||
| 67 | MappingCommandsUtil.write(result, resultFormat, output, saveParameters); | ||
| 68 | } | ||
| 69 | } | ||