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


Java LabelNode类代码示例

本文整理汇总了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);
    }
}
 
开发者ID:ItzSomebody,项目名称:DirectLeaks-AntiReleak-Remover,代码行数:23,代码来源:JSRInlinerAdapter.java

示例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));
  }
}
 
开发者ID:kroepke,项目名称:luna,代码行数:18,代码来源:BytecodeEmitVisitor.java

示例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;
}
 
开发者ID:kroepke,项目名称:luna,代码行数:19,代码来源:RunMethod.java

示例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;
}
 
开发者ID:kroepke,项目名称:luna,代码行数:25,代码来源:RunMethod.java

示例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());
    }
}
 
开发者ID:4Space,项目名称:4Space-5,代码行数:25,代码来源:ASMBlock.java

示例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;
}
 
开发者ID:4Space,项目名称:4Space-5,代码行数:24,代码来源:ASMBlock.java

示例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++;
    }
}
 
开发者ID:oltolm,项目名称:continuations,代码行数:18,代码来源:InstrumentMethod.java

示例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);
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:23,代码来源:AsmMethodSource.java

示例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);
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:20,代码来源:AsmMethodSource.java

示例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;
}
 
开发者ID:roryclaasen,项目名称:RorysMod,代码行数:25,代码来源:InstructionComparator.java

示例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);
}
 
开发者ID:roryclaasen,项目名称:RorysMod,代码行数:24,代码来源:InstructionComparator.java

示例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);
}
 
开发者ID:roryclaasen,项目名称:RorysMod,代码行数:20,代码来源:SleepingTransformer.java

示例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);
		}
	}
}
 
开发者ID:OrN,项目名称:rscplus,代码行数:21,代码来源:JClassPatcher.java

示例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();
}
 
开发者ID:disassemble-io,项目名称:asm-framework-full,代码行数:22,代码来源:BasicBlock.java

示例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();
    }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:ControlFlowGraph.java


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