Package org.objectweb.asm.tree

Examples of org.objectweb.asm.tree.VarInsnNode


        }
        else {
            instructionList.add(new InsnNode(ACONST_NULL));
        }

        instructionList.add(new VarInsnNode(Type.getType(type.getType()).getOpcode(ISTORE), variable.getSlot()));

        return this;
    }
View Full Code Here


    }

    public MethodDefinition loadVariable(LocalVariableDefinition variable)
    {
        ParameterizedType type = variable.getType();
        instructionList.add(new VarInsnNode(Type.getType(type.getType()).getOpcode(ILOAD), variable.getSlot()));
        return this;
    }
View Full Code Here

    }

    public MethodDefinition storeVariable(LocalVariableDefinition variable)
    {
        ParameterizedType type = variable.getType();
        instructionList.add(new VarInsnNode(Type.getType(type.getType()).getOpcode(ISTORE), variable.getSlot()));
        return this;
    }
View Full Code Here

 
  @Override
  public boolean accept(AbstractInsnNode t) {
    if (!(t instanceof VarInsnNode))
      return false;
    VarInsnNode vin = (VarInsnNode) t;
    return opcodeFilter.accept(vin) && varFilter.accept(vin.var);
  }
View Full Code Here

      case LSTORE:
      case FSTORE:
      case DSTORE:
      case ASTORE:
      case RET:
        return new VarInsnNode(opcode, toint(args[1]));

      case GETSTATIC:
      case PUTSTATIC:
      case GETFIELD:
      case PUTFIELD:
View Full Code Here

        case AbstractInsnNode.TYPE_INSN:
          TypeInsnNode tin = (TypeInsnNode) ain;
          fullInsn += ' ' + tin.desc;
          break;
        case AbstractInsnNode.VAR_INSN:
          VarInsnNode vin = (VarInsnNode) ain;
          fullInsn += " " + vin.var;
          break;
        case AbstractInsnNode.LABEL:
          continue;
        case AbstractInsnNode.INVOKE_DYNAMIC_INSN:
View Full Code Here

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

      // 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);
      nm= doNew.getLast();
    }
View Full Code Here

         *      {
         *              super();
         *      }
         */
        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);
View Full Code Here

                        {
                            int offset = 1;
                            while (m.instructions.get(index + offset).getOpcode() != ASTORE)
                                offset++;
                            System.out.println("Found Block object ASTORE Node at " + (index + offset));
                            VarInsnNode blockNode = (VarInsnNode) m.instructions.get(index + offset);
                            blockIndex = blockNode.var;
                            System.out.println("Block object is in local object " + blockIndex);
                        }
                    }
                   
                    // find local metadata variable node and from that, local
                    // variable index
                    if (m.instructions.get(index).getType() == AbstractInsnNode.METHOD_INSN)
                    {
                        MethodInsnNode mdNode = (MethodInsnNode) m.instructions.get(index);
                        if (mdNode.owner.equals(hm.get("worldJavaClassName")) && mdNode.name.equals(hm.get("getBlockMetadataMethodName")))
                        {
                            int offset = 1;
                            while (m.instructions.get(index + offset).getOpcode() != ISTORE)
                                offset++;
                            System.out.println("Found metadata local variable ISTORE Node at " + (index + offset));
                            VarInsnNode mdFieldNode = (VarInsnNode) m.instructions.get(index + offset);
                            mdIndex = mdFieldNode.var;
                            System.out.println("Metadata is in local variable " + mdIndex);
                        }
                    }
                   
                    if (m.instructions.get(index).getOpcode() == IFNULL)
                    {
                        System.out.println("Found IFNULL Node at " + index);
                       
                        int offset = 1;
                        while (m.instructions.get(index + offset).getOpcode() != ALOAD)
                            offset++;
                       
                        System.out.println("Found ALOAD Node at offset " + offset + " from IFNULL Node");
                        System.out.println("Patching method " + (String) hm.get("javaClassName") + "/" + m.name + m.desc + "...");
                       
                        // make a new label node for the end of our code
                        LabelNode lmm1Node = new LabelNode(new Label());
                       
                        // make new instruction list
                        InsnList toInject = new InsnList();
                       
                        // construct instruction nodes for list
                        toInject.add(new VarInsnNode(ALOAD, 0));
                        toInject.add(new FieldInsnNode(GETFIELD, (String) hm.get("javaClassName"), (String) hm.get("worldFieldName"), "L" + (String) hm.get("worldJavaClassName") + ";"));
                        toInject.add(new VarInsnNode(ILOAD, 1));
                        toInject.add(new VarInsnNode(ILOAD, 2));
                        toInject.add(new VarInsnNode(ILOAD, 3));
                        toInject.add(new VarInsnNode(ALOAD, blockIndex));
                        toInject.add(new VarInsnNode(ILOAD, mdIndex));
                        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));
View Full Code Here

TOP

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

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.