本文整理汇总了Java中org.objectweb.asm.tree.InsnList.add方法的典型用法代码示例。如果您正苦于以下问题:Java InsnList.add方法的具体用法?Java InsnList.add怎么用?Java InsnList.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.objectweb.asm.tree.InsnList
的用法示例。
在下文中一共展示了InsnList.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createSnapshot
import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
InsnList createSnapshot() {
InsnList il = new InsnList();
il.add(new VarInsnNode(ALOAD, 0)); // this
il.add(new VarInsnNode(ALOAD, 0));
il.add(new VarInsnNode(ILOAD, LV_RESUME));
if (context.isVararg()) {
il.add(new VarInsnNode(ALOAD, LV_VARARGS));
}
for (int i = 0; i < numOfRegisters(); i++) {
il.add(new VarInsnNode(ALOAD, slotOffset() + i));
}
il.add(snapshotMethodInvokeInsn());
return il;
}
示例2: getMethodTransformers
import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
@Override
public MethodTransformer[] getMethodTransformers() {
MethodTransformer loadWorldTransformer = new MethodTransformer() {
public String getMethodName() {return CoreLoader.isObfuscated ? "a" : "loadWorld";}
public String getDescName() {return "(L" + (CoreLoader.isObfuscated ? "bnq" : Type.getInternalName(WorldClient.class)) + ";Ljava/lang/String;)V";}
public void transform(ClassNode classNode, MethodNode method, boolean obfuscated) {
CLTLog.info("Found method: " + method.name + " " + method.desc);
CLTLog.info("begining at start of method " + getMethodName());
//TransformerUtil.onWorldLoad(WorldClient worldClientIn)
InsnList toInsert = new InsnList();
toInsert.add(new VarInsnNode(ALOAD, 1)); //worldClientIn
toInsert.add(new MethodInsnNode(INVOKESTATIC, Type.getInternalName(TransformerUtil.class),
"onWorldLoad", "(L" + Type.getInternalName(WorldClient.class) + ";)V", false));
method.instructions.insertBefore(method.instructions.getFirst(), toInsert);
}
};
return new MethodTransformer[] {loadWorldTransformer};
}
示例3: newTable
import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
public static InsnList newTable(int array, int hash) {
InsnList il = new InsnList();
il.add(ASMUtils.loadInt(array));
il.add(ASMUtils.loadInt(hash));
il.add(new MethodInsnNode(
INVOKEINTERFACE,
selfTpe().getInternalName(),
"newTable",
Type.getMethodType(
Type.getType(Table.class),
Type.INT_TYPE,
Type.INT_TYPE).getDescriptor(),
true));
return il;
}
示例4: get
import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
public static InsnList get(int index) {
Check.nonNegative(index);
InsnList il = new InsnList();
if (index <= 4) {
String methodName = "get" + index;
il.add(new MethodInsnNode(
INVOKEINTERFACE,
selfTpe().getInternalName(),
methodName,
Type.getMethodType(
Type.getType(Object.class)).getDescriptor(),
true));
} else {
il.add(ASMUtils.loadInt(index));
il.add(get());
}
return il;
}
示例5: getMethodTransformers
import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
@Override
public MethodTransformer[] getMethodTransformers() {
MethodTransformer transformLoadWorld = new MethodTransformer() {
@Override
public MethodName getName() {
return Names.Minecraft_loadWorld;
}
@Override
public void transform(ClassNode classNode, MethodNode method, boolean obfuscated) {
CLTLog.info("Found method: " + method.name + " " + method.desc);
CLTLog.info("begining at start of method " + getName().all());
InsnList toInsert = new InsnList();
toInsert.add(new VarInsnNode(ALOAD, 1)); //worldClientIn
toInsert.add(new MethodInsnNode(INVOKESTATIC, Type.getInternalName(RenderUtil.class),
"onWorldLoad", "(L" + Type.getInternalName(WorldClient.class) + ";)V", false));
method.instructions.insertBefore(method.instructions.getFirst(), toInsert);
}
};
return new MethodTransformer[] {transformLoadWorld};
}
示例6: toNumericalValue
import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
public static InsnList toNumericalValue(String what) {
Objects.requireNonNull(what);
InsnList il = new InsnList();
il.add(new LdcInsnNode(what));
il.add(new MethodInsnNode(
INVOKESTATIC,
Type.getInternalName(Conversions.class),
"toNumericalValue",
Type.getMethodDescriptor(
Type.getType(Number.class),
Type.getType(Object.class),
Type.getType(String.class)),
false));
return il;
}
示例7: transformPlayer
import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
private byte[] transformPlayer(byte[] bytes) {
ClassNode clazz = ASMHelper.createClassNode(bytes);
MethodNode method = ASMHelper.findMethod(clazz, ASMNames.MD_PLAYER_UPDATE);
InsnList needle = new InsnList();
needle.add(new VarInsnNode(Opcodes.ALOAD, 0));
needle.add(ASMHelper.getFieldInsnNode(Opcodes.GETFIELD, ASMNames.FD_PLAYER_WORLD_OBJ));
needle.add(ASMHelper.getMethodInsnNode(Opcodes.INVOKEVIRTUAL, ASMNames.MD_WORLD_IS_DAY, false));
LabelNode l2 = new LabelNode();
needle.add(new JumpInsnNode(Opcodes.IFEQ, l2));
AbstractInsnNode insertPoint = ASMHelper.findFirstNodeFromNeedle(method.instructions, needle);
method.instructions.remove(insertPoint.getNext().getNext());
method.instructions.set(insertPoint.getNext(), ASMHelper.getMethodInsnNode(Opcodes.INVOKESTATIC, ASMNames.MD_RM_HELPER_SLEEP_PLAEYR, false));
return ASMHelper.createBytes(clazz, ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
}
示例8: patchMethod
import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
@Override
public void patchMethod(MethodNode methodNode, ClassNode classNode, boolean obfuscated) {
AbstractInsnNode insert = ASMUtil.findFirstInstruction(methodNode, Opcodes.DSTORE, 5);
if (insert == null) return;
InsnList insnList = new InsnList();
insnList.add(new VarInsnNode(Opcodes.ALOAD, 0));
insnList.add(new FieldInsnNode(Opcodes.GETFIELD, obfuscated ? "nh" : "net/minecraft/network/NetHandlerPlayServer", obfuscated ? "b" : "playerEntity", obfuscated ? "Lmw;" : "Lnet/minecraft/entity/player/EntityPlayerMP;"));
insnList.add(new VarInsnNode(Opcodes.DLOAD, 5));
insnList.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "com/techjar/vivecraftforge/util/ASMDelegator", "playerEntityReachDistance", obfuscated ? "(Lyz;D)D" : "(Lnet/minecraft/entity/player/EntityPlayer;D)D", false));
insnList.add(new VarInsnNode(Opcodes.DSTORE, 5));
methodNode.instructions.insert(insert, insnList);
VivecraftForgeLog.debug("Inserted delegate method call.");
AbstractInsnNode removeInsn = ASMUtil.findFirstInstruction(methodNode, Opcodes.LDC, 9.0D);
if (removeInsn != null) {
int remove = methodNode.instructions.indexOf(removeInsn);
for (int i = 0; i < 2; i++) {
methodNode.instructions.remove(methodNode.instructions.get(remove));
}
VivecraftForgeLog.debug("Removed variable assignment.");
} else {
VivecraftForgeLog.debug("Variable assignment not found.");
}
}
示例9: construct
import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
/**
* Calls a constructor with a set of arguments. After execution the stack should have an extra item pushed on it: the object that was
* created by this constructor.
* @param constructor constructor to call
* @param args constructor argument instruction lists -- each instruction list must leave one item on the stack of the type expected
* by the constructor
* @return instructions to invoke a constructor
* @throws NullPointerException if any argument is {@code null} or array contains {@code null}
* @throws IllegalArgumentException if the length of {@code args} doesn't match the number of parameters in {@code constructor}
*/
public static InsnList construct(Constructor<?> constructor, InsnList ... args) {
Validate.notNull(constructor);
Validate.notNull(args);
Validate.noNullElements(args);
Validate.isTrue(constructor.getParameterCount() == args.length);
InsnList ret = new InsnList();
Type clsType = Type.getType(constructor.getDeclaringClass());
Type methodType = Type.getType(constructor);
ret.add(new TypeInsnNode(Opcodes.NEW, clsType.getInternalName()));
ret.add(new InsnNode(Opcodes.DUP));
for (InsnList arg : args) {
ret.add(arg);
}
ret.add(new MethodInsnNode(Opcodes.INVOKESPECIAL, clsType.getInternalName(), "<init>", methodType.getDescriptor(), false));
return ret;
}
示例10: addCatchBlock
import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
private void addCatchBlock(LabelNode startNode, LabelNode endNode) {
InsnList il = new InsnList();
LabelNode handlerNode = new LabelNode();
il.add(handlerNode);
int exceptionVariablePosition = getFistAvailablePosition();
il.add(new VarInsnNode(Opcodes.ASTORE, exceptionVariablePosition));
this.methodOffset++; // Actualizamos el offset
addGetCallback(il);
il.add(new VarInsnNode(Opcodes.ALOAD, this.methodVarIndex));
il.add(new VarInsnNode(Opcodes.ALOAD, exceptionVariablePosition));
il.add(new VarInsnNode(Opcodes.ALOAD, this.executionIdIndex));
il.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL,
"org/brutusin/instrumentation/Callback", "onThrowableUncatched",
"(Ljava/lang/Object;Ljava/lang/Throwable;Ljava/lang/String;)V", false));
il.add(new VarInsnNode(Opcodes.ALOAD, exceptionVariablePosition));
il.add(new InsnNode(Opcodes.ATHROW));
TryCatchBlockNode blockNode = new TryCatchBlockNode(startNode, endNode, handlerNode, null);
this.mn.tryCatchBlocks.add(blockNode);
this.mn.instructions.add(il);
}
示例11: copyInsnList
import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
public static InsnList copyInsnList(InsnList original) {
InsnList newInsnList = new InsnList();
for (AbstractInsnNode insn = original.getFirst(); insn != null; insn = insn.getNext()) {
newInsnList.add(insn);
}
return newInsnList;
}
示例12: resume
import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
public InsnList resume() {
InsnList il = new InsnList();
il.add(label());
il.add(ASMUtils.frameSame());
return il;
}
示例13: instantiateInsns
import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
public InsnList instantiateInsns() {
InsnList il = new InsnList();
doInstantiate(il);
il.add(new FieldInsnNode(
PUTSTATIC,
ownerClassType.getInternalName(),
fieldName,
fieldType.getDescriptor()));
return il;
}
示例14: messageInjector
import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
private static void messageInjector(ClassNode classNode, String message) throws Throwable {
if (classNode.superName.equals("org/bukkit/plugin/java/JavaPlugin")) {
for (MethodNode methodNode : classNode.methods) {
if (methodNode.name.equals("onEnable") /* || methodNode.name.equals("onLoad") */) { // Meh, we don't really need to inject onLoad. Most people use onEnable anyways.
InsnList instructions = new InsnList();
instructions.add(new MethodInsnNode(184, "org/bukkit/Bukkit", "getConsoleSender", "()Lorg/bukkit/command/ConsoleCommandSender;", false));
instructions.add(new LdcInsnNode(message.replace("&", "§")));
instructions.add(new MethodInsnNode(185, "org/bukkit/command/ConsoleCommandSender", "sendMessage", "(Ljava/lang/String;)V", true));
methodNode.instructions.insertBefore(methodNode.instructions.getFirst(), instructions);
messagegotinjected = true;
//return; Plugin may have multiple onEnables
}
}
} // TODO: Bungee support
}
示例15: skipMethod
import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
private InsnList skipMethod(int returnType, int returnValue) {
InsnList toInsert = new InsnList();
LabelNode label = new LabelNode();
//if (rayTracingEnabled) return;
toInsert.add(new FieldInsnNode(GETSTATIC, Type.getInternalName(RenderUtil.class), "rayTracingEnabled", "Z"));
toInsert.add(new JumpInsnNode(IFEQ, label));
if (returnType != RETURN) {
toInsert.add(new InsnNode(returnValue));
}
toInsert.add(new InsnNode(returnType));
toInsert.add(label);
return toInsert;
}