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


Java InsnList.getFirst方法代码示例

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


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

示例1: getImportantList

import org.objectweb.asm.tree.InsnList; //导入方法依赖的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

示例2: injectFieldsIn

import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
private void injectFieldsIn(MethodNode rootNode)
{
    InsnList instructions = rootNode.instructions;
    if (instructions.size() == 0)
    {
        return;
    }
    AbstractInsnNode node = instructions.getFirst();
    while (node != null)
    {
        while (! (node instanceof FieldInsnNode) || ! AsmUtils.isPutField(node.getOpcode()))
        {
            node = node.getNext();
            if (node == null)
            {
                return;
            }
        }
        this.trackFieldToInject((FieldInsnNode) node, rootNode.instructions);
        node = node.getNext();
    }
}
 
开发者ID:Diorite,项目名称:Diorite,代码行数:23,代码来源:TransformerFieldInjector.java

示例3: getImportantList

import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
public static InsnList getImportantList(InsnList list) {
	if (list.size() == 0) {
		return list;
	}

	HashMap<LabelNode, LabelNode> labels = new HashMap<LabelNode, LabelNode>();
	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:NOVA-Team,项目名称:NOVA-Core,代码行数:23,代码来源:InstructionComparator.java

示例4: visitInsnList

import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
public void visitInsnList(InsnList list) {
	text.clear();
	if (labelNames == null) {
		labelNames = new HashMap<Label, String>();
	} else {
		labelNames.clear();
	}

	buildingLabelMap = true;
	for (AbstractInsnNode insn = list.getFirst(); insn != null; insn = insn.getNext()) {
		if (insn.getType() == 8) {
			visitLabel(((LabelNode) insn).getLabel());
		}
	}

	text.clear();
	buildingLabelMap = false;

	for (AbstractInsnNode insn = list.getFirst(); insn != null; insn = insn.getNext()) {
		_visitInsn(insn);
	}
}
 
开发者ID:NOVA-Team,项目名称:NOVA-Core,代码行数:23,代码来源:InsnListPrinter.java

示例5: copyInsnList

import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
public static InsnList copyInsnList(InsnList original) {
    InsnList newInsnList = new InsnList();

    for (AbstractInsnNode insn = original.getFirst(); insn != null; insn = insn.getNext()) {
        newInsnList.add(insn);
    }

    return newInsnList;
}
 
开发者ID:ItzSomebody,项目名称:DirectLeaks-AntiReleak-Remover,代码行数:10,代码来源:InjectorRemover.java

示例6: cloneLabels

import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
public static Map<LabelNode, LabelNode> cloneLabels(InsnList insns) {
	HashMap<LabelNode, LabelNode> labelMap = new HashMap<LabelNode, LabelNode>();
	for (AbstractInsnNode insn = insns.getFirst(); insn != null; insn = insn.getNext()) {
		if (insn.getType() == 8) {
			labelMap.put((LabelNode) insn, new LabelNode());
		}
	}
	return labelMap;
}
 
开发者ID:NOVA-Team,项目名称:NOVA-Core,代码行数:10,代码来源:ASMHelper.java

示例7: cloneInsnList

import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
public static InsnList cloneInsnList(Map<LabelNode, LabelNode> labelMap, InsnList insns) {
	InsnList clone = new InsnList();
	for (AbstractInsnNode insn = insns.getFirst(); insn != null; insn = insn.getNext()) {
		clone.add(insn.clone(labelMap));
	}

	return clone;
}
 
开发者ID:NOVA-Team,项目名称:NOVA-Core,代码行数:9,代码来源:ASMHelper.java

示例8: matches

import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
/**
 * <p>matches</p>
 *
 * @param instructions a {@link org.objectweb.asm.tree.InsnList} object.
 * @return a boolean.
 */
public boolean matches(InsnList instructions) {
	int match = 0;

	AbstractInsnNode node = instructions.getFirst();
	while (node != instructions.getLast()) {
		if (node.getType() == AbstractInsnNode.FRAME
		        || node.getType() == AbstractInsnNode.LABEL
		        || node.getType() == AbstractInsnNode.LINE) {
			node = node.getNext();
			continue;
		} else {
			boolean found = false;
			for (int opcode : pattern[match]) {
				if (node.getOpcode() == opcode) {
					match++;
					found = true;
					break;
				}
			}
			if (!found)
				match = 0;
		}
		if (match == pattern.length)
			return true;

		node = node.getNext();
	}

	return false;
}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:37,代码来源:NodeRegularExpression.java

示例9: NodeCopier

import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
public NodeCopier(InsnList sourceList) {
    this.sourceList = sourceList;
    this.labelMap = Maps.newHashMap();

    // build the label map
    for (AbstractInsnNode instruction = sourceList.getFirst(); instruction != null; instruction = instruction.getNext()) {
        if (instruction instanceof LabelNode) {
            labelMap.put(((LabelNode) instruction), new LabelNode());
        }
    }
}
 
开发者ID:dmillerw,项目名称:ASMTemplates,代码行数:12,代码来源:NodeCopier.java

示例10: checkMethods

import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
private static Map<String, String> checkMethods(ClassNode classNode, Set<String> names) {
    Map<String, String> validGetters = Maps.newHashMap();
    @SuppressWarnings("rawtypes")
    List methods = classNode.methods;
    String fieldName = null;
    checkMethod:
    for (Object methodObject : methods) {
        MethodNode method = (MethodNode) methodObject;
        if (names.contains(method.name)
                && method.desc.startsWith("()")) { //$NON-NLS-1$ // (): No arguments
            InsnList instructions = method.instructions;
            int mState = 1;
            for (AbstractInsnNode curr = instructions.getFirst();
                    curr != null;
                    curr = curr.getNext()) {
                switch (curr.getOpcode()) {
                    case -1:
                        // Skip label and line number nodes
                        continue;
                    case Opcodes.ALOAD:
                        if (mState == 1) {
                            fieldName = null;
                            mState = 2;
                        } else {
                            continue checkMethod;
                        }
                        break;
                    case Opcodes.GETFIELD:
                        if (mState == 2) {
                            FieldInsnNode field = (FieldInsnNode) curr;
                            fieldName = field.name;
                            mState = 3;
                        } else {
                            continue checkMethod;
                        }
                        break;
                    case Opcodes.ARETURN:
                    case Opcodes.FRETURN:
                    case Opcodes.IRETURN:
                    case Opcodes.DRETURN:
                    case Opcodes.LRETURN:
                    case Opcodes.RETURN:
                        if (mState == 3) {
                            validGetters.put(method.name, fieldName);
                        }
                        continue checkMethod;
                    default:
                        continue checkMethod;
                }
            }
        }
    }

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

示例11: processMethod

import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
private void processMethod(MethodNode methodNode) {
    InsnList insns = methodNode.instructions;

    // Filter out debugging nodes/labels
    int count = 0;
    int maxCount = insns.size();
    AbstractInsnNode[] nodes = new AbstractInsnNode[maxCount];
    for (AbstractInsnNode node = insns.getFirst(); node != null; node = node.getNext())
        if (node.getOpcode() > 0)
            nodes[count++] = node;

    // Find mapper get() calls and create an own flyweight instance for each
    for (int i = 0; i <= count - 4; i++) {
        if (!(nodes[i + 0] instanceof VarInsnNode))
            continue;
        if (!(nodes[i + 1] instanceof FieldInsnNode))
            continue;
        if (!(nodes[i + 2] instanceof VarInsnNode))
            continue;
        if (!(nodes[i + 3] instanceof MethodInsnNode))
            continue;

        VarInsnNode loadThis = (VarInsnNode) nodes[i + 0];
        FieldInsnNode getField = (FieldInsnNode) nodes[i + 1];
        VarInsnNode loadEntity = (VarInsnNode) nodes[i + 2];
        MethodInsnNode getMethod = (MethodInsnNode) nodes[i + 3];

        if (loadThis.var != 0 || loadThis.getOpcode() != ALOAD)
            continue;

        if (!getField.owner.equals(metadata.internalName) ||
                !getField.desc.equals("L" + WeaverConstants.MAPPER_NAME + ";") ||
                !metadata.mappersByName.containsKey(getField.name))
            continue;
        if (loadEntity.getOpcode() != ILOAD)
            continue;
        if (!getMethod.owner.equals(WeaverConstants.MAPPER_NAME) ||
                !getMethod.desc.equals("(I)L" + WeaverConstants.COMPONENT_NAME + ";") ||
                !getMethod.name.equals("get"))
            continue;

        SystemMapper mapper = metadata.mappersByName.get(getField.name);

        // Add field to hold the flyweight
        String fieldName = "flyweight$" + flyweightFields.size();
        String fieldDesc = mapper.componentType.getDescriptor();
        FieldNode fieldNode = new FieldNode(ACC_PRIVATE, fieldName, fieldDesc, null, null);
        fieldNode.visitAnnotation("Lcom/github/antag99/retinazer/SkipWire;", true);
        FlyweightField flyweightField = new FlyweightField();
        flyweightField.fieldNode = fieldNode;
        flyweightField.mapper = mapper;
        flyweightFields.add(flyweightField);

        // Rewrite access to use the flyweight
        getField.owner = metadata.internalName;
        getField.name = fieldName;
        getField.desc = fieldDesc;
        insns.insert(getField, new InsnNode(DUP));
        insns.insert(loadEntity, new FieldInsnNode(PUTFIELD, mapper.componentType.getInternalName(),
                WeaverConstants.INDEX_FIELD_NAME, WeaverConstants.INDEX_FIELD_DESC));
        insns.remove(getMethod);
    }
}
 
开发者ID:antag99,项目名称:retinazer,代码行数:64,代码来源:SystemProcessor.java

示例12: NodeCopier

import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
public NodeCopier(InsnList sourceList) {

            for (AbstractInsnNode instruction = sourceList.getFirst(); instruction != null; instruction = instruction.getNext())
                if (instruction instanceof LabelNode)
                    labelMap.put(((LabelNode) instruction), new LabelNode());
        }
 
开发者ID:amadornes,项目名称:JTraits,代码行数:7,代码来源:ASMUtils.java


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