當前位置: 首頁>>代碼示例>>Java>>正文


Java InsnList.indexOf方法代碼示例

本文整理匯總了Java中org.objectweb.asm.tree.InsnList.indexOf方法的典型用法代碼示例。如果您正苦於以下問題:Java InsnList.indexOf方法的具體用法?Java InsnList.indexOf怎麽用?Java InsnList.indexOf使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.objectweb.asm.tree.InsnList的用法示例。


在下文中一共展示了InsnList.indexOf方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: findLineNumberForInstruction

import org.objectweb.asm.tree.InsnList; //導入方法依賴的package包/類
/**
 * Find line number associated with an instruction.
 * @param insnList instruction list for method
 * @param insnNode instruction within method being searched against
 * @throws NullPointerException if any argument is {@code null} or contains {@code null}
 * @throws IllegalArgumentException if arguments aren't all from the same method
 * @return line number node associated with the instruction, or {@code null} if no line number exists
 */
public static LineNumberNode findLineNumberForInstruction(InsnList insnList, AbstractInsnNode insnNode) {
    Validate.notNull(insnList);
    Validate.notNull(insnNode);
    
    int idx = insnList.indexOf(insnNode);
    Validate.isTrue(idx != -1);
    
    // Get index of labels and insnNode within method
    ListIterator<AbstractInsnNode> insnIt = insnList.iterator(idx);
    while (insnIt.hasPrevious()) {
        AbstractInsnNode node = insnIt.previous();
        
        if (node instanceof LineNumberNode) {
            return (LineNumberNode) node;
        }
    }
    
    return null;
}
 
開發者ID:offbynull,項目名稱:coroutines,代碼行數:28,代碼來源:SearchUtils.java

示例2: removeNeedleFromHaystack

import org.objectweb.asm.tree.InsnList; //導入方法依賴的package包/類
/**
 * removes an entire instruction set in the haystack.
 *
 * @param haystack
 *            The instruction set to be searched in
 * @param needle
 *            The instruction set to search for and to be removed
 */
public static void removeNeedleFromHaystack(InsnList haystack, InsnList needle) {
	int firstInd = haystack.indexOf(findFirstNodeFromNeedle(haystack, needle));
	int lastInd = haystack.indexOf(findLastNodeFromNeedle(haystack, needle));
	List<AbstractInsnNode> realNeedle = new ArrayList<>();

	for (int i = firstInd; i <= lastInd; i++) {
		realNeedle.add(haystack.get(i));
	}

	for (AbstractInsnNode node : realNeedle) {
		haystack.remove(node);
	}
}
 
開發者ID:roryclaasen,項目名稱:RorysMod,代碼行數:22,代碼來源:ASMHelper.java


注:本文中的org.objectweb.asm.tree.InsnList.indexOf方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。