Example usage for org.objectweb.asm.tree AbstractInsnNode getOpcode

List of usage examples for org.objectweb.asm.tree AbstractInsnNode getOpcode

Introduction

In this page you can find the example usage for org.objectweb.asm.tree AbstractInsnNode getOpcode.

Prototype

public int getOpcode() 

Source Link

Document

Returns the opcode of this instruction.

Usage

From source file:com.liferay.portal.nio.intraband.proxy.IntrabandProxyUtilTest.java

License:Open Source License

private void _assertIntInsnNode(AbstractInsnNode abstractInsnNode, int opcode, int operand) {

    Assert.assertEquals(opcode, abstractInsnNode.getOpcode());

    IntInsnNode intInsnNode = (IntInsnNode) abstractInsnNode;

    Assert.assertEquals(operand, intInsnNode.operand);
}

From source file:com.liferay.portal.nio.intraband.proxy.IntrabandProxyUtilTest.java

License:Open Source License

private LabelNode _assertJumpInsnNode(AbstractInsnNode abstractInsnNode, int opcode) {

    Assert.assertEquals(opcode, abstractInsnNode.getOpcode());

    JumpInsnNode jumpInsnNode = (JumpInsnNode) abstractInsnNode;

    return jumpInsnNode.label;
}

From source file:com.liferay.portal.nio.intraband.proxy.IntrabandProxyUtilTest.java

License:Open Source License

private void _assertLdcInsnNode(AbstractInsnNode abstractInsnNode, int opcode, Object obj) {

    Assert.assertEquals(opcode, abstractInsnNode.getOpcode());

    LdcInsnNode ldcInsnNode = (LdcInsnNode) abstractInsnNode;

    Assert.assertEquals(obj, ldcInsnNode.cst);
}

From source file:com.liferay.portal.nio.intraband.proxy.IntrabandProxyUtilTest.java

License:Open Source License

private void _assertMethodInsnNode(AbstractInsnNode abstractInsnNode, int opcode, String owner, String name,
        Type returnType, Type... argumentTypes) {

    Assert.assertEquals(opcode, abstractInsnNode.getOpcode());

    MethodInsnNode methodInsnNode = (MethodInsnNode) abstractInsnNode;

    Assert.assertEquals(owner, methodInsnNode.owner);
    Assert.assertEquals(name, methodInsnNode.name);
    Assert.assertEquals(Type.getMethodDescriptor(returnType, argumentTypes), methodInsnNode.desc);
}

From source file:com.liferay.portal.nio.intraband.proxy.IntrabandProxyUtilTest.java

License:Open Source License

private void _assertTypeInsnNode(AbstractInsnNode abstractInsnNode, int opcode, Class<?> clazz) {

    Assert.assertEquals(opcode, abstractInsnNode.getOpcode());

    TypeInsnNode typeInsnNode = (TypeInsnNode) abstractInsnNode;

    Assert.assertEquals(Type.getInternalName(clazz), typeInsnNode.desc);
}

From source file:com.liferay.portal.nio.intraband.proxy.IntrabandProxyUtilTest.java

License:Open Source License

private void _assertVarInsnNode(AbstractInsnNode abstractInsnNode, int opcode, int var) {

    Assert.assertEquals(opcode, abstractInsnNode.getOpcode());

    VarInsnNode varInsnNode = (VarInsnNode) abstractInsnNode;

    Assert.assertEquals(var, varInsnNode.var);
}

From source file:com.lion328.thaifixes.coremod.patcher.GuiNewChatBytecodePatcher.java

License:Open Source License

@Override
public byte[] patchClass(byte[] source) {
    if (ThaiFixesConfiguration.getFontStyle() != ThaiFixesFontStyle.MCPX)
        return source;

    ClassReader classReader = new ClassReader(source);
    ClassNode classNode = new ClassNode();
    classReader.accept(classNode, 0);//from  w  w w  . java 2  s.  c o  m

    for (MethodNode method : classNode.methods) {
        if (method.name.equals(CLASSMAP.getMethod("drawChat")) && method.desc.equals("(I)V")) {
            AbstractInsnNode currentNode = null;
            for (int i = 0; i < method.instructions.size(); i++) {
                currentNode = method.instructions.get(i);
                if (currentNode.getOpcode() == Opcodes.BIPUSH) {
                    if (method.instructions.get(i + 1).getOpcode() == Opcodes.IMUL)
                        method.instructions.set(currentNode,
                                new VarInsnNode(Opcodes.BIPUSH, ThaiFixesFontRenderer.MCPX_CHATBLOCK_HEIGHT));
                    else if (method.instructions.get(i + 1).getOpcode() == Opcodes.ISUB
                            && method.instructions.get(i - 1).getOpcode() == Opcodes.ILOAD) {
                        IntInsnNode node = (IntInsnNode) currentNode;
                        if (node.operand == 9)
                            method.instructions.set(currentNode, new VarInsnNode(Opcodes.BIPUSH,
                                    ThaiFixesFontRenderer.MCPX_CHATBLOCK_HEIGHT));
                        else if (node.operand == 8)
                            method.instructions.set(currentNode, new VarInsnNode(Opcodes.BIPUSH,
                                    ThaiFixesFontRenderer.MCPX_CHATBLOCK_TEXT_YPOS));
                    }
                }
            }
        } else if (method.name.equals(CLASSMAP.getMethod("func_146236_a"))
                && method.desc.equals("(II)L" + ClassMap.getClassMap("net.minecraft.util.IChatComponent")
                        .getClassInfo().getProductionClassName().replace('.', '/') + ";")) {
            for (int i = 0; i < method.instructions.size(); i++) {
                if (method.instructions.get(i).getOpcode() == Opcodes.GETFIELD) {
                    FieldInsnNode node = (FieldInsnNode) method.instructions.get(i);
                    if (node.owner.equals(ClassMap.getClassMap("net.minecraft.client.gui.FontRenderer")
                            .getClassInfo().getProductionClassName().replace('.', '/'))
                            && node.name.equals(ClassMap.getClassMap("net.minecraft.client.gui.FontRenderer")
                                    .getField("FONT_HEIGHT"))) {
                        method.instructions.set(node,
                                new VarInsnNode(Opcodes.BIPUSH, ThaiFixesFontRenderer.MCPX_CHATBLOCK_HEIGHT));
                        method.instructions.remove(method.instructions.get(i - 1)); // GETFIELD Minecraft.mc
                        method.instructions.remove(method.instructions.get(i - 2)); // GETFIELD GuiNewChat.mc
                        method.instructions.remove(method.instructions.get(i - 3)); // ALOAD 0
                    }
                }
            }
        }
    }

    ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS);
    classNode.accept(writer);
    return writer.toByteArray();
}

From source file:com.lodgon.parboiled.transform.AsmUtils.java

License:Open Source License

public static boolean isBooleanValueOfZ(AbstractInsnNode insn) {
    checkArgNotNull(insn, "insn");
    if (insn.getOpcode() != Opcodes.INVOKESTATIC)
        return false;
    MethodInsnNode mi = (MethodInsnNode) insn;
    return isBooleanValueOfZ(mi.owner, mi.name, mi.desc);
}

From source file:com.lodgon.parboiled.transform.AsmUtils.java

License:Open Source License

public static boolean isActionRoot(AbstractInsnNode insn) {
    checkArgNotNull(insn, "insn");
    if (insn.getOpcode() != Opcodes.INVOKESTATIC)
        return false;
    MethodInsnNode mi = (MethodInsnNode) insn;
    return isActionRoot(mi.owner, mi.name);
}

From source file:com.lodgon.parboiled.transform.AsmUtils.java

License:Open Source License

public static boolean isVarRoot(AbstractInsnNode insn) {
    checkArgNotNull(insn, "insn");
    if (insn.getOpcode() != Opcodes.INVOKESPECIAL)
        return false;
    MethodInsnNode mi = (MethodInsnNode) insn;
    return isVarRoot(mi.owner, mi.name, mi.desc);
}