diff options
Diffstat (limited to 'src/main/java/cuchaz/enigma/bytecode')
| -rw-r--r-- | src/main/java/cuchaz/enigma/bytecode/translators/SourceFixVisitor.java | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/main/java/cuchaz/enigma/bytecode/translators/SourceFixVisitor.java b/src/main/java/cuchaz/enigma/bytecode/translators/SourceFixVisitor.java new file mode 100644 index 0000000..99eef6a --- /dev/null +++ b/src/main/java/cuchaz/enigma/bytecode/translators/SourceFixVisitor.java | |||
| @@ -0,0 +1,43 @@ | |||
| 1 | package cuchaz.enigma.bytecode.translators; | ||
| 2 | |||
| 3 | import cuchaz.enigma.analysis.index.BridgeMethodIndex; | ||
| 4 | import cuchaz.enigma.analysis.index.JarIndex; | ||
| 5 | import cuchaz.enigma.translation.representation.entry.ClassDefEntry; | ||
| 6 | import cuchaz.enigma.translation.representation.entry.MethodDefEntry; | ||
| 7 | import cuchaz.enigma.translation.representation.entry.MethodEntry; | ||
| 8 | import org.objectweb.asm.ClassVisitor; | ||
| 9 | import org.objectweb.asm.MethodVisitor; | ||
| 10 | import org.objectweb.asm.Opcodes; | ||
| 11 | |||
| 12 | public class SourceFixVisitor extends ClassVisitor { | ||
| 13 | private final JarIndex index; | ||
| 14 | private ClassDefEntry ownerEntry; | ||
| 15 | |||
| 16 | public SourceFixVisitor(int api, ClassVisitor visitor, JarIndex index) { | ||
| 17 | super(api, visitor); | ||
| 18 | this.index = index; | ||
| 19 | } | ||
| 20 | |||
| 21 | @Override | ||
| 22 | public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) { | ||
| 23 | ownerEntry = ClassDefEntry.parse(access, name, signature, superName, interfaces); | ||
| 24 | super.visit(version, access, name, signature, superName, interfaces); | ||
| 25 | } | ||
| 26 | |||
| 27 | @Override | ||
| 28 | public MethodVisitor visitMethod(int access, String name, String descriptor, String signature, String[] exceptions) { | ||
| 29 | MethodDefEntry methodEntry = MethodDefEntry.parse(ownerEntry, access, name, descriptor, signature); | ||
| 30 | |||
| 31 | BridgeMethodIndex bridgeIndex = index.getBridgeMethodIndex(); | ||
| 32 | if (bridgeIndex.isBridgeMethod(methodEntry)) { | ||
| 33 | access |= Opcodes.ACC_BRIDGE; | ||
| 34 | } else { | ||
| 35 | MethodEntry bridgeMethod = bridgeIndex.getBridgeFromAccessed(methodEntry); | ||
| 36 | if (bridgeMethod != null) { | ||
| 37 | name = bridgeMethod.getName(); | ||
| 38 | } | ||
| 39 | } | ||
| 40 | |||
| 41 | return super.visitMethod(access, name, descriptor, signature, exceptions); | ||
| 42 | } | ||
| 43 | } | ||