diff options
Diffstat (limited to 'src/main/java/cuchaz/enigma/analysis')
5 files changed, 32 insertions, 20 deletions
diff --git a/src/main/java/cuchaz/enigma/analysis/EntryRenamer.java b/src/main/java/cuchaz/enigma/analysis/EntryRenamer.java index 656fa32..e37c1d0 100644 --- a/src/main/java/cuchaz/enigma/analysis/EntryRenamer.java +++ b/src/main/java/cuchaz/enigma/analysis/EntryRenamer.java | |||
| @@ -122,10 +122,22 @@ public class EntryRenamer { | |||
| 122 | return (T) new ClassEntry(renameClassesInThing(renames, classEntry.getClassName())); | 122 | return (T) new ClassEntry(renameClassesInThing(renames, classEntry.getClassName())); |
| 123 | } else if (thing instanceof FieldDefEntry) { | 123 | } else if (thing instanceof FieldDefEntry) { |
| 124 | FieldDefEntry fieldEntry = (FieldDefEntry) thing; | 124 | FieldDefEntry fieldEntry = (FieldDefEntry) thing; |
| 125 | return (T) new FieldDefEntry(renameClassesInThing(renames, fieldEntry.getOwnerClassEntry()), fieldEntry.getName(), renameClassesInThing(renames, fieldEntry.getDesc()), fieldEntry.getAccess()); | 125 | return (T) new FieldDefEntry( |
| 126 | renameClassesInThing(renames, fieldEntry.getOwnerClassEntry()), | ||
| 127 | fieldEntry.getName(), | ||
| 128 | renameClassesInThing(renames, fieldEntry.getDesc()), | ||
| 129 | renameClassesInThing(renames, fieldEntry.getSignature()), | ||
| 130 | fieldEntry.getAccess() | ||
| 131 | ); | ||
| 126 | } else if (thing instanceof MethodDefEntry) { | 132 | } else if (thing instanceof MethodDefEntry) { |
| 127 | MethodDefEntry methodEntry = (MethodDefEntry) thing; | 133 | MethodDefEntry methodEntry = (MethodDefEntry) thing; |
| 128 | return (T) new MethodDefEntry(renameClassesInThing(renames, methodEntry.getOwnerClassEntry()), methodEntry.getName(), renameClassesInThing(renames, methodEntry.getDesc()), methodEntry.getAccess()); | 134 | return (T) new MethodDefEntry( |
| 135 | renameClassesInThing(renames, methodEntry.getOwnerClassEntry()), | ||
| 136 | methodEntry.getName(), | ||
| 137 | renameClassesInThing(renames, methodEntry.getDesc()), | ||
| 138 | renameClassesInThing(renames, methodEntry.getSignature()), | ||
| 139 | methodEntry.getAccess() | ||
| 140 | ); | ||
| 129 | } else if (thing instanceof LocalVariableEntry) { | 141 | } else if (thing instanceof LocalVariableEntry) { |
| 130 | LocalVariableEntry argumentEntry = (LocalVariableEntry) thing; | 142 | LocalVariableEntry argumentEntry = (LocalVariableEntry) thing; |
| 131 | return (T) new LocalVariableEntry(renameClassesInThing(renames, argumentEntry.getOwnerEntry()), argumentEntry.getIndex(), argumentEntry.getName()); | 143 | return (T) new LocalVariableEntry(renameClassesInThing(renames, argumentEntry.getOwnerEntry()), argumentEntry.getIndex(), argumentEntry.getName()); |
| @@ -138,6 +150,8 @@ public class EntryRenamer { | |||
| 138 | return (T) ((MethodDescriptor) thing).remap(className -> renameClassesInThing(renames, className)); | 150 | return (T) ((MethodDescriptor) thing).remap(className -> renameClassesInThing(renames, className)); |
| 139 | } else if (thing instanceof TypeDescriptor) { | 151 | } else if (thing instanceof TypeDescriptor) { |
| 140 | return (T) ((TypeDescriptor) thing).remap(className -> renameClassesInThing(renames, className)); | 152 | return (T) ((TypeDescriptor) thing).remap(className -> renameClassesInThing(renames, className)); |
| 153 | } else if (thing instanceof Signature) { | ||
| 154 | return (T) ((Signature) thing).remap(className -> renameClassesInThing(renames, className)); | ||
| 141 | } | 155 | } |
| 142 | 156 | ||
| 143 | return thing; | 157 | return thing; |
diff --git a/src/main/java/cuchaz/enigma/analysis/IndexClassVisitor.java b/src/main/java/cuchaz/enigma/analysis/IndexClassVisitor.java index 7828fa9..69fe54f 100644 --- a/src/main/java/cuchaz/enigma/analysis/IndexClassVisitor.java +++ b/src/main/java/cuchaz/enigma/analysis/IndexClassVisitor.java | |||
| @@ -16,14 +16,14 @@ public class IndexClassVisitor extends ClassVisitor { | |||
| 16 | 16 | ||
| 17 | @Override | 17 | @Override |
| 18 | public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) { | 18 | public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) { |
| 19 | this.classEntry = this.index.indexClass(access, name, superName, interfaces); | 19 | this.classEntry = this.index.indexClass(access, name, signature, superName, interfaces); |
| 20 | super.visit(version, access, name, signature, superName, interfaces); | 20 | super.visit(version, access, name, signature, superName, interfaces); |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | @Override | 23 | @Override |
| 24 | public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) { | 24 | public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) { |
| 25 | if (this.classEntry != null) { | 25 | if (this.classEntry != null) { |
| 26 | this.index.indexField(this.classEntry, access, name, desc); | 26 | this.index.indexField(this.classEntry, access, name, desc, signature); |
| 27 | } | 27 | } |
| 28 | return super.visitField(access, name, desc, signature, value); | 28 | return super.visitField(access, name, desc, signature, value); |
| 29 | } | 29 | } |
| @@ -31,7 +31,7 @@ public class IndexClassVisitor extends ClassVisitor { | |||
| 31 | @Override | 31 | @Override |
| 32 | public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { | 32 | public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { |
| 33 | if (this.classEntry != null) { | 33 | if (this.classEntry != null) { |
| 34 | this.index.indexMethod(this.classEntry, access, name, desc); | 34 | this.index.indexMethod(this.classEntry, access, name, desc, signature); |
| 35 | } | 35 | } |
| 36 | return super.visitMethod(access, name, desc, signature, exceptions); | 36 | return super.visitMethod(access, name, desc, signature, exceptions); |
| 37 | } | 37 | } |
diff --git a/src/main/java/cuchaz/enigma/analysis/IndexReferenceVisitor.java b/src/main/java/cuchaz/enigma/analysis/IndexReferenceVisitor.java index bd64bfc..c05281b 100644 --- a/src/main/java/cuchaz/enigma/analysis/IndexReferenceVisitor.java +++ b/src/main/java/cuchaz/enigma/analysis/IndexReferenceVisitor.java | |||
| @@ -1,22 +1,20 @@ | |||
| 1 | package cuchaz.enigma.analysis; | 1 | package cuchaz.enigma.analysis; |
| 2 | 2 | ||
| 3 | import cuchaz.enigma.bytecode.AccessFlags; | 3 | import cuchaz.enigma.bytecode.AccessFlags; |
| 4 | import cuchaz.enigma.mapping.*; | 4 | import cuchaz.enigma.mapping.MethodDescriptor; |
| 5 | import cuchaz.enigma.mapping.Signature; | ||
| 5 | import cuchaz.enigma.mapping.entry.ClassEntry; | 6 | import cuchaz.enigma.mapping.entry.ClassEntry; |
| 6 | import cuchaz.enigma.mapping.entry.MethodDefEntry; | 7 | import cuchaz.enigma.mapping.entry.MethodDefEntry; |
| 7 | import cuchaz.enigma.mapping.entry.ReferencedEntryPool; | ||
| 8 | import org.objectweb.asm.ClassVisitor; | 8 | import org.objectweb.asm.ClassVisitor; |
| 9 | import org.objectweb.asm.MethodVisitor; | 9 | import org.objectweb.asm.MethodVisitor; |
| 10 | 10 | ||
| 11 | public class IndexReferenceVisitor extends ClassVisitor { | 11 | public class IndexReferenceVisitor extends ClassVisitor { |
| 12 | private final JarIndex index; | 12 | private final JarIndex index; |
| 13 | private final ReferencedEntryPool entryPool; | ||
| 14 | private ClassEntry classEntry; | 13 | private ClassEntry classEntry; |
| 15 | 14 | ||
| 16 | public IndexReferenceVisitor(JarIndex index, ReferencedEntryPool entryPool, int api) { | 15 | public IndexReferenceVisitor(JarIndex index, int api) { |
| 17 | super(api); | 16 | super(api); |
| 18 | this.index = index; | 17 | this.index = index; |
| 19 | this.entryPool = entryPool; | ||
| 20 | } | 18 | } |
| 21 | 19 | ||
| 22 | @Override | 20 | @Override |
| @@ -26,7 +24,7 @@ public class IndexReferenceVisitor extends ClassVisitor { | |||
| 26 | 24 | ||
| 27 | @Override | 25 | @Override |
| 28 | public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { | 26 | public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { |
| 29 | MethodDefEntry entry = new MethodDefEntry(classEntry, name, new MethodDescriptor(desc), new AccessFlags(access)); | 27 | MethodDefEntry entry = new MethodDefEntry(classEntry, name, new MethodDescriptor(desc), Signature.createSignature(signature), new AccessFlags(access)); |
| 30 | return new Method(this.index, entry, this.api); | 28 | return new Method(this.index, entry, this.api); |
| 31 | } | 29 | } |
| 32 | 30 | ||
diff --git a/src/main/java/cuchaz/enigma/analysis/JarIndex.java b/src/main/java/cuchaz/enigma/analysis/JarIndex.java index 54dd506..3479c5d 100644 --- a/src/main/java/cuchaz/enigma/analysis/JarIndex.java +++ b/src/main/java/cuchaz/enigma/analysis/JarIndex.java | |||
| @@ -61,7 +61,7 @@ public class JarIndex { | |||
| 61 | jar.visit(node -> node.accept(new IndexClassVisitor(this, Opcodes.ASM5))); | 61 | jar.visit(node -> node.accept(new IndexClassVisitor(this, Opcodes.ASM5))); |
| 62 | 62 | ||
| 63 | // step 3: index field, method, constructor references | 63 | // step 3: index field, method, constructor references |
| 64 | jar.visit(node -> node.accept(new IndexReferenceVisitor(this, entryPool, Opcodes.ASM5))); | 64 | jar.visit(node -> node.accept(new IndexReferenceVisitor(this, Opcodes.ASM5))); |
| 65 | 65 | ||
| 66 | // step 4: index bridged methods | 66 | // step 4: index bridged methods |
| 67 | for (MethodDefEntry methodEntry : methods.values()) { | 67 | for (MethodDefEntry methodEntry : methods.values()) { |
| @@ -95,24 +95,24 @@ public class JarIndex { | |||
| 95 | } | 95 | } |
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | protected ClassDefEntry indexClass(int access, String name, String superName, String[] interfaces) { | 98 | protected ClassDefEntry indexClass(int access, String name, String signature, String superName, String[] interfaces) { |
| 99 | for (String interfaceName : interfaces) { | 99 | for (String interfaceName : interfaces) { |
| 100 | if (name.equals(interfaceName)) { | 100 | if (name.equals(interfaceName)) { |
| 101 | throw new IllegalArgumentException("Class cannot be its own interface! " + name); | 101 | throw new IllegalArgumentException("Class cannot be its own interface! " + name); |
| 102 | } | 102 | } |
| 103 | } | 103 | } |
| 104 | return this.translationIndex.indexClass(access, name, superName, interfaces); | 104 | return this.translationIndex.indexClass(access, name, signature, superName, interfaces); |
| 105 | } | 105 | } |
| 106 | 106 | ||
| 107 | protected void indexField(ClassDefEntry owner, int access, String name, String desc) { | 107 | protected void indexField(ClassDefEntry owner, int access, String name, String desc, String signature) { |
| 108 | FieldDefEntry fieldEntry = new FieldDefEntry(owner, name, new TypeDescriptor(desc), new AccessFlags(access)); | 108 | FieldDefEntry fieldEntry = new FieldDefEntry(owner, name, new TypeDescriptor(desc), Signature.createTypedSignature(signature), new AccessFlags(access)); |
| 109 | this.translationIndex.indexField(fieldEntry); | 109 | this.translationIndex.indexField(fieldEntry); |
| 110 | this.access.put(fieldEntry, Access.get(access)); | 110 | this.access.put(fieldEntry, Access.get(access)); |
| 111 | this.fields.put(fieldEntry.getOwnerClassEntry(), fieldEntry); | 111 | this.fields.put(fieldEntry.getOwnerClassEntry(), fieldEntry); |
| 112 | } | 112 | } |
| 113 | 113 | ||
| 114 | protected void indexMethod(ClassDefEntry owner, int access, String name, String desc) { | 114 | protected void indexMethod(ClassDefEntry owner, int access, String name, String desc, String signature) { |
| 115 | MethodDefEntry methodEntry = new MethodDefEntry(owner, name, new MethodDescriptor(desc), new AccessFlags(access)); | 115 | MethodDefEntry methodEntry = new MethodDefEntry(owner, name, new MethodDescriptor(desc), Signature.createSignature(signature), new AccessFlags(access)); |
| 116 | this.translationIndex.indexMethod(methodEntry); | 116 | this.translationIndex.indexMethod(methodEntry); |
| 117 | this.access.put(methodEntry, Access.get(access)); | 117 | this.access.put(methodEntry, Access.get(access)); |
| 118 | this.methods.put(methodEntry.getOwnerClassEntry(), methodEntry); | 118 | this.methods.put(methodEntry.getOwnerClassEntry(), methodEntry); |
diff --git a/src/main/java/cuchaz/enigma/analysis/TranslationIndex.java b/src/main/java/cuchaz/enigma/analysis/TranslationIndex.java index 0c8ed9c..644a3f2 100644 --- a/src/main/java/cuchaz/enigma/analysis/TranslationIndex.java +++ b/src/main/java/cuchaz/enigma/analysis/TranslationIndex.java | |||
| @@ -76,8 +76,8 @@ public class TranslationIndex { | |||
| 76 | } | 76 | } |
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | protected ClassDefEntry indexClass(int access, String name, String superName, String[] interfaces) { | 79 | protected ClassDefEntry indexClass(int access, String name, String signature, String superName, String[] interfaces) { |
| 80 | ClassDefEntry classEntry = new ClassDefEntry(name, new AccessFlags(access)); | 80 | ClassDefEntry classEntry = new ClassDefEntry(name, Signature.createSignature(signature), new AccessFlags(access)); |
| 81 | if (isJre(classEntry)) { | 81 | if (isJre(classEntry)) { |
| 82 | return null; | 82 | return null; |
| 83 | } | 83 | } |