本文整理汇总了Java中org.objectweb.asm.tree.InsnList.clear方法的典型用法代码示例。如果您正苦于以下问题:Java InsnList.clear方法的具体用法?Java InsnList.clear怎么用?Java InsnList.clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.objectweb.asm.tree.InsnList
的用法示例。
在下文中一共展示了InsnList.clear方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: extractFrom
import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
public void extractFrom(ImagineASM asm, InsnList list) {
//Pair<String, String> fieldChunkProvider = asm.field("net/minecraft/world/World", "chunkProvider");
list.clear();
list.add(new IntInsnNode(ALOAD, 1));
list.add(new FieldInsnNode(GETFIELD, "ahb", "v", "Lapu;"));
list.add(new InsnNode(ARETURN));
}
示例2: constMethod
import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
public ImagineMethod constMethod(final int value) {
final InsnList instructions = this.mMethod.instructions;
instructions.clear();
pushInt(value, instructions);
instructions.add((AbstractInsnNode)new InsnNode(172));
return this;
}
示例3: transform
import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
@Override
public void transform(byte[] bytes, ClassNode cn) {
////////////////////////////////////////////////////////////////
MethodNode method = this.findMethod(cn, "sendClickBlockToController", "func_147115_a");
InsnList code = method.instructions;
code.clear();
LabelNode l0 = new LabelNode();
code.add(l0);
code.add(new LineNumberNode(1460, l0));
code.add(new VarInsnNode(Opcodes.ILOAD, 1));
LabelNode l1 = new LabelNode();
code.add(new JumpInsnNode(Opcodes.IFNE, l1));
LabelNode l2 = new LabelNode();
code.add(l2);
code.add(new LineNumberNode(1462, l2));
code.add(new VarInsnNode(Opcodes.ALOAD, 0));
code.add(new InsnNode(Opcodes.ICONST_0));
code.add(leftClickCounter.putField());
code.add(l1);
code.add(new LineNumberNode(1484, l1));
code.add(new FrameNode(Opcodes.F_SAME, 0, null, 0, null));
code.add(new InsnNode(Opcodes.RETURN));
method.maxStack = 2;
method.maxLocals = 2;
////////////////////////////////////////////////////////////////
}
示例4: fixMethodBody
import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
/**
* Rewrites the method bytecode to remove the "Stub!" exception.
*/
private void fixMethodBody(MethodNode methodNode, ClassNode classNode) {
if ((methodNode.access & Opcodes.ACC_NATIVE) != 0
|| (methodNode.access & Opcodes.ACC_ABSTRACT) != 0) {
// Abstract and native method don't have bodies to rewrite.
return;
}
if ((classNode.access & Opcodes.ACC_ENUM) != 0 && ENUM_METHODS.contains(methodNode.name)) {
// Don't break enum classes.
return;
}
Type returnType = Type.getReturnType(methodNode.desc);
InsnList instructions = methodNode.instructions;
List localVariables = methodNode.localVariables;
List tryCatchBlocks = methodNode.tryCatchBlocks;
if (localVariables != null && !localVariables.isEmpty()) {
localVariables.clear();
}
if (tryCatchBlocks != null && !tryCatchBlocks.isEmpty()) {
tryCatchBlocks.clear();
}
if (methodNode.name.equals(CONSTRUCTOR)) {
// Keep the call to parent constructor, delete the exception after that.
boolean deadCode = false;
for (AbstractInsnNode instruction : instructions.toArray()) {
if (!deadCode) {
if (instruction.getOpcode() == Opcodes.INVOKESPECIAL) {
instructions.insert(instruction, new InsnNode(Opcodes.RETURN));
// Start removing all following instructions.
deadCode = true;
}
} else {
instructions.remove(instruction);
}
}
} else {
instructions.clear();
if (returnDefaultValues || methodNode.name.equals(CLASS_CONSTRUCTOR)) {
if (INTEGER_LIKE_TYPES.contains(returnType)) {
instructions.add(new InsnNode(Opcodes.ICONST_0));
} else if (returnType.equals(Type.LONG_TYPE)) {
instructions.add(new InsnNode(Opcodes.LCONST_0));
} else if (returnType.equals(Type.FLOAT_TYPE)) {
instructions.add(new InsnNode(Opcodes.FCONST_0));
} else if (returnType.equals(Type.DOUBLE_TYPE)) {
instructions.add(new InsnNode(Opcodes.DCONST_0));
} else {
instructions.add(new InsnNode(Opcodes.ACONST_NULL));
}
instructions.add(new InsnNode(returnType.getOpcode(Opcodes.IRETURN)));
} else {
instructions.insert(throwExceptionsList(methodNode, classNode));
}
}
}
示例5: forward
import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
private static void forward(final ImagineMethod img, final String owner, final String methodName, final boolean staticForward) {
final InsnList list = img.mMethod.instructions;
list.clear();
list.add(methodCall(img, owner, methodName, staticForward, true));
}
示例6: fixMethodBody
import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
/**
* Rewrites the method bytecode to remove the "Stub!" exception.
*/
private void fixMethodBody(MethodNode methodNode, ClassNode classNode) {
if ((methodNode.access & Opcodes.ACC_NATIVE) != 0
|| (methodNode.access & Opcodes.ACC_ABSTRACT) != 0) {
// Abstract and native method don't have bodies to rewrite.
return;
}
if ((classNode.access & Opcodes.ACC_ENUM) != 0 && ENUM_METHODS.contains(methodNode.name)) {
// Don't break enum classes.
return;
}
Type returnType = Type.getReturnType(methodNode.desc);
InsnList instructions = methodNode.instructions;
if (methodNode.name.equals(CONSTRUCTOR)) {
// Keep the call to parent constructor, delete the exception after that.
boolean deadCode = false;
for (AbstractInsnNode instruction : instructions.toArray()) {
if (!deadCode) {
if (instruction.getOpcode() == Opcodes.INVOKESPECIAL) {
instructions.insert(instruction, new InsnNode(Opcodes.RETURN));
// Start removing all following instructions.
deadCode = true;
}
} else {
instructions.remove(instruction);
}
}
} else {
instructions.clear();
if (returnDefaultValues || methodNode.name.equals(CLASS_CONSTRUCTOR)) {
if (INTEGER_LIKE_TYPES.contains(returnType)) {
instructions.add(new InsnNode(Opcodes.ICONST_0));
} else if (returnType.equals(Type.LONG_TYPE)) {
instructions.add(new InsnNode(Opcodes.LCONST_0));
} else if (returnType.equals(Type.FLOAT_TYPE)) {
instructions.add(new InsnNode(Opcodes.FCONST_0));
} else if (returnType.equals(Type.DOUBLE_TYPE)) {
instructions.add(new InsnNode(Opcodes.DCONST_0));
} else {
instructions.add(new InsnNode(Opcodes.ACONST_NULL));
}
instructions.add(new InsnNode(returnType.getOpcode(Opcodes.IRETURN)));
} else {
instructions.insert(throwExceptionsList(methodNode, classNode));
}
}
}