本文整理汇总了Java中org.objectweb.asm.tree.LabelNode类的典型用法代码示例。如果您正苦于以下问题:Java LabelNode类的具体用法?Java LabelNode怎么用?Java LabelNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LabelNode类属于org.objectweb.asm.tree包,在下文中一共展示了LabelNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: markSubroutines
import org.objectweb.asm.tree.LabelNode; //导入依赖的package包/类
/**
* Walks the method and determines which internal subroutine(s), if any,
* each instruction is a method of.
*/
private void markSubroutines() {
BitSet anyvisited = new BitSet();
// First walk the main subroutine and find all those instructions which
// can be reached without invoking any JSR at all
markSubroutineWalk(mainSubroutine, 0, anyvisited);
// Go through the head of each subroutine and find any nodes reachable
// to that subroutine without following any JSR links.
for (Iterator<Map.Entry<LabelNode, BitSet>> it = subroutineHeads
.entrySet().iterator(); it.hasNext();) {
Map.Entry<LabelNode, BitSet> entry = it.next();
LabelNode lab = entry.getKey();
BitSet sub = entry.getValue();
int index = instructions.indexOf(lab);
markSubroutineWalk(sub, index, anyvisited);
}
}
示例2: visit
import org.objectweb.asm.tree.LabelNode; //导入依赖的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));
}
}
示例3: dispatchTable
import org.objectweb.asm.tree.LabelNode; //导入依赖的package包/类
private InsnList dispatchTable(List<LabelNode> extLabels, List<LabelNode> resumptionLabels,
LabelNode errorStateLabel) {
InsnList il = new InsnList();
assert (!extLabels.isEmpty());
ArrayList<LabelNode> labels = new ArrayList<>();
labels.addAll(extLabels);
labels.addAll(resumptionLabels);
LabelNode[] labelArray = labels.toArray(new LabelNode[labels.size()]);
int min = 1 - extLabels.size();
int max = resumptionLabels.size();
il.add(new VarInsnNode(ILOAD, LV_RESUME));
il.add(new TableSwitchInsnNode(min, max, errorStateLabel, labelArray));
return il;
}
示例4: resumptionHandler
import org.objectweb.asm.tree.LabelNode; //导入依赖的package包/类
protected InsnList resumptionHandler(LabelNode label) {
InsnList il = new InsnList();
il.add(label);
il.add(ASMUtils.frameSame1(UnresolvedControlThrowable.class));
il.add(createSnapshot());
// register snapshot with the control exception
il.add(new MethodInsnNode(
INVOKEVIRTUAL,
Type.getInternalName(UnresolvedControlThrowable.class),
"resolve",
Type.getMethodType(
Type.getType(ResolvedControlThrowable.class),
Type.getType(Resumable.class),
Type.getType(Object.class)).getDescriptor(),
false));
// rethrow
il.add(new InsnNode(ATHROW));
return il;
}
示例5: replaceLabels
import org.objectweb.asm.tree.LabelNode; //导入依赖的package包/类
public void replaceLabels(Map<LabelNode, LabelNode> labelMap, Set<LabelNode> usedLabels) {
for (AbstractInsnNode insn : list)
switch (insn.getType()) {
case LABEL:
AbstractInsnNode insn2 = insn.clone(labelMap);
if (insn2 == insn)//identity mapping
continue;
if (usedLabels.contains(insn2))
throw new IllegalStateException("LabelNode cannot be a part of two InsnLists");
list.replace(insn, insn2);
break;
case JUMP_INSN:
case FRAME:
case LOOKUPSWITCH_INSN:
case TABLESWITCH_INSN:
list.replace(insn, insn.clone(labelMap));
}
for(Entry<LabelNode, LabelNode> entry : labelMap.entrySet()) {
String key = labels.inverse().get(entry.getKey());
if(key != null)
labels.put(key, entry.getValue());
}
}
示例6: mergeLabels
import org.objectweb.asm.tree.LabelNode; //导入依赖的package包/类
/**
* Pulls all common labels from other into this
* @return this
*/
public ASMBlock mergeLabels(ASMBlock other) {
if(labels.isEmpty() || other.labels.isEmpty())
return this;
//common labels, give them our nodes
HashMap<LabelNode, LabelNode> labelMap = list.identityLabelMap();
for(Entry<String, LabelNode> entry : other.labels.entrySet()) {
LabelNode old = labels.get(entry.getKey());
if(old != null)
labelMap.put(old, entry.getValue());
}
HashSet<LabelNode> usedLabels = new HashSet<LabelNode>();
for (AbstractInsnNode insn = other.list.list.getFirst(); insn != null; insn = insn.getNext())
if(insn.getType() == LABEL)
usedLabels.add((LabelNode) insn);
replaceLabels(labelMap, usedLabels);
return this;
}
示例7: getLabelIdx
import org.objectweb.asm.tree.LabelNode; //导入依赖的package包/类
private int getLabelIdx(LabelNode l) {
int idx;
if(l instanceof BlockLabelNode) {
idx = ((BlockLabelNode)l).idx;
} else {
idx = mn.instructions.indexOf(l);
}
// search for the "real" instruction
for(;;) {
int type = mn.instructions.get(idx).getType();
if(type != AbstractInsnNode.LABEL && type != AbstractInsnNode.LINE) {
return idx;
}
idx++;
}
}
示例8: convertTableSwitchInsn
import org.objectweb.asm.tree.LabelNode; //导入依赖的package包/类
private void convertTableSwitchInsn(TableSwitchInsnNode insn) {
StackFrame frame = getFrame(insn);
if (units.containsKey(insn)) {
frame.mergeIn(pop());
return;
}
Operand key = popImmediate();
UnitBox dflt = Jimple.v().newStmtBox(null);
List<UnitBox> targets = new ArrayList<UnitBox>(insn.labels.size());
labels.put(insn.dflt, dflt);
for (LabelNode ln : insn.labels) {
UnitBox box = Jimple.v().newStmtBox(null);
targets.add(box);
labels.put(ln, box);
}
TableSwitchStmt tss = Jimple.v().newTableSwitchStmt(key.stackOrValue(),
insn.min, insn.max, targets, dflt);
key.addBox(tss.getKeyBox());
frame.in(key);
frame.boxes(tss.getKeyBox());
setUnit(insn, tss);
}
示例9: convertLabel
import org.objectweb.asm.tree.LabelNode; //导入依赖的package包/类
private void convertLabel(LabelNode ln) {
if (!trapHandlers.containsKey(ln))
return;
StackFrame frame = getFrame(ln);
Operand[] out = frame.out();
Operand opr;
if (out == null) {
CaughtExceptionRef ref = Jimple.v().newCaughtExceptionRef();
Local stack = newStackLocal();
DefinitionStmt as = Jimple.v().newIdentityStmt(stack, ref);
opr = new Operand(ln, ref);
opr.stack = stack;
frame.out(opr);
setUnit(ln, as);
} else {
opr = out[0];
}
push(opr);
}
示例10: getImportantList
import org.objectweb.asm.tree.LabelNode; //导入依赖的package包/类
public static InsnList getImportantList(InsnList list) {
if (list.size() == 0) {
return list;
}
HashMap<LabelNode, LabelNode> labels = new HashMap<>();
for (AbstractInsnNode insn = list.getFirst(); insn != null; insn = insn.getNext()) {
if (insn instanceof LabelNode) {
labels.put((LabelNode) insn, (LabelNode) insn);
}
}
InsnList importantNodeList = new InsnList();
for (AbstractInsnNode insn = list.getFirst(); insn != null; insn = insn.getNext()) {
if (insn instanceof LabelNode || insn instanceof LineNumberNode) {
continue;
}
importantNodeList.add(insn.clone(labels));
}
return importantNodeList;
}
示例11: insnListMatchesL
import org.objectweb.asm.tree.LabelNode; //导入依赖的package包/类
private static InsnListSection insnListMatchesL(InsnList haystack, InsnList needle, int start, HashSet<LabelNode> controlFlowLabels) {
int h = start, n = 0;
for (; h < haystack.size() && n < needle.size(); h++) {
AbstractInsnNode insn = haystack.get(h);
if (insn.getType() == 15) {
continue;
}
if (insn.getType() == 8 && !controlFlowLabels.contains(insn)) {
continue;
}
if (!insnEqual(haystack.get(h), needle.get(n))) {
return null;
}
n++;
}
if (n != needle.size()) {
return null;
}
return new InsnListSection(haystack, start, h - 1);
}
示例12: transformPlayer
import org.objectweb.asm.tree.LabelNode; //导入依赖的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);
}
示例13: patchMenu
import org.objectweb.asm.tree.LabelNode; //导入依赖的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);
}
}
}
示例14: trueBranch
import org.objectweb.asm.tree.LabelNode; //导入依赖的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();
}
示例15: exception
import org.objectweb.asm.tree.LabelNode; //导入依赖的package包/类
/** Adds an exception try block node to this graph */
protected void exception(@NonNull AbstractInsnNode from, @NonNull TryCatchBlockNode tcb) {
// Add tcb's to all instructions in the range
LabelNode start = tcb.start;
LabelNode end = tcb.end; // exclusive
// Add exception edges for all method calls in the range
AbstractInsnNode curr = start;
Node handlerNode = getNode(tcb.handler);
while (curr != end && curr != null) {
if (curr.getType() == AbstractInsnNode.METHOD_INSN) {
// Method call; add exception edge to handler
if (tcb.type == null) {
// finally block: not an exception path
getNode(curr).addSuccessor(handlerNode);
}
getNode(curr).addExceptionPath(handlerNode);
}
curr = curr.getNext();
}
}