mirror of
https://github.com/LegacyModdingMC/UniMix.git
synced 2026-11-22 21:19:57 +00:00
Resolve methods references recursively as well as fields, fixes #93
This commit is contained in:
1 parent
ec42236133
commit
a99012eabc
2 files changed
+55
-28
No files matched your search
@@ -627,7 +627,7 @@ class AnnotatedMixin {
|
||||
}
|
||||
|
||||
if (targetMember.isField()) {
|
||||
ObfuscationData<String> obfFieldData = this.getObfFieldRecursive(targetMember);
|
||||
ObfuscationData<String> obfFieldData = this.mixins.getObfFieldRecursive(targetMember);
|
||||
if (obfFieldData.isEmpty()) {
|
||||
this.mixins.printMessage(Kind.WARNING, "Cannot find field mapping for @At(" + key + ") '" + target + "'", element, inject);
|
||||
return false;
|
||||
@@ -645,33 +645,6 @@ class AnnotatedMixin {
|
||||
return true;
|
||||
}
|
||||
|
||||
private ObfuscationData<String> getObfFieldRecursive(MemberInfo targetMember) {
|
||||
ObfuscationData<String> targetNames = this.mixins.getObfClass(targetMember.owner);
|
||||
ObfuscationData<String> obfFieldData = this.mixins.getObfField(targetMember.toSrg());
|
||||
try {
|
||||
while (obfFieldData.isEmpty()) {
|
||||
TypeHandle targetType = this.mixins.getTypeHandle(targetMember.owner);
|
||||
if (targetType == null) {
|
||||
return obfFieldData;
|
||||
}
|
||||
TypeHandle superClass = targetType.getSuperclass();
|
||||
if (superClass == null) {
|
||||
return obfFieldData;
|
||||
}
|
||||
targetMember = targetMember.move(superClass.getName());
|
||||
obfFieldData = this.mixins.getObfField(targetMember.toSrg());
|
||||
if (!obfFieldData.isEmpty()) {
|
||||
for (ObfuscationType type : obfFieldData) {
|
||||
obfFieldData.add(type, MemberInfo.fromSrgField(obfFieldData.get(type), "").move(targetNames.get(type)).toSrg());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
// ???
|
||||
}
|
||||
return obfFieldData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a field mapping to the local table
|
||||
*/
|
||||
|
||||
@@ -300,6 +300,33 @@ class AnnotatedMixins implements Messager, ITokenProvider, IOptionProvider, ITyp
|
||||
return new PrintWriter(outSrg.openWriter());
|
||||
}
|
||||
|
||||
public ObfuscationData<MethodData> getObfMethodRecursive(MemberInfo targetMember) {
|
||||
ObfuscationData<String> targetNames = this.getObfClass(targetMember.owner);
|
||||
ObfuscationData<MethodData> obfMethodData = this.getObfMethod(targetMember.asMethodData());
|
||||
try {
|
||||
while (obfMethodData.isEmpty()) {
|
||||
TypeHandle targetType = this.getTypeHandle(targetMember.owner);
|
||||
if (targetType == null) {
|
||||
return obfMethodData;
|
||||
}
|
||||
TypeHandle superClass = targetType.getSuperclass();
|
||||
if (superClass == null) {
|
||||
return obfMethodData;
|
||||
}
|
||||
targetMember = targetMember.move(superClass.getName());
|
||||
obfMethodData = this.getObfMethod(targetMember.asMethodData());
|
||||
if (!obfMethodData.isEmpty()) {
|
||||
for (ObfuscationType type : obfMethodData) {
|
||||
obfMethodData.add(type, MemberInfo.fromSrgMethod(obfMethodData.get(type)).move(targetNames.get(type)).asMethodData());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
// ???
|
||||
}
|
||||
return obfMethodData;
|
||||
}
|
||||
|
||||
public ObfuscationData<MethodData> getObfMethod(MemberInfo method) {
|
||||
ObfuscationData<MethodData> data = new ObfuscationData<MethodData>();
|
||||
|
||||
@@ -329,6 +356,33 @@ class AnnotatedMixins implements Messager, ITokenProvider, IOptionProvider, ITyp
|
||||
return data;
|
||||
}
|
||||
|
||||
public ObfuscationData<String> getObfFieldRecursive(MemberInfo targetMember) {
|
||||
ObfuscationData<String> targetNames = this.getObfClass(targetMember.owner);
|
||||
ObfuscationData<String> obfFieldData = this.getObfField(targetMember.toSrg());
|
||||
try {
|
||||
while (obfFieldData.isEmpty()) {
|
||||
TypeHandle targetType = this.getTypeHandle(targetMember.owner);
|
||||
if (targetType == null) {
|
||||
return obfFieldData;
|
||||
}
|
||||
TypeHandle superClass = targetType.getSuperclass();
|
||||
if (superClass == null) {
|
||||
return obfFieldData;
|
||||
}
|
||||
targetMember = targetMember.move(superClass.getName());
|
||||
obfFieldData = this.getObfField(targetMember.toSrg());
|
||||
if (!obfFieldData.isEmpty()) {
|
||||
for (ObfuscationType type : obfFieldData) {
|
||||
obfFieldData.add(type, MemberInfo.fromSrgField(obfFieldData.get(type), "").move(targetNames.get(type)).toSrg());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
// ???
|
||||
}
|
||||
return obfFieldData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an obfuscation mapping for a field
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user