当前位置: 首页>>代码示例>>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;未经允许,请勿转载。