public class ASMUtils
extends java.lang.Object
| Constructor and Description |
|---|
ASMUtils() |
| Modifier and Type | Method and Description |
|---|---|
static org.objectweb.asm.tree.AbstractInsnNode |
boxPrimitive(org.objectweb.asm.Type primitive)
Get the instruction to box a primitive type.
|
static org.objectweb.asm.tree.InsnList |
castObjectTo(org.objectweb.asm.Type targetType)
Get the instructions to cast an object to a specific type.
|
static org.objectweb.asm.tree.ClassNode |
createEmptyClass(java.lang.String name)
Create a new empty class node.
|
static java.lang.String |
dot(java.lang.String s)
Replace all slashes with dots.
|
static org.objectweb.asm.tree.AbstractInsnNode |
doublePush(double d)
Get the most optimal instruction to push the given double onto the stack.
|
static org.objectweb.asm.tree.AbstractInsnNode |
floatPush(float f)
Get the most optimal instruction to push the given float onto the stack.
|
static int |
freeVarIndex(org.objectweb.asm.tree.MethodNode methodNode)
Calculate the variable index of the first free variable in a method.
|
static java.lang.String |
generateVariableName(org.objectweb.asm.Type type,
java.util.function.Predicate<java.lang.String> doesExist)
Generate a variable name for a type that does not exist yet.
|
static org.objectweb.asm.tree.FieldNode |
getField(org.objectweb.asm.tree.ClassNode classNode,
java.lang.String name,
java.lang.String desc)
Get a field from a class node.
|
static org.objectweb.asm.tree.MethodNode |
getMethod(org.objectweb.asm.tree.ClassNode classNode,
java.lang.String name,
java.lang.String desc)
Get a method from a class node.
|
static org.objectweb.asm.tree.AbstractInsnNode |
intPush(int i)
Get the most optimal instruction to push the given integer onto the stack.
|
static org.objectweb.asm.tree.InsnList |
loadMethodArgs(org.objectweb.asm.tree.MethodNode method)
Get the instructions to load the arguments of a method onto the stack.
|
static org.objectweb.asm.tree.AbstractInsnNode |
longPush(long l)
Get the most optimal instruction to push the given long onto the stack.
|
static int[] |
parameterIndices(org.objectweb.asm.tree.MethodNode methodNode)
Calculate the indices of the parameters of a method.
|
static java.lang.String |
slash(java.lang.String s)
Replace all dots with slashes.
|
static org.objectweb.asm.tree.InsnList |
swap(org.objectweb.asm.Type top,
org.objectweb.asm.Type bottom)
Get the instructions to swap the first two elements on the stack.
|
static java.lang.Number |
toNumber(org.objectweb.asm.tree.AbstractInsnNode instruction)
Get the number the given instruction pushes onto the stack.
|
public static java.lang.String dot(java.lang.String s)
s - The string to replacepublic static java.lang.String slash(java.lang.String s)
s - The string to replacepublic static org.objectweb.asm.tree.FieldNode getField(org.objectweb.asm.tree.ClassNode classNode,
java.lang.String name,
@Nullable
java.lang.String desc)
classNode - The class node to search inname - The name of the fielddesc - The descriptor of the field (null for any descriptor)public static org.objectweb.asm.tree.MethodNode getMethod(org.objectweb.asm.tree.ClassNode classNode,
java.lang.String name,
java.lang.String desc)
classNode - The class node to search inname - The name of the methoddesc - The descriptor of the methodpublic static int freeVarIndex(org.objectweb.asm.tree.MethodNode methodNode)
methodNode - The method to calculate the free variable index forpublic static org.objectweb.asm.tree.InsnList castObjectTo(org.objectweb.asm.Type targetType)
targetType - The target type@Nullable public static org.objectweb.asm.tree.AbstractInsnNode boxPrimitive(org.objectweb.asm.Type primitive)
primitive - The primitive type to box@Nullable
public static java.lang.Number toNumber(@Nullable
org.objectweb.asm.tree.AbstractInsnNode instruction)
instruction - The instruction to get the number frompublic static org.objectweb.asm.tree.AbstractInsnNode intPush(int i)
i - The integer to pushpublic static org.objectweb.asm.tree.AbstractInsnNode longPush(long l)
l - The long to pushpublic static org.objectweb.asm.tree.AbstractInsnNode floatPush(float f)
f - The float to pushpublic static org.objectweb.asm.tree.AbstractInsnNode doublePush(double d)
d - The double to pushpublic static org.objectweb.asm.tree.ClassNode createEmptyClass(java.lang.String name)
name - The name of the classpublic static int[] parameterIndices(org.objectweb.asm.tree.MethodNode methodNode)
methodNode - The method to calculate the indices forpublic static org.objectweb.asm.tree.InsnList swap(org.objectweb.asm.Type top,
org.objectweb.asm.Type bottom)
top - The type of the top elementbottom - The type of the bottom elementpublic static org.objectweb.asm.tree.InsnList loadMethodArgs(org.objectweb.asm.tree.MethodNode method)
method - The method to load the arguments frompublic static java.lang.String generateVariableName(org.objectweb.asm.Type type,
java.util.function.Predicate<java.lang.String> doesExist)
type - The type to generate the name fordoesExist - A predicate that checks if a name already exists (true if it exists)