Renamed MemberRef inner classes

This commit is contained in:
BenLewis committed 2015-10-14 17:43:57 +13:00
1 parent 2b715538bd
commit b4f06960dc
2 files changed
+20 -22

No files matched your search

@@ -24,7 +24,6 @@
*/
package org.spongepowered.asm.mixin.transformer;
import org.spongepowered.asm.lib.Handle;
import org.spongepowered.asm.lib.Opcodes;
import org.spongepowered.asm.lib.tree.FieldInsnNode;
import org.spongepowered.asm.lib.tree.MethodInsnNode;
@@ -42,7 +41,7 @@ public abstract class MemberRef {
/**
* A static reference to a method backed by an invoke instruction
*/
public static final class StaticMethodRef extends MemberRef {
public static final class Method extends MemberRef {
/**
* Method invocation instruction
@@ -54,7 +53,7 @@ public abstract class MemberRef {
*
* @param insn Method instruction of this member reference
*/
public StaticMethodRef(MethodInsnNode insn) {
public Method(MethodInsnNode insn) {
this.insn = insn;
}
@@ -97,7 +96,7 @@ public abstract class MemberRef {
/**
* A static reference to a field backed by field get/put instruction
*/
public static final class StaticFieldRef extends MemberRef {
public static final class Field extends MemberRef {
/**
* Field accessor instruction
@@ -109,7 +108,7 @@ public abstract class MemberRef {
*
* @param insn Field instruction this member reference
*/
public StaticFieldRef(FieldInsnNode insn) {
public Field(FieldInsnNode insn) {
this.insn = insn;
}
@@ -152,9 +151,9 @@ public abstract class MemberRef {
/**
* A reference to a field or method backed by a method handle
*/
public static final class HandleRef extends MemberRef {
public static final class Handle extends MemberRef {
private Handle handle;
private org.spongepowered.asm.lib.Handle handle;
/**
* Creates a member reference initially referring to the member referred
@@ -163,7 +162,7 @@ public abstract class MemberRef {
*
* @param handle Initial method handle.
*/
public HandleRef(Handle handle) {
public Handle(org.spongepowered.asm.lib.Handle handle) {
this.handle = handle;
}
@@ -172,7 +171,7 @@ public abstract class MemberRef {
*
* @return Method handle representing this object
*/
public Handle getMethodHandle() {
public org.spongepowered.asm.lib.Handle getMethodHandle() {
return this.handle;
}
@@ -227,7 +226,7 @@ public abstract class MemberRef {
@Override
public void setOwner(String owner) {
this.handle = new Handle(this.handle.getTag(), owner, this.handle.getName(), this.handle.getDesc());
this.handle = new org.spongepowered.asm.lib.Handle(this.handle.getTag(), owner, this.handle.getName(), this.handle.getDesc());
}
@Override
@@ -242,7 +241,7 @@ public abstract class MemberRef {
@Override
public void setDesc(String desc) {
this.handle = new Handle(this.handle.getTag(), this.handle.getOwner(), this.handle.getName(), desc);
this.handle = new org.spongepowered.asm.lib.Handle(this.handle.getTag(), this.handle.getOwner(), this.handle.getName(), desc);
}
}
@@ -39,7 +39,6 @@ import org.spongepowered.asm.lib.tree.*;
import org.spongepowered.asm.mixin.SoftOverride;
import org.spongepowered.asm.mixin.injection.struct.ReferenceMapper;
import org.spongepowered.asm.mixin.injection.struct.Target;
import org.spongepowered.asm.mixin.transformer.ClassInfo.Method;
import org.spongepowered.asm.mixin.transformer.ClassInfo.Traversal;
import org.spongepowered.asm.util.ASMHelper;
import org.spongepowered.asm.util.Constants;
@@ -231,9 +230,9 @@ public class MixinTargetContext implements IReferenceMapperContext {
AbstractInsnNode insn = iter.next();
if (insn instanceof MethodInsnNode) {
this.transformMethodRef(method, iter, new MemberRef.StaticMethodRef((MethodInsnNode)insn));
this.transformMethodRef(method, iter, new MemberRef.Method((MethodInsnNode)insn));
} else if (insn instanceof FieldInsnNode) {
this.transformFieldRef(method, iter, new MemberRef.StaticFieldRef((FieldInsnNode)insn));
this.transformFieldRef(method, iter, new MemberRef.Field((FieldInsnNode)insn));
} else if (insn instanceof TypeInsnNode) {
this.transformTypeNode(method, iter, (TypeInsnNode)insn);
} else if (insn instanceof LdcInsnNode) {
@@ -253,7 +252,7 @@ public class MixinTargetContext implements IReferenceMapperContext {
private void validateMethod(MethodNode method) {
// Any method tagged with @SoftOverride must have an implementation visible from
if (ASMHelper.getInvisibleAnnotation(method, SoftOverride.class) != null) {
Method superMethod = this.targetClassInfo.findMethodInHierarchy(method.name, method.desc, false, Traversal.SUPER);
ClassInfo.Method superMethod = this.targetClassInfo.findMethodInHierarchy(method.name, method.desc, false, Traversal.SUPER);
if (superMethod == null || !superMethod.isInjected()) {
throw new InvalidMixinException(this, "Mixin method " + method.name + method.desc + " is tagged with @SoftOverride but no "
+ "valid method was found in superclasses of " + this.targetClass.name);
@@ -295,8 +294,8 @@ public class MixinTargetContext implements IReferenceMapperContext {
*/
private void transformFieldRef(MethodNode method, Iterator<AbstractInsnNode> iter, MemberRef fieldRef) {
if (Constants.IMAGINARY_SUPER.equals(fieldRef.getName())) {
if (fieldRef instanceof MemberRef.StaticFieldRef) {
this.processImaginarySuper(method, ((MemberRef.StaticFieldRef) fieldRef).insn);
if (fieldRef instanceof MemberRef.Field) {
this.processImaginarySuper(method, ((MemberRef.Field) fieldRef).insn);
iter.remove();
} else {
throw new InvalidMixinException(this.mixin, "Cannot call imaginary super from method handle.");
@@ -392,7 +391,7 @@ public class MixinTargetContext implements IReferenceMapperContext {
* @param handle Handle to transform
*/
private Handle transformHandle(MethodNode method, Iterator<AbstractInsnNode> iter, Handle handle) {
MemberRef.HandleRef memberRef = new MemberRef.HandleRef(handle);
MemberRef.Handle memberRef = new MemberRef.Handle(handle);
if (memberRef.isField()) {
this.transformFieldRef(method, iter, memberRef);
} else {
@@ -440,7 +439,7 @@ public class MixinTargetContext implements IReferenceMapperContext {
MethodInsnNode methodNode = (MethodInsnNode)insn;
if (methodNode.owner.equals(this.getClassRef()) && methodNode.name.equals(method.name) && methodNode.desc.equals(method.desc)) {
methodNode.setOpcode(Opcodes.INVOKESPECIAL);
this.updateStaticBinding(method, new MemberRef.StaticMethodRef(methodNode));
this.updateStaticBinding(method, new MemberRef.Method(methodNode));
return;
}
}
@@ -476,8 +475,8 @@ public class MixinTargetContext implements IReferenceMapperContext {
return;
}
Method superMethod = this.targetClassInfo.findMethodInHierarchy(methodRef.getName(), methodRef.getDesc(), traversal == Traversal.ALL,
traversal);
ClassInfo.Method superMethod = this.targetClassInfo.findMethodInHierarchy(methodRef.getName(), methodRef.getDesc(),
traversal == Traversal.ALL, traversal);
if (superMethod != null) {
if (superMethod.getOwner().isMixin()) {
throw new InvalidMixinException(this, "Invalid " + methodRef + " in " + this + " resolved " + superMethod.getOwner()
@@ -719,7 +718,7 @@ public class MixinTargetContext implements IReferenceMapperContext {
}
/**
* Called imediately after the mixin is applied to targetClass
* Called immediately after the mixin is applied to targetClass
*
* @param transformedName Target class's transformed name
* @param targetClass Target class