當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。