diff options
| author | 2018-10-27 00:51:21 +0200 | |
|---|---|---|
| committer | 2018-10-27 00:51:30 +0200 | |
| commit | 39f2f2e73dfec20faef67f957e92452617ceda11 (patch) | |
| tree | 3d6626dfff2cc3e0e75b7f0edca7b90899fefc29 | |
| parent | remove parallelStreams on non-thread-safe ooperations in rebuildMethodNames, ... (diff) | |
| download | enigma-39f2f2e73dfec20faef67f957e92452617ceda11.tar.gz enigma-39f2f2e73dfec20faef67f957e92452617ceda11.tar.xz enigma-39f2f2e73dfec20faef67f957e92452617ceda11.zip | |
update gson, fix argument indexing, delete empty class mappings
6 files changed, 35 insertions, 12 deletions
diff --git a/build.gradle b/build.gradle index bcafc1c8..2a9d2a4e 100644 --- a/build.gradle +++ b/build.gradle | |||
| @@ -66,7 +66,7 @@ configurations { | |||
| 66 | dependencies { | 66 | dependencies { |
| 67 | compile 'com.google.guava:guava:23.+' | 67 | compile 'com.google.guava:guava:23.+' |
| 68 | compile 'org.bitbucket.mstrobel:procyon-compilertools:0.5.33.8-enigma' | 68 | compile 'org.bitbucket.mstrobel:procyon-compilertools:0.5.33.8-enigma' |
| 69 | compile 'com.google.code.gson:gson:2.8.1' | 69 | compile 'com.google.code.gson:gson:2.8.5' |
| 70 | compile 'org.ow2.asm:asm:6.2.1' | 70 | compile 'org.ow2.asm:asm:6.2.1' |
| 71 | compile 'org.ow2.asm:asm-analysis:6.2.1' | 71 | compile 'org.ow2.asm:asm-analysis:6.2.1' |
| 72 | compile 'org.ow2.asm:asm-commons:6.2.1' | 72 | compile 'org.ow2.asm:asm-commons:6.2.1' |
diff --git a/src/main/java/cuchaz/enigma/analysis/SourceIndexMethodVisitor.java b/src/main/java/cuchaz/enigma/analysis/SourceIndexMethodVisitor.java index 83e5e04f..2a638db5 100644 --- a/src/main/java/cuchaz/enigma/analysis/SourceIndexMethodVisitor.java +++ b/src/main/java/cuchaz/enigma/analysis/SourceIndexMethodVisitor.java | |||
| @@ -33,6 +33,7 @@ public class SourceIndexMethodVisitor extends SourceIndexVisitor { | |||
| 33 | 33 | ||
| 34 | private Multimap<String, Identifier> unmatchedIdentifier = HashMultimap.create(); | 34 | private Multimap<String, Identifier> unmatchedIdentifier = HashMultimap.create(); |
| 35 | private Map<String, Entry> identifierEntryCache = new HashMap<>(); | 35 | private Map<String, Entry> identifierEntryCache = new HashMap<>(); |
| 36 | private int argumentPosition = 0; | ||
| 36 | 37 | ||
| 37 | public SourceIndexMethodVisitor(ReferencedEntryPool entryPool, ClassDefEntry ownerEntry, MethodDefEntry methodEntry) { | 38 | public SourceIndexMethodVisitor(ReferencedEntryPool entryPool, ClassDefEntry ownerEntry, MethodDefEntry methodEntry) { |
| 38 | super(entryPool); | 39 | super(entryPool); |
| @@ -107,10 +108,9 @@ public class SourceIndexMethodVisitor extends SourceIndexVisitor { | |||
| 107 | 108 | ||
| 108 | @Override | 109 | @Override |
| 109 | public Void visitParameterDeclaration(ParameterDeclaration node, SourceIndex index) { | 110 | public Void visitParameterDeclaration(ParameterDeclaration node, SourceIndex index) { |
| 110 | ParameterDefinition def = node.getUserData(Keys.PARAMETER_DEFINITION); | 111 | // DO NOT USE def.getSlot()! Doubleword slots increase by 2, not by 1 |
| 111 | 112 | ||
| 112 | int variableOffset = this.methodEntry.getVariableOffset(ownerEntry); | 113 | int parameterIndex = (argumentPosition++); |
| 113 | int parameterIndex = def.getSlot() - variableOffset; | ||
| 114 | 114 | ||
| 115 | if (parameterIndex >= 0) { | 115 | if (parameterIndex >= 0) { |
| 116 | LocalVariableEntry localVariableEntry = new LocalVariableEntry(methodEntry, parameterIndex, node.getName()); | 116 | LocalVariableEntry localVariableEntry = new LocalVariableEntry(methodEntry, parameterIndex, node.getName()); |
| @@ -184,8 +184,7 @@ public class SourceIndexMethodVisitor extends SourceIndexVisitor { | |||
| 184 | if (variable != null) { | 184 | if (variable != null) { |
| 185 | VariableDefinition originalVariable = variable.getOriginalVariable(); | 185 | VariableDefinition originalVariable = variable.getOriginalVariable(); |
| 186 | if (originalVariable != null) { | 186 | if (originalVariable != null) { |
| 187 | int variableOffset = methodEntry.getVariableOffset(ownerEntry); | 187 | int variableIndex = (argumentPosition++); |
| 188 | int variableIndex = originalVariable.getSlot() - variableOffset; | ||
| 189 | if (variableIndex >= 0) { | 188 | if (variableIndex >= 0) { |
| 190 | LocalVariableEntry localVariableEntry = new LocalVariableEntry(methodEntry, variableIndex, initializer.getName()); | 189 | LocalVariableEntry localVariableEntry = new LocalVariableEntry(methodEntry, variableIndex, initializer.getName()); |
| 191 | identifierEntryCache.put(identifier.getName(), localVariableEntry); | 190 | identifierEntryCache.put(identifier.getName(), localVariableEntry); |
diff --git a/src/main/java/cuchaz/enigma/config/Themes.java b/src/main/java/cuchaz/enigma/config/Themes.java index 79c245b4..04ecfde3 100644 --- a/src/main/java/cuchaz/enigma/config/Themes.java +++ b/src/main/java/cuchaz/enigma/config/Themes.java | |||
| @@ -13,7 +13,7 @@ import java.io.IOException; | |||
| 13 | public class Themes { | 13 | public class Themes { |
| 14 | 14 | ||
| 15 | public static void setDefault(Gui gui) { | 15 | public static void setDefault(Gui gui) { |
| 16 | //TODO set to default | 16 | // TODO set to default |
| 17 | try { | 17 | try { |
| 18 | Config.getInstance().reset(); | 18 | Config.getInstance().reset(); |
| 19 | } catch (IOException e) { | 19 | } catch (IOException e) { |
diff --git a/src/main/java/cuchaz/enigma/mapping/ClassMapping.java b/src/main/java/cuchaz/enigma/mapping/ClassMapping.java index 369ba8c6..9c193ef4 100644 --- a/src/main/java/cuchaz/enigma/mapping/ClassMapping.java +++ b/src/main/java/cuchaz/enigma/mapping/ClassMapping.java | |||
| @@ -577,7 +577,7 @@ public class ClassMapping implements Comparable<ClassMapping> { | |||
| 577 | } | 577 | } |
| 578 | 578 | ||
| 579 | // Used for tiny parsing to keep track of deobfuscate inner classes | 579 | // Used for tiny parsing to keep track of deobfuscate inner classes |
| 580 | public ClassMapping setDeobInner(String deobName) { | 580 | public ClassMapping setDeobfInner(String deobName) { |
| 581 | this.deobfFullName = deobName; | 581 | this.deobfFullName = deobName; |
| 582 | return this; | 582 | return this; |
| 583 | } | 583 | } |
| @@ -607,4 +607,21 @@ public class ClassMapping implements Comparable<ClassMapping> { | |||
| 607 | public boolean equals(Object obj) { | 607 | public boolean equals(Object obj) { |
| 608 | return obj instanceof ClassMapping && ((ClassMapping) obj).obfFullName.equals(this.obfFullName); | 608 | return obj instanceof ClassMapping && ((ClassMapping) obj).obfFullName.equals(this.obfFullName); |
| 609 | } | 609 | } |
| 610 | |||
| 611 | public boolean isEmpty() { | ||
| 612 | if (fieldsByDeobf.isEmpty() && methodsByDeobf.isEmpty() && deobfFullName == null && deobfName == null | ||
| 613 | && innerClassesByObfSimple.values().stream().allMatch(ClassMapping::isEmpty)) { | ||
| 614 | |||
| 615 | // check args | ||
| 616 | for (MethodMapping mapping : methodsByObf.values()) { | ||
| 617 | if (mapping.arguments().iterator().hasNext()) { | ||
| 618 | return false; | ||
| 619 | } | ||
| 620 | } | ||
| 621 | |||
| 622 | return true; | ||
| 623 | } | ||
| 624 | |||
| 625 | return false; | ||
| 626 | } | ||
| 610 | } | 627 | } |
diff --git a/src/main/java/cuchaz/enigma/mapping/MappingsEnigmaWriter.java b/src/main/java/cuchaz/enigma/mapping/MappingsEnigmaWriter.java index b29990f5..e3302b14 100644 --- a/src/main/java/cuchaz/enigma/mapping/MappingsEnigmaWriter.java +++ b/src/main/java/cuchaz/enigma/mapping/MappingsEnigmaWriter.java | |||
| @@ -33,10 +33,19 @@ public class MappingsEnigmaWriter { | |||
| 33 | 33 | ||
| 34 | Mappings previousState = mappings.getPreviousState(); | 34 | Mappings previousState = mappings.getPreviousState(); |
| 35 | for (ClassMapping classMapping : sorted(mappings.classes())) { | 35 | for (ClassMapping classMapping : sorted(mappings.classes())) { |
| 36 | File result = new File(target, classMapping.getSaveName() + ".mapping"); | ||
| 37 | |||
| 36 | if (!classMapping.isDirty()) { | 38 | if (!classMapping.isDirty()) { |
| 37 | continue; | 39 | continue; |
| 38 | } | 40 | } |
| 39 | 41 | ||
| 42 | if (classMapping.isEmpty()) { | ||
| 43 | if (result.exists()) { | ||
| 44 | result.delete(); | ||
| 45 | } | ||
| 46 | continue; | ||
| 47 | } | ||
| 48 | |||
| 40 | if (previousState != null) { | 49 | if (previousState != null) { |
| 41 | ClassMapping previousClass = previousState.classesByObf.get(classMapping.getObfFullName()); | 50 | ClassMapping previousClass = previousState.classesByObf.get(classMapping.getObfFullName()); |
| 42 | File previousFile; | 51 | File previousFile; |
| @@ -50,8 +59,6 @@ public class MappingsEnigmaWriter { | |||
| 50 | } | 59 | } |
| 51 | } | 60 | } |
| 52 | 61 | ||
| 53 | File result = new File(target, classMapping.getSaveName() + ".mapping"); | ||
| 54 | |||
| 55 | File packageFile = result.getParentFile(); | 62 | File packageFile = result.getParentFile(); |
| 56 | if (!packageFile.exists()) { | 63 | if (!packageFile.exists()) { |
| 57 | packageFile.mkdirs(); | 64 | packageFile.mkdirs(); |
diff --git a/src/main/java/cuchaz/enigma/mapping/MappingsTinyReader.java b/src/main/java/cuchaz/enigma/mapping/MappingsTinyReader.java index 69d5684b..756ac432 100644 --- a/src/main/java/cuchaz/enigma/mapping/MappingsTinyReader.java +++ b/src/main/java/cuchaz/enigma/mapping/MappingsTinyReader.java | |||
| @@ -17,7 +17,7 @@ public class MappingsTinyReader { | |||
| 17 | public ClassMapping readClass(String[] parts) { | 17 | public ClassMapping readClass(String[] parts) { |
| 18 | // Extract the inner naming of the deob form if it have one | 18 | // Extract the inner naming of the deob form if it have one |
| 19 | String deobName = parts[2].contains("$") ? parts[2].substring(parts[2].lastIndexOf('$') + 1) : parts[2]; | 19 | String deobName = parts[2].contains("$") ? parts[2].substring(parts[2].lastIndexOf('$') + 1) : parts[2]; |
| 20 | return new ClassMapping(parts[1], deobName).setDeobInner(parts[2]); | 20 | return new ClassMapping(parts[1], deobName).setDeobfInner(parts[2]); |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | public FieldMapping readField(String[] parts) { | 23 | public FieldMapping readField(String[] parts) { |
| @@ -52,7 +52,7 @@ public class MappingsTinyReader { | |||
| 52 | parts[2]; | 52 | parts[2]; |
| 53 | 53 | ||
| 54 | // Add full deob name to the class mapping to handle inner class after this loop | 54 | // Add full deob name to the class mapping to handle inner class after this loop |
| 55 | classMappingMap.put(parts[2], classMapping.setDeobInner(parts[2])); | 55 | classMappingMap.put(parts[2], classMapping.setDeobfInner(parts[2])); |
| 56 | classMapping.setDeobfName(deobName); | 56 | classMapping.setDeobfName(deobName); |
| 57 | 57 | ||
| 58 | // Avoid to make the mapping dirty directly at the startup | 58 | // Avoid to make the mapping dirty directly at the startup |