Search in sources :

Example 11 with InsnNode

use of org.objectweb.asm.tree.InsnNode in project pinpoint by naver.

the class ASMMethodVariables method loadInterceptorThrowVar.

public void loadInterceptorThrowVar(final InsnList instructions) {
    assertInitializedInterceptorLocalVariables();
    loadVar(instructions, this.throwableVarIndex);
    instructions.add(new InsnNode(Opcodes.ATHROW));
}
Also used : MethodInsnNode(org.objectweb.asm.tree.MethodInsnNode) IntInsnNode(org.objectweb.asm.tree.IntInsnNode) LdcInsnNode(org.objectweb.asm.tree.LdcInsnNode) TypeInsnNode(org.objectweb.asm.tree.TypeInsnNode) AbstractInsnNode(org.objectweb.asm.tree.AbstractInsnNode) VarInsnNode(org.objectweb.asm.tree.VarInsnNode) InsnNode(org.objectweb.asm.tree.InsnNode)

Example 12 with InsnNode

use of org.objectweb.asm.tree.InsnNode in project Bookshelf by Darkhax-Minecraft.

the class TransformerEnchantmentHelper method transform.

public static byte[] transform(String name, String transformedName, byte[] classBytes) {
    final ClassNode clazz = ASMUtils.createClassFromByteArray(classBytes);
    final MethodNode method = METHOD_GET_ENCH_LEVEL.getMethodNode(clazz);
    final InsnList n1 = new InsnList();
    final LabelNode start = new LabelNode();
    n1.add(start);
    n1.add(new TypeInsnNode(Opcodes.NEW, "net/darkhax/bookshelf/events/EnchantmentModifierEvent"));
    n1.add(new InsnNode(Opcodes.DUP));
    n1.add(new VarInsnNode(Opcodes.ALOAD, 0));
    n1.add(new VarInsnNode(Opcodes.ALOAD, 1));
    n1.add(METHOD_INIT_EVENT.getMethodInsn(Opcodes.INVOKESPECIAL, false));
    n1.add(new VarInsnNode(Opcodes.ASTORE, 2));
    final LabelNode l1 = new LabelNode();
    n1.add(l1);
    n1.add(FIELD_EVENT_BUS.getFieldNode(Opcodes.GETSTATIC));
    n1.add(new VarInsnNode(Opcodes.ALOAD, 2));
    n1.add(METHOD_POST.getMethodInsn(Opcodes.INVOKEVIRTUAL, false));
    n1.add(new InsnNode(Opcodes.POP));
    final LabelNode l2 = new LabelNode();
    n1.add(l2);
    n1.add(new VarInsnNode(Opcodes.ALOAD, 2));
    n1.add(METHOD_CANCELED.getMethodInsn(Opcodes.INVOKEVIRTUAL, false));
    final LabelNode vanillaLogic = new LabelNode();
    n1.add(new JumpInsnNode(Opcodes.IFEQ, vanillaLogic));
    final LabelNode l4 = new LabelNode();
    n1.add(l4);
    n1.add(new VarInsnNode(Opcodes.ALOAD, 2));
    n1.add(METHOD_GET_LEVELS.getMethodInsn(Opcodes.INVOKEVIRTUAL, false));
    n1.add(new InsnNode(Opcodes.IRETURN));
    n1.add(vanillaLogic);
    method.instructions.insertBefore(method.instructions.getFirst(), n1);
    return ASMUtils.createByteArrayFromClass(clazz, ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);
}
Also used : LabelNode(org.objectweb.asm.tree.LabelNode) ClassNode(org.objectweb.asm.tree.ClassNode) TypeInsnNode(org.objectweb.asm.tree.TypeInsnNode) VarInsnNode(org.objectweb.asm.tree.VarInsnNode) JumpInsnNode(org.objectweb.asm.tree.JumpInsnNode) InsnNode(org.objectweb.asm.tree.InsnNode) MethodNode(org.objectweb.asm.tree.MethodNode) JumpInsnNode(org.objectweb.asm.tree.JumpInsnNode) TypeInsnNode(org.objectweb.asm.tree.TypeInsnNode) InsnList(org.objectweb.asm.tree.InsnList) VarInsnNode(org.objectweb.asm.tree.VarInsnNode)

Aggregations

InsnNode (org.objectweb.asm.tree.InsnNode)12 VarInsnNode (org.objectweb.asm.tree.VarInsnNode)8 TypeInsnNode (org.objectweb.asm.tree.TypeInsnNode)7 MethodInsnNode (org.objectweb.asm.tree.MethodInsnNode)6 Type (org.objectweb.asm.Type)5 FieldInsnNode (org.objectweb.asm.tree.FieldInsnNode)5 JumpInsnNode (org.objectweb.asm.tree.JumpInsnNode)5 AbstractInsnNode (org.objectweb.asm.tree.AbstractInsnNode)4 LdcInsnNode (org.objectweb.asm.tree.LdcInsnNode)4 MethodNode (org.objectweb.asm.tree.MethodNode)4 LocalVariable (org.develnext.jphp.core.compiler.jvm.misc.LocalVariable)3 InsnList (org.objectweb.asm.tree.InsnList)3 IntInsnNode (org.objectweb.asm.tree.IntInsnNode)3 LabelNode (org.objectweb.asm.tree.LabelNode)3 InvokeDynamicInsnNode (org.objectweb.asm.tree.InvokeDynamicInsnNode)2 InterceptorType (com.navercorp.pinpoint.profiler.instrument.interceptor.InterceptorType)1 MethodType (java.lang.invoke.MethodType)1 MethodType.methodType (java.lang.invoke.MethodType.methodType)1 Event (net.minecraftforge.fml.common.eventhandler.Event)1 MethodStmtCompiler (org.develnext.jphp.core.compiler.jvm.statement.MethodStmtCompiler)1