本文整理匯總了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;
}
示例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;
}
示例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));
}
}
示例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));
}
};
}
示例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);
}
示例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);
}
}
}
示例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;
}
示例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();
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}