当前位置: 首页>>代码示例>>Java>>正文


Java JumpInsnNode类代码示例

本文整理汇总了Java中org.objectweb.asm.tree.JumpInsnNode的典型用法代码示例。如果您正苦于以下问题:Java JumpInsnNode类的具体用法?Java JumpInsnNode怎么用?Java JumpInsnNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JumpInsnNode类属于org.objectweb.asm.tree包,在下文中一共展示了JumpInsnNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findJumpTargets

import org.objectweb.asm.tree.JumpInsnNode; //导入依赖的package包/类
private static Set<AbstractInsnNode> findJumpTargets(final InsnList instructions) {
  final Set<AbstractInsnNode> jumpTargets = new HashSet<AbstractInsnNode>();
  final ListIterator<AbstractInsnNode> it = instructions.iterator();
  while (it.hasNext()) {
    final AbstractInsnNode o = it.next();
    if (o instanceof JumpInsnNode) {
      jumpTargets.add(((JumpInsnNode) o).label);
    } else if (o instanceof TableSwitchInsnNode) {
      final TableSwitchInsnNode twn = (TableSwitchInsnNode) o;
      jumpTargets.add(twn.dflt);
      jumpTargets.addAll(twn.labels);
    } else if (o instanceof LookupSwitchInsnNode) {
      final LookupSwitchInsnNode lsn = (LookupSwitchInsnNode) o;
      jumpTargets.add(lsn.dflt);
      jumpTargets.addAll(lsn.labels);
    }
  }
  return jumpTargets;
}
 
开发者ID:ncredinburgh,项目名称:QuickTheories,代码行数:20,代码来源:ControlFlowAnalyser.java

示例2: merge

import org.objectweb.asm.tree.JumpInsnNode; //导入依赖的package包/类
public boolean merge(final Subroutine subroutine) throws AnalyzerException {
    boolean changes = false;
    for (int i = 0; i < access.length; ++i) {
        if (subroutine.access[i] && !access[i]) {
            access[i] = true;
            changes = true;
        }
    }
    if (subroutine.start == start) {
        for (int i = 0; i < subroutine.callers.size(); ++i) {
            JumpInsnNode caller = subroutine.callers.get(i);
            if (!callers.contains(caller)) {
                callers.add(caller);
                changes = true;
            }
        }
    }
    return changes;
}
 
开发者ID:ItzSomebody,项目名称:DirectLeaks-AntiReleak-Remover,代码行数:20,代码来源:Subroutine.java

示例3: visit

import org.objectweb.asm.tree.JumpInsnNode; //导入依赖的package包/类
@Override
public void visit(Branch.Condition.Nil cond) {
  assert (destLabel != null);
  il.add(new VarInsnNode(ALOAD, slot(cond.addr())));

  if (!isSub() || resolver.isLocalLabel(destLabel)) {
    // local jump
    il.add(new JumpInsnNode(IFNULL, l(destLabel)));
  } else {
    // non-local jump
    LabelNode l_nojump = new LabelNode();
    il.add(new JumpInsnNode(IFNONNULL, l_nojump));
    il.add(_nonLocalGoto(destLabel));
    il.add(l_nojump);
    il.add(new FrameNode(F_SAME, 0, null, 0, null));
  }
}
 
开发者ID:kroepke,项目名称:luna,代码行数:18,代码来源:BytecodeEmitVisitor.java

示例4: iterator

import org.objectweb.asm.tree.JumpInsnNode; //导入依赖的package包/类
@Override
public Iterator<AbstractInsnNode> iterator() {
    return new Iterator<AbstractInsnNode>() {

        private int index = 0;

        @Override
        public boolean hasNext() {
            return index < insns.size();
        }

        @Override
        public AbstractInsnNode next() {
            AbstractInsnNode insn = insns.get(index++);
            return insn.getOpcode() == GOTO ? insns.get(
                    insns.indexOf(((JumpInsnNode) insn).label)
            ).getNext() : insn;
        }

        @Override
        public void remove() {
            insns.remove(insns.get(index));
        }
    };
}
 
开发者ID:disassemble-io,项目名称:kNN,代码行数:26,代码来源:FlowIterator.java

示例5: transformPlayer

import org.objectweb.asm.tree.JumpInsnNode; //导入依赖的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

示例6: patchMenu

import org.objectweb.asm.tree.JumpInsnNode; //导入依赖的package包/类
private void patchMenu(ClassNode node) {
	Logger.Info("Patching menu (" + node.name + ".class)");
	
	Iterator<MethodNode> methodNodeList = node.methods.iterator();
	while (methodNodeList.hasNext()) {
		MethodNode methodNode = methodNodeList.next();
		
		// Menu swap hook
		if (methodNode.name.equals("e") && methodNode.desc.equals("(II)V")) {
			AbstractInsnNode first = methodNode.instructions.getFirst();
			
			LabelNode label = new LabelNode();
			methodNode.instructions.insertBefore(first, new VarInsnNode(Opcodes.ALOAD, 0));
			methodNode.instructions.insertBefore(first, new MethodInsnNode(Opcodes.INVOKESTATIC, "Game/Menu", "switchList", "(Ljava/lang/Object;)Z"));
			methodNode.instructions.insertBefore(first, new JumpInsnNode(Opcodes.IFGT, label));
			methodNode.instructions.insertBefore(first, new InsnNode(Opcodes.RETURN));
			methodNode.instructions.insertBefore(first, label);
		}
	}
}
 
开发者ID:OrN,项目名称:rscplus,代码行数:21,代码来源:JClassPatcher.java

示例7: matches

import org.objectweb.asm.tree.JumpInsnNode; //导入依赖的package包/类
@Override
public boolean matches(ClassMethod method) {
    List<String> visitedLabels = new ArrayList<>();
    AbstractInsnNode[] instructions = method.instructions().toArray();
    for (AbstractInsnNode insn : instructions) {
        if (insn instanceof JumpInsnNode) {
            Label label = ((JumpInsnNode) insn).label.getLabel();
            String labelString = label.toString();
            if (visitedLabels.contains(labelString)) {
                return true;
            } else {
                visitedLabels.add(labelString);
            }
        }
    }
    return false;
}
 
开发者ID:disassemble-io,项目名称:asm-framework-full,代码行数:18,代码来源:Looping.java

示例8: trueBranch

import org.objectweb.asm.tree.JumpInsnNode; //导入依赖的package包/类
/**
 * Gets the path that branches to a true value.
 *
 * @return The path that branches to a true value.
 */
public Optional<BasicBlock> trueBranch() {
    if (successors.size() == 1) {
        return Optional.of(successors.get(0));
    }
    BasicInstruction endInsn = exit();
    if (endInsn.insn instanceof JumpInsnNode) {
        LabelNode label = ((JumpInsnNode) endInsn.insn).label;
        for (BasicBlock successor : successors) {
            BasicInstruction startInsn = successor.entry();
            if (startInsn != null && label == startInsn.insn) {
                return Optional.of(successor);
            }
        }
    }
    return Optional.empty();
}
 
开发者ID:disassemble-io,项目名称:asm-framework-full,代码行数:22,代码来源:BasicBlock.java

示例9: build

import org.objectweb.asm.tree.JumpInsnNode; //导入依赖的package包/类
@Override
public InsnList build(MethodContext context) {
	Type returnType = context.getResultType();
	InsnList insnList = new InsnList();
	LabelNode continueLabel = new LabelNode();
	insnList.add(new InsnNode(DUP));
	insnList.add(new FieldInsnNode(GETSTATIC, Type.getInternalName(clazz), field, Type.getDescriptor(Object.class)));
	insnList.add(new JumpInsnNode(IF_ACMPEQ, continueLabel));
	if (returnType.getSize() == 0) {
		insnList.add(new InsnNode(POP));
		insnList.add(new InsnNode(RETURN));
	} else if (isPrimitive(returnType)) {
		insnList.add(new UnboxPrimitives(returnType).build(context));
		insnList.add(new InsnNode(returnType.getOpcode(IRETURN)));
	} else {
		insnList.add(new TypeInsnNode(CHECKCAST, returnType.getInternalName()));
		insnList.add(new InsnNode(ARETURN));
	}
	insnList.add(continueLabel);
	insnList.add(new InsnNode(POP));
	return insnList;
}
 
开发者ID:almondtools,项目名称:testrecorder,代码行数:23,代码来源:ReturnFakeOrProceed.java

示例10: transformDamageItem

import org.objectweb.asm.tree.JumpInsnNode; //导入依赖的package包/类
private void transformDamageItem(MethodNode method) {
	InsnList postEvent = new InsnList();
	LabelNode label = new LabelNode(new Label());
	
	postEvent.add(new TypeInsnNode(Opcodes.NEW, DAMAGE_ITEM_EVENT.getInternalName()));
	postEvent.add(new InsnNode(Opcodes.DUP));
	postEvent.add(new VarInsnNode(Opcodes.ALOAD, 2));
	postEvent.add(new VarInsnNode(Opcodes.ILOAD, 1));
	postEvent.add(new VarInsnNode(Opcodes.ALOAD, 0));
	postEvent.add(new MethodInsnNode(Opcodes.INVOKESPECIAL, DAMAGE_ITEM_EVENT_INIT.getOwnerInternalName(), DAMAGE_ITEM_EVENT_INIT.getEnvName(), DAMAGE_ITEM_EVENT_INIT.getDesc(), false));
	postEvent.add(new VarInsnNode(Opcodes.ASTORE, 3));
	
	postEvent.add(new FieldInsnNode(Opcodes.GETSTATIC, EVENTHANDLER_DAMAGE_ITEM.getOwnerInternalName(), EVENTHANDLER_DAMAGE_ITEM.getEnvName(), EVENTHANDLER_DAMAGE_ITEM.getDesc()));
	postEvent.add(new VarInsnNode(Opcodes.ALOAD, 3));
	postEvent.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, POST.getOwnerInternalName(), POST.getEnvName(), POST.getDesc(), false));
	postEvent.add(new JumpInsnNode(Opcodes.IFEQ, label));
	postEvent.add(new InsnNode(Opcodes.RETURN));
	
	postEvent.add(label);
	postEvent.add(new FrameNode(Opcodes.F_APPEND, 1, new Object[] {DAMAGE_ITEM_EVENT.getInternalName()}, 0, null));
	postEvent.add(new VarInsnNode(Opcodes.ALOAD, 3));
	postEvent.add(new FieldInsnNode(Opcodes.GETFIELD, DAMAGE.getOwnerInternalName(), DAMAGE.getEnvName(), DAMAGE.getDesc()));
	postEvent.add(new VarInsnNode(Opcodes.ISTORE, 1));
	
	method.instructions.insert(postEvent);
}
 
开发者ID:MrNobody98,项目名称:morecommands,代码行数:27,代码来源:TransformItemStack.java

示例11: transformAddPrefix

import org.objectweb.asm.tree.JumpInsnNode; //导入依赖的package包/类
private void transformAddPrefix(ClassNode cnode) {
	ObfMapping mapping = new ObfMapping("net/minecraftforge/fml/common/registry/GameData", "addPrefix", "(Ljava/lang/String;)Ljava/lang/String;");
	MethodNode method = ASMHelper.findMethod(mapping, cnode);

	if (method == null) {
		throw new IllegalStateException("[NOVA] Lookup " + mapping + " failed!");
	}

	Game.logger().info("Transforming method {}", method.name);

	@SuppressWarnings("unchecked")
	JumpInsnNode prev = (JumpInsnNode) method.instructions.get(49);

	InsnList list = new InsnList();
	list.add(new VarInsnNode(ALOAD, 4));
	list.add(new MethodInsnNode(INVOKESTATIC, "nova/core/wrapper/mc/forge/v18/asm/StaticForwarder", "isNovaPrefix", "(Ljava/lang/String;)Z", false));
	list.add(new JumpInsnNode(IFNE, prev.label));

	method.instructions.insert(prev, list);

	Game.logger().info("Injected instruction to method: {}", method.name);
}
 
开发者ID:NOVA-Team,项目名称:NOVA-Core,代码行数:23,代码来源:GameDataTransformer.java

示例12: transformAddPrefix

import org.objectweb.asm.tree.JumpInsnNode; //导入依赖的package包/类
private void transformAddPrefix(ClassNode cnode) {
	ObfMapping mapping = new ObfMapping("cpw/mods/fml/common/registry/GameData", "addPrefix", "(Ljava/lang/String;)Ljava/lang/String;");
	MethodNode method = ASMHelper.findMethod(mapping, cnode);

	if (method == null) {
		throw new IllegalStateException("[NOVA] Lookup " + mapping + " failed!");
	}

	Game.logger().info("Transforming method {}", method.name);

	@SuppressWarnings("unchecked")
	JumpInsnNode prev = (JumpInsnNode) method.instructions.get(49);

	InsnList list = new InsnList();
	list.add(new VarInsnNode(ALOAD, 4));
	list.add(new MethodInsnNode(INVOKESTATIC, "nova/core/wrapper/mc/forge/v17/asm/StaticForwarder", "isNovaPrefix", "(Ljava/lang/String;)Z", false));
	list.add(new JumpInsnNode(IFNE, prev.label));

	method.instructions.insert(prev, list);

	Game.logger().info("Injected instruction to method: {}", method.name);
}
 
开发者ID:NOVA-Team,项目名称:NOVA-Core,代码行数:23,代码来源:GameDataTransformer.java

示例13: insertPushNull

import org.objectweb.asm.tree.JumpInsnNode; //导入依赖的package包/类
/**
 * Insert a call to the isNull helper function
 * 
 * @param opcode
 * @param position
 * @param list
 */
public void insertPushNull(int opcode, JumpInsnNode position, InsnList list) {
	int branchId = getBranchID(currentMethodNode, position);
	logger.info("Inserting instrumentation for NULL check at branch " + branchId
	        + " in method " + currentMethodNode.name);

	MethodInsnNode nullCheck = new MethodInsnNode(Opcodes.INVOKESTATIC,
	        Type.getInternalName(BooleanHelper.class), "isNull",
	        Type.getMethodDescriptor(Type.INT_TYPE,
	                                 new Type[] { Type.getType(Object.class),
	                                         Type.INT_TYPE }), false);
	list.insertBefore(position, new InsnNode(Opcodes.DUP));
	list.insertBefore(position, new LdcInsnNode(opcode));
	list.insertBefore(position, nullCheck);
	//list.insertBefore(position,
	//                  new LdcInsnNode(getBranchID(currentMethodNode, position)));
	insertBranchIdPlaceholder(currentMethodNode, position, branchId);
	MethodInsnNode push = new MethodInsnNode(Opcodes.INVOKESTATIC,
	        Type.getInternalName(BooleanHelper.class), "pushPredicate",
	        Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] { Type.INT_TYPE,
	                Type.INT_TYPE }), false);
	list.insertBefore(position, push);

}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:31,代码来源:BooleanTestabilityTransformation.java

示例14: insertPushEquals

import org.objectweb.asm.tree.JumpInsnNode; //导入依赖的package包/类
/**
 * Insert a call to the reference equality check helper function
 * 
 * @param opcode
 * @param position
 * @param list
 */
public void insertPushEquals(int opcode, JumpInsnNode position, InsnList list) {
	MethodInsnNode equalCheck = new MethodInsnNode(Opcodes.INVOKESTATIC,
	        Type.getInternalName(BooleanHelper.class), "isEqual",
	        Type.getMethodDescriptor(Type.INT_TYPE,
	                                 new Type[] { Type.getType(Object.class),
	                                         Type.getType(Object.class),
	                                         Type.INT_TYPE }), false);
	list.insertBefore(position, new InsnNode(Opcodes.DUP2));
	list.insertBefore(position, new LdcInsnNode(opcode));
	list.insertBefore(position, equalCheck);
	//list.insertBefore(position,
	//                  new LdcInsnNode(getBranchID(currentMethodNode, position)));
	insertBranchIdPlaceholder(currentMethodNode, position);
	MethodInsnNode push = new MethodInsnNode(Opcodes.INVOKESTATIC,
	        Type.getInternalName(BooleanHelper.class), "pushPredicate",
	        Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] { Type.INT_TYPE,
	                Type.INT_TYPE }), false);
	list.insertBefore(position, push);

}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:28,代码来源:BooleanTestabilityTransformation.java

示例15: insertPush

import org.objectweb.asm.tree.JumpInsnNode; //导入依赖的package包/类
/**
 * Insert a call to the distance function for unary comparison
 * 
 * @param opcode
 * @param position
 * @param list
 */
public void insertPush(int opcode, JumpInsnNode position, InsnList list) {
	list.insertBefore(position, new InsnNode(Opcodes.DUP));
	// TODO: We have to put a placeholder here instead of the actual branch ID
	// TODO: And then later add another transformation where we replace this with
	//       actual branch IDs
	//list.insertBefore(position,
	//                  new LdcInsnNode(getBranchID(currentMethodNode, position)));
	insertBranchIdPlaceholder(currentMethodNode, position);
	MethodInsnNode push = new MethodInsnNode(Opcodes.INVOKESTATIC,
	        Type.getInternalName(BooleanHelper.class), "pushPredicate",
	        Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] { Type.INT_TYPE,
	                Type.INT_TYPE }), false);
	list.insertBefore(position, push);

}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:23,代码来源:BooleanTestabilityTransformation.java


注:本文中的org.objectweb.asm.tree.JumpInsnNode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。