diff options
| author | 2016-09-07 16:58:12 +0200 | |
|---|---|---|
| committer | 2016-09-07 16:58:12 +0200 | |
| commit | 591f44c85c392ecf281039a9f3c52673c11d9584 (patch) | |
| tree | 3210b2c45643a286dda715915fb7776deac84ee3 /src/main/java/cuchaz | |
| parent | Generify ProcyonEntryFactory (Fix #18) (diff) | |
| download | enigma-591f44c85c392ecf281039a9f3c52673c11d9584.tar.gz enigma-591f44c85c392ecf281039a9f3c52673c11d9584.tar.xz enigma-591f44c85c392ecf281039a9f3c52673c11d9584.zip | |
Follow Javassist signature instead of ignoring generic classes (Fix #19)
Diffstat (limited to 'src/main/java/cuchaz')
| -rw-r--r-- | src/main/java/cuchaz/enigma/analysis/SourceIndexClassVisitor.java | 2 | ||||
| -rw-r--r-- | src/main/java/cuchaz/enigma/mapping/ProcyonEntryFactory.java | 31 |
2 files changed, 26 insertions, 7 deletions
diff --git a/src/main/java/cuchaz/enigma/analysis/SourceIndexClassVisitor.java b/src/main/java/cuchaz/enigma/analysis/SourceIndexClassVisitor.java index 06ce042b..2a212222 100644 --- a/src/main/java/cuchaz/enigma/analysis/SourceIndexClassVisitor.java +++ b/src/main/java/cuchaz/enigma/analysis/SourceIndexClassVisitor.java | |||
| @@ -16,7 +16,6 @@ import com.strobel.assembler.metadata.TypeDefinition; | |||
| 16 | import com.strobel.assembler.metadata.TypeReference; | 16 | import com.strobel.assembler.metadata.TypeReference; |
| 17 | import com.strobel.decompiler.languages.TextLocation; | 17 | import com.strobel.decompiler.languages.TextLocation; |
| 18 | import com.strobel.decompiler.languages.java.ast.*; | 18 | import com.strobel.decompiler.languages.java.ast.*; |
| 19 | |||
| 20 | import cuchaz.enigma.mapping.*; | 19 | import cuchaz.enigma.mapping.*; |
| 21 | 20 | ||
| 22 | public class SourceIndexClassVisitor extends SourceIndexVisitor { | 21 | public class SourceIndexClassVisitor extends SourceIndexVisitor { |
| @@ -57,7 +56,6 @@ public class SourceIndexClassVisitor extends SourceIndexVisitor { | |||
| 57 | MethodDefinition def = node.getUserData(Keys.METHOD_DEFINITION); | 56 | MethodDefinition def = node.getUserData(Keys.METHOD_DEFINITION); |
| 58 | BehaviorEntry behaviorEntry = ProcyonEntryFactory.getBehaviorEntry(def); | 57 | BehaviorEntry behaviorEntry = ProcyonEntryFactory.getBehaviorEntry(def); |
| 59 | AstNode tokenNode = node.getNameToken(); | 58 | AstNode tokenNode = node.getNameToken(); |
| 60 | |||
| 61 | if (behaviorEntry instanceof ConstructorEntry) { | 59 | if (behaviorEntry instanceof ConstructorEntry) { |
| 62 | ConstructorEntry constructorEntry = (ConstructorEntry) behaviorEntry; | 60 | ConstructorEntry constructorEntry = (ConstructorEntry) behaviorEntry; |
| 63 | if (constructorEntry.isStatic()) { | 61 | if (constructorEntry.isStatic()) { |
diff --git a/src/main/java/cuchaz/enigma/mapping/ProcyonEntryFactory.java b/src/main/java/cuchaz/enigma/mapping/ProcyonEntryFactory.java index 08dc8b18..8cbca13d 100644 --- a/src/main/java/cuchaz/enigma/mapping/ProcyonEntryFactory.java +++ b/src/main/java/cuchaz/enigma/mapping/ProcyonEntryFactory.java | |||
| @@ -10,19 +10,40 @@ | |||
| 10 | ******************************************************************************/ | 10 | ******************************************************************************/ |
| 11 | package cuchaz.enigma.mapping; | 11 | package cuchaz.enigma.mapping; |
| 12 | 12 | ||
| 13 | import com.strobel.assembler.metadata.FieldDefinition; | 13 | import com.strobel.assembler.metadata.*; |
| 14 | import com.strobel.assembler.metadata.MemberReference; | 14 | |
| 15 | import com.strobel.assembler.metadata.MethodDefinition; | 15 | import java.util.List; |
| 16 | import com.strobel.assembler.metadata.MethodReference; | ||
| 17 | 16 | ||
| 18 | public class ProcyonEntryFactory { | 17 | public class ProcyonEntryFactory { |
| 19 | 18 | ||
| 19 | private static String getErasedSignature(MemberReference def) | ||
| 20 | { | ||
| 21 | if (!(def instanceof MethodReference)) | ||
| 22 | return def.getErasedSignature(); | ||
| 23 | MethodReference methodReference = (MethodReference) def; | ||
| 24 | StringBuilder builder = new StringBuilder("("); | ||
| 25 | for (ParameterDefinition param : methodReference.getParameters()) | ||
| 26 | { | ||
| 27 | TypeReference paramType = param.getParameterType(); | ||
| 28 | if (paramType.getErasedSignature().equals("Ljava/lang/Object;") && paramType.hasExtendsBound() && paramType.getExtendsBound() instanceof CompoundTypeReference) | ||
| 29 | { | ||
| 30 | List<TypeReference> interfaces = ((CompoundTypeReference) paramType.getExtendsBound()).getInterfaces(); | ||
| 31 | interfaces.forEach((inter) -> builder.append(inter.getErasedSignature())); | ||
| 32 | } | ||
| 33 | else | ||
| 34 | builder.append(paramType.getErasedSignature()); | ||
| 35 | } | ||
| 36 | builder.append(")"); | ||
| 37 | builder.append(methodReference.getReturnType().getErasedSignature()); | ||
| 38 | return builder.toString(); | ||
| 39 | } | ||
| 40 | |||
| 20 | public static FieldEntry getFieldEntry(MemberReference def) { | 41 | public static FieldEntry getFieldEntry(MemberReference def) { |
| 21 | return new FieldEntry(new ClassEntry(def.getDeclaringType().getInternalName()), def.getName(), new Type(def.getErasedSignature())); | 42 | return new FieldEntry(new ClassEntry(def.getDeclaringType().getInternalName()), def.getName(), new Type(def.getErasedSignature())); |
| 22 | } | 43 | } |
| 23 | 44 | ||
| 24 | public static MethodEntry getMethodEntry(MemberReference def) { | 45 | public static MethodEntry getMethodEntry(MemberReference def) { |
| 25 | return new MethodEntry(new ClassEntry(def.getDeclaringType().getInternalName()), def.getName(), new Signature(def.getErasedSignature())); | 46 | return new MethodEntry(new ClassEntry(def.getDeclaringType().getInternalName()), def.getName(), new Signature(getErasedSignature(def))); |
| 26 | } | 47 | } |
| 27 | 48 | ||
| 28 | public static ConstructorEntry getConstructorEntry(MethodReference def) { | 49 | public static ConstructorEntry getConstructorEntry(MethodReference def) { |