diff options
Diffstat (limited to 'src/main/java/cuchaz/enigma/mapping/EntryFactory.java')
| -rw-r--r-- | src/main/java/cuchaz/enigma/mapping/EntryFactory.java | 132 |
1 files changed, 0 insertions, 132 deletions
diff --git a/src/main/java/cuchaz/enigma/mapping/EntryFactory.java b/src/main/java/cuchaz/enigma/mapping/EntryFactory.java deleted file mode 100644 index 993bb64b..00000000 --- a/src/main/java/cuchaz/enigma/mapping/EntryFactory.java +++ /dev/null | |||
| @@ -1,132 +0,0 @@ | |||
| 1 | /******************************************************************************* | ||
| 2 | * Copyright (c) 2015 Jeff Martin. | ||
| 3 | * All rights reserved. This program and the accompanying materials | ||
| 4 | * are made available under the terms of the GNU Lesser General Public | ||
| 5 | * License v3.0 which accompanies this distribution, and is available at | ||
| 6 | * http://www.gnu.org/licenses/lgpl.html | ||
| 7 | * <p> | ||
| 8 | * Contributors: | ||
| 9 | * Jeff Martin - initial API and implementation | ||
| 10 | ******************************************************************************/ | ||
| 11 | |||
| 12 | package cuchaz.enigma.mapping; | ||
| 13 | |||
| 14 | import cuchaz.enigma.analysis.JarIndex; | ||
| 15 | import javassist.*; | ||
| 16 | import javassist.bytecode.Descriptor; | ||
| 17 | import javassist.expr.ConstructorCall; | ||
| 18 | import javassist.expr.FieldAccess; | ||
| 19 | import javassist.expr.MethodCall; | ||
| 20 | import javassist.expr.NewExpr; | ||
| 21 | |||
| 22 | public class EntryFactory { | ||
| 23 | |||
| 24 | public static ClassEntry getClassEntry(CtClass c) { | ||
| 25 | return new ClassEntry(Descriptor.toJvmName(c.getName())); | ||
| 26 | } | ||
| 27 | |||
| 28 | public static ClassEntry getObfClassEntry(JarIndex jarIndex, ClassMapping classMapping) { | ||
| 29 | ClassEntry obfClassEntry = new ClassEntry(classMapping.getObfFullName()); | ||
| 30 | return obfClassEntry.buildClassEntry(jarIndex.getObfClassChain(obfClassEntry)); | ||
| 31 | } | ||
| 32 | |||
| 33 | private static ClassEntry getObfClassEntry(ClassMapping classMapping) { | ||
| 34 | return new ClassEntry(classMapping.getObfFullName()); | ||
| 35 | } | ||
| 36 | |||
| 37 | public static ClassEntry getDeobfClassEntry(ClassMapping classMapping) { | ||
| 38 | return new ClassEntry(classMapping.getDeobfName()); | ||
| 39 | } | ||
| 40 | |||
| 41 | public static ClassEntry getSuperclassEntry(CtClass c) { | ||
| 42 | return new ClassEntry(Descriptor.toJvmName(c.getClassFile().getSuperclass())); | ||
| 43 | } | ||
| 44 | |||
| 45 | public static FieldEntry getFieldEntry(CtField field) { | ||
| 46 | return new FieldEntry(getClassEntry(field.getDeclaringClass()), field.getName(), new Type(field.getFieldInfo().getDescriptor())); | ||
| 47 | } | ||
| 48 | |||
| 49 | public static FieldEntry getFieldEntry(FieldAccess call) { | ||
| 50 | return new FieldEntry(new ClassEntry(Descriptor.toJvmName(call.getClassName())), call.getFieldName(), new Type(call.getSignature())); | ||
| 51 | } | ||
| 52 | |||
| 53 | public static FieldEntry getFieldEntry(String className, String name, String type) { | ||
| 54 | return new FieldEntry(new ClassEntry(className), name, new Type(type)); | ||
| 55 | } | ||
| 56 | |||
| 57 | public static FieldEntry getObfFieldEntry(ClassMapping classMapping, FieldMapping fieldMapping) { | ||
| 58 | return new FieldEntry(getObfClassEntry(classMapping), fieldMapping.getObfName(), fieldMapping.getObfType()); | ||
| 59 | } | ||
| 60 | |||
| 61 | public static MethodEntry getMethodEntry(CtMethod method) { | ||
| 62 | return new MethodEntry(getClassEntry(method.getDeclaringClass()), method.getName(), new Signature(method.getMethodInfo().getDescriptor())); | ||
| 63 | } | ||
| 64 | |||
| 65 | public static MethodEntry getMethodEntry(MethodCall call) { | ||
| 66 | return new MethodEntry(new ClassEntry(Descriptor.toJvmName(call.getClassName())), call.getMethodName(), new Signature(call.getSignature())); | ||
| 67 | } | ||
| 68 | |||
| 69 | public static ConstructorEntry getConstructorEntry(CtConstructor constructor) { | ||
| 70 | if (constructor.isClassInitializer()) { | ||
| 71 | return new ConstructorEntry(getClassEntry(constructor.getDeclaringClass())); | ||
| 72 | } else { | ||
| 73 | return new ConstructorEntry(getClassEntry(constructor.getDeclaringClass()), new Signature(constructor.getMethodInfo().getDescriptor())); | ||
| 74 | } | ||
| 75 | } | ||
| 76 | |||
| 77 | public static ConstructorEntry getConstructorEntry(ConstructorCall call) { | ||
| 78 | return new ConstructorEntry(new ClassEntry(Descriptor.toJvmName(call.getClassName())), new Signature(call.getSignature())); | ||
| 79 | } | ||
| 80 | |||
| 81 | public static ConstructorEntry getConstructorEntry(NewExpr call) { | ||
| 82 | return new ConstructorEntry(new ClassEntry(Descriptor.toJvmName(call.getClassName())), new Signature(call.getSignature())); | ||
| 83 | } | ||
| 84 | |||
| 85 | public static BehaviorEntry getBehaviorEntry(CtBehavior behavior) { | ||
| 86 | if (behavior instanceof CtMethod) { | ||
| 87 | return getMethodEntry((CtMethod) behavior); | ||
| 88 | } else if (behavior instanceof CtConstructor) { | ||
| 89 | return getConstructorEntry((CtConstructor) behavior); | ||
| 90 | } | ||
| 91 | throw new Error("behavior is neither Method nor Constructor!"); | ||
| 92 | } | ||
| 93 | |||
| 94 | public static BehaviorEntry getBehaviorEntry(String className, String behaviorName, String behaviorSignature) { | ||
| 95 | return getBehaviorEntry(new ClassEntry(className), behaviorName, new Signature(behaviorSignature)); | ||
| 96 | } | ||
| 97 | |||
| 98 | public static BehaviorEntry getBehaviorEntry(String className, String behaviorName) { | ||
| 99 | return getBehaviorEntry(new ClassEntry(className), behaviorName); | ||
| 100 | } | ||
| 101 | |||
| 102 | public static BehaviorEntry getBehaviorEntry(String className) { | ||
| 103 | return new ConstructorEntry(new ClassEntry(className)); | ||
| 104 | } | ||
| 105 | |||
| 106 | public static BehaviorEntry getBehaviorEntry(ClassEntry classEntry, String behaviorName, Signature behaviorSignature) { | ||
| 107 | switch (behaviorName) { | ||
| 108 | case "<init>": | ||
| 109 | return new ConstructorEntry(classEntry, behaviorSignature); | ||
| 110 | case "<clinit>": | ||
| 111 | return new ConstructorEntry(classEntry); | ||
| 112 | default: | ||
| 113 | return new MethodEntry(classEntry, behaviorName, behaviorSignature); | ||
| 114 | } | ||
| 115 | } | ||
| 116 | |||
| 117 | public static BehaviorEntry getBehaviorEntry(ClassEntry classEntry, String behaviorName) { | ||
| 118 | if (behaviorName.equals("<clinit>")) { | ||
| 119 | return new ConstructorEntry(classEntry); | ||
| 120 | } else { | ||
| 121 | throw new IllegalArgumentException("Only class initializers don't have signatures"); | ||
| 122 | } | ||
| 123 | } | ||
| 124 | |||
| 125 | public static BehaviorEntry getObfBehaviorEntry(ClassEntry classEntry, MethodMapping methodMapping) { | ||
| 126 | return getBehaviorEntry(classEntry, methodMapping.getObfName(), methodMapping.getObfSignature()); | ||
| 127 | } | ||
| 128 | |||
| 129 | public static BehaviorEntry getObfBehaviorEntry(ClassMapping classMapping, MethodMapping methodMapping) { | ||
| 130 | return getObfBehaviorEntry(getObfClassEntry(classMapping), methodMapping); | ||
| 131 | } | ||
| 132 | } | ||