Rename MethodData to more meaningful SrgMethod

This commit is contained in:
Mumfrey committed 2016-01-26 13:47:35 +00:00
1 parent 5afccbd4dd
commit 204a10c64d
10 files changed
+69 -69

No files matched your search

@@ -29,7 +29,7 @@ import org.spongepowered.asm.lib.tree.AbstractInsnNode;
import org.spongepowered.asm.lib.tree.FieldInsnNode;
import org.spongepowered.asm.lib.tree.MethodInsnNode;
import org.spongepowered.asm.mixin.transformer.IReferenceMapperContext;
import org.spongepowered.asm.obfuscation.MethodData;
import org.spongepowered.asm.obfuscation.SrgMethod;
import org.spongepowered.asm.util.SignaturePrinter;
/**
@@ -163,26 +163,26 @@ public class MemberInfo {
}
/**
* Initialise a MemberInfo using the supplied MethodData object
* Initialise a MemberInfo using the supplied SrgMethod object
*
* @param methodData MethodData object to copy values from
* @param srgMethod SrgMethod object to copy values from
*/
public MemberInfo(MethodData methodData) {
this.owner = methodData.getOwner();
this.name = methodData.getSimpleName();
this.desc = methodData.getDesc();
public MemberInfo(SrgMethod srgMethod) {
this.owner = srgMethod.getOwner();
this.name = srgMethod.getSimpleName();
this.desc = srgMethod.getDesc();
this.matchAll = false;
}
/**
* Initialise a remapped MemberInfo using the supplied MethodData object
* Initialise a remapped MemberInfo using the supplied SrgMethod object
*
* @param methodData MethodData object to copy values from
* @param srgMethod SrgMethod object to copy values from
*/
private MemberInfo(MemberInfo remapped, MethodData methodData, boolean setOwner) {
this.owner = setOwner ? methodData.getOwner() : remapped.owner;
this.name = methodData.getSimpleName();
this.desc = methodData.getDesc();
private MemberInfo(MemberInfo remapped, SrgMethod srgMethod, boolean setOwner) {
this.owner = setOwner ? srgMethod.getOwner() : remapped.owner;
this.name = srgMethod.getSimpleName();
this.desc = srgMethod.getDesc();
this.matchAll = remapped.matchAll;
}
@@ -237,16 +237,16 @@ public class MemberInfo {
return new SignaturePrinter(this).setFullyQualified(true).toDescriptor();
}
public MethodData asMethodData() {
public SrgMethod asSrgMethod() {
if (!this.isFullyQualified()) {
throw new RuntimeException("Cannot convert unqualified reference to MethodData");
throw new RuntimeException("Cannot convert unqualified reference to SrgMethod");
}
if (this.isField()) {
throw new RuntimeException("Cannot convert a non-method reference to MethodData");
throw new RuntimeException("Cannot convert a non-method reference to SrgMethod");
}
return new MethodData(this.owner + "/" + this.name, this.desc);
return new SrgMethod(this.owner + "/" + this.name, this.desc);
}
/**
@@ -410,12 +410,12 @@ public class MemberInfo {
/**
* Create a remapped version of this member using the supplied method data
*
* @param methodData Method data to use
* @param srgMethod SRG method data to use
* @param setOwner True to set the owner as well as the name
* @return New MethodInfo with remapped values
*/
public MemberInfo remapUsing(MethodData methodData, boolean setOwner) {
return new MemberInfo(this, methodData, setOwner);
public MemberInfo remapUsing(SrgMethod srgMethod, boolean setOwner) {
return new MemberInfo(this, srgMethod, setOwner);
}
/**
@@ -517,7 +517,7 @@ public class MemberInfo {
return new MemberInfo(name, owner, desc, false);
}
public static MemberInfo fromSrgMethod(MethodData methodData) {
return new MemberInfo(methodData);
public static MemberInfo fromSrgMethod(SrgMethod srgMethod) {
return new MemberInfo(srgMethod);
}
}
@@ -44,7 +44,7 @@ public class SrgContainer {
private final BiMap<String, String> classMap = HashBiMap.create();
private final BiMap<String, String> fieldMap = HashBiMap.create();
private final BiMap<String, String> packageMap = HashBiMap.create();
private final BiMap<MethodData, MethodData> methodMap = HashBiMap.create();
private final BiMap<SrgMethod, SrgMethod> methodMap = HashBiMap.create();
public void readSrg(File srg) throws IOException {
for (String line : Files.readLines(srg, Charset.defaultCharset())) {
@@ -62,14 +62,14 @@ public class SrgContainer {
} else if (type.equals("FD")) {
this.fieldMap.forcePut(args[0], args[1]);
} else if (type.equals("MD")) {
this.methodMap.forcePut(new MethodData(args[0], args[1]), new MethodData(args[2], args[3]));
this.methodMap.forcePut(new SrgMethod(args[0], args[1]), new SrgMethod(args[2], args[3]));
} else {
throw new RuntimeException("Invalid SRG file: " + srg);
}
}
}
public MethodData getMethodMapping(MethodData methodName) {
public SrgMethod getMethodMapping(SrgMethod methodName) {
return this.methodMap.get(methodName);
}
@@ -26,14 +26,14 @@ package org.spongepowered.asm.obfuscation;
import com.google.common.base.Objects;
public final class MethodData {
public final class SrgMethod {
private final String name;
private final String desc;
public MethodData(String name, String sig) {
public SrgMethod(String name, String desc) {
this.name = name;
this.desc = sig;
this.desc = desc;
}
public String getName() {
@@ -70,8 +70,8 @@ public final class MethodData {
if (this == obj) {
return true;
}
if (obj instanceof MethodData) {
return Objects.equal(this.name, ((MethodData)obj).name) && Objects.equal(this.desc, ((MethodData)obj).desc);
if (obj instanceof SrgMethod) {
return Objects.equal(this.name, ((SrgMethod)obj).name) && Objects.equal(this.desc, ((SrgMethod)obj).desc);
}
return false;
}