diff options
| author | 2015-02-09 22:23:45 -0500 | |
|---|---|---|
| committer | 2015-02-09 22:23:45 -0500 | |
| commit | af1041731c8c0ce1846ff7e7b6052ed7327a5dbc (patch) | |
| tree | e781b93f526a6c1ba7b6f5e14c319450199aa1df /src/cuchaz/enigma/analysis | |
| parent | Don't automatically move mappings around. We're more interested in stability ... (diff) | |
| download | enigma-fork-af1041731c8c0ce1846ff7e7b6052ed7327a5dbc.tar.gz enigma-fork-af1041731c8c0ce1846ff7e7b6052ed7327a5dbc.tar.xz enigma-fork-af1041731c8c0ce1846ff7e7b6052ed7327a5dbc.zip | |
fix translation issues, particularly with fields
Diffstat (limited to 'src/cuchaz/enigma/analysis')
5 files changed, 134 insertions, 41 deletions
diff --git a/src/cuchaz/enigma/analysis/JarIndex.java b/src/cuchaz/enigma/analysis/JarIndex.java index f54beda..24d110e 100644 --- a/src/cuchaz/enigma/analysis/JarIndex.java +++ b/src/cuchaz/enigma/analysis/JarIndex.java | |||
| @@ -42,12 +42,11 @@ import cuchaz.enigma.Constants; | |||
| 42 | import cuchaz.enigma.bytecode.ClassRenamer; | 42 | import cuchaz.enigma.bytecode.ClassRenamer; |
| 43 | import cuchaz.enigma.mapping.ArgumentEntry; | 43 | import cuchaz.enigma.mapping.ArgumentEntry; |
| 44 | import cuchaz.enigma.mapping.BehaviorEntry; | 44 | import cuchaz.enigma.mapping.BehaviorEntry; |
| 45 | import cuchaz.enigma.mapping.BehaviorEntryFactory; | ||
| 46 | import cuchaz.enigma.mapping.ClassEntry; | 45 | import cuchaz.enigma.mapping.ClassEntry; |
| 47 | import cuchaz.enigma.mapping.ConstructorEntry; | 46 | import cuchaz.enigma.mapping.ConstructorEntry; |
| 48 | import cuchaz.enigma.mapping.Entry; | 47 | import cuchaz.enigma.mapping.Entry; |
| 48 | import cuchaz.enigma.mapping.EntryFactory; | ||
| 49 | import cuchaz.enigma.mapping.FieldEntry; | 49 | import cuchaz.enigma.mapping.FieldEntry; |
| 50 | import cuchaz.enigma.mapping.JavassistUtil; | ||
| 51 | import cuchaz.enigma.mapping.MethodEntry; | 50 | import cuchaz.enigma.mapping.MethodEntry; |
| 52 | import cuchaz.enigma.mapping.Translator; | 51 | import cuchaz.enigma.mapping.Translator; |
| 53 | 52 | ||
| @@ -92,10 +91,10 @@ public class JarIndex { | |||
| 92 | for (CtClass c : JarClassIterator.classes(jar)) { | 91 | for (CtClass c : JarClassIterator.classes(jar)) { |
| 93 | ClassRenamer.moveAllClassesOutOfDefaultPackage(c, Constants.NonePackage); | 92 | ClassRenamer.moveAllClassesOutOfDefaultPackage(c, Constants.NonePackage); |
| 94 | for (CtField field : c.getDeclaredFields()) { | 93 | for (CtField field : c.getDeclaredFields()) { |
| 95 | m_access.put(JavassistUtil.getFieldEntry(field), Access.get(field)); | 94 | m_access.put(EntryFactory.getFieldEntry(field), Access.get(field)); |
| 96 | } | 95 | } |
| 97 | for (CtBehavior behavior : c.getDeclaredBehaviors()) { | 96 | for (CtBehavior behavior : c.getDeclaredBehaviors()) { |
| 98 | m_access.put(JavassistUtil.getBehaviorEntry(behavior), Access.get(behavior)); | 97 | m_access.put(EntryFactory.getBehaviorEntry(behavior), Access.get(behavior)); |
| 99 | } | 98 | } |
| 100 | } | 99 | } |
| 101 | 100 | ||
| @@ -166,7 +165,7 @@ public class JarIndex { | |||
| 166 | 165 | ||
| 167 | private void indexBehavior(CtBehavior behavior) { | 166 | private void indexBehavior(CtBehavior behavior) { |
| 168 | // get the behavior entry | 167 | // get the behavior entry |
| 169 | final BehaviorEntry behaviorEntry = BehaviorEntryFactory.create(behavior); | 168 | final BehaviorEntry behaviorEntry = EntryFactory.getBehaviorEntry(behavior); |
| 170 | if (behaviorEntry instanceof MethodEntry) { | 169 | if (behaviorEntry instanceof MethodEntry) { |
| 171 | MethodEntry methodEntry = (MethodEntry)behaviorEntry; | 170 | MethodEntry methodEntry = (MethodEntry)behaviorEntry; |
| 172 | 171 | ||
| @@ -178,12 +177,12 @@ public class JarIndex { | |||
| 178 | 177 | ||
| 179 | private void indexBehaviorReferences(CtBehavior behavior) { | 178 | private void indexBehaviorReferences(CtBehavior behavior) { |
| 180 | // index method calls | 179 | // index method calls |
| 181 | final BehaviorEntry behaviorEntry = BehaviorEntryFactory.create(behavior); | 180 | final BehaviorEntry behaviorEntry = EntryFactory.getBehaviorEntry(behavior); |
| 182 | try { | 181 | try { |
| 183 | behavior.instrument(new ExprEditor() { | 182 | behavior.instrument(new ExprEditor() { |
| 184 | @Override | 183 | @Override |
| 185 | public void edit(MethodCall call) { | 184 | public void edit(MethodCall call) { |
| 186 | MethodEntry calledMethodEntry = JavassistUtil.getMethodEntry(call); | 185 | MethodEntry calledMethodEntry = EntryFactory.getMethodEntry(call); |
| 187 | ClassEntry resolvedClassEntry = m_translationIndex.resolveEntryClass(calledMethodEntry); | 186 | ClassEntry resolvedClassEntry = m_translationIndex.resolveEntryClass(calledMethodEntry); |
| 188 | if (resolvedClassEntry != null && !resolvedClassEntry.equals(calledMethodEntry.getClassEntry())) { | 187 | if (resolvedClassEntry != null && !resolvedClassEntry.equals(calledMethodEntry.getClassEntry())) { |
| 189 | calledMethodEntry = new MethodEntry( | 188 | calledMethodEntry = new MethodEntry( |
| @@ -202,7 +201,7 @@ public class JarIndex { | |||
| 202 | 201 | ||
| 203 | @Override | 202 | @Override |
| 204 | public void edit(FieldAccess call) { | 203 | public void edit(FieldAccess call) { |
| 205 | FieldEntry calledFieldEntry = JavassistUtil.getFieldEntry(call); | 204 | FieldEntry calledFieldEntry = EntryFactory.getFieldEntry(call); |
| 206 | ClassEntry resolvedClassEntry = m_translationIndex.resolveEntryClass(calledFieldEntry); | 205 | ClassEntry resolvedClassEntry = m_translationIndex.resolveEntryClass(calledFieldEntry); |
| 207 | if (resolvedClassEntry != null && !resolvedClassEntry.equals(calledFieldEntry.getClassEntry())) { | 206 | if (resolvedClassEntry != null && !resolvedClassEntry.equals(calledFieldEntry.getClassEntry())) { |
| 208 | calledFieldEntry = new FieldEntry(calledFieldEntry, resolvedClassEntry); | 207 | calledFieldEntry = new FieldEntry(calledFieldEntry, resolvedClassEntry); |
| @@ -217,7 +216,7 @@ public class JarIndex { | |||
| 217 | 216 | ||
| 218 | @Override | 217 | @Override |
| 219 | public void edit(ConstructorCall call) { | 218 | public void edit(ConstructorCall call) { |
| 220 | ConstructorEntry calledConstructorEntry = JavassistUtil.getConstructorEntry(call); | 219 | ConstructorEntry calledConstructorEntry = EntryFactory.getConstructorEntry(call); |
| 221 | EntryReference<BehaviorEntry,BehaviorEntry> reference = new EntryReference<BehaviorEntry,BehaviorEntry>( | 220 | EntryReference<BehaviorEntry,BehaviorEntry> reference = new EntryReference<BehaviorEntry,BehaviorEntry>( |
| 222 | calledConstructorEntry, | 221 | calledConstructorEntry, |
| 223 | call.getMethodName(), | 222 | call.getMethodName(), |
| @@ -228,7 +227,7 @@ public class JarIndex { | |||
| 228 | 227 | ||
| 229 | @Override | 228 | @Override |
| 230 | public void edit(NewExpr call) { | 229 | public void edit(NewExpr call) { |
| 231 | ConstructorEntry calledConstructorEntry = JavassistUtil.getConstructorEntry(call); | 230 | ConstructorEntry calledConstructorEntry = EntryFactory.getConstructorEntry(call); |
| 232 | EntryReference<BehaviorEntry,BehaviorEntry> reference = new EntryReference<BehaviorEntry,BehaviorEntry>( | 231 | EntryReference<BehaviorEntry,BehaviorEntry> reference = new EntryReference<BehaviorEntry,BehaviorEntry>( |
| 233 | calledConstructorEntry, | 232 | calledConstructorEntry, |
| 234 | call.getClassName(), | 233 | call.getClassName(), |
| @@ -256,7 +255,7 @@ public class JarIndex { | |||
| 256 | } | 255 | } |
| 257 | 256 | ||
| 258 | ClassEntry classEntry = new ClassEntry(Descriptor.toJvmName(c.getName())); | 257 | ClassEntry classEntry = new ClassEntry(Descriptor.toJvmName(c.getName())); |
| 259 | ConstructorEntry constructorEntry = JavassistUtil.getConstructorEntry(constructor); | 258 | ConstructorEntry constructorEntry = EntryFactory.getConstructorEntry(constructor); |
| 260 | 259 | ||
| 261 | // gather the classes from the illegally-set synthetic fields | 260 | // gather the classes from the illegally-set synthetic fields |
| 262 | Set<ClassEntry> illegallySetClasses = Sets.newHashSet(); | 261 | Set<ClassEntry> illegallySetClasses = Sets.newHashSet(); |
| @@ -422,7 +421,7 @@ public class JarIndex { | |||
| 422 | CtConstructor constructor = c.getDeclaredConstructors()[0]; | 421 | CtConstructor constructor = c.getDeclaredConstructors()[0]; |
| 423 | 422 | ||
| 424 | // is this constructor called exactly once? | 423 | // is this constructor called exactly once? |
| 425 | ConstructorEntry constructorEntry = JavassistUtil.getConstructorEntry(constructor); | 424 | ConstructorEntry constructorEntry = EntryFactory.getConstructorEntry(constructor); |
| 426 | Collection<EntryReference<BehaviorEntry,BehaviorEntry>> references = getBehaviorReferences(constructorEntry); | 425 | Collection<EntryReference<BehaviorEntry,BehaviorEntry>> references = getBehaviorReferences(constructorEntry); |
| 427 | if (references.size() != 1) { | 426 | if (references.size() != 1) { |
| 428 | return null; | 427 | return null; |
| @@ -520,17 +519,17 @@ public class JarIndex { | |||
| 520 | return rootNode; | 519 | return rootNode; |
| 521 | } | 520 | } |
| 522 | 521 | ||
| 523 | public MethodImplementationsTreeNode getMethodImplementations(Translator deobfuscatingTranslator, MethodEntry obfMethodEntry) { | 522 | public List<MethodImplementationsTreeNode> getMethodImplementations(Translator deobfuscatingTranslator, MethodEntry obfMethodEntry) { |
| 524 | 523 | ||
| 525 | MethodEntry interfaceMethodEntry; | 524 | List<MethodEntry> interfaceMethodEntries = Lists.newArrayList(); |
| 526 | 525 | ||
| 527 | // is this method on an interface? | 526 | // is this method on an interface? |
| 528 | if (isInterface(obfMethodEntry.getClassName())) { | 527 | if (isInterface(obfMethodEntry.getClassName())) { |
| 529 | interfaceMethodEntry = obfMethodEntry; | 528 | interfaceMethodEntries.add(obfMethodEntry); |
| 530 | } else { | 529 | } else { |
| 531 | // get the interface class | 530 | // get the interface class |
| 532 | List<MethodEntry> methodInterfaces = Lists.newArrayList(); | ||
| 533 | for (String interfaceName : getInterfaces(obfMethodEntry.getClassName())) { | 531 | for (String interfaceName : getInterfaces(obfMethodEntry.getClassName())) { |
| 532 | |||
| 534 | // is this method defined in this interface? | 533 | // is this method defined in this interface? |
| 535 | MethodEntry methodInterface = new MethodEntry( | 534 | MethodEntry methodInterface = new MethodEntry( |
| 536 | new ClassEntry(interfaceName), | 535 | new ClassEntry(interfaceName), |
| @@ -538,21 +537,20 @@ public class JarIndex { | |||
| 538 | obfMethodEntry.getSignature() | 537 | obfMethodEntry.getSignature() |
| 539 | ); | 538 | ); |
| 540 | if (containsObfBehavior(methodInterface)) { | 539 | if (containsObfBehavior(methodInterface)) { |
| 541 | methodInterfaces.add(methodInterface); | 540 | interfaceMethodEntries.add(methodInterface); |
| 542 | } | 541 | } |
| 543 | } | 542 | } |
| 544 | if (methodInterfaces.isEmpty()) { | ||
| 545 | return null; | ||
| 546 | } | ||
| 547 | if (methodInterfaces.size() > 1) { | ||
| 548 | throw new Error("Too many interfaces define this method! This is not yet supported by Enigma!"); | ||
| 549 | } | ||
| 550 | interfaceMethodEntry = methodInterfaces.get(0); | ||
| 551 | } | 543 | } |
| 552 | 544 | ||
| 553 | MethodImplementationsTreeNode rootNode = new MethodImplementationsTreeNode(deobfuscatingTranslator, interfaceMethodEntry); | 545 | List<MethodImplementationsTreeNode> nodes = Lists.newArrayList(); |
| 554 | rootNode.load(this); | 546 | if (!interfaceMethodEntries.isEmpty()) { |
| 555 | return rootNode; | 547 | for (MethodEntry interfaceMethodEntry : interfaceMethodEntries) { |
| 548 | MethodImplementationsTreeNode node = new MethodImplementationsTreeNode(deobfuscatingTranslator, interfaceMethodEntry); | ||
| 549 | node.load(this); | ||
| 550 | nodes.add(node); | ||
| 551 | } | ||
| 552 | } | ||
| 553 | return nodes; | ||
| 556 | } | 554 | } |
| 557 | 555 | ||
| 558 | public Set<MethodEntry> getRelatedMethodImplementations(MethodEntry obfMethodEntry) { | 556 | public Set<MethodEntry> getRelatedMethodImplementations(MethodEntry obfMethodEntry) { |
| @@ -569,9 +567,8 @@ public class JarIndex { | |||
| 569 | } | 567 | } |
| 570 | 568 | ||
| 571 | // look at interface methods too | 569 | // look at interface methods too |
| 572 | MethodImplementationsTreeNode implementations = getMethodImplementations(null, methodEntry); | 570 | for (MethodImplementationsTreeNode implementationsNode : getMethodImplementations(null, methodEntry)) { |
| 573 | if (implementations != null) { | 571 | getRelatedMethodImplementations(methodEntries, implementationsNode); |
| 574 | getRelatedMethodImplementations(methodEntries, implementations); | ||
| 575 | } | 572 | } |
| 576 | 573 | ||
| 577 | // recurse | 574 | // recurse |
diff --git a/src/cuchaz/enigma/analysis/MethodImplementationsTreeNode.java b/src/cuchaz/enigma/analysis/MethodImplementationsTreeNode.java index 1009226..6cafc55 100644 --- a/src/cuchaz/enigma/analysis/MethodImplementationsTreeNode.java +++ b/src/cuchaz/enigma/analysis/MethodImplementationsTreeNode.java | |||
| @@ -63,6 +63,7 @@ public class MethodImplementationsTreeNode extends DefaultMutableTreeNode { | |||
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | public void load(JarIndex index) { | 65 | public void load(JarIndex index) { |
| 66 | |||
| 66 | // get all method implementations | 67 | // get all method implementations |
| 67 | List<MethodImplementationsTreeNode> nodes = Lists.newArrayList(); | 68 | List<MethodImplementationsTreeNode> nodes = Lists.newArrayList(); |
| 68 | for (String implementingClassName : index.getImplementingClasses(m_entry.getClassName())) { | 69 | for (String implementingClassName : index.getImplementingClasses(m_entry.getClassName())) { |
diff --git a/src/cuchaz/enigma/analysis/RelatedMethodChecker.java b/src/cuchaz/enigma/analysis/RelatedMethodChecker.java new file mode 100644 index 0000000..5bd67a0 --- /dev/null +++ b/src/cuchaz/enigma/analysis/RelatedMethodChecker.java | |||
| @@ -0,0 +1,96 @@ | |||
| 1 | package cuchaz.enigma.analysis; | ||
| 2 | |||
| 3 | import java.util.Map; | ||
| 4 | import java.util.Set; | ||
| 5 | |||
| 6 | import com.beust.jcommander.internal.Maps; | ||
| 7 | import com.google.common.collect.Sets; | ||
| 8 | |||
| 9 | import cuchaz.enigma.mapping.BehaviorEntry; | ||
| 10 | import cuchaz.enigma.mapping.ClassEntry; | ||
| 11 | import cuchaz.enigma.mapping.EntryFactory; | ||
| 12 | import cuchaz.enigma.mapping.MethodEntry; | ||
| 13 | import cuchaz.enigma.mapping.MethodMapping; | ||
| 14 | |||
| 15 | public class RelatedMethodChecker { | ||
| 16 | |||
| 17 | private JarIndex m_jarIndex; | ||
| 18 | private Map<Set<MethodEntry>,String> m_deobfNamesByGroup; | ||
| 19 | private Map<MethodEntry,String> m_deobfNamesByObfMethod; | ||
| 20 | private Map<MethodEntry,Set<MethodEntry>> m_groupsByObfMethod; | ||
| 21 | private Set<Set<MethodEntry>> m_inconsistentGroups; | ||
| 22 | |||
| 23 | public RelatedMethodChecker(JarIndex jarIndex) { | ||
| 24 | m_jarIndex = jarIndex; | ||
| 25 | m_deobfNamesByGroup = Maps.newHashMap(); | ||
| 26 | m_deobfNamesByObfMethod = Maps.newHashMap(); | ||
| 27 | m_groupsByObfMethod = Maps.newHashMap(); | ||
| 28 | m_inconsistentGroups = Sets.newHashSet(); | ||
| 29 | } | ||
| 30 | |||
| 31 | public void checkMethod(ClassEntry classEntry, MethodMapping methodMapping) { | ||
| 32 | |||
| 33 | // TEMP: disable the expensive check for now, maybe we can optimize it later, or just use it for debugging | ||
| 34 | if (true) return; | ||
| 35 | |||
| 36 | BehaviorEntry obfBehaviorEntry = EntryFactory.getObfBehaviorEntry(classEntry, methodMapping); | ||
| 37 | if (!(obfBehaviorEntry instanceof MethodEntry)) { | ||
| 38 | // only methods have related implementations | ||
| 39 | return; | ||
| 40 | } | ||
| 41 | MethodEntry obfMethodEntry = (MethodEntry)obfBehaviorEntry; | ||
| 42 | String deobfName = methodMapping.getDeobfName(); | ||
| 43 | m_deobfNamesByObfMethod.put(obfMethodEntry, deobfName); | ||
| 44 | |||
| 45 | // have we seen this method's group before? | ||
| 46 | Set<MethodEntry> group = m_groupsByObfMethod.get(obfMethodEntry); | ||
| 47 | if (group == null) { | ||
| 48 | |||
| 49 | // no, compute the group and save the name | ||
| 50 | group = m_jarIndex.getRelatedMethodImplementations(obfMethodEntry); | ||
| 51 | m_deobfNamesByGroup.put(group, deobfName); | ||
| 52 | |||
| 53 | assert(group.contains(obfMethodEntry)); | ||
| 54 | for (MethodEntry relatedMethodEntry : group) { | ||
| 55 | m_groupsByObfMethod.put(relatedMethodEntry, group); | ||
| 56 | } | ||
| 57 | } | ||
| 58 | |||
| 59 | // check the name | ||
| 60 | if (!sameName(m_deobfNamesByGroup.get(group), deobfName)) { | ||
| 61 | m_inconsistentGroups.add(group); | ||
| 62 | } | ||
| 63 | } | ||
| 64 | |||
| 65 | private boolean sameName(String a, String b) { | ||
| 66 | if (a == null && b == null) { | ||
| 67 | return true; | ||
| 68 | } else if (a != null && b != null) { | ||
| 69 | return a.equals(b); | ||
| 70 | } | ||
| 71 | return false; | ||
| 72 | } | ||
| 73 | |||
| 74 | public boolean hasProblems() { | ||
| 75 | return m_inconsistentGroups.size() > 0; | ||
| 76 | } | ||
| 77 | |||
| 78 | public String getReport() { | ||
| 79 | StringBuilder buf = new StringBuilder(); | ||
| 80 | buf.append(m_inconsistentGroups.size()); | ||
| 81 | buf.append(" groups of methods related by inheritance and/or interfaces have different deobf names!\n"); | ||
| 82 | for (Set<MethodEntry> group : m_inconsistentGroups) { | ||
| 83 | buf.append("\tGroup with "); | ||
| 84 | buf.append(group.size()); | ||
| 85 | buf.append(" methods:\n"); | ||
| 86 | for (MethodEntry methodEntry : group) { | ||
| 87 | buf.append("\t\t"); | ||
| 88 | buf.append(methodEntry.toString()); | ||
| 89 | buf.append(" => "); | ||
| 90 | buf.append(m_deobfNamesByObfMethod.get(methodEntry)); | ||
| 91 | buf.append("\n"); | ||
| 92 | } | ||
| 93 | } | ||
| 94 | return buf.toString(); | ||
| 95 | } | ||
| 96 | } | ||
diff --git a/src/cuchaz/enigma/analysis/SourceIndexClassVisitor.java b/src/cuchaz/enigma/analysis/SourceIndexClassVisitor.java index e2ff300..d6692f6 100644 --- a/src/cuchaz/enigma/analysis/SourceIndexClassVisitor.java +++ b/src/cuchaz/enigma/analysis/SourceIndexClassVisitor.java | |||
| @@ -26,11 +26,10 @@ import com.strobel.decompiler.languages.java.ast.TypeDeclaration; | |||
| 26 | import com.strobel.decompiler.languages.java.ast.VariableInitializer; | 26 | import com.strobel.decompiler.languages.java.ast.VariableInitializer; |
| 27 | 27 | ||
| 28 | import cuchaz.enigma.mapping.BehaviorEntry; | 28 | import cuchaz.enigma.mapping.BehaviorEntry; |
| 29 | import cuchaz.enigma.mapping.BehaviorEntryFactory; | ||
| 30 | import cuchaz.enigma.mapping.ClassEntry; | 29 | import cuchaz.enigma.mapping.ClassEntry; |
| 31 | import cuchaz.enigma.mapping.ConstructorEntry; | 30 | import cuchaz.enigma.mapping.ConstructorEntry; |
| 31 | import cuchaz.enigma.mapping.EntryFactory; | ||
| 32 | import cuchaz.enigma.mapping.FieldEntry; | 32 | import cuchaz.enigma.mapping.FieldEntry; |
| 33 | import cuchaz.enigma.mapping.Signature; | ||
| 34 | import cuchaz.enigma.mapping.Type; | 33 | import cuchaz.enigma.mapping.Type; |
| 35 | 34 | ||
| 36 | public class SourceIndexClassVisitor extends SourceIndexVisitor { | 35 | public class SourceIndexClassVisitor extends SourceIndexVisitor { |
| @@ -69,12 +68,13 @@ public class SourceIndexClassVisitor extends SourceIndexVisitor { | |||
| 69 | @Override | 68 | @Override |
| 70 | public Void visitMethodDeclaration(MethodDeclaration node, SourceIndex index) { | 69 | public Void visitMethodDeclaration(MethodDeclaration node, SourceIndex index) { |
| 71 | MethodDefinition def = node.getUserData(Keys.METHOD_DEFINITION); | 70 | MethodDefinition def = node.getUserData(Keys.METHOD_DEFINITION); |
| 72 | ClassEntry classEntry = new ClassEntry(def.getDeclaringType().getInternalName()); | 71 | BehaviorEntry behaviorEntry = EntryFactory.getBehaviorEntry(def); |
| 73 | BehaviorEntry behaviorEntry = BehaviorEntryFactory.create(classEntry, def.getName(), def.getSignature()); | ||
| 74 | AstNode tokenNode = node.getNameToken(); | 72 | AstNode tokenNode = node.getNameToken(); |
| 73 | |||
| 75 | if (behaviorEntry instanceof ConstructorEntry) { | 74 | if (behaviorEntry instanceof ConstructorEntry) { |
| 76 | ConstructorEntry constructorEntry = (ConstructorEntry)behaviorEntry; | 75 | ConstructorEntry constructorEntry = (ConstructorEntry)behaviorEntry; |
| 77 | if (constructorEntry.isStatic()) { | 76 | if (constructorEntry.isStatic()) { |
| 77 | // for static initializers, check elsewhere for the token node | ||
| 78 | tokenNode = node.getModifiers().firstOrNullObject(); | 78 | tokenNode = node.getModifiers().firstOrNullObject(); |
| 79 | } | 79 | } |
| 80 | } | 80 | } |
| @@ -85,8 +85,7 @@ public class SourceIndexClassVisitor extends SourceIndexVisitor { | |||
| 85 | @Override | 85 | @Override |
| 86 | public Void visitConstructorDeclaration(ConstructorDeclaration node, SourceIndex index) { | 86 | public Void visitConstructorDeclaration(ConstructorDeclaration node, SourceIndex index) { |
| 87 | MethodDefinition def = node.getUserData(Keys.METHOD_DEFINITION); | 87 | MethodDefinition def = node.getUserData(Keys.METHOD_DEFINITION); |
| 88 | ClassEntry classEntry = new ClassEntry(def.getDeclaringType().getInternalName()); | 88 | ConstructorEntry constructorEntry = EntryFactory.getConstructorEntry(def); |
| 89 | ConstructorEntry constructorEntry = new ConstructorEntry(classEntry, new Signature(def.getSignature())); | ||
| 90 | index.addDeclaration(node.getNameToken(), constructorEntry); | 89 | index.addDeclaration(node.getNameToken(), constructorEntry); |
| 91 | return node.acceptVisitor(new SourceIndexBehaviorVisitor(constructorEntry), index); | 90 | return node.acceptVisitor(new SourceIndexBehaviorVisitor(constructorEntry), index); |
| 92 | } | 91 | } |
diff --git a/src/cuchaz/enigma/analysis/TranslationIndex.java b/src/cuchaz/enigma/analysis/TranslationIndex.java index 7597c3a..8651ebd 100644 --- a/src/cuchaz/enigma/analysis/TranslationIndex.java +++ b/src/cuchaz/enigma/analysis/TranslationIndex.java | |||
| @@ -37,7 +37,7 @@ import cuchaz.enigma.mapping.BehaviorEntry; | |||
| 37 | import cuchaz.enigma.mapping.ClassEntry; | 37 | import cuchaz.enigma.mapping.ClassEntry; |
| 38 | import cuchaz.enigma.mapping.Entry; | 38 | import cuchaz.enigma.mapping.Entry; |
| 39 | import cuchaz.enigma.mapping.FieldEntry; | 39 | import cuchaz.enigma.mapping.FieldEntry; |
| 40 | import cuchaz.enigma.mapping.JavassistUtil; | 40 | import cuchaz.enigma.mapping.EntryFactory; |
| 41 | import cuchaz.enigma.mapping.Translator; | 41 | import cuchaz.enigma.mapping.Translator; |
| 42 | 42 | ||
| 43 | public class TranslationIndex implements Serializable { | 43 | public class TranslationIndex implements Serializable { |
| @@ -85,23 +85,23 @@ public class TranslationIndex implements Serializable { | |||
| 85 | 85 | ||
| 86 | public void indexClass(CtClass c) { | 86 | public void indexClass(CtClass c) { |
| 87 | 87 | ||
| 88 | ClassEntry classEntry = JavassistUtil.getClassEntry(c); | 88 | ClassEntry classEntry = EntryFactory.getClassEntry(c); |
| 89 | 89 | ||
| 90 | // add the superclass | 90 | // add the superclass |
| 91 | ClassEntry superclassEntry = JavassistUtil.getSuperclassEntry(c); | 91 | ClassEntry superclassEntry = EntryFactory.getSuperclassEntry(c); |
| 92 | if (!isJre(classEntry) && superclassEntry != null && !isJre(superclassEntry)) { | 92 | if (!isJre(classEntry) && superclassEntry != null && !isJre(superclassEntry)) { |
| 93 | m_superclasses.put(classEntry, superclassEntry); | 93 | m_superclasses.put(classEntry, superclassEntry); |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | // add fields | 96 | // add fields |
| 97 | for (CtField field : c.getDeclaredFields()) { | 97 | for (CtField field : c.getDeclaredFields()) { |
| 98 | FieldEntry fieldEntry = JavassistUtil.getFieldEntry(field); | 98 | FieldEntry fieldEntry = EntryFactory.getFieldEntry(field); |
| 99 | m_fieldEntries.put(fieldEntry.getClassEntry(), fieldEntry); | 99 | m_fieldEntries.put(fieldEntry.getClassEntry(), fieldEntry); |
| 100 | } | 100 | } |
| 101 | 101 | ||
| 102 | // add behaviors | 102 | // add behaviors |
| 103 | for (CtBehavior behavior : c.getDeclaredBehaviors()) { | 103 | for (CtBehavior behavior : c.getDeclaredBehaviors()) { |
| 104 | BehaviorEntry behaviorEntry = JavassistUtil.getBehaviorEntry(behavior); | 104 | BehaviorEntry behaviorEntry = EntryFactory.getBehaviorEntry(behavior); |
| 105 | m_behaviorEntries.put(behaviorEntry.getClassEntry(), behaviorEntry); | 105 | m_behaviorEntries.put(behaviorEntry.getClassEntry(), behaviorEntry); |
| 106 | } | 106 | } |
| 107 | } | 107 | } |