|
|
@ -4,6 +4,7 @@ import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
|
import dev.openrs2.asm.Transformer; |
|
|
|
import dev.openrs2.asm.Transformer; |
|
|
|
|
|
|
|
import dev.openrs2.deob.annotation.OriginalArg; |
|
|
|
import dev.openrs2.deob.annotation.OriginalClass; |
|
|
|
import dev.openrs2.deob.annotation.OriginalClass; |
|
|
|
import dev.openrs2.deob.annotation.OriginalMember; |
|
|
|
import dev.openrs2.deob.annotation.OriginalMember; |
|
|
|
import org.objectweb.asm.Type; |
|
|
|
import org.objectweb.asm.Type; |
|
|
@ -29,6 +30,12 @@ public final class OriginalNameTransformer extends Transformer { |
|
|
|
return annotation; |
|
|
|
return annotation; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static AnnotationNode createOriginalArgAnnotation(int index) { |
|
|
|
|
|
|
|
var annotation = new AnnotationNode(Type.getDescriptor(OriginalArg.class)); |
|
|
|
|
|
|
|
annotation.values = List.of("value", index); |
|
|
|
|
|
|
|
return annotation; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void transformClass(ClassNode clazz) { |
|
|
|
public void transformClass(ClassNode clazz) { |
|
|
|
if (clazz.invisibleAnnotations == null) { |
|
|
|
if (clazz.invisibleAnnotations == null) { |
|
|
@ -45,6 +52,7 @@ public final class OriginalNameTransformer extends Transformer { |
|
|
|
field.invisibleAnnotations.add(createOriginalMemberAnnotation(clazz.name, field.name, field.desc)); |
|
|
|
field.invisibleAnnotations.add(createOriginalMemberAnnotation(clazz.name, field.name, field.desc)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void transformMethod(ClassNode clazz, MethodNode method) { |
|
|
|
public void transformMethod(ClassNode clazz, MethodNode method) { |
|
|
|
if (method.name.equals("<init>") || method.name.equals("<clinit>")) { |
|
|
|
if (method.name.equals("<init>") || method.name.equals("<clinit>")) { |
|
|
@ -55,5 +63,17 @@ public final class OriginalNameTransformer extends Transformer { |
|
|
|
method.invisibleAnnotations = new ArrayList<>(); |
|
|
|
method.invisibleAnnotations = new ArrayList<>(); |
|
|
|
} |
|
|
|
} |
|
|
|
method.invisibleAnnotations.add(createOriginalMemberAnnotation(clazz.name, method.name, method.desc)); |
|
|
|
method.invisibleAnnotations.add(createOriginalMemberAnnotation(clazz.name, method.name, method.desc)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int args = Type.getArgumentTypes(method.desc).length; |
|
|
|
|
|
|
|
if (method.invisibleParameterAnnotations == null) { |
|
|
|
|
|
|
|
method.invisibleParameterAnnotations = (List<AnnotationNode>[]) new List<?>[args]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
for (int i = 0; i < method.invisibleParameterAnnotations.length; i++) { |
|
|
|
|
|
|
|
var annotations = method.invisibleParameterAnnotations[i]; |
|
|
|
|
|
|
|
if (annotations == null) { |
|
|
|
|
|
|
|
annotations = method.invisibleParameterAnnotations[i] = new ArrayList<>(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
annotations.add(createOriginalArgAnnotation(i)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|