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