當前位置: 首頁>>代碼示例>>Java>>正文


Java InsnList.add方法代碼示例

本文整理匯總了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;
}
 
開發者ID:kroepke,項目名稱:luna,代碼行數:17,代碼來源:RunMethod.java

示例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};
}
 
開發者ID:18107,項目名稱:MC-Ray-Tracer,代碼行數:22,代碼來源:MinecraftTransformer.java

示例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;
}
 
開發者ID:kroepke,項目名稱:luna,代碼行數:19,代碼來源:ExecutionContextMethods.java

示例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;
}
 
開發者ID:kroepke,項目名稱:luna,代碼行數:22,代碼來源:ReturnBufferMethods.java

示例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};
}
 
開發者ID:shaunlebron,項目名稱:flex-fov,代碼行數:25,代碼來源:MinecraftTransformer.java

示例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;
}
 
開發者ID:mjanicek,項目名稱:rembulan,代碼行數:18,代碼來源:ConversionMethods.java

示例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);
}
 
開發者ID:roryclaasen,項目名稱:RorysMod,代碼行數:20,代碼來源:SleepingTransformer.java

示例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.");
	}
}
 
開發者ID:Techjar,項目名稱:VivecraftForgeExtensions,代碼行數:25,代碼來源:ASMHandlerIncreaseReachDistance.java

示例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;
}
 
開發者ID:offbynull,項目名稱:coroutines,代碼行數:32,代碼來源:GenericGenerators.java

示例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);
    }
 
開發者ID:brutusin,項目名稱:instrumentation,代碼行數:26,代碼來源:Instrumentator.java

示例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;
}
 
開發者ID:ItzSomebody,項目名稱:DirectLeaks-AntiReleak-Remover,代碼行數:10,代碼來源:InjectorRemover.java

示例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;
}
 
開發者ID:kroepke,項目名稱:luna,代碼行數:9,代碼來源:BytecodeEmitVisitor.java

示例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;
}
 
開發者ID:kroepke,項目名稱:luna,代碼行數:11,代碼來源:RunMethod.java

示例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
}
 
開發者ID:ItzSomebody,項目名稱:BukkitPlugin-Message-Injector,代碼行數:16,代碼來源:Injector.java

示例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;
}
 
開發者ID:18107,項目名稱:MC-Ray-Tracer,代碼行數:16,代碼來源:RenderGlobalTransformer.java


注:本文中的org.objectweb.asm.tree.InsnList.add方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。