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


Java InsnList.iterator方法代码示例

本文整理汇总了Java中org.objectweb.asm.tree.InsnList.iterator方法的典型用法代码示例。如果您正苦于以下问题:Java InsnList.iterator方法的具体用法?Java InsnList.iterator怎么用?Java InsnList.iterator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.objectweb.asm.tree.InsnList的用法示例。


在下文中一共展示了InsnList.iterator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findMethodCallInstruction

import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
@SuppressWarnings("unchecked") // ASM API
@Nullable
private static AbstractInsnNode findMethodCallInstruction(
        @NonNull InsnList instructions,
        @NonNull String owner,
        @NonNull String name,
        @NonNull String desc) {
    ListIterator<AbstractInsnNode> iterator = instructions.iterator();

    while (iterator.hasNext()) {
        AbstractInsnNode insnNode = iterator.next();
        if (insnNode.getType() == AbstractInsnNode.METHOD_INSN) {
            MethodInsnNode methodInsnNode = (MethodInsnNode) insnNode;
            if ((methodInsnNode.owner.equals(owner))
                    && (methodInsnNode.name.equals(name))
                    && (methodInsnNode.desc.equals(desc))) {
                return methodInsnNode;
            }
        }
    }

    return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:ClickableViewAccessibilityDetector.java

示例2: findJumpTargets

import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
private static Set<AbstractInsnNode> findJumpTargets(final InsnList instructions) {
  final Set<AbstractInsnNode> jumpTargets = new HashSet<AbstractInsnNode>();
  final ListIterator<AbstractInsnNode> it = instructions.iterator();
  while (it.hasNext()) {
    final AbstractInsnNode o = it.next();
    if (o instanceof JumpInsnNode) {
      jumpTargets.add(((JumpInsnNode) o).label);
    } else if (o instanceof TableSwitchInsnNode) {
      final TableSwitchInsnNode twn = (TableSwitchInsnNode) o;
      jumpTargets.add(twn.dflt);
      jumpTargets.addAll(twn.labels);
    } else if (o instanceof LookupSwitchInsnNode) {
      final LookupSwitchInsnNode lsn = (LookupSwitchInsnNode) o;
      jumpTargets.add(lsn.dflt);
      jumpTargets.addAll(lsn.labels);
    }
  }
  return jumpTargets;
}
 
开发者ID:ncredinburgh,项目名称:QuickTheories,代码行数:20,代码来源:ControlFlowAnalyser.java

示例3: addTraceReturn

import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
private void addTraceReturn() {

        InsnList il = this.mn.instructions;

        Iterator<AbstractInsnNode> it = il.iterator();
        while (it.hasNext()) {
            AbstractInsnNode abstractInsnNode = it.next();

            switch (abstractInsnNode.getOpcode()) {
                case Opcodes.RETURN:
                    il.insertBefore(abstractInsnNode, getVoidReturnTraceInstructions());
                    break;
                case Opcodes.IRETURN:
                case Opcodes.LRETURN:
                case Opcodes.FRETURN:
                case Opcodes.ARETURN:
                case Opcodes.DRETURN:
                    il.insertBefore(abstractInsnNode, getReturnTraceInstructions());
            }
        }
    }
 
开发者ID:brutusin,项目名称:instrumentation,代码行数:22,代码来源:Instrumentator.java

示例4: addTraceThrow

import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
private void addTraceThrow() {

        InsnList il = this.mn.instructions;

        Iterator<AbstractInsnNode> it = il.iterator();
        while (it.hasNext()) {
            AbstractInsnNode abstractInsnNode = it.next();

            switch (abstractInsnNode.getOpcode()) {
                case Opcodes.ATHROW:
                    il.insertBefore(abstractInsnNode, getThrowTraceInstructions());
                    break;
            }
        }

    }
 
开发者ID:brutusin,项目名称:instrumentation,代码行数:17,代码来源:Instrumentator.java

示例5: handleMethodNode

import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
/**
 * Add all possible calls for a given method
 * 
 * @param callGraph
 * @param mn
 */
@SuppressWarnings("unchecked")
private static void handleMethodNode(GetStaticGraph staticUsageTree,
		ClassNode cn, MethodNode mn, int depth) {

	InsnList instructions = mn.instructions;
	Iterator<AbstractInsnNode> iterator = instructions.iterator();

	// TODO: This really shouldn't be here but in its own class
	while (iterator.hasNext()) {
		AbstractInsnNode insn = iterator.next();
		if (insn instanceof MethodInsnNode) {
			handleMethodInsnNode(staticUsageTree, cn, mn,
					(MethodInsnNode) insn, depth + 1);
		} else if (insn instanceof FieldInsnNode) {
			handleFieldInsnNode(staticUsageTree, cn, mn,
					(FieldInsnNode) insn, depth + 1);
		}

	}
}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:27,代码来源:GetStaticGraphGenerator.java

示例6: handleMethodNode

import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private void handleMethodNode(Set<String> calledClasses, ClassNode cn, MethodNode mn,
        Set<String> targetClasses) throws IOException {
	InsnList instructions = mn.instructions;
	Iterator<AbstractInsnNode> iterator = instructions.iterator();

	while (iterator.hasNext()) {
		AbstractInsnNode insn = iterator.next();
		if (insn instanceof MethodInsnNode) {
			String name = ResourceList.getClassNameFromResourcePath(((MethodInsnNode) insn).owner);
			if (!targetClasses.contains(name))
				continue;

			if (isValidClass(name))
				calledClasses.add(name);
		}
	}
}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:19,代码来源:DetermineSUT.java

示例7: searchForOpcodes

import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
/**
 * Find instructions in a certain class that are of a certain set of opcodes.
 * @param insnList instruction list to search through
 * @param opcodes opcodes to search for
 * @return list of instructions that contain the opcodes being searched for
 * @throws NullPointerException if any argument is {@code null}
 * @throws IllegalArgumentException if {@code opcodes} is empty
 */
public static List<AbstractInsnNode> searchForOpcodes(InsnList insnList, int ... opcodes) {
    Validate.notNull(insnList);
    Validate.notNull(opcodes);
    Validate.isTrue(opcodes.length > 0);
    
    List<AbstractInsnNode> ret = new LinkedList<>();
    
    Set<Integer> opcodeSet = new HashSet<>();
    Arrays.stream(opcodes).forEach((x) -> opcodeSet.add(x));
    
    Iterator<AbstractInsnNode> it = insnList.iterator();
    while (it.hasNext()) {
        AbstractInsnNode insnNode = it.next();
        if (opcodeSet.contains(insnNode.getOpcode())) {
            ret.add(insnNode);
        }
    }
    
    return ret;
}
 
开发者ID:offbynull,项目名称:coroutines,代码行数:29,代码来源:SearchUtils.java

示例8: 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

示例9: findNode

import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
public AbstractInsnNode findNode(InsnList instructions, AbstractInsnNode node) {
	ListIterator<AbstractInsnNode> iterator = instructions.iterator();
	while (iterator.hasNext()) {
		AbstractInsnNode insn = iterator.next();
		if (areNodesEqual(insn, node)) {
			return insn;
		}
	}
	return null;
}
 
开发者ID:PorPit,项目名称:MineCamera,代码行数:11,代码来源:Transformer.java

示例10: asList

import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
public static List<AbstractInsnNode> asList(final InsnList instructions) {
    final List<AbstractInsnNode> list = new ArrayList<AbstractInsnNode>(instructions.size());
    final Iterator<AbstractInsnNode> iterator = (Iterator<AbstractInsnNode>)instructions.iterator();
    while (iterator.hasNext()) {
        list.add(iterator.next());
    }
    return list;
}
 
开发者ID:CyberdyneCC,项目名称:ThermosRebased,代码行数:9,代码来源:ImagineASM.java

示例11: isSimpleGetter

import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
/**
 * Return true if the instructions are supposed to be a simple getter.
 * 
 * <code>
 * 1 (IRRELEVANT INTERNAL INSTRUCTION)
 * 2 (IRRELEVANT INTERNAL INSTRUCTION)
 * 3 ALOAD
 * 4 GETFIELD
 * 5 xRETURN
 * 6 (IRRELEVANT INTERNAL INSTRUCTION)
 * </code>
 */
private boolean isSimpleGetter(InsnList instructionList) {
	if (instructionList.size() != 6) {
		return false;
	}

	@SuppressWarnings("unchecked")
	Iterator<AbstractInsnNode> it = instructionList.iterator();
	AbstractInsnNode node;

	// drop instruction 1 (irrelevant)
	it.next();

	// drop instruction 2 (irrelevant)
	it.next();

	// instruction 3
	node = it.next();

	if (node.getOpcode() != Opcodes.ALOAD) {
		return false;
	}

	// instruction 4
	node = it.next();

	if (node.getOpcode() != Opcodes.GETFIELD) {
		return false;
	}

	// instruction 5
	node = it.next();

	if (!OpcodesUtility.isXRETURN(node.getOpcode())) {
		return false;
	}

	return true;
}
 
开发者ID:cqse,项目名称:test-analyzer,代码行数:51,代码来源:SetterGetterFilter.java

示例12: isSimpleConstantGetter

import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
/**
 * Return true if the instructions are supposed to be a simple constant
 * getter. <code>
 * 1 (IRRELEVANT INTERNAL INSTRUCTION) 
 * 2 (IRRELEVANT INTERNAL INSTRUCTION) 
 * 3 xCONST_x | xPUSH | LDC | LDC_W | LDC2_W 
 * 4 xRETURN 5 (IRRELEVANT INTERNAL INSTRUCTION)
 * </code>
 */
private boolean isSimpleConstantGetter(InsnList instructionList) {
	if (instructionList.size() != 5) {
		return false;
	} else {
		@SuppressWarnings("unchecked")
		Iterator<AbstractInsnNode> it = instructionList.iterator();
		AbstractInsnNode node;

		// drop instruction 1 (irrelevant)
		it.next();

		// drop instruction 2 (irrelevant)
		it.next();

		// instruction 3
		node = it.next();

		if (node.getOpcode() > 20) {
			return false;
		}

		// instruction 4
		node = it.next();

		if (!OpcodesUtility.isXRETURN(node.getOpcode())) {
			return false;
		}

		return true;
	}
}
 
开发者ID:cqse,项目名称:test-analyzer,代码行数:41,代码来源:SetterGetterFilter.java

示例13: handleMethodNode

import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
/**
 * Add all possible calls for a given method
 * 
 * @param callGraph
 * @param mn
 */
@SuppressWarnings("unchecked")
private static void handleMethodNode(CallGraph callGraph, ClassNode cn, MethodNode mn, int depth) {
	handlePublicMethodNode(callGraph, cn, mn);

	// TODO: Integrate this properly - it is currently an unexpected side-effect
	if(!ExceptionTransformationClassAdapter.methodExceptionMap.containsKey(cn.name))
		ExceptionTransformationClassAdapter.methodExceptionMap.put(cn.name, new LinkedHashMap<>());

	String methodNameDesc = mn.name + mn.desc;
	Set<Type> exceptionTypes = new LinkedHashSet<>();
	if(mn.exceptions != null) {
		for (String exceptionName : ((List<String>)mn.exceptions)) {
			exceptionTypes.add(Type.getType(exceptionName));
		}
	}
	ExceptionTransformationClassAdapter.methodExceptionMap.get(cn.name).put(methodNameDesc, exceptionTypes);

	InsnList instructions = mn.instructions;
	Iterator<AbstractInsnNode> iterator = instructions.iterator();

	// TODO: This really shouldn't be here but in its own class
	while (iterator.hasNext()) {
		AbstractInsnNode insn = iterator.next();
		if (insn instanceof MethodInsnNode) {
			handleMethodInsnNode(callGraph, cn, mn, (MethodInsnNode) insn, depth + 1);
		}
	}
}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:35,代码来源:CallGraphGenerator.java

示例14: findInvocationsOf

import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
/**
 * Find invocations of a certain method.
 * @param insnList instruction list to search through
 * @param expectedMethod type of method being invoked
 * @return list of invocations (may be nodes of type {@link MethodInsnNode} or {@link InvokeDynamicInsnNode})
 * @throws NullPointerException if any argument is {@code null}
 * @throws NullPointerException if {@code expectedMethodType} isn't of sort {@link Type#METHOD}
 */
public static List<AbstractInsnNode> findInvocationsOf(InsnList insnList, Method expectedMethod) {
    Validate.notNull(insnList);
    Validate.notNull(expectedMethod);

    List<AbstractInsnNode> ret = new ArrayList<>();
    
    Type expectedMethodDesc = Type.getType(expectedMethod);
    Type expectedMethodOwner = Type.getType(expectedMethod.getDeclaringClass());
    String expectedMethodName = expectedMethod.getName();
    
    Iterator<AbstractInsnNode> it = insnList.iterator();
    while (it.hasNext()) {
        AbstractInsnNode instructionNode = it.next();
        
        Type methodDesc;
        Type methodOwner;
        String methodName;
        if (instructionNode instanceof MethodInsnNode) {
            MethodInsnNode methodInsnNode = (MethodInsnNode) instructionNode;
            methodDesc = Type.getType(methodInsnNode.desc);
            methodOwner = Type.getObjectType(methodInsnNode.owner);
            methodName = expectedMethod.getName();
        } else {
            continue;
        }

        if (methodDesc.equals(expectedMethodDesc) && methodOwner.equals(expectedMethodOwner) && methodName.equals(expectedMethodName)) {
            ret.add(instructionNode);
        }
    }

    return ret;
}
 
开发者ID:offbynull,项目名称:coroutines,代码行数:42,代码来源:SearchUtils.java

示例15: findMatchingCallSites

import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
List<Result> findMatchingCallSites(final InsnList instructions, final List<LocalVariableAnnotationNode> varAnnotations, final Map<Integer, List<AnnotationNode>> paramAnnotations) {
    final List<Result> result = new ArrayList<>();
    for (@SuppressWarnings("unchecked") Iterator<AbstractInsnNode> i = instructions.iterator(); i.hasNext(); ) {
        final AbstractInsnNode ins = i.next();
        if (ins instanceof MethodInsnNode) {
            final MethodInsnNode mins = (MethodInsnNode)ins;
            final Result entry = findMatchingCallSite(mins, varAnnotations, paramAnnotations);
            if (entry != null) {
                result.add(entry);
            }
        }
    }
    return result;
}
 
开发者ID:vsilaev,项目名称:tascalate-javaflow,代码行数:15,代码来源:CallSiteFinder.java


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