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


Java InsnList.clear方法代碼示例

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


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

示例1: extractFrom

import org.objectweb.asm.tree.InsnList; //導入方法依賴的package包/類
public void extractFrom(ImagineASM asm, InsnList list) {
    //Pair<String, String> fieldChunkProvider = asm.field("net/minecraft/world/World", "chunkProvider");
    list.clear();
    list.add(new IntInsnNode(ALOAD, 1));
    list.add(new FieldInsnNode(GETFIELD, "ahb", "v", "Lapu;"));
    list.add(new InsnNode(ARETURN));
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:8,代碼來源:UraniumClassTransformer.java

示例2: constMethod

import org.objectweb.asm.tree.InsnList; //導入方法依賴的package包/類
public ImagineMethod constMethod(final int value) {
    final InsnList instructions = this.mMethod.instructions;
    instructions.clear();
    pushInt(value, instructions);
    instructions.add((AbstractInsnNode)new InsnNode(172));
    return this;
}
 
開發者ID:CyberdyneCC,項目名稱:ThermosRebased,代碼行數:8,代碼來源:ImagineMethod.java

示例3: transform

import org.objectweb.asm.tree.InsnList; //導入方法依賴的package包/類
@Override
public void transform(byte[] bytes, ClassNode cn) {
	////////////////////////////////////////////////////////////////
	MethodNode method = this.findMethod(cn, "sendClickBlockToController", "func_147115_a");
	InsnList code = method.instructions;

	code.clear();
	LabelNode l0 = new LabelNode();
	code.add(l0);

	code.add(new LineNumberNode(1460, l0));
	code.add(new VarInsnNode(Opcodes.ILOAD, 1));
	LabelNode l1 = new LabelNode();
	code.add(new JumpInsnNode(Opcodes.IFNE, l1));
	LabelNode l2 = new LabelNode();
	code.add(l2);

	code.add(new LineNumberNode(1462, l2));
	code.add(new VarInsnNode(Opcodes.ALOAD, 0));
	code.add(new InsnNode(Opcodes.ICONST_0));
	code.add(leftClickCounter.putField());
	code.add(l1);

	code.add(new LineNumberNode(1484, l1));
	code.add(new FrameNode(Opcodes.F_SAME, 0, null, 0, null));
	code.add(new InsnNode(Opcodes.RETURN));

	method.maxStack = 2;
	method.maxLocals = 2;
	////////////////////////////////////////////////////////////////
}
 
開發者ID:fewizz,項目名稱:HardcoredMining,代碼行數:32,代碼來源:MinecraftTransformer.java

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

示例5: forward

import org.objectweb.asm.tree.InsnList; //導入方法依賴的package包/類
private static void forward(final ImagineMethod img, final String owner, final String methodName, final boolean staticForward) {
    final InsnList list = img.mMethod.instructions;
    list.clear();
    list.add(methodCall(img, owner, methodName, staticForward, true));
}
 
開發者ID:CyberdyneCC,項目名稱:ThermosRebased,代碼行數:6,代碼來源:ImagineMethod.java

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


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