List of usage examples for org.objectweb.asm Opcodes RETURN
int RETURN
To view the source code for org.objectweb.asm Opcodes RETURN.
Click Source Link
From source file:uk.co.unclealex.executable.generator.jar.JarServiceImplTest.java
License:Apache License
protected byte[] generateClass(String className) { ClassWriter cw = new ClassWriter(0); MethodVisitor mv;/*from ww w. j a v a 2s.c o m*/ cw.visit(Opcodes.V1_7, Opcodes.ACC_PUBLIC + Opcodes.ACC_SUPER, className.replace('.', '/'), null, "java/lang/Object", null); mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "<init>", "()V", null, null); mv.visitCode(); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/lang/Object", "<init>", "()V"); mv.visitInsn(Opcodes.RETURN); mv.visitMaxs(1, 1); mv.visitEnd(); mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "execute", "()Ljava/lang/String;", null, null); mv.visitCode(); mv.visitLdcInsn(className); mv.visitInsn(Opcodes.ARETURN); mv.visitMaxs(1, 1); mv.visitEnd(); cw.visitEnd(); return cw.toByteArray(); }
From source file:vazkii.quark.base.asm.ClassTransformer.java
License:Creative Commons License
private static byte[] transformModelBiped(byte[] basicClass) { log("Transforming ModelBiped"); MethodSignature sig = new MethodSignature("setRotationAngles", "func_78087_a", "a", "(FFFFFFLnet/minecraft/entity/Entity;)V"); return transform(basicClass, Pair.of(sig, combine((AbstractInsnNode node) -> { // Filter return node.getOpcode() == Opcodes.RETURN; }, (MethodNode method, AbstractInsnNode node) -> { // Action InsnList newInstructions = new InsnList(); newInstructions.add(new VarInsnNode(Opcodes.ALOAD, 7)); newInstructions.add(new MethodInsnNode(Opcodes.INVOKESTATIC, ASM_HOOKS, "updateEmotes", "(Lnet/minecraft/entity/Entity;)V")); method.instructions.insertBefore(node, newInstructions); return true; })));//from ww w . ja v a 2 s .c o m }
From source file:vazkii.quark.base.asm.ClassTransformer.java
License:Creative Commons License
private static byte[] transformRender(byte[] basicClass) { log("Transforming Render"); MethodSignature sig = new MethodSignature("renderEntityOnFire", "func_76977_a", "a", "(Lnet/minecraft/entity/Entity;DDDF)V"); return transform(basicClass, Pair.of(sig, combine((AbstractInsnNode node) -> { // Filter return true; }, (MethodNode method, AbstractInsnNode node) -> { // Action InsnList newInstructions = new InsnList(); newInstructions.add(new VarInsnNode(Opcodes.ALOAD, 1)); newInstructions.add(new VarInsnNode(Opcodes.DLOAD, 2)); newInstructions.add(new VarInsnNode(Opcodes.DLOAD, 4)); newInstructions.add(new VarInsnNode(Opcodes.DLOAD, 6)); newInstructions.add(new VarInsnNode(Opcodes.FLOAD, 8)); newInstructions.add(new MethodInsnNode(Opcodes.INVOKESTATIC, ASM_HOOKS, "renderFire", "(Lnet/minecraft/entity/Entity;DDDF)Z")); LabelNode label = new LabelNode(); newInstructions.add(new JumpInsnNode(Opcodes.IFEQ, label)); newInstructions.add(new InsnNode(Opcodes.RETURN)); newInstructions.add(label);//from ww w.j a va2 s . c o m method.instructions.insertBefore(node, newInstructions); return true; }))); }