diff options
Diffstat (limited to 'src/cuchaz/enigma/mapping/EntryFactory.java')
| -rw-r--r-- | src/cuchaz/enigma/mapping/EntryFactory.java | 34 |
1 files changed, 2 insertions, 32 deletions
diff --git a/src/cuchaz/enigma/mapping/EntryFactory.java b/src/cuchaz/enigma/mapping/EntryFactory.java index bbdfa73..f4d62c8 100644 --- a/src/cuchaz/enigma/mapping/EntryFactory.java +++ b/src/cuchaz/enigma/mapping/EntryFactory.java | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | package cuchaz.enigma.mapping; | 1 | package cuchaz.enigma.mapping; |
| 2 | 2 | ||
| 3 | import java.util.List; | ||
| 4 | |||
| 5 | import javassist.CtBehavior; | 3 | import javassist.CtBehavior; |
| 6 | import javassist.CtClass; | 4 | import javassist.CtClass; |
| 7 | import javassist.CtConstructor; | 5 | import javassist.CtConstructor; |
| @@ -13,7 +11,6 @@ import javassist.expr.FieldAccess; | |||
| 13 | import javassist.expr.MethodCall; | 11 | import javassist.expr.MethodCall; |
| 14 | import javassist.expr.NewExpr; | 12 | import javassist.expr.NewExpr; |
| 15 | 13 | ||
| 16 | import com.beust.jcommander.internal.Lists; | ||
| 17 | import com.strobel.assembler.metadata.MethodDefinition; | 14 | import com.strobel.assembler.metadata.MethodDefinition; |
| 18 | 15 | ||
| 19 | import cuchaz.enigma.analysis.JarIndex; | 16 | import cuchaz.enigma.analysis.JarIndex; |
| @@ -25,35 +22,8 @@ public class EntryFactory { | |||
| 25 | } | 22 | } |
| 26 | 23 | ||
| 27 | public static ClassEntry getObfClassEntry(JarIndex jarIndex, ClassMapping classMapping) { | 24 | public static ClassEntry getObfClassEntry(JarIndex jarIndex, ClassMapping classMapping) { |
| 28 | return getChainedOuterClassName(jarIndex, new ClassEntry(classMapping.getObfFullName())); | 25 | ClassEntry obfClassEntry = new ClassEntry(classMapping.getObfFullName()); |
| 29 | } | 26 | return obfClassEntry.buildClassEntry(jarIndex.getObfClassChain(obfClassEntry)); |
| 30 | |||
| 31 | public static ClassEntry getChainedOuterClassName(JarIndex jarIndex, ClassEntry obfClassEntry) { | ||
| 32 | |||
| 33 | // lookup the chain of outer classes | ||
| 34 | List<ClassEntry> obfClassChain = Lists.newArrayList(obfClassEntry); | ||
| 35 | ClassEntry checkClassEntry = obfClassEntry; | ||
| 36 | while (true) { | ||
| 37 | ClassEntry obfOuterClassEntry = jarIndex.getOuterClass(checkClassEntry); | ||
| 38 | if (obfOuterClassEntry != null) { | ||
| 39 | obfClassChain.add(obfOuterClassEntry); | ||
| 40 | checkClassEntry = obfOuterClassEntry; | ||
| 41 | } else { | ||
| 42 | break; | ||
| 43 | } | ||
| 44 | } | ||
| 45 | |||
| 46 | // build the chained class name | ||
| 47 | StringBuilder buf = new StringBuilder(); | ||
| 48 | for (int i=obfClassChain.size()-1; i>=0; i--) { | ||
| 49 | if (buf.length() == 0) { | ||
| 50 | buf.append(obfClassChain.get(i).getName()); | ||
| 51 | } else { | ||
| 52 | buf.append("$"); | ||
| 53 | buf.append(obfClassChain.get(i).getSimpleName()); | ||
| 54 | } | ||
| 55 | } | ||
| 56 | return new ClassEntry(buf.toString()); | ||
| 57 | } | 27 | } |
| 58 | 28 | ||
| 59 | public static ClassEntry getDeobfClassEntry(ClassMapping classMapping) { | 29 | public static ClassEntry getDeobfClassEntry(ClassMapping classMapping) { |