mirror of
https://github.com/LegacyModdingMC/UniMix.git
synced 2026-11-20 12:19:52 +00:00
Refactoring - ASMHelper -> Bytecode
This commit is contained in:
1 parent
c30a17e872
commit
8917cccf28
23 files changed
+122
-122
No files matched your search
@@ -30,7 +30,7 @@ import org.spongepowered.asm.lib.tree.InsnNode;
|
||||
import org.spongepowered.asm.lib.tree.MethodInsnNode;
|
||||
import org.spongepowered.asm.lib.tree.MethodNode;
|
||||
import org.spongepowered.asm.lib.tree.VarInsnNode;
|
||||
import org.spongepowered.asm.util.ASMHelper;
|
||||
import org.spongepowered.asm.util.Bytecode;
|
||||
|
||||
/**
|
||||
* Generator for proxy methods
|
||||
@@ -62,18 +62,18 @@ public class AccessorGeneratorMethodProxy extends AccessorGenerator {
|
||||
this.targetMethod = info.getTargetMethod();
|
||||
this.argTypes = info.getArgTypes();
|
||||
this.returnType = info.getReturnType();
|
||||
this.isInstanceMethod = !ASMHelper.hasFlag(this.targetMethod, Opcodes.ACC_STATIC);
|
||||
this.isInstanceMethod = !Bytecode.hasFlag(this.targetMethod, Opcodes.ACC_STATIC);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MethodNode generate() {
|
||||
int size = ASMHelper.getArgsSize(this.argTypes) + this.returnType.getSize();
|
||||
int size = Bytecode.getArgsSize(this.argTypes) + this.returnType.getSize();
|
||||
MethodNode method = this.createMethod(size, size);
|
||||
if (this.isInstanceMethod) {
|
||||
method.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0));
|
||||
}
|
||||
ASMHelper.loadArgs(this.argTypes, method.instructions, this.isInstanceMethod ? 1 : 0);
|
||||
boolean isPrivate = ASMHelper.hasFlag(this.targetMethod, Opcodes.ACC_PRIVATE);
|
||||
Bytecode.loadArgs(this.argTypes, method.instructions, this.isInstanceMethod ? 1 : 0);
|
||||
boolean isPrivate = Bytecode.hasFlag(this.targetMethod, Opcodes.ACC_PRIVATE);
|
||||
int opcode = this.isInstanceMethod ? (isPrivate ? Opcodes.INVOKESPECIAL : Opcodes.INVOKEVIRTUAL) : Opcodes.INVOKESTATIC;
|
||||
method.instructions.add(new MethodInsnNode(opcode, this.info.getClassNode().name, this.targetMethod.name, this.targetMethod.desc, false));
|
||||
method.instructions.add(new InsnNode(this.returnType.getOpcode(Opcodes.IRETURN)));
|
||||
|
||||
@@ -41,7 +41,7 @@ import org.spongepowered.asm.mixin.injection.struct.MemberInfo;
|
||||
import org.spongepowered.asm.mixin.refmap.IMixinContext;
|
||||
import org.spongepowered.asm.mixin.struct.SpecialMethodInfo;
|
||||
import org.spongepowered.asm.mixin.transformer.MixinTargetContext;
|
||||
import org.spongepowered.asm.util.ASMHelper;
|
||||
import org.spongepowered.asm.util.Bytecode;
|
||||
import org.spongepowered.asm.util.Annotations;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
@@ -308,7 +308,7 @@ public class AccessorInfo extends SpecialMethodInfo {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s->@%s[%s]::%s%s", this.mixin.toString(), ASMHelper.getSimpleName(this.annotation), this.type.toString(),
|
||||
return String.format("%s->@%s[%s]::%s%s", this.mixin.toString(), Bytecode.getSimpleName(this.annotation), this.type.toString(),
|
||||
this.method.name, this.method.desc);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ import java.util.Map;
|
||||
|
||||
import org.spongepowered.asm.lib.tree.AbstractInsnNode;
|
||||
import org.spongepowered.asm.mixin.injection.struct.Target;
|
||||
import org.spongepowered.asm.util.ASMHelper;
|
||||
import org.spongepowered.asm.util.Bytecode;
|
||||
|
||||
/**
|
||||
* Used to keep track of instruction nodes in a {@link Target} method which are
|
||||
@@ -188,7 +188,7 @@ public class InjectionNodes extends ArrayList<InjectionNodes.InjectionNode> {
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("InjectionNode[%s]", ASMHelper.describeNode(this.currentTarget).replaceAll("\\s+", " "));
|
||||
return String.format("InjectionNode[%s]", Bytecode.describeNode(this.currentTarget).replaceAll("\\s+", " "));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ import org.spongepowered.asm.mixin.injection.struct.InjectionInfo;
|
||||
import org.spongepowered.asm.mixin.injection.struct.Target;
|
||||
import org.spongepowered.asm.mixin.injection.throwables.InjectionError;
|
||||
import org.spongepowered.asm.mixin.injection.throwables.InvalidInjectionException;
|
||||
import org.spongepowered.asm.util.ASMHelper;
|
||||
import org.spongepowered.asm.util.Bytecode;
|
||||
import org.spongepowered.asm.util.Annotations;
|
||||
import org.spongepowered.asm.util.Constants;
|
||||
import org.spongepowered.asm.util.Locals;
|
||||
@@ -156,7 +156,7 @@ public class CallbackInjector extends Injector {
|
||||
this.node = node.getCurrentTarget();
|
||||
this.locals = locals;
|
||||
this.localTypes = locals != null ? new Type[locals.length] : null;
|
||||
this.frameSize = ASMHelper.getFirstNonArgLocalIndex(target.arguments, !CallbackInjector.this.isStatic());
|
||||
this.frameSize = Bytecode.getFirstNonArgLocalIndex(target.arguments, !CallbackInjector.this.isStatic());
|
||||
List<String> argNames = null;
|
||||
|
||||
if (locals != null) {
|
||||
@@ -176,7 +176,7 @@ public class CallbackInjector extends Injector {
|
||||
}
|
||||
|
||||
// Calc number of args for the handler method, additional 1 is to ignore the CallbackInfo arg
|
||||
this.extraArgs = Math.max(0, ASMHelper.getFirstNonArgLocalIndex(this.handler) - (this.frameSize + 1));
|
||||
this.extraArgs = Math.max(0, Bytecode.getFirstNonArgLocalIndex(this.handler) - (this.frameSize + 1));
|
||||
this.argNames = argNames != null ? argNames.toArray(new String[argNames.size()]) : null;
|
||||
this.canCaptureLocals = captureLocals && locals != null && locals.length > this.frameSize;
|
||||
this.isAtReturn = this.node instanceof InsnNode && this.isValueReturnOpcode(this.node.getOpcode());
|
||||
@@ -318,7 +318,7 @@ public class CallbackInjector extends Injector {
|
||||
protected void sanityCheck(Target target, List<InjectionPoint> injectionPoints) {
|
||||
super.sanityCheck(target, injectionPoints);
|
||||
|
||||
if (ASMHelper.methodIsStatic(target.method) != this.isStatic) {
|
||||
if (Bytecode.methodIsStatic(target.method) != this.isStatic) {
|
||||
throw new InvalidInjectionException(this.info, "'static' modifier of callback method does not match target in " + this);
|
||||
}
|
||||
|
||||
@@ -376,7 +376,7 @@ public class CallbackInjector extends Injector {
|
||||
// signature for the current locals. This allows silent failover
|
||||
// if changes to the local variable table are EXPECTED for some
|
||||
// reason.
|
||||
MethodNode surrogateHandler = ASMHelper.findMethod(this.classNode, this.methodNode.name, callback.getDescriptor());
|
||||
MethodNode surrogateHandler = Bytecode.findMethod(this.classNode, this.methodNode.name, callback.getDescriptor());
|
||||
if (surrogateHandler != null && Annotations.getVisible(surrogateHandler, Surrogate.class) != null) {
|
||||
// Found a matching method, use it
|
||||
callbackMethod = surrogateHandler;
|
||||
@@ -409,7 +409,7 @@ public class CallbackInjector extends Injector {
|
||||
throw new InvalidInjectionException(this.info, "Invalid descriptor on " + this.info + "! CallbackInfoReturnable is required!");
|
||||
}
|
||||
|
||||
MethodNode surrogateHandler = ASMHelper.findMethod(this.classNode, this.methodNode.name, callback.getDescriptor());
|
||||
MethodNode surrogateHandler = Bytecode.findMethod(this.classNode, this.methodNode.name, callback.getDescriptor());
|
||||
if (surrogateHandler != null && Annotations.getVisible(surrogateHandler, Surrogate.class) != null) {
|
||||
// Found a matching surrogate method, use it
|
||||
callbackMethod = surrogateHandler;
|
||||
@@ -456,7 +456,7 @@ public class CallbackInjector extends Injector {
|
||||
*/
|
||||
private MethodNode generateErrorMethod(Callback callback, String errorClass, String message) {
|
||||
MethodNode method = this.info.addMethod(this.methodNode.access, this.methodNode.name + "$missing", callback.getDescriptor());
|
||||
method.maxLocals = ASMHelper.getFirstNonArgLocalIndex(Type.getArgumentTypes(callback.getDescriptor()), !this.isStatic);
|
||||
method.maxLocals = Bytecode.getFirstNonArgLocalIndex(Type.getArgumentTypes(callback.getDescriptor()), !this.isStatic);
|
||||
method.maxStack = 3;
|
||||
InsnList insns = method.instructions;
|
||||
insns.add(new TypeInsnNode(Opcodes.NEW, errorClass));
|
||||
@@ -484,7 +484,7 @@ public class CallbackInjector extends Injector {
|
||||
printer.kv("Target Max LOCALS", callback.target.getMaxLocals());
|
||||
printer.kv("Initial Frame Size", callback.frameSize);
|
||||
printer.kv("Callback Name", this.methodNode.name);
|
||||
printer.kv("Instruction", "%s %s", callback.node.getClass().getSimpleName(), ASMHelper.getOpcodeName(callback.node.getOpcode()));
|
||||
printer.kv("Instruction", "%s %s", callback.node.getClass().getSimpleName(), Bytecode.getOpcodeName(callback.node.getOpcode()));
|
||||
printer.hr();
|
||||
if (callback.locals.length > callback.frameSize) {
|
||||
printer.add(" %s %20s %s", "LOCAL", "TYPE", "NAME");
|
||||
@@ -577,7 +577,7 @@ public class CallbackInjector extends Injector {
|
||||
|
||||
// Push the target method's parameters onto the stack
|
||||
if (callback.captureArgs()) {
|
||||
ASMHelper.loadArgs(callback.target.arguments, callback, this.isStatic ? 0 : 1);
|
||||
Bytecode.loadArgs(callback.target.arguments, callback, this.isStatic ? 0 : 1);
|
||||
}
|
||||
|
||||
// Push the callback info onto the stack
|
||||
|
||||
@@ -50,7 +50,7 @@ import org.spongepowered.asm.mixin.injection.InjectionPoint;
|
||||
import org.spongepowered.asm.mixin.injection.struct.InjectionInfo;
|
||||
import org.spongepowered.asm.mixin.injection.struct.Target;
|
||||
import org.spongepowered.asm.mixin.injection.throwables.InvalidInjectionException;
|
||||
import org.spongepowered.asm.util.ASMHelper;
|
||||
import org.spongepowered.asm.util.Bytecode;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
|
||||
@@ -129,7 +129,7 @@ public abstract class Injector {
|
||||
this.methodNode = methodNode;
|
||||
this.methodArgs = Type.getArgumentTypes(this.methodNode.desc);
|
||||
this.returnType = Type.getReturnType(this.methodNode.desc);
|
||||
this.isStatic = ASMHelper.methodIsStatic(this.methodNode);
|
||||
this.isStatic = Bytecode.methodIsStatic(this.methodNode);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -39,7 +39,7 @@ import org.spongepowered.asm.mixin.injection.InjectionPoint.Selector;
|
||||
import org.spongepowered.asm.mixin.injection.Slice;
|
||||
import org.spongepowered.asm.mixin.injection.throwables.InjectionError;
|
||||
import org.spongepowered.asm.mixin.injection.throwables.InvalidSliceException;
|
||||
import org.spongepowered.asm.util.ASMHelper;
|
||||
import org.spongepowered.asm.util.Bytecode;
|
||||
import org.spongepowered.asm.util.Annotations;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
@@ -419,7 +419,7 @@ public final class MethodSlice {
|
||||
}
|
||||
|
||||
private static String describeSlice(String description, ISliceContext owner) {
|
||||
String annotation = ASMHelper.getSimpleName(owner.getAnnotation());
|
||||
String annotation = Bytecode.getSimpleName(owner.getAnnotation());
|
||||
MethodNode method = owner.getMethod();
|
||||
return String.format("%s->%s(%s)::%s%s", owner.getContext(), annotation, description, method.name, method.desc);
|
||||
}
|
||||
|
||||
+6
-6
@@ -35,7 +35,7 @@ import org.spongepowered.asm.mixin.injection.InjectionNodes.InjectionNode;
|
||||
import org.spongepowered.asm.mixin.injection.struct.InjectionInfo;
|
||||
import org.spongepowered.asm.mixin.injection.struct.Target;
|
||||
import org.spongepowered.asm.mixin.injection.throwables.InvalidInjectionException;
|
||||
import org.spongepowered.asm.util.ASMHelper;
|
||||
import org.spongepowered.asm.util.Bytecode;
|
||||
|
||||
/**
|
||||
* A bytecode injector which allows a specific
|
||||
@@ -71,7 +71,7 @@ public class ModifyConstantInjector extends RedirectInjector {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ASMHelper.isConstant(targetNode)) {
|
||||
if (Bytecode.isConstant(targetNode)) {
|
||||
this.injectConstantModifier(target, targetNode);
|
||||
return;
|
||||
}
|
||||
@@ -90,7 +90,7 @@ public class ModifyConstantInjector extends RedirectInjector {
|
||||
int opcode = jumpNode.getOpcode();
|
||||
if (opcode < Opcodes.IFLT || opcode > Opcodes.IFLE) {
|
||||
throw new InvalidInjectionException(this.info, this.annotationType + " annotation selected an invalid opcode "
|
||||
+ ASMHelper.getOpcodeName(opcode) + " in " + target + " in " + this);
|
||||
+ Bytecode.getOpcodeName(opcode) + " in " + target + " in " + this);
|
||||
}
|
||||
|
||||
final InsnList insns = new InsnList();
|
||||
@@ -102,7 +102,7 @@ public class ModifyConstantInjector extends RedirectInjector {
|
||||
}
|
||||
|
||||
private void injectConstantModifier(Target target, AbstractInsnNode constNode) {
|
||||
final Type constantType = ASMHelper.getConstantType(constNode);
|
||||
final Type constantType = Bytecode.getConstantType(constNode);
|
||||
final InsnList before = new InsnList();
|
||||
final InsnList after = new InsnList();
|
||||
AbstractInsnNode invoke = this.invokeConstantHandler(constantType, target, before, after);
|
||||
@@ -110,7 +110,7 @@ public class ModifyConstantInjector extends RedirectInjector {
|
||||
}
|
||||
|
||||
private AbstractInsnNode invokeConstantHandler(Type constantType, Target target, InsnList before, InsnList after) {
|
||||
final String handlerDesc = ASMHelper.generateDescriptor(constantType, constantType);
|
||||
final String handlerDesc = Bytecode.generateDescriptor(constantType, constantType);
|
||||
final boolean withArgs = this.checkDescriptor(handlerDesc, target, "getter");
|
||||
|
||||
if (!this.isStatic) {
|
||||
@@ -120,7 +120,7 @@ public class ModifyConstantInjector extends RedirectInjector {
|
||||
|
||||
if (withArgs) {
|
||||
this.pushArgs(target.arguments, after, target.argIndices, 0, target.arguments.length);
|
||||
target.addToStack(ASMHelper.getArgsSize(target.arguments));
|
||||
target.addToStack(Bytecode.getArgsSize(target.arguments));
|
||||
}
|
||||
|
||||
return this.invokeHandler(after);
|
||||
|
||||
@@ -51,7 +51,7 @@ import org.spongepowered.asm.mixin.injection.points.BeforeNew;
|
||||
import org.spongepowered.asm.mixin.injection.struct.InjectionInfo;
|
||||
import org.spongepowered.asm.mixin.injection.struct.Target;
|
||||
import org.spongepowered.asm.mixin.injection.throwables.InvalidInjectionException;
|
||||
import org.spongepowered.asm.util.ASMHelper;
|
||||
import org.spongepowered.asm.util.Bytecode;
|
||||
import org.spongepowered.asm.util.Annotations;
|
||||
import org.spongepowered.asm.util.Constants;
|
||||
|
||||
@@ -297,11 +297,11 @@ public class RedirectInjector extends InvokeInjector {
|
||||
}
|
||||
|
||||
InsnList insns = new InsnList();
|
||||
int extraLocals = ASMHelper.getArgsSize(stackVars) + 1;
|
||||
int extraLocals = Bytecode.getArgsSize(stackVars) + 1;
|
||||
int extraStack = 1; // Normally only need 1 extra stack pos to store target ref
|
||||
int[] argMap = this.storeArgs(target, stackVars, insns, 0);
|
||||
if (injectTargetParams) {
|
||||
int argSize = ASMHelper.getArgsSize(target.arguments);
|
||||
int argSize = Bytecode.getArgsSize(target.arguments);
|
||||
extraLocals += argSize;
|
||||
extraStack += argSize;
|
||||
argMap = Ints.concat(argMap, target.argIndices);
|
||||
@@ -340,7 +340,7 @@ public class RedirectInjector extends InvokeInjector {
|
||||
private void injectAtArrayField(Target target, FieldInsnNode fieldNode, int opCode, Type ownerType, Type fieldType, int fuzz) {
|
||||
Type elementType = fieldType.getElementType();
|
||||
if (opCode != Opcodes.GETSTATIC && opCode != Opcodes.GETFIELD) {
|
||||
throw new InvalidInjectionException(this.info, "Unspported opcode " + ASMHelper.getOpcodeName(opCode) + " for array access " + this.info);
|
||||
throw new InvalidInjectionException(this.info, "Unspported opcode " + Bytecode.getOpcodeName(opCode) + " for array access " + this.info);
|
||||
} else if (this.returnType.getSort() != Type.VOID) {
|
||||
AbstractInsnNode varNode = BeforeFieldAccess.findArrayNode(target.insns, fieldNode, elementType.getOpcode(Opcodes.IALOAD), fuzz);
|
||||
this.injectAtGetArray(target, fieldNode, varNode, ownerType, fieldType);
|
||||
@@ -354,7 +354,7 @@ public class RedirectInjector extends InvokeInjector {
|
||||
* Array element read (xALOAD)
|
||||
*/
|
||||
private void injectAtGetArray(Target target, FieldInsnNode fieldNode, AbstractInsnNode varNode, Type ownerType, Type fieldType) {
|
||||
String handlerDesc = ASMHelper.generateDescriptor(this.returnType, (Object[])RedirectInjector.getArrayArgs(fieldType));
|
||||
String handlerDesc = Bytecode.generateDescriptor(this.returnType, (Object[])RedirectInjector.getArrayArgs(fieldType));
|
||||
boolean withArgs = this.checkDescriptor(handlerDesc, target, "array getter");
|
||||
this.injectArrayRedirect(target, fieldNode, varNode, withArgs);
|
||||
}
|
||||
@@ -363,7 +363,7 @@ public class RedirectInjector extends InvokeInjector {
|
||||
* Array element write (xASTORE)
|
||||
*/
|
||||
private void injectAtSetArray(Target target, FieldInsnNode fieldNode, AbstractInsnNode varNode, Type ownerType, Type fieldType) {
|
||||
String handlerDesc = ASMHelper.generateDescriptor(null, (Object[])RedirectInjector.getArrayArgs(fieldType, fieldType.getElementType()));
|
||||
String handlerDesc = Bytecode.generateDescriptor(null, (Object[])RedirectInjector.getArrayArgs(fieldType, fieldType.getElementType()));
|
||||
boolean withArgs = this.checkDescriptor(handlerDesc, target, "array setter");
|
||||
this.injectArrayRedirect(target, fieldNode, varNode, withArgs);
|
||||
}
|
||||
@@ -389,7 +389,7 @@ public class RedirectInjector extends InvokeInjector {
|
||||
InsnList invokeInsns = new InsnList();
|
||||
if (withArgs) {
|
||||
this.pushArgs(target.arguments, invokeInsns, target.argIndices, 0, target.arguments.length);
|
||||
target.addToStack(ASMHelper.getArgsSize(target.arguments));
|
||||
target.addToStack(Bytecode.getArgsSize(target.arguments));
|
||||
}
|
||||
target.replaceNode(varNode, this.invokeHandler(invokeInsns), invokeInsns);
|
||||
}
|
||||
@@ -411,7 +411,7 @@ public class RedirectInjector extends InvokeInjector {
|
||||
} else if (opCode == Opcodes.PUTSTATIC || opCode == Opcodes.PUTFIELD) {
|
||||
invoke = this.injectAtPutField(insns, target, fieldNode, opCode == Opcodes.PUTSTATIC, ownerType, fieldType);
|
||||
} else {
|
||||
throw new InvalidInjectionException(this.info, "Unspported opcode " + ASMHelper.getOpcodeName(opCode) + " for " + this.info);
|
||||
throw new InvalidInjectionException(this.info, "Unspported opcode " + Bytecode.getOpcodeName(opCode) + " for " + this.info);
|
||||
}
|
||||
|
||||
target.replaceNode(fieldNode, invoke, insns);
|
||||
@@ -424,7 +424,7 @@ public class RedirectInjector extends InvokeInjector {
|
||||
* handler and the field itself.
|
||||
*/
|
||||
private AbstractInsnNode injectAtGetField(InsnList insns, Target target, FieldInsnNode node, boolean staticField, Type owner, Type fieldType) {
|
||||
final String handlerDesc = staticField ? ASMHelper.generateDescriptor(fieldType) : ASMHelper.generateDescriptor(fieldType, owner);
|
||||
final String handlerDesc = staticField ? Bytecode.generateDescriptor(fieldType) : Bytecode.generateDescriptor(fieldType, owner);
|
||||
final boolean withArgs = this.checkDescriptor(handlerDesc, target, "getter");
|
||||
|
||||
if (!this.isStatic) {
|
||||
@@ -436,7 +436,7 @@ public class RedirectInjector extends InvokeInjector {
|
||||
|
||||
if (withArgs) {
|
||||
this.pushArgs(target.arguments, insns, target.argIndices, 0, target.arguments.length);
|
||||
target.addToStack(ASMHelper.getArgsSize(target.arguments));
|
||||
target.addToStack(Bytecode.getArgsSize(target.arguments));
|
||||
}
|
||||
|
||||
target.addToStack(this.isStatic ? 0 : 1);
|
||||
@@ -450,7 +450,7 @@ public class RedirectInjector extends InvokeInjector {
|
||||
* handler and the field itself.
|
||||
*/
|
||||
private AbstractInsnNode injectAtPutField(InsnList insns, Target target, FieldInsnNode node, boolean staticField, Type owner, Type fieldType) {
|
||||
String handlerDesc = staticField ? ASMHelper.generateDescriptor(null, fieldType) : ASMHelper.generateDescriptor(null, owner, fieldType);
|
||||
String handlerDesc = staticField ? Bytecode.generateDescriptor(null, fieldType) : Bytecode.generateDescriptor(null, owner, fieldType);
|
||||
boolean withArgs = this.checkDescriptor(handlerDesc, target, "setter");
|
||||
|
||||
if (!this.isStatic) {
|
||||
@@ -468,7 +468,7 @@ public class RedirectInjector extends InvokeInjector {
|
||||
|
||||
if (withArgs) {
|
||||
this.pushArgs(target.arguments, insns, target.argIndices, 0, target.arguments.length);
|
||||
target.addToStack(ASMHelper.getArgsSize(target.arguments));
|
||||
target.addToStack(Bytecode.getArgsSize(target.arguments));
|
||||
}
|
||||
|
||||
target.addToStack(!this.isStatic && !staticField ? 1 : 0);
|
||||
@@ -541,7 +541,7 @@ public class RedirectInjector extends InvokeInjector {
|
||||
InsnList insns = new InsnList();
|
||||
if (withArgs) {
|
||||
this.pushArgs(target.arguments, insns, target.argIndices, 0, target.arguments.length);
|
||||
target.addToStack(ASMHelper.getArgsSize(target.arguments));
|
||||
target.addToStack(Bytecode.getArgsSize(target.arguments));
|
||||
}
|
||||
|
||||
this.invokeHandler(insns);
|
||||
|
||||
+2
-2
@@ -37,7 +37,7 @@ import org.spongepowered.asm.lib.tree.AnnotationNode;
|
||||
import org.spongepowered.asm.lib.tree.LocalVariableNode;
|
||||
import org.spongepowered.asm.mixin.injection.modify.LocalVariableDiscriminator.Context.Local;
|
||||
import org.spongepowered.asm.mixin.injection.struct.Target;
|
||||
import org.spongepowered.asm.util.ASMHelper;
|
||||
import org.spongepowered.asm.util.Bytecode;
|
||||
import org.spongepowered.asm.util.Annotations;
|
||||
import org.spongepowered.asm.util.Locals;
|
||||
import org.spongepowered.asm.util.PrettyPrinter;
|
||||
@@ -122,7 +122,7 @@ public class LocalVariableDiscriminator {
|
||||
private final boolean isStatic;
|
||||
|
||||
public Context(Type returnType, boolean argsOnly, Target target, AbstractInsnNode node) {
|
||||
this.isStatic = ASMHelper.methodIsStatic(target.method);
|
||||
this.isStatic = Bytecode.methodIsStatic(target.method);
|
||||
this.returnType = returnType;
|
||||
this.target = target;
|
||||
this.node = node;
|
||||
|
||||
+2
-2
@@ -41,7 +41,7 @@ import org.spongepowered.asm.mixin.injection.struct.InjectionInfo;
|
||||
import org.spongepowered.asm.mixin.injection.struct.Target;
|
||||
import org.spongepowered.asm.mixin.injection.throwables.InvalidInjectionException;
|
||||
import org.spongepowered.asm.mixin.refmap.IMixinContext;
|
||||
import org.spongepowered.asm.util.ASMHelper;
|
||||
import org.spongepowered.asm.util.Bytecode;
|
||||
import org.spongepowered.asm.util.PrettyPrinter;
|
||||
import org.spongepowered.asm.util.SignaturePrinter;
|
||||
|
||||
@@ -182,7 +182,7 @@ public class ModifyVariableInjector extends Injector {
|
||||
.kv("Target Method", context.target.method.name)
|
||||
.kv("Callback Name", this.methodNode.name)
|
||||
.kv("Capture Type", SignaturePrinter.getTypeName(this.returnType, false))
|
||||
.kv("Instruction", "%s %s", context.node.getClass().getSimpleName(), ASMHelper.getOpcodeName(context.node.getOpcode())).hr()
|
||||
.kv("Instruction", "%s %s", context.node.getClass().getSimpleName(), Bytecode.getOpcodeName(context.node.getOpcode())).hr()
|
||||
.kv("Match mode", this.discriminator.isImplicit(context) ? "IMPLICIT (match single)" : "EXPLICIT (match by criteria)")
|
||||
.kv("Match ordinal", this.discriminator.getOrdinal() < 0 ? "any" : this.discriminator.getOrdinal())
|
||||
.kv("Match index", this.discriminator.getIndex() < context.baseArgIndex ? "any" : this.discriminator.getIndex())
|
||||
|
||||
@@ -37,7 +37,7 @@ import org.spongepowered.asm.mixin.injection.InjectionPoint.AtCode;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.struct.InjectionPointData;
|
||||
import org.spongepowered.asm.mixin.injection.struct.MemberInfo;
|
||||
import org.spongepowered.asm.util.ASMHelper;
|
||||
import org.spongepowered.asm.util.Bytecode;
|
||||
|
||||
/**
|
||||
* <p>This injection point searches for GETFIELD and PUTFIELD (and static
|
||||
@@ -143,7 +143,7 @@ public class BeforeFieldAccess extends BeforeInvoke {
|
||||
if (this.arrOpcode > 0) {
|
||||
FieldInsnNode fieldInsn = (FieldInsnNode)insn;
|
||||
int accOpcode = Type.getType(fieldInsn.desc).getElementType().getOpcode(this.arrOpcode);
|
||||
this.log("{} > > > > searching for array access opcode {} fuzz={}", this.className, ASMHelper.getOpcodeName(accOpcode), this.fuzzFactor);
|
||||
this.log("{} > > > > searching for array access opcode {} fuzz={}", this.className, Bytecode.getOpcodeName(accOpcode), this.fuzzFactor);
|
||||
|
||||
if (BeforeFieldAccess.findArrayNode(insns, fieldInsn, accOpcode, this.fuzzFactor) == null) {
|
||||
this.log("{} > > > > > failed to locate matching insn", this.className);
|
||||
|
||||
@@ -60,7 +60,7 @@ import org.spongepowered.asm.mixin.struct.SpecialMethodInfo;
|
||||
import org.spongepowered.asm.mixin.transformer.MixinTargetContext;
|
||||
import org.spongepowered.asm.mixin.transformer.meta.MixinMerged;
|
||||
import org.spongepowered.asm.mixin.transformer.throwables.InvalidMixinException;
|
||||
import org.spongepowered.asm.util.ASMHelper;
|
||||
import org.spongepowered.asm.util.Bytecode;
|
||||
import org.spongepowered.asm.util.Annotations;
|
||||
|
||||
/**
|
||||
@@ -134,7 +134,7 @@ public abstract class InjectionInfo extends SpecialMethodInfo implements ISliceC
|
||||
*/
|
||||
protected InjectionInfo(MixinTargetContext mixin, MethodNode method, AnnotationNode annotation) {
|
||||
super(mixin, method, annotation);
|
||||
this.isStatic = ASMHelper.methodIsStatic(method);
|
||||
this.isStatic = Bytecode.methodIsStatic(method);
|
||||
this.slices = MethodSlices.parse(this);
|
||||
this.readAnnotation();
|
||||
}
|
||||
@@ -147,7 +147,7 @@ public abstract class InjectionInfo extends SpecialMethodInfo implements ISliceC
|
||||
return;
|
||||
}
|
||||
|
||||
String type = "@" + ASMHelper.getSimpleName(this.annotation);
|
||||
String type = "@" + Bytecode.getSimpleName(this.annotation);
|
||||
List<AnnotationNode> injectionPoints = this.readInjectionPoints(type);
|
||||
this.findMethods(this.parseTarget(type), type);
|
||||
this.parseInjectionPoints(injectionPoints);
|
||||
@@ -352,7 +352,7 @@ public abstract class InjectionInfo extends SpecialMethodInfo implements ISliceC
|
||||
for (MethodNode target : this.classNode.methods) {
|
||||
if (searchFor.matches(target.name, target.desc, ordinal)) {
|
||||
boolean isMixinMethod = Annotations.getVisible(target, MixinMerged.class) != null;
|
||||
if (searchFor.matchAll && (ASMHelper.methodIsStatic(target) != this.isStatic || target == this.method || isMixinMethod)) {
|
||||
if (searchFor.matchAll && (Bytecode.methodIsStatic(target) != this.isStatic || target == this.method || isMixinMethod)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -468,7 +468,7 @@ public abstract class InjectionInfo extends SpecialMethodInfo implements ISliceC
|
||||
}
|
||||
|
||||
static String describeInjector(IMixinContext mixin, AnnotationNode annotation, MethodNode method) {
|
||||
return String.format("%s->@%s::%s%s", mixin.toString(), ASMHelper.getSimpleName(annotation), method.name, method.desc);
|
||||
return String.format("%s->@%s::%s%s", mixin.toString(), Bytecode.getSimpleName(annotation), method.name, method.desc);
|
||||
}
|
||||
|
||||
}
|
||||
+7
-7
@@ -45,7 +45,7 @@ import org.spongepowered.asm.mixin.injection.code.Injector;
|
||||
import org.spongepowered.asm.mixin.injection.invoke.ModifyConstantInjector;
|
||||
import org.spongepowered.asm.mixin.injection.throwables.InvalidInjectionException;
|
||||
import org.spongepowered.asm.mixin.transformer.MixinTargetContext;
|
||||
import org.spongepowered.asm.util.ASMHelper;
|
||||
import org.spongepowered.asm.util.Bytecode;
|
||||
import org.spongepowered.asm.util.Annotations;
|
||||
import org.spongepowered.asm.util.Constants;
|
||||
|
||||
@@ -137,7 +137,7 @@ public class ModifyConstantInjectionInfo extends InjectionInfo {
|
||||
if (matchesInsn) {
|
||||
this.log(" BeforeConstant found a matching constant{} at ordinal {}", this.matchByType != null ? " TYPE" : " value", ordinal);
|
||||
if (this.ordinal == -1 || this.ordinal == ordinal) {
|
||||
this.log(" BeforeConstant found {}", ASMHelper.describeNode(insn).trim());
|
||||
this.log(" BeforeConstant found {}", Bytecode.describeNode(insn).trim());
|
||||
nodes.add(insn);
|
||||
found = true;
|
||||
}
|
||||
@@ -151,13 +151,13 @@ public class ModifyConstantInjectionInfo extends InjectionInfo {
|
||||
private boolean matchesConditionalInsn(AbstractInsnNode insn) {
|
||||
for (int conditionalOpcode : this.expandOpcodes) {
|
||||
if (insn.getOpcode() == conditionalOpcode) {
|
||||
this.log(" BeforeConstant found %s instruction", ASMHelper.getOpcodeName(conditionalOpcode));
|
||||
this.log(" BeforeConstant found %s instruction", Bytecode.getOpcodeName(conditionalOpcode));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.intValue != null && this.intValue.intValue() == 0 && ASMHelper.isConstant(insn)) {
|
||||
Object value = ASMHelper.getConstant(insn);
|
||||
if (this.intValue != null && this.intValue.intValue() == 0 && Bytecode.isConstant(insn)) {
|
||||
Object value = Bytecode.getConstant(insn);
|
||||
this.log(" BeforeConstant found INTEGER constant: value = {}", value);
|
||||
return value instanceof Integer && ((Integer)value).intValue() == 0;
|
||||
}
|
||||
@@ -166,11 +166,11 @@ public class ModifyConstantInjectionInfo extends InjectionInfo {
|
||||
}
|
||||
|
||||
private boolean matchesConstantInsn(AbstractInsnNode insn) {
|
||||
if (!ASMHelper.isConstant(insn)) {
|
||||
if (!Bytecode.isConstant(insn)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Object value = ASMHelper.getConstant(insn);
|
||||
Object value = Bytecode.getConstant(insn);
|
||||
if (value == null) {
|
||||
this.log(" BeforeConstant found NULL constant: nullValue = {}", this.nullValue);
|
||||
return this.nullValue || Constants.OBJECT.equals(this.matchByType);
|
||||
|
||||
@@ -33,7 +33,7 @@ import org.spongepowered.asm.lib.tree.InsnList;
|
||||
import org.spongepowered.asm.lib.tree.MethodNode;
|
||||
import org.spongepowered.asm.mixin.injection.InjectionNodes;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.util.ASMHelper;
|
||||
import org.spongepowered.asm.util.Bytecode;
|
||||
|
||||
/**
|
||||
* Information about the current injection target, mainly just convenience
|
||||
@@ -110,7 +110,7 @@ public class Target implements Comparable<Target>, Iterable<AbstractInsnNode> {
|
||||
this.classNode = classNode;
|
||||
this.method = method;
|
||||
this.insns = method.instructions;
|
||||
this.isStatic = ASMHelper.methodIsStatic(method);
|
||||
this.isStatic = Bytecode.methodIsStatic(method);
|
||||
this.arguments = Type.getArgumentTypes(method.desc);
|
||||
this.argIndices = this.calcArgIndices(this.isStatic ? 0 : 1);
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.spongepowered.asm.lib.Opcodes;
|
||||
import org.spongepowered.asm.lib.tree.FieldInsnNode;
|
||||
import org.spongepowered.asm.lib.tree.MethodInsnNode;
|
||||
import org.spongepowered.asm.mixin.transformer.throwables.MixinTransformerError;
|
||||
import org.spongepowered.asm.util.ASMHelper;
|
||||
import org.spongepowered.asm.util.Bytecode;
|
||||
|
||||
/**
|
||||
* Reference to a field or method that also includes invocation instructions.
|
||||
@@ -318,7 +318,7 @@ public abstract class MemberRef {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ASMHelper.getOpcodeName(this.getOpcode()) + " for "
|
||||
return Bytecode.getOpcodeName(this.getOpcode()) + " for "
|
||||
+ this.getOwner() + "." + this.getName() + (this.isField() ? ":" : "") + this.getDesc();
|
||||
}
|
||||
|
||||
|
||||
+10
-10
@@ -58,7 +58,7 @@ import org.spongepowered.asm.mixin.transformer.ClassInfo.Field;
|
||||
import org.spongepowered.asm.mixin.transformer.meta.MixinMerged;
|
||||
import org.spongepowered.asm.mixin.transformer.meta.MixinRenamed;
|
||||
import org.spongepowered.asm.mixin.transformer.throwables.InvalidMixinException;
|
||||
import org.spongepowered.asm.util.ASMHelper;
|
||||
import org.spongepowered.asm.util.Bytecode;
|
||||
import org.spongepowered.asm.util.Annotations;
|
||||
import org.spongepowered.asm.util.Constants;
|
||||
import org.spongepowered.asm.util.ConstraintParser;
|
||||
@@ -365,7 +365,7 @@ class MixinApplicatorStandard {
|
||||
this.mergeAnnotations(shadow, target);
|
||||
|
||||
// Strip the FINAL flag from @Mutable non-private fields
|
||||
if (entry.getValue().isDecoratedMutable() && !ASMHelper.hasFlag(target, Opcodes.ACC_PRIVATE)) {
|
||||
if (entry.getValue().isDecoratedMutable() && !Bytecode.hasFlag(target, Opcodes.ACC_PRIVATE)) {
|
||||
target.access &= ~Opcodes.ACC_FINAL;
|
||||
}
|
||||
}
|
||||
@@ -483,8 +483,8 @@ class MixinApplicatorStandard {
|
||||
throw new ClassFormatError("Invalid @MixinMerged annotation found in" + mixin + " at " + method.name + " in " + this.targetClass.name);
|
||||
}
|
||||
|
||||
if (ASMHelper.hasFlag(target, Opcodes.ACC_SYNTHETIC | Opcodes.ACC_BRIDGE)
|
||||
&& ASMHelper.hasFlag(method, Opcodes.ACC_SYNTHETIC | Opcodes.ACC_BRIDGE)) {
|
||||
if (Bytecode.hasFlag(target, Opcodes.ACC_SYNTHETIC | Opcodes.ACC_BRIDGE)
|
||||
&& Bytecode.hasFlag(method, Opcodes.ACC_SYNTHETIC | Opcodes.ACC_BRIDGE)) {
|
||||
if (mixin.getEnvironment().getOption(Option.DEBUG_VERBOSE)) {
|
||||
this.logger.warn("Synthetic bridge method clash for {} in {}", method.name, mixin);
|
||||
}
|
||||
@@ -529,7 +529,7 @@ class MixinApplicatorStandard {
|
||||
}
|
||||
|
||||
String methodName = method.name + method.desc;
|
||||
if (ASMHelper.hasFlag(method, Opcodes.ACC_STATIC)) {
|
||||
if (Bytecode.hasFlag(method, Opcodes.ACC_STATIC)) {
|
||||
throw new InvalidMixinException(mixin, "@Intrinsic method cannot be static, found " + methodName + " in " + mixin);
|
||||
}
|
||||
|
||||
@@ -760,7 +760,7 @@ class MixinApplicatorStandard {
|
||||
if (opcode == ivalidOp) {
|
||||
// At the moment I don't handle any transient locals because I haven't seen any in the wild, but let's avoid writing
|
||||
// code which will likely break things and fix it if a real test case ever appears
|
||||
throw new InvalidMixinException(mixin, "Cannot handle " + ASMHelper.getOpcodeName(opcode) + " opcode (0x"
|
||||
throw new InvalidMixinException(mixin, "Cannot handle " + Bytecode.getOpcodeName(opcode) + " opcode (0x"
|
||||
+ Integer.toHexString(opcode).toUpperCase() + ") in class initialiser");
|
||||
}
|
||||
}
|
||||
@@ -790,7 +790,7 @@ class MixinApplicatorStandard {
|
||||
* @param initialiser initialiser instructions
|
||||
*/
|
||||
protected final void injectInitialiser(MixinTargetContext mixin, MethodNode ctor, Deque<AbstractInsnNode> initialiser) {
|
||||
Map<LabelNode, LabelNode> labels = ASMHelper.cloneLabels(ctor.instructions);
|
||||
Map<LabelNode, LabelNode> labels = Bytecode.cloneLabels(ctor.instructions);
|
||||
|
||||
AbstractInsnNode insn = this.findInitialiserInjectionPoint(mixin, ctor, initialiser);
|
||||
if (insn == null) {
|
||||
@@ -910,9 +910,9 @@ class MixinApplicatorStandard {
|
||||
* @param mixinMethod method to check
|
||||
*/
|
||||
protected void checkMethodVisibility(MixinTargetContext mixin, MethodNode mixinMethod) {
|
||||
if (ASMHelper.hasFlag(mixinMethod, Opcodes.ACC_STATIC)
|
||||
&& !ASMHelper.hasFlag(mixinMethod, Opcodes.ACC_PRIVATE)
|
||||
&& !ASMHelper.hasFlag(mixinMethod, Opcodes.ACC_SYNTHETIC)
|
||||
if (Bytecode.hasFlag(mixinMethod, Opcodes.ACC_STATIC)
|
||||
&& !Bytecode.hasFlag(mixinMethod, Opcodes.ACC_PRIVATE)
|
||||
&& !Bytecode.hasFlag(mixinMethod, Opcodes.ACC_SYNTHETIC)
|
||||
&& !(Annotations.getVisible(mixinMethod, Overwrite.class) != null)) {
|
||||
throw new InvalidMixinException(mixin,
|
||||
String.format("Mixin %s contains non-private static method %s", mixin, mixinMethod));
|
||||
|
||||
@@ -47,7 +47,7 @@ import org.spongepowered.asm.mixin.transformer.MixinInfo.MixinClassNode;
|
||||
import org.spongepowered.asm.mixin.transformer.MixinInfo.MixinMethodNode;
|
||||
import org.spongepowered.asm.mixin.transformer.throwables.MixinTransformerError;
|
||||
import org.spongepowered.asm.transformers.TreeTransformer;
|
||||
import org.spongepowered.asm.util.ASMHelper;
|
||||
import org.spongepowered.asm.util.Bytecode;
|
||||
|
||||
/**
|
||||
* TODO Description for MixinPostProcessor
|
||||
@@ -171,7 +171,7 @@ class MixinPostProcessor extends TreeTransformer implements MixinConfig.IListene
|
||||
|
||||
for (Iterator<MixinMethodNode> iter = classNode.mixinMethods.iterator(); iter.hasNext();) {
|
||||
MixinMethodNode methodNode = iter.next();
|
||||
if (!ASMHelper.hasFlag(methodNode, Opcodes.ACC_STATIC)) {
|
||||
if (!Bytecode.hasFlag(methodNode, Opcodes.ACC_STATIC)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -207,10 +207,10 @@ class MixinPostProcessor extends TreeTransformer implements MixinConfig.IListene
|
||||
methodNode.instructions.clear();
|
||||
Type[] args = Type.getArgumentTypes(methodNode.desc);
|
||||
Type returnType = Type.getReturnType(methodNode.desc);
|
||||
ASMHelper.loadArgs(args, methodNode.instructions, 0);
|
||||
Bytecode.loadArgs(args, methodNode.instructions, 0);
|
||||
methodNode.instructions.add(new MethodInsnNode(Opcodes.INVOKESTATIC, targetClass.getName(), method.getName(), methodNode.desc, false));
|
||||
methodNode.instructions.add(new InsnNode(returnType.getOpcode(Opcodes.IRETURN)));
|
||||
methodNode.maxStack = ASMHelper.getFirstNonArgLocalIndex(args, false);
|
||||
methodNode.maxStack = Bytecode.getFirstNonArgLocalIndex(args, false);
|
||||
methodNode.maxLocals = 0;
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -31,7 +31,7 @@ import org.spongepowered.asm.mixin.transformer.ClassInfo.Method;
|
||||
import org.spongepowered.asm.mixin.transformer.MixinInfo.MixinClassNode;
|
||||
import org.spongepowered.asm.mixin.transformer.MixinInfo.MixinMethodNode;
|
||||
import org.spongepowered.asm.mixin.transformer.throwables.InvalidInterfaceMixinException;
|
||||
import org.spongepowered.asm.util.ASMHelper;
|
||||
import org.spongepowered.asm.util.Bytecode;
|
||||
|
||||
/**
|
||||
* Bytecode preprocessor for interface mixins, simply performs some additional
|
||||
@@ -57,7 +57,7 @@ class MixinPreProcessorInterface extends MixinPreProcessorStandard {
|
||||
@Override
|
||||
protected void prepareMethod(MixinMethodNode mixinMethod, Method method) {
|
||||
// Userland interfaces should not have non-public methods except for lambda bodies
|
||||
if (!ASMHelper.hasFlag(mixinMethod, Opcodes.ACC_PUBLIC) && !ASMHelper.hasFlag(mixinMethod, Opcodes.ACC_SYNTHETIC)) {
|
||||
if (!Bytecode.hasFlag(mixinMethod, Opcodes.ACC_PUBLIC) && !Bytecode.hasFlag(mixinMethod, Opcodes.ACC_SYNTHETIC)) {
|
||||
throw new InvalidInterfaceMixinException(this.mixin, "Interface mixin contains a non-public method! Found " + method + " in "
|
||||
+ this.mixin);
|
||||
}
|
||||
@@ -74,7 +74,7 @@ class MixinPreProcessorInterface extends MixinPreProcessorStandard {
|
||||
*/
|
||||
@Override
|
||||
protected boolean validateField(MixinTargetContext context, FieldNode field, AnnotationNode shadow) {
|
||||
if (!ASMHelper.hasFlag(field, Opcodes.ACC_STATIC)) {
|
||||
if (!Bytecode.hasFlag(field, Opcodes.ACC_STATIC)) {
|
||||
throw new InvalidInterfaceMixinException(this.mixin, "Interface mixin contains an instance field! Found " + field.name + " in "
|
||||
+ this.mixin);
|
||||
}
|
||||
|
||||
+9
-9
@@ -51,7 +51,7 @@ import org.spongepowered.asm.mixin.transformer.MixinInfo.MixinClassNode;
|
||||
import org.spongepowered.asm.mixin.transformer.MixinInfo.MixinMethodNode;
|
||||
import org.spongepowered.asm.mixin.transformer.meta.MixinRenamed;
|
||||
import org.spongepowered.asm.mixin.transformer.throwables.InvalidMixinException;
|
||||
import org.spongepowered.asm.util.ASMHelper;
|
||||
import org.spongepowered.asm.util.Bytecode;
|
||||
import org.spongepowered.asm.util.Annotations;
|
||||
import org.spongepowered.asm.util.Constants;
|
||||
|
||||
@@ -261,7 +261,7 @@ class MixinPreProcessorStandard {
|
||||
return false;
|
||||
}
|
||||
|
||||
String description = "@" + ASMHelper.getSimpleName(type) + " method " + mixinMethod.name;
|
||||
String description = "@" + Bytecode.getSimpleName(type) + " method " + mixinMethod.name;
|
||||
Method method = this.getSpecialMethod(mixinMethod, type);
|
||||
if (MixinEnvironment.getCompatibilityLevel().isAtLeast(CompatibilityLevel.JAVA_8) && method.isStatic()) {
|
||||
if (this.mixin.getTargets().size() > 1) {
|
||||
@@ -320,7 +320,7 @@ class MixinPreProcessorStandard {
|
||||
}
|
||||
target = context.findRemappedMethod(mixinMethod);
|
||||
if (target == null) {
|
||||
throw new InvalidMixinException(this.mixin, "@" + ASMHelper.getSimpleName(type) + " method " + mixinMethod.name
|
||||
throw new InvalidMixinException(this.mixin, "@" + Bytecode.getSimpleName(type) + " method " + mixinMethod.name
|
||||
+ " was not located in the target class");
|
||||
}
|
||||
mixinMethod.name = method.renameTo(target.name);
|
||||
@@ -349,14 +349,14 @@ class MixinPreProcessorStandard {
|
||||
|
||||
protected void checkMethodNotUnique(Class<? extends Annotation> type, Method method) {
|
||||
if (method.isUnique()) {
|
||||
String annotation = "@" + ASMHelper.getSimpleName(type);
|
||||
String annotation = "@" + Bytecode.getSimpleName(type);
|
||||
throw new InvalidMixinException(this.mixin, annotation + " method " + method.getName() + " cannot be @Unique");
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkMixinNotUnique(MixinMethodNode mixinMethod, Class<? extends Annotation> type) {
|
||||
if (this.mixin.isUnique()) {
|
||||
String annotation = "@" + ASMHelper.getSimpleName(type);
|
||||
String annotation = "@" + Bytecode.getSimpleName(type);
|
||||
throw new InvalidMixinException(this.mixin, annotation + " method " + mixinMethod.name + " found in a @Unique mixin");
|
||||
}
|
||||
}
|
||||
@@ -473,7 +473,7 @@ class MixinPreProcessorStandard {
|
||||
|
||||
if (isShadow) {
|
||||
boolean isFinal = field.isDecoratedFinal();
|
||||
if (this.verboseLogging && ASMHelper.hasFlag(target, Opcodes.ACC_FINAL) != isFinal) {
|
||||
if (this.verboseLogging && Bytecode.hasFlag(target, Opcodes.ACC_FINAL) != isFinal) {
|
||||
String message = isFinal
|
||||
? "@Shadow field {}::{} is decorated with @Final but target is not final"
|
||||
: "@Shadow target {}::{} is final but shadow is not decorated with @Final";
|
||||
@@ -487,9 +487,9 @@ class MixinPreProcessorStandard {
|
||||
|
||||
protected boolean validateField(MixinTargetContext context, FieldNode field, AnnotationNode shadow) {
|
||||
// Public static fields will fall foul of early static binding in java, including them in a mixin is an error condition
|
||||
if (ASMHelper.hasFlag(field, Opcodes.ACC_STATIC)
|
||||
&& !ASMHelper.hasFlag(field, Opcodes.ACC_PRIVATE)
|
||||
&& !ASMHelper.hasFlag(field, Opcodes.ACC_SYNTHETIC)
|
||||
if (Bytecode.hasFlag(field, Opcodes.ACC_STATIC)
|
||||
&& !Bytecode.hasFlag(field, Opcodes.ACC_PRIVATE)
|
||||
&& !Bytecode.hasFlag(field, Opcodes.ACC_SYNTHETIC)
|
||||
&& shadow == null) {
|
||||
throw new InvalidMixinException(context, String.format("Mixin %s contains non-private static field %s:%s",
|
||||
context, field.name, field.desc));
|
||||
|
||||
@@ -65,7 +65,7 @@ import org.spongepowered.asm.mixin.transformer.meta.SourceMap.File;
|
||||
import org.spongepowered.asm.mixin.transformer.throwables.InvalidMixinException;
|
||||
import org.spongepowered.asm.mixin.transformer.throwables.MixinTransformerError;
|
||||
import org.spongepowered.asm.obfuscation.RemapperChain;
|
||||
import org.spongepowered.asm.util.ASMHelper;
|
||||
import org.spongepowered.asm.util.Bytecode;
|
||||
import org.spongepowered.asm.util.Annotations;
|
||||
import org.spongepowered.asm.util.ClassSignature;
|
||||
import org.spongepowered.asm.util.Constants;
|
||||
@@ -653,7 +653,7 @@ public class MixinTargetContext implements IMixinContext {
|
||||
+ " must not specify an initialiser");
|
||||
}
|
||||
|
||||
throw new InvalidMixinException(this, "Illegal imaginary super access: found " + ASMHelper.getOpcodeName(fieldInsn.getOpcode())
|
||||
throw new InvalidMixinException(this, "Illegal imaginary super access: found " + Bytecode.getOpcodeName(fieldInsn.getOpcode())
|
||||
+ " opcode in " + method.name + method.desc);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ import org.spongepowered.asm.mixin.MixinEnvironment;
|
||||
import org.spongepowered.asm.mixin.MixinEnvironment.Option;
|
||||
import org.spongepowered.asm.mixin.injection.struct.Target;
|
||||
import org.spongepowered.asm.mixin.transformer.meta.SourceMap;
|
||||
import org.spongepowered.asm.util.ASMHelper;
|
||||
import org.spongepowered.asm.util.Bytecode;
|
||||
import org.spongepowered.asm.util.Annotations;
|
||||
import org.spongepowered.asm.util.ClassSignature;
|
||||
|
||||
@@ -302,14 +302,14 @@ class TargetClassContext {
|
||||
if (classDebugAnnotation != null) {
|
||||
this.forceExport = Boolean.TRUE.equals(Annotations.<String>getValue(classDebugAnnotation, "export"));
|
||||
if (Boolean.TRUE.equals(Annotations.<String>getValue(classDebugAnnotation, "print"))) {
|
||||
ASMHelper.textify(this.classNode, System.err);
|
||||
Bytecode.textify(this.classNode, System.err);
|
||||
}
|
||||
}
|
||||
|
||||
for (MethodNode method : this.classNode.methods) {
|
||||
AnnotationNode methodDebugAnnotation = Annotations.getVisible(method, Debug.class);
|
||||
if (methodDebugAnnotation != null && Boolean.TRUE.equals(Annotations.<String>getValue(methodDebugAnnotation, "print"))) {
|
||||
ASMHelper.textify(method, System.err);
|
||||
Bytecode.textify(method, System.err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.spongepowered.asm.lib.tree.AbstractInsnNode;
|
||||
import org.spongepowered.asm.lib.tree.ClassNode;
|
||||
import org.spongepowered.asm.lib.tree.LineNumberNode;
|
||||
import org.spongepowered.asm.lib.tree.MethodNode;
|
||||
import org.spongepowered.asm.util.ASMHelper;
|
||||
import org.spongepowered.asm.util.Bytecode;
|
||||
|
||||
/**
|
||||
* Structure which contains information about a SourceDebugExtension SMAP
|
||||
@@ -240,7 +240,7 @@ public class SourceMap {
|
||||
* @return new File
|
||||
*/
|
||||
public File addFile(String stratumName, ClassNode classNode) {
|
||||
return this.addFile(stratumName, classNode.sourceFile, classNode.name + ".java", ASMHelper.getMaxLineNumber(classNode, 500, 50));
|
||||
return this.addFile(stratumName, classNode.sourceFile, classNode.name + ".java", Bytecode.getMaxLineNumber(classNode, 500, 50));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+26
-26
@@ -45,9 +45,9 @@ import org.spongepowered.asm.lib.util.TraceClassVisitor;
|
||||
import com.google.common.primitives.Ints;
|
||||
|
||||
/**
|
||||
* Utility methods for working with ASM
|
||||
* Utility methods for working with bytecode via ASM
|
||||
*/
|
||||
public final class ASMHelper {
|
||||
public final class Bytecode {
|
||||
|
||||
/**
|
||||
* Integer constant opcodes
|
||||
@@ -112,7 +112,7 @@ public final class ASMHelper {
|
||||
"I", //"S"
|
||||
};
|
||||
|
||||
private ASMHelper() {
|
||||
private Bytecode() {
|
||||
// utility class
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ public final class ASMHelper {
|
||||
public static void dumpClass(ClassNode classNode) {
|
||||
ClassWriter cw = new ClassWriter(COMPUTE_MAXS | COMPUTE_FRAMES);
|
||||
classNode.accept(cw);
|
||||
ASMHelper.dumpClass(cw.toByteArray());
|
||||
Bytecode.dumpClass(cw.toByteArray());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -189,7 +189,7 @@ public final class ASMHelper {
|
||||
System.err.printf("%s%s\n", method.name, method.desc);
|
||||
int i = 0;
|
||||
for (Iterator<AbstractInsnNode> iter = method.instructions.iterator(); iter.hasNext();) {
|
||||
System.err.printf("[%4d] %s\n", i++, ASMHelper.describeNode(iter.next()));
|
||||
System.err.printf("[%4d] %s\n", i++, Bytecode.describeNode(iter.next()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,7 +202,7 @@ public final class ASMHelper {
|
||||
System.err.printf("%s%s\n", method.name, method.desc);
|
||||
for (Iterator<AbstractInsnNode> iter = method.instructions.iterator(); iter.hasNext();) {
|
||||
System.err.print(" ");
|
||||
ASMHelper.printNode(iter.next());
|
||||
Bytecode.printNode(iter.next());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,7 +212,7 @@ public final class ASMHelper {
|
||||
* @param node Node to print
|
||||
*/
|
||||
public static void printNode(AbstractInsnNode node) {
|
||||
System.err.printf("%s\n", ASMHelper.describeNode(node));
|
||||
System.err.printf("%s\n", Bytecode.describeNode(node));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -232,15 +232,15 @@ public final class ASMHelper {
|
||||
|
||||
String out = String.format(" %-14s ", node.getClass().getSimpleName().replace("Node", ""));
|
||||
if (node instanceof JumpInsnNode) {
|
||||
out += String.format("[%s] [%s]", ASMHelper.getOpcodeName(node), ((JumpInsnNode)node).label.getLabel());
|
||||
out += String.format("[%s] [%s]", Bytecode.getOpcodeName(node), ((JumpInsnNode)node).label.getLabel());
|
||||
} else if (node instanceof VarInsnNode) {
|
||||
out += String.format("[%s] %d", ASMHelper.getOpcodeName(node), ((VarInsnNode)node).var);
|
||||
out += String.format("[%s] %d", Bytecode.getOpcodeName(node), ((VarInsnNode)node).var);
|
||||
} else if (node instanceof MethodInsnNode) {
|
||||
MethodInsnNode mth = (MethodInsnNode)node;
|
||||
out += String.format("[%s] %s %s %s", ASMHelper.getOpcodeName(node), mth.owner, mth.name, mth.desc);
|
||||
out += String.format("[%s] %s %s %s", Bytecode.getOpcodeName(node), mth.owner, mth.name, mth.desc);
|
||||
} else if (node instanceof FieldInsnNode) {
|
||||
FieldInsnNode fld = (FieldInsnNode)node;
|
||||
out += String.format("[%s] %s %s %s", ASMHelper.getOpcodeName(node), fld.owner, fld.name, fld.desc);
|
||||
out += String.format("[%s] %s %s %s", Bytecode.getOpcodeName(node), fld.owner, fld.name, fld.desc);
|
||||
} else if (node instanceof LineNumberNode) {
|
||||
LineNumberNode ln = (LineNumberNode)node;
|
||||
out += String.format("LINE=[%d] LABEL=[%s]", ln.line, ln.start.getLabel());
|
||||
@@ -249,9 +249,9 @@ public final class ASMHelper {
|
||||
} else if (node instanceof IntInsnNode) {
|
||||
out += (((IntInsnNode)node).operand);
|
||||
} else if (node instanceof FrameNode) {
|
||||
out += String.format("[%s] ", ASMHelper.getOpcodeName(((FrameNode)node).type, "H_INVOKEINTERFACE", -1));
|
||||
out += String.format("[%s] ", Bytecode.getOpcodeName(((FrameNode)node).type, "H_INVOKEINTERFACE", -1));
|
||||
} else {
|
||||
out += String.format("[%s] ", ASMHelper.getOpcodeName(node));
|
||||
out += String.format("[%s] ", Bytecode.getOpcodeName(node));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@@ -265,7 +265,7 @@ public final class ASMHelper {
|
||||
* the {@link Opcodes} class have the same value as opcodes
|
||||
*/
|
||||
public static String getOpcodeName(AbstractInsnNode node) {
|
||||
return ASMHelper.getOpcodeName(node.getOpcode());
|
||||
return Bytecode.getOpcodeName(node.getOpcode());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -277,7 +277,7 @@ public final class ASMHelper {
|
||||
* the {@link Opcodes} class have the same value as opcodes
|
||||
*/
|
||||
public static String getOpcodeName(int opcode) {
|
||||
return ASMHelper.getOpcodeName(opcode, "UNINITIALIZED_THIS", 1);
|
||||
return Bytecode.getOpcodeName(opcode, "UNINITIALIZED_THIS", 1);
|
||||
}
|
||||
|
||||
private static String getOpcodeName(int opcode, String start, int min) {
|
||||
@@ -333,7 +333,7 @@ public final class ASMHelper {
|
||||
* argument or "this"
|
||||
*/
|
||||
public static int getFirstNonArgLocalIndex(MethodNode method) {
|
||||
return ASMHelper.getFirstNonArgLocalIndex(Type.getArgumentTypes(method.desc), (method.access & Opcodes.ACC_STATIC) == 0);
|
||||
return Bytecode.getFirstNonArgLocalIndex(Type.getArgumentTypes(method.desc), (method.access & Opcodes.ACC_STATIC) == 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -349,7 +349,7 @@ public final class ASMHelper {
|
||||
* argument or "this"
|
||||
*/
|
||||
public static int getFirstNonArgLocalIndex(Type[] args, boolean includeThis) {
|
||||
return ASMHelper.getArgsSize(args) + (includeThis ? 1 : 0);
|
||||
return Bytecode.getArgsSize(args) + (includeThis ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -378,7 +378,7 @@ public final class ASMHelper {
|
||||
* @param pos Start position
|
||||
*/
|
||||
public static void loadArgs(Type[] args, InsnList insns, int pos) {
|
||||
ASMHelper.loadArgs(args, insns, pos, -1);
|
||||
Bytecode.loadArgs(args, insns, pos, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -436,10 +436,10 @@ public final class ASMHelper {
|
||||
StringBuilder sb = new StringBuilder().append('(');
|
||||
|
||||
for (Object arg : args) {
|
||||
sb.append(ASMHelper.toDescriptor(arg));
|
||||
sb.append(Bytecode.toDescriptor(arg));
|
||||
}
|
||||
|
||||
return sb.append(')').append(returnType != null ? ASMHelper.toDescriptor(returnType) : "V").toString();
|
||||
return sb.append(')').append(returnType != null ? Bytecode.toDescriptor(returnType) : "V").toString();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -478,7 +478,7 @@ public final class ASMHelper {
|
||||
* @return annotation's simple name
|
||||
*/
|
||||
public static String getSimpleName(AnnotationNode annotation) {
|
||||
return ASMHelper.getSimpleName(annotation.desc);
|
||||
return Bytecode.getSimpleName(annotation.desc);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -503,7 +503,7 @@ public final class ASMHelper {
|
||||
if (insn == null) {
|
||||
return false;
|
||||
}
|
||||
return Ints.contains(ASMHelper.CONSTANTS_ALL, insn.getOpcode());
|
||||
return Ints.contains(Bytecode.CONSTANTS_ALL, insn.getOpcode());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -527,8 +527,8 @@ public final class ASMHelper {
|
||||
throw new IllegalArgumentException("IntInsnNode with invalid opcode " + insn.getOpcode() + " in getConstant");
|
||||
}
|
||||
|
||||
int index = Ints.indexOf(ASMHelper.CONSTANTS_ALL, insn.getOpcode());
|
||||
return index < 0 ? null : ASMHelper.CONSTANTS_VALUES[index];
|
||||
int index = Ints.indexOf(Bytecode.CONSTANTS_ALL, insn.getOpcode());
|
||||
return index < 0 ? null : Bytecode.CONSTANTS_VALUES[index];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -559,8 +559,8 @@ public final class ASMHelper {
|
||||
throw new IllegalArgumentException("LdcInsnNode with invalid payload type " + cst.getClass() + " in getConstant");
|
||||
}
|
||||
|
||||
int index = Ints.indexOf(ASMHelper.CONSTANTS_ALL, insn.getOpcode());
|
||||
return index < 0 ? null : Type.getType(ASMHelper.CONSTANTS_TYPES[index]);
|
||||
int index = Ints.indexOf(Bytecode.CONSTANTS_ALL, insn.getOpcode());
|
||||
return index < 0 ? null : Type.getType(Bytecode.CONSTANTS_TYPES[index]);
|
||||
}
|
||||
|
||||
/**
|
||||
Reference in new issue
Block a user