Java Code Examples for org.objectweb.asm.tree.LabelNode#getPrevious()

The following examples show how to use org.objectweb.asm.tree.LabelNode#getPrevious() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlockLogMethodAdapter.java    From jumbune with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * <p>
 * This method gets the end index for the provided Jump instruction
 * </p>
 * 
 * @param ain
 *            The given jump node
 * @return int end index
 */
private int getEndIndexForBlock(AbstractInsnNode ain) {
	int retIndex = 0;
	if (ain instanceof JumpInsnNode) {
		JumpInsnNode jin = (JumpInsnNode) ain;
		LabelNode targetAIN = jin.label;
		if (targetAIN.getPrevious() instanceof JumpInsnNode
				&& Opcodes.GOTO == targetAIN.getPrevious().getOpcode()) {
			retIndex = CollectionUtil.getObjectIndexInArray(this.insnArr, targetAIN
					.getPrevious().getPrevious());
		} else {
			retIndex = CollectionUtil.getObjectIndexInArray(this.insnArr,
					targetAIN.getPrevious());
		}
	}
	return retIndex;
}
 
Example 2
Source File: FrameHack.java    From Cafebabe with GNU General Public License v3.0 5 votes vote down vote up
private static int labelIndex(LabelNode label) {
	int i = 0;
	AbstractInsnNode ain = label.getPrevious();
	while (ain != null) {
		if (ain.getType() == AbstractInsnNode.LABEL) {
			i++;
		}
		ain = ain.getPrevious();
	}
	return i;
}
 
Example 3
Source File: CaseAdapter.java    From jumbune with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * <p>
 * This method find the last node of every switch cases in a method
 * </p>.
 *
 * @param caseList the case list
 * @param currentInsnNode current switch case Label node
 * @param currentLabel default of switch case Label node
 * @return AbstractInsnNode
 */
private AbstractInsnNode lookNode(List<AbstractInsnNode> caseList,
		final AbstractInsnNode currentInsnNode, LabelNode currentLabel) {
	AbstractInsnNode tempCurrentInsnNode=currentInsnNode,insnNode = null;
	boolean scanFurther = true;
	while (scanFurther) {
		if (caseList.contains(tempCurrentInsnNode.getNext())) {
			scanFurther = false;
			if (tempCurrentInsnNode instanceof JumpInsnNode){
				insnNode = tempCurrentInsnNode.getPrevious();
			}
			else{
				insnNode = tempCurrentInsnNode.getNext();
			}

		} else {

			tempCurrentInsnNode = tempCurrentInsnNode.getNext();
		}

		if (currentLabel.equals(tempCurrentInsnNode)) {
			scanFurther = false;
			insnNode = currentLabel.getPrevious();
		}

	}
	return insnNode;
}