diff options
| author | 2015-08-02 15:47:27 -0400 | |
|---|---|---|
| committer | 2015-08-02 15:47:27 -0400 | |
| commit | 4923fdfe8a01f361b76bd4c7d045184272d41ad5 (patch) | |
| tree | 6692a634a597276f872d891799d60dfe4f074c53 /src/cuchaz/enigma/convert | |
| parent | Merged in mikesmiffy128/enigma/fix-unit-tests (pull request #2) (diff) | |
| download | enigma-fork-4923fdfe8a01f361b76bd4c7d045184272d41ad5.tar.gz enigma-fork-4923fdfe8a01f361b76bd4c7d045184272d41ad5.tar.xz enigma-fork-4923fdfe8a01f361b76bd4c7d045184272d41ad5.zip | |
fix up class matcher a bit
Diffstat (limited to 'src/cuchaz/enigma/convert')
| -rw-r--r-- | src/cuchaz/enigma/convert/ClassIdentity.java | 11 | ||||
| -rw-r--r-- | src/cuchaz/enigma/convert/MappingsConverter.java | 27 |
2 files changed, 30 insertions, 8 deletions
diff --git a/src/cuchaz/enigma/convert/ClassIdentity.java b/src/cuchaz/enigma/convert/ClassIdentity.java index 2e164ae..d9ed08e 100644 --- a/src/cuchaz/enigma/convert/ClassIdentity.java +++ b/src/cuchaz/enigma/convert/ClassIdentity.java | |||
| @@ -117,7 +117,7 @@ public class ClassIdentity { | |||
| 117 | 117 | ||
| 118 | // stuff from the bytecode | 118 | // stuff from the bytecode |
| 119 | 119 | ||
| 120 | m_classEntry = new ClassEntry(Descriptor.toJvmName(c.getName())); | 120 | m_classEntry = EntryFactory.getClassEntry(c); |
| 121 | m_fields = HashMultiset.create(); | 121 | m_fields = HashMultiset.create(); |
| 122 | for (CtField field : c.getDeclaredFields()) { | 122 | for (CtField field : c.getDeclaredFields()) { |
| 123 | m_fields.add(scrubType(field.getSignature())); | 123 | m_fields.add(scrubType(field.getSignature())); |
| @@ -180,7 +180,10 @@ public class ClassIdentity { | |||
| 180 | } | 180 | } |
| 181 | } | 181 | } |
| 182 | 182 | ||
| 183 | m_outer = EntryFactory.getClassEntry(c).getOuterClassName(); | 183 | m_outer = null; |
| 184 | if (m_classEntry.isInnerClass()) { | ||
| 185 | m_outer = m_classEntry.getOuterClassName(); | ||
| 186 | } | ||
| 184 | } | 187 | } |
| 185 | 188 | ||
| 186 | private void addReference(EntryReference<? extends Entry,BehaviorEntry> reference) { | 189 | private void addReference(EntryReference<? extends Entry,BehaviorEntry> reference) { |
| @@ -460,7 +463,9 @@ public class ClassIdentity { | |||
| 460 | } | 463 | } |
| 461 | 464 | ||
| 462 | private int getNumMatches(String a, String b) { | 465 | private int getNumMatches(String a, String b) { |
| 463 | if (a.equals(b)) { | 466 | if (a == null && b == null) { |
| 467 | return 1; | ||
| 468 | } else if (a != null && b != null && a.equals(b)) { | ||
| 464 | return 1; | 469 | return 1; |
| 465 | } | 470 | } |
| 466 | return 0; | 471 | return 0; |
diff --git a/src/cuchaz/enigma/convert/MappingsConverter.java b/src/cuchaz/enigma/convert/MappingsConverter.java index b457d6c..b404e8f 100644 --- a/src/cuchaz/enigma/convert/MappingsConverter.java +++ b/src/cuchaz/enigma/convert/MappingsConverter.java | |||
| @@ -207,18 +207,35 @@ public class MappingsConverter { | |||
| 207 | newClassMapping = new ClassMapping(newObfClass.getName()); | 207 | newClassMapping = new ClassMapping(newObfClass.getName()); |
| 208 | } | 208 | } |
| 209 | 209 | ||
| 210 | // copy fields | 210 | // migrate fields |
| 211 | for (FieldMapping fieldMapping : oldClassMapping.fields()) { | 211 | for (FieldMapping fieldMapping : oldClassMapping.fields()) { |
| 212 | newClassMapping.addFieldMapping(new FieldMapping(fieldMapping, replacer)); | 212 | if (canMigrate(fieldMapping.getObfType(), replacer)) { |
| 213 | newClassMapping.addFieldMapping(new FieldMapping(fieldMapping, replacer)); | ||
| 214 | } | ||
| 213 | } | 215 | } |
| 214 | 216 | ||
| 215 | // copy methods | 217 | // migrate methods |
| 216 | for (MethodMapping methodMapping : oldClassMapping.methods()) { | 218 | for (MethodMapping oldMethodMapping : oldClassMapping.methods()) { |
| 217 | newClassMapping.addMethodMapping(new MethodMapping(methodMapping, replacer)); | 219 | if (canMigrate(oldMethodMapping.getObfSignature(), replacer)) { |
| 220 | newClassMapping.addMethodMapping(new MethodMapping(oldMethodMapping, replacer)); | ||
| 221 | } | ||
| 218 | } | 222 | } |
| 219 | 223 | ||
| 220 | return newClassMapping; | 224 | return newClassMapping; |
| 221 | } | 225 | } |
| 226 | |||
| 227 | private static boolean canMigrate(Signature obfSignature, ClassNameReplacer replacer) { | ||
| 228 | for (Type type : obfSignature.types()) { | ||
| 229 | if (!canMigrate(type, replacer)) { | ||
| 230 | return false; | ||
| 231 | } | ||
| 232 | } | ||
| 233 | return true; | ||
| 234 | } | ||
| 235 | |||
| 236 | private static boolean canMigrate(Type type, ClassNameReplacer replacer) { | ||
| 237 | return !type.hasClass() || replacer.replace(type.getClassEntry().getClassName()) != null; | ||
| 238 | } | ||
| 222 | 239 | ||
| 223 | public static void convertMappings(Mappings mappings, BiMap<ClassEntry,ClassEntry> changes) { | 240 | public static void convertMappings(Mappings mappings, BiMap<ClassEntry,ClassEntry> changes) { |
| 224 | 241 | ||