aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/ftbsc/lll/processor/tools/containers
diff options
context:
space:
mode:
author zaaarf <zaaarf@proton.me>2023-08-26 23:55:11 +0200
committer zaaarf <zaaarf@proton.me>2023-08-26 23:55:11 +0200
commit30f8e080ae5d7bd811abb5b96bc6b85aa89350a8 (patch)
treeeecf91d07fefb6a327d4a1e426e160b90bc555fe /src/main/java/ftbsc/lll/processor/tools/containers
parent8e3284a904633b5434104668936be5251e520241 (diff)
feat: updated to use mapper lib 0.2.0
Diffstat (limited to 'src/main/java/ftbsc/lll/processor/tools/containers')
-rw-r--r--src/main/java/ftbsc/lll/processor/tools/containers/ClassContainer.java16
-rw-r--r--src/main/java/ftbsc/lll/processor/tools/containers/FieldContainer.java20
-rw-r--r--src/main/java/ftbsc/lll/processor/tools/containers/MethodContainer.java33
3 files changed, 23 insertions, 46 deletions
diff --git a/src/main/java/ftbsc/lll/processor/tools/containers/ClassContainer.java b/src/main/java/ftbsc/lll/processor/tools/containers/ClassContainer.java
index 2c10dd6..b145e71 100644
--- a/src/main/java/ftbsc/lll/processor/tools/containers/ClassContainer.java
+++ b/src/main/java/ftbsc/lll/processor/tools/containers/ClassContainer.java
@@ -1,6 +1,7 @@
package ftbsc.lll.processor.tools.containers;
import ftbsc.lll.exceptions.TargetNotFoundException;
+import ftbsc.lll.mapper.tools.data.ClassData;
import ftbsc.lll.processor.annotations.Find;
import ftbsc.lll.processor.annotations.Patch;
import ftbsc.lll.processor.tools.ProcessorOptions;
@@ -20,15 +21,9 @@ import static ftbsc.lll.processor.tools.ASTUtils.*;
*/
public class ClassContainer {
/**
- * The fully-qualified name of the class.
+ * The {@link ClassData} for the class represented by this container.
*/
- public final String fqn;
-
- /**
- * The obfuscated fully-qualified name of the class.
- * If the mapper passed is null, then this will be identical to {@link #fqn}
- */
- public final String fqnObf;
+ public final ClassData data;
/**
* The {@link Element} corresponding to the class.
@@ -84,8 +79,7 @@ public class ClassContainer {
throw new TargetNotFoundException("class", inner);
}
}
- this.fqn = fqnBuilder.toString();
- this.fqnObf = findClassName(this.fqn, options);
+ this.data = getClassData(fqnBuilder.toString(), options.mapper);
this.elem = elem;
}
@@ -131,6 +125,6 @@ public class ClassContainer {
public static ClassContainer findOrFallback(ClassContainer fallback, Patch p, Find f, ProcessorOptions options) {
if(f == null) return ClassContainer.from(p, Patch::value, p.innerName(), options);
ClassContainer cl = ClassContainer.from(f, Find::value, f.innerName(), options);
- return cl.fqn.equals("java.lang.Object") ? fallback : cl;
+ return cl.data.name.equals("java/lang/Object") ? fallback : cl;
}
}
diff --git a/src/main/java/ftbsc/lll/processor/tools/containers/FieldContainer.java b/src/main/java/ftbsc/lll/processor/tools/containers/FieldContainer.java
index 9154193..6ef4741 100644
--- a/src/main/java/ftbsc/lll/processor/tools/containers/FieldContainer.java
+++ b/src/main/java/ftbsc/lll/processor/tools/containers/FieldContainer.java
@@ -2,6 +2,7 @@ package ftbsc.lll.processor.tools.containers;
import ftbsc.lll.exceptions.AmbiguousDefinitionException;
import ftbsc.lll.mapper.tools.MappingUtils;
+import ftbsc.lll.mapper.tools.data.FieldData;
import ftbsc.lll.processor.annotations.Find;
import ftbsc.lll.processor.annotations.Patch;
import ftbsc.lll.processor.tools.ProcessorOptions;
@@ -21,9 +22,9 @@ import static ftbsc.lll.processor.tools.ASTUtils.*;
*/
public class FieldContainer {
/**
- * The name of the field.
+ * The {@link FieldData} for the field represented by this container.
*/
- public final String name;
+ public final FieldData data;
/**
* The descriptor of the field.
@@ -31,12 +32,6 @@ public class FieldContainer {
public final String descriptor;
/**
- * The obfuscated name of the field.
- * If the mapper passed is null, then this will be identical to {@link #name}.
- */
- public final String nameObf;
-
- /**
* The obfuscated descriptor of the field.
* If the mapper passed is null, then this will be identical to {@link #descriptor}.
*/
@@ -67,16 +62,15 @@ public class FieldContainer {
if(descriptor == null)
throw new AmbiguousDefinitionException("Cannot use name-based lookups for fields of unverifiable classes!");
this.elem = null;
- this.name = name;
this.descriptor = descriptor;
} else {
this.elem = (VariableElement) findMember(parent, name, descriptor, descriptor != null, true, options.env);
- this.name = this.elem.getSimpleName().toString();
this.descriptor = descriptorFromType(this.elem.asType(), options.env);
+ name = this.elem.getSimpleName().toString();
}
+ this.data = getFieldData(parent.data.name, name, options.mapper);
this.descriptorObf = options.mapper == null ? this.descriptor
: MappingUtils.mapType(Type.getType(this.descriptor), options.mapper, false).getDescriptor();
- this.nameObf = findMemberName(parent.fqn, this.name, null, options.mapper);
}
/**
@@ -96,7 +90,7 @@ public class FieldContainer {
ClassContainer.from((TypeElement) finder.getEnclosingElement(), options), patchAnn, f, options
);
- String name = f.name().equals("") ? finder.getSimpleName().toString() : f.name();
+ String name = f.name().isEmpty() ? finder.getSimpleName().toString() : f.name();
String descriptor;
TypeMirror fieldType = getTypeFromAnnotation(f, Find::type, options.env);
if(fieldType.toString().equals("java.lang.Object")) {
@@ -106,7 +100,7 @@ public class FieldContainer {
descriptor = //jank af but this is temporary anyway
"L" + ClassContainer.from(
f, Find::type, f.typeInner(), options
- ).fqnObf.replace('.', '/') + ";";
+ ).data.nameMapped + ";";
else descriptor = descriptorFromType(fieldType, options.env);
}
diff --git a/src/main/java/ftbsc/lll/processor/tools/containers/MethodContainer.java b/src/main/java/ftbsc/lll/processor/tools/containers/MethodContainer.java
index 2878ec6..266858d 100644
--- a/src/main/java/ftbsc/lll/processor/tools/containers/MethodContainer.java
+++ b/src/main/java/ftbsc/lll/processor/tools/containers/MethodContainer.java
@@ -3,6 +3,7 @@ package ftbsc.lll.processor.tools.containers;
import ftbsc.lll.exceptions.AmbiguousDefinitionException;
import ftbsc.lll.exceptions.TargetNotFoundException;
import ftbsc.lll.mapper.tools.MappingUtils;
+import ftbsc.lll.mapper.tools.data.MethodData;
import ftbsc.lll.processor.annotations.Find;
import ftbsc.lll.processor.annotations.Patch;
import ftbsc.lll.processor.annotations.Target;
@@ -20,24 +21,14 @@ import static ftbsc.lll.processor.tools.ASTUtils.*;
*/
public class MethodContainer {
/**
- * The name of the method.
+ * The {@link MethodData} for the method represented by this container.
*/
- public final String name;
-
- /**
- * The descriptor of the method.
- */
- public final String descriptor;
-
- /**
- * The obfuscated name of the method.
- * If the mapper passed is null, then this will be identical to {@link #name}.
- */
- public final String nameObf;
+ public final MethodData data;
/**
* The obfuscated descriptor of the field.
- * If the mapper passed is null, then this will be identical to {@link #descriptor}.
+ * If the mapper passed is null, this will be identical to the one inside
+ * {@link #data}.
*/
public final String descriptorObf;
@@ -69,19 +60,17 @@ public class MethodContainer {
if(descriptor == null)
throw new AmbiguousDefinitionException("Cannot use name-based lookups for methods of unverifiable classes!");
this.elem = null;
- this.name = name;
- this.descriptor = descriptor;
} else {
ExecutableElement tmp = (ExecutableElement) findMember(
parent, name, descriptor, descriptor != null && strict,false, options.env
);
this.elem = bridge ? findSyntheticBridge((TypeElement) this.parent.elem, tmp, options.env) : tmp;
- this.name = this.elem.getSimpleName().toString();
- this.descriptor = descriptorFromExecutableElement(this.elem, options.env);
+ name = this.elem.getSimpleName().toString();
+ descriptor = descriptorFromExecutableElement(this.elem, options.env);
}
- this.descriptorObf = options.mapper == null ? this.descriptor
- : MappingUtils.mapMethodDescriptor(this.descriptor, options.mapper, false);
- this.nameObf = findMemberName(parent.fqn, this.name, this.descriptor, options.mapper);
+ this.data = getMethodData(parent.data.name, name, descriptor, options.mapper);
+ this.descriptorObf = options.mapper == null ? this.data.signature.descriptor
+ : MappingUtils.mapMethodDescriptor(this.data.signature.descriptor, options.mapper, false);
}
/**
@@ -101,7 +90,7 @@ public class MethodContainer {
ClassContainer parent = ClassContainer.findOrFallback(
ClassContainer.from((TypeElement) stub.getEnclosingElement(), options), patchAnn, f, options
);
- String name = !t.methodName().equals("")
+ String name = !t.methodName().isEmpty()
? t.methodName() //name was specified in target
: stub.getSimpleName().toString();
String descriptor = t.strict()