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


Java InsnList.remove方法代碼示例

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


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

示例1: moveUp

import org.objectweb.asm.tree.InsnList; //導入方法依賴的package包/類
/**
 * Moves the insns up one in the list.
 * 
 * @param list
 *            Complete list of opcodes.
 * @param insn
 *            Sublist to be moved.
 */
public static void moveUp(InsnList list, List<AbstractInsnNode> insns) {
	AbstractInsnNode prev = insns.get(0).getPrevious();
	if (prev == null) return;
	InsnList x = new InsnList();
	for (AbstractInsnNode ain : insns) {
		list.remove(ain);
		x.add(ain);
	}
	list.insertBefore(prev, x);
}
 
開發者ID:Col-E,項目名稱:Recaf,代碼行數:19,代碼來源:Asm.java

示例2: moveDown

import org.objectweb.asm.tree.InsnList; //導入方法依賴的package包/類
/**
 * Moves the insns down one in the list.
 * 
 * @param list
 *            Complete list of opcodes.
 * @param insn
 *            Sublist to be moved.
 */
public static void moveDown(InsnList list, List<AbstractInsnNode> insns) {
	AbstractInsnNode prev = insns.get(insns.size() - 1).getNext();
	if (prev == null) return;
	InsnList x = new InsnList();
	for (AbstractInsnNode ain : insns) {
		list.remove(ain);
		x.add(ain);
	}
	list.insert(prev, x);
}
 
開發者ID:Col-E,項目名稱:Recaf,代碼行數:19,代碼來源:Asm.java

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

示例4: removeBlock

import org.objectweb.asm.tree.InsnList; //導入方法依賴的package包/類
public static void removeBlock(InsnList insns, InstructionComparator.InsnListSection block) {
	AbstractInsnNode insn = block.first;
	while (true) {
		AbstractInsnNode next = insn.getNext();
		insns.remove(insn);
		if (insn == block.last) {
			break;
		}
		insn = next;
	}
}
 
開發者ID:NOVA-Team,項目名稱:NOVA-Core,代碼行數:12,代碼來源:ASMHelper.java

示例5: insertLongComparison

import org.objectweb.asm.tree.InsnList; //導入方法依賴的package包/類
private void insertLongComparison(AbstractInsnNode position, InsnList list) {
	MethodInsnNode get = new MethodInsnNode(Opcodes.INVOKESTATIC,
	        Type.getInternalName(BooleanHelper.class), "longSub",
	        Type.getMethodDescriptor(Type.INT_TYPE, new Type[] { Type.LONG_TYPE,
	                Type.LONG_TYPE }), false);
	list.insert(position, get);
	list.remove(position);
}
 
開發者ID:EvoSuite,項目名稱:evosuite,代碼行數:9,代碼來源:ComparisonTransformation.java

示例6: insertFloatComparisonG

import org.objectweb.asm.tree.InsnList; //導入方法依賴的package包/類
private void insertFloatComparisonG(AbstractInsnNode position, InsnList list) {
	MethodInsnNode get = new MethodInsnNode(Opcodes.INVOKESTATIC,
	        Type.getInternalName(BooleanHelper.class), "floatSubG",
	        Type.getMethodDescriptor(Type.INT_TYPE, new Type[] { Type.FLOAT_TYPE,
	                Type.FLOAT_TYPE }), false);
	list.insert(position, get);
	list.remove(position);
}
 
開發者ID:EvoSuite,項目名稱:evosuite,代碼行數:9,代碼來源:ComparisonTransformation.java

示例7: insertFloatComparisonL

import org.objectweb.asm.tree.InsnList; //導入方法依賴的package包/類
private void insertFloatComparisonL(AbstractInsnNode position, InsnList list) {
	MethodInsnNode get = new MethodInsnNode(Opcodes.INVOKESTATIC,
			Type.getInternalName(BooleanHelper.class), "floatSubL",
			Type.getMethodDescriptor(Type.INT_TYPE, new Type[] { Type.FLOAT_TYPE,
					Type.FLOAT_TYPE }), false);
	list.insert(position, get);
	list.remove(position);
}
 
開發者ID:EvoSuite,項目名稱:evosuite,代碼行數:9,代碼來源:ComparisonTransformation.java

示例8: insertDoubleComparisonG

import org.objectweb.asm.tree.InsnList; //導入方法依賴的package包/類
private void insertDoubleComparisonG(AbstractInsnNode position, InsnList list) {
	MethodInsnNode get = new MethodInsnNode(Opcodes.INVOKESTATIC,
	        Type.getInternalName(BooleanHelper.class), "doubleSubG",
	        Type.getMethodDescriptor(Type.INT_TYPE, new Type[] { Type.DOUBLE_TYPE,
	                Type.DOUBLE_TYPE }), false);
	list.insert(position, get);
	list.remove(position);
}
 
開發者ID:EvoSuite,項目名稱:evosuite,代碼行數:9,代碼來源:ComparisonTransformation.java

示例9: insertDoubleComparisonL

import org.objectweb.asm.tree.InsnList; //導入方法依賴的package包/類
private void insertDoubleComparisonL(AbstractInsnNode position, InsnList list) {
	MethodInsnNode get = new MethodInsnNode(Opcodes.INVOKESTATIC,
			Type.getInternalName(BooleanHelper.class), "doubleSubL",
			Type.getMethodDescriptor(Type.INT_TYPE, new Type[] { Type.DOUBLE_TYPE,
					Type.DOUBLE_TYPE }), false);
	list.insert(position, get);
	list.remove(position);
}
 
開發者ID:EvoSuite,項目名稱:evosuite,代碼行數:9,代碼來源:ComparisonTransformation.java

示例10: fixMethodBody

import org.objectweb.asm.tree.InsnList; //導入方法依賴的package包/類
/**
 * Rewrites the method bytecode to remove the "Stub!" exception.
 */
private void fixMethodBody(MethodNode methodNode, ClassNode classNode) {
    if ((methodNode.access & Opcodes.ACC_NATIVE) != 0
            || (methodNode.access & Opcodes.ACC_ABSTRACT) != 0) {
        // Abstract and native method don't have bodies to rewrite.
        return;
    }
    
    if ((classNode.access & Opcodes.ACC_ENUM) != 0 && ENUM_METHODS.contains(methodNode.name)) {
        // Don't break enum classes.
        return;
    }
    
    Type returnType = Type.getReturnType(methodNode.desc);
    InsnList instructions = methodNode.instructions;
    List localVariables = methodNode.localVariables;
    List tryCatchBlocks = methodNode.tryCatchBlocks;

    if (localVariables != null && !localVariables.isEmpty()) {
        localVariables.clear();
    }
    if (tryCatchBlocks != null && !tryCatchBlocks.isEmpty()) {
        tryCatchBlocks.clear();
    }
    
    if (methodNode.name.equals(CONSTRUCTOR)) {
        // Keep the call to parent constructor, delete the exception after that.
        
        boolean deadCode = false;
        for (AbstractInsnNode instruction : instructions.toArray()) {
            if (!deadCode) {
                if (instruction.getOpcode() == Opcodes.INVOKESPECIAL) {
                    instructions.insert(instruction, new InsnNode(Opcodes.RETURN));
                    // Start removing all following instructions.
                    deadCode = true;
                }
            } else {
                instructions.remove(instruction);
            }
        }
    } else {
        instructions.clear();
        
        if (returnDefaultValues || methodNode.name.equals(CLASS_CONSTRUCTOR)) {
            if (INTEGER_LIKE_TYPES.contains(returnType)) {
                instructions.add(new InsnNode(Opcodes.ICONST_0));
            } else if (returnType.equals(Type.LONG_TYPE)) {
                instructions.add(new InsnNode(Opcodes.LCONST_0));
            } else if (returnType.equals(Type.FLOAT_TYPE)) {
                instructions.add(new InsnNode(Opcodes.FCONST_0));
            } else if (returnType.equals(Type.DOUBLE_TYPE)) {
                instructions.add(new InsnNode(Opcodes.DCONST_0));
            } else {
                instructions.add(new InsnNode(Opcodes.ACONST_NULL));
            }
            
            instructions.add(new InsnNode(returnType.getOpcode(Opcodes.IRETURN)));
        } else {
            instructions.insert(throwExceptionsList(methodNode, classNode));
        }
    }
}
 
開發者ID:codezjx,項目名稱:MockableJarGenerator,代碼行數:65,代碼來源:MockableJarGenerator.java

示例11: fixMethodBody

import org.objectweb.asm.tree.InsnList; //導入方法依賴的package包/類
/**
 * Rewrites the method bytecode to remove the "Stub!" exception.
 */
private void fixMethodBody(MethodNode methodNode, ClassNode classNode) {
    if ((methodNode.access & Opcodes.ACC_NATIVE) != 0
            || (methodNode.access & Opcodes.ACC_ABSTRACT) != 0) {
        // Abstract and native method don't have bodies to rewrite.
        return;
    }

    if ((classNode.access & Opcodes.ACC_ENUM) != 0 && ENUM_METHODS.contains(methodNode.name)) {
        // Don't break enum classes.
        return;
    }

    Type returnType = Type.getReturnType(methodNode.desc);
    InsnList instructions = methodNode.instructions;

    if (methodNode.name.equals(CONSTRUCTOR)) {
        // Keep the call to parent constructor, delete the exception after that.

        boolean deadCode = false;
        for (AbstractInsnNode instruction : instructions.toArray()) {
            if (!deadCode) {
                if (instruction.getOpcode() == Opcodes.INVOKESPECIAL) {
                    instructions.insert(instruction, new InsnNode(Opcodes.RETURN));
                    // Start removing all following instructions.
                    deadCode = true;
                }
            } else {
                instructions.remove(instruction);
            }
        }
    } else {
        instructions.clear();

        if (returnDefaultValues || methodNode.name.equals(CLASS_CONSTRUCTOR)) {
            if (INTEGER_LIKE_TYPES.contains(returnType)) {
                instructions.add(new InsnNode(Opcodes.ICONST_0));
            } else if (returnType.equals(Type.LONG_TYPE)) {
                instructions.add(new InsnNode(Opcodes.LCONST_0));
            } else if (returnType.equals(Type.FLOAT_TYPE)) {
                instructions.add(new InsnNode(Opcodes.FCONST_0));
            } else if (returnType.equals(Type.DOUBLE_TYPE)) {
                instructions.add(new InsnNode(Opcodes.DCONST_0));
            } else {
                instructions.add(new InsnNode(Opcodes.ACONST_NULL));
            }

            instructions.add(new InsnNode(returnType.getOpcode(Opcodes.IRETURN)));
        } else {
            instructions.insert(throwExceptionsList(methodNode, classNode));
        }
    }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:56,代碼來源:MockableJarGenerator.java

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


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