Package org.objectweb.asm.tree

Examples of org.objectweb.asm.tree.InsnNode


   
  @Override
    public InsnNode deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
        JsonObject jsonObject = (JsonObject) json;
        int opcode = jsonObject.get("opcode").getAsInt();
        return new InsnNode(opcode);
    }
View Full Code Here


      if (args.length == 0)
      {
        final InsnList doNew= new InsnList();
        doNew.add(node1); // NEW
        if (requireDup)
          doNew.add(new InsnNode(DUP));
        instructions.insertBefore(nm, doNew);
        nm= doNew.getLast();
        continue;
      }

      if (args.length == 1 && args[0].getSize() == 1)
      {
        final InsnList doNew= new InsnList();
        doNew.add(node1); // NEW
        if (requireDup)
        {
          doNew.add(new InsnNode(DUP));
          doNew.add(new InsnNode(DUP2_X1));
          doNew.add(new InsnNode(POP2));
          updateMaxStack= updateMaxStack < 2 ? 2 : updateMaxStack; // a two extra slots for temp values
        }
        else
          doNew.add(new InsnNode(SWAP));
        instructions.insertBefore(nm, doNew);
        nm= doNew.getLast();
        continue;
      }

      // TODO this one untested!
      if ((args.length == 1 && args[0].getSize() == 2) || (args.length == 2 && args[0].getSize() == 1 && args[1].getSize() == 1))
      {
        final InsnList doNew= new InsnList();
        doNew.add(node1); // NEW
        if (requireDup)
        {
          doNew.add(new InsnNode(DUP));
          doNew.add(new InsnNode(DUP2_X2));
          doNew.add(new InsnNode(POP2));
          updateMaxStack= updateMaxStack < 2 ? 2 : updateMaxStack; // a two extra slots for temp values
        }
        else
        {
          doNew.add(new InsnNode(DUP_X2));
          doNew.add(new InsnNode(POP));
          updateMaxStack= updateMaxStack < 1 ? 1 : updateMaxStack; // an extra slot for temp value
        }
        instructions.insertBefore(nm, doNew);
        nm= doNew.getLast();
        continue;
      }

      final InsnList doNew= new InsnList();
      // generic code using temporary locals
      // save stack
      for (int j= args.length - 1; j >= 0; j--)
      {
        Type type= args[j];

        doNew.add(new VarInsnNode(type.getOpcode(ISTORE), varOffset));
        varOffset+= type.getSize();
      }
      if (varOffset > maxLocals)
      {
        maxLocals= varOffset;
      }

      doNew.add(node1); // NEW

      if (requireDup)
        doNew.add(new InsnNode(DUP));

      // restore stack
      for (int j= 0; j < args.length; j++)
      {
        Type type= args[j];
        varOffset-= type.getSize();

        doNew.add(new VarInsnNode(type.getOpcode(ILOAD), varOffset));

        // clean up store to avoid memory leak?
        if (type.getSort() == Type.OBJECT || type.getSort() == Type.ARRAY)
        {
          updateMaxStack= updateMaxStack < 1 ? 1 : updateMaxStack; // an extra slot for ACONST_NULL

          doNew.add(new InsnNode(ACONST_NULL));

          doNew.add(new VarInsnNode(type.getOpcode(ISTORE), varOffset));
        }
      }
      instructions.insertBefore(nm, doNew);
View Full Code Here

         *      }
         */
        MethodNode method = new MethodNode(ASM4, ACC_PUBLIC, "<init>", getMethodDescriptor(VOID_TYPE), null, null);
        method.instructions.add(new VarInsnNode(ALOAD, 0));
        method.instructions.add(new MethodInsnNode(INVOKESPECIAL, tSuper.getInternalName(), "<init>", getMethodDescriptor(VOID_TYPE), false));
        method.instructions.add(new InsnNode(RETURN));
        if (!hasDefaultCtr)
        {
            classNode.methods.add(method);
        }

        /*Add:
         *      protected void setup()
         *      {
         *              super.setup();
         *              if (LISTENER_LIST != NULL)
         *              {
         *                      return;
         *              }
         *              LISTENER_LIST = new ListenerList(super.getListenerList());
         *      }
         */
        method = new MethodNode(ASM4, ACC_PROTECTED, "setup", getMethodDescriptor(VOID_TYPE), null, null);
        method.instructions.add(new VarInsnNode(ALOAD, 0));
        method.instructions.add(new MethodInsnNode(INVOKESPECIAL, tSuper.getInternalName(), "setup", getMethodDescriptor(VOID_TYPE), false));
        method.instructions.add(new FieldInsnNode(GETSTATIC, classNode.name, "LISTENER_LIST", tList.getDescriptor()));
        LabelNode initLisitener = new LabelNode();
        method.instructions.add(new JumpInsnNode(IFNULL, initLisitener));
        method.instructions.add(new InsnNode(RETURN));
        method.instructions.add(initLisitener);
        method.instructions.add(new FrameNode(F_SAME, 0, null, 0, null));
        method.instructions.add(new TypeInsnNode(NEW, tList.getInternalName()));
        method.instructions.add(new InsnNode(DUP));
        method.instructions.add(new VarInsnNode(ALOAD, 0));
        method.instructions.add(new MethodInsnNode(INVOKESPECIAL, tSuper.getInternalName(), "getListenerList", getMethodDescriptor(tList), false));
        method.instructions.add(new MethodInsnNode(INVOKESPECIAL, tList.getInternalName(), "<init>", getMethodDescriptor(VOID_TYPE, tList), false));
        method.instructions.add(new FieldInsnNode(PUTSTATIC, classNode.name, "LISTENER_LIST", tList.getDescriptor()));
        method.instructions.add(new InsnNode(RETURN));
        classNode.methods.add(method);

        /*Add:
         *      public ListenerList getListenerList()
         *      {
         *              return this.LISTENER_LIST;
         *      }
         */
        method = new MethodNode(ASM4, ACC_PUBLIC, "getListenerList", getMethodDescriptor(tList), null, null);
        method.instructions.add(new FieldInsnNode(GETSTATIC, classNode.name, "LISTENER_LIST", tList.getDescriptor()));
        method.instructions.add(new InsnNode(ARETURN));
        classNode.methods.add(method);
        return true;
    }
View Full Code Here

                        toInject.add(new VarInsnNode(ALOAD, 0));
                        toInject.add(new FieldInsnNode(GETFIELD, (String) hm.get("javaClassName"), (String) hm.get("entityPlayerFieldName"), "L" + (String) hm.get("entityPlayerMPJavaClassName") + ";"));
                        toInject.add(new MethodInsnNode(INVOKESTATIC, "keepcalm/mods/events/EventFactory", "onBlockHarvested", "(L" + (String) hm.get("worldJavaClassName") + ";IIIL" + (String) hm.get("blockJavaClassName") + ";IL" + (String) hm.get("entityPlayerJavaClassName") + ";)Z"));
                        LabelNode endIf = new LabelNode(new Label());
                        toInject.add(new JumpInsnNode(Opcodes.IFEQ, endIf));
                        toInject.add(new InsnNode(Opcodes.ICONST_0));
                        toInject.add(new InsnNode(Opcodes.IRETURN));
                        toInject.add(endIf);
                        toInject.add(lmm1Node);
                       
                        m.instructions.insertBefore(m.instructions.get(index + offset), toInject);
                       
View Full Code Here

        insns.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "keepcalm/mods/events/ForgeEventHelper", "onSignChange", "(L" + names.get("netServerHandler_javaName") + ";L" + names.get("packet130UpdateSign_javaName") + ";)L" + names.get("packet130UpdateSign_javaName") + ";" ));
        LabelNode endIf = new LabelNode(new Label());
        insns.add(new VarInsnNode(Opcodes.ASTORE, 1));
        insns.add(new VarInsnNode(Opcodes.ALOAD, 1));
        insns.add(new JumpInsnNode(Opcodes.IFNONNULL, endIf));
        insns.add(new InsnNode(Opcodes.RETURN));
        insns.add(endIf);
       
        m.instructions.insert(insns);
      }
    }
View Full Code Here

              insns.add(new VarInsnNode(Opcodes.ILOAD, 4));
              insns.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "keepcalm/mods/events/ForgeEventHelper",
                  "onPressurePlateInteract", "(L" + names.get("blockPressurePlate_javaName") + ";L" + names.get("world_javaName") + ";III)Z"));
              LabelNode endIf = new LabelNode(new Label());
              insns.add(new JumpInsnNode(Opcodes.IFEQ, endIf));
              insns.add(new InsnNode(Opcodes.RETURN));
              insns.add(endIf);
              insns.add(new LabelNode(new Label()));
             
              m.instructions.insertBefore(m.instructions.get(i), insns);
             
View Full Code Here

        toAdd.add(new MethodInsnNode(Opcodes.INVOKESTATIC,
            "keepcalm/mods/events/ForgeEventHelper", "onBlockFlow",
            "(L" + names.get("block_javaName") + ";L" + names.get("world_javaName") + ";III)Z"));
        LabelNode endIf = new LabelNode(new Label());
        toAdd.add(new JumpInsnNode(Opcodes.IFEQ, endIf));
        toAdd.add(new InsnNode(Opcodes.RETURN));
        toAdd.add(endIf);
        toAdd.add(new LabelNode(new Label()));
       
        m.instructions.add(toAdd);
    }
View Full Code Here

                "(L" + names.get("world_javaName") + ";IIIL" + names.get("itemStack_javaName") + ";)Z"));

            LabelNode endLabel = new LabelNode(new Label());
            toAdd.add(new JumpInsnNode(Opcodes.IFEQ, endLabel)); // if the return value of ^ is true
            // then return - it was cancelled - and so will not be run
            toAdd.add(new InsnNode(Opcodes.RETURN));
            toAdd.add(endLabel); // otherwise, continue on
            toAdd.add(lmmnode);

            System.out.println("Instructions have been compiled, adding to bytecode...");
View Full Code Here

            System.out.println("Using desc: " + "(L" + names.get("itemInWorldManager_javaName") + ";)V");
            toInject.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "keepcalm/mods/events/ForgeEventHelper",
                "onBlockDamage", "(L" + names.get("itemInWorldManager_javaName") + ";)Z"));
            LabelNode endIf = new LabelNode(new Label());
            toInject.add(new JumpInsnNode(Opcodes.IFEQ, endIf));
            toInject.add(new InsnNode(Opcodes.RETURN));
            toInject.add(endIf);
            toInject.add(lmmnode);
            System.out.println("Finished compiling instruction nodes, inserting new instructions... at " + loc);

            m.instructions.insertBefore(m.instructions.get(index + 1), toInject);
View Full Code Here

        toInsert.add(new VarInsnNode(Opcodes.ALOAD, 0));
        toInsert.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "keepcalm/mods/events/ForgeEventHelper", "onPlayerMove",
            "(L" + names.get("packet10Flying_javaName") + ";L" + names.get("netServerHandler_javaName") + ";)Z"));
        LabelNode endIf = new LabelNode(new Label());
        toInsert.add(new JumpInsnNode(Opcodes.IFEQ, endIf));
        toInsert.add(new InsnNode(Opcodes.RETURN));
        toInsert.add(endIf);
        toInsert.add(new LabelNode(new Label()));
        m.instructions.insert(toInsert);
       
       
View Full Code Here

TOP

Related Classes of org.objectweb.asm.tree.InsnNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.