当前位置: 首页>>代码示例>>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;未经允许,请勿转载。