Package org.objectweb.asm.tree

Examples of org.objectweb.asm.tree.MethodInsnNode


            if ( mn.name.equals( "func_146977_a" ) || (mn.name.equals( "a" ) && mn.desc.equals( "(Lzk;)V" )) )
            {
              MethodNode newNode = new MethodNode( Opcodes.ACC_PUBLIC, "func_146977_a_original", mn.desc, mn.signature, new String[0] );
              newNode.instructions.add( new VarInsnNode( Opcodes.ALOAD, 0 ) );
              newNode.instructions.add( new VarInsnNode( Opcodes.ALOAD, 1 ) );
              newNode.instructions.add( new MethodInsnNode( Opcodes.INVOKESPECIAL, classNode.name, mn.name, mn.desc, false ) );
              newNode.instructions.add( new InsnNode( Opcodes.RETURN ) );
              log( newNode.name + newNode.desc + " - New Method" );
              classNode.methods.add( newNode );
              break;
            }
          }

          for (MethodNode mn : classNode.methods)
          {
            if ( mn.name.equals( "func_73863_a" ) || mn.name.equals( "drawScreen" ) || (mn.name.equals( "a" ) && mn.desc.equals( "(IIF)V" )) )
            {
              Iterator<AbstractInsnNode> i = mn.instructions.iterator();
              while (i.hasNext())
              {
                AbstractInsnNode in = i.next();
                if ( in.getOpcode() == Opcodes.INVOKESPECIAL )
                {
                  MethodInsnNode n = (MethodInsnNode) in;
                  if ( n.name.equals( "func_146977_a" ) || (n.name.equals( "a" ) && n.desc.equals( "(Lzk;)V" )) )
                  {
                    log( n.name + n.desc + " - Invoke Virtual" );
                    mn.instructions.insertBefore( n, new MethodInsnNode( Opcodes.INVOKEVIRTUAL, n.owner, n.name, n.desc, false ) );
                    mn.instructions.remove( in );
                    break;
                  }
                }
              }
View Full Code Here


  private void processNode(AbstractInsnNode next, String nePar)
  {
    if ( next instanceof MethodInsnNode )
    {
      MethodInsnNode min = (MethodInsnNode) next;
      if ( min.owner.equals( "appeng/api/parts/LayerBase" ) )
      {
        min.owner = nePar;
      }
    }
View Full Code Here

    return super.visitAnnotation(desc, visible);
  }

  public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf)
  {
    MethodInsnNode mnode= new MethodInsnNode(opcode, owner, name, desc, itf);
    if (opcode == INVOKESPECIAL || "<init>".equals(name))
    {
      methods.add(mnode);
    }
    if (needsFrameGuard(opcode, owner, name, desc) /* && transformer.inScope(owner, name)*/)
 
View Full Code Here

    final HashMap<AbstractInsnNode, MethodInsnNode> movable= new HashMap<AbstractInsnNode, MethodInsnNode>();

    Frame[] frames= a.getFrames();
    for (int j= 0; j < methods.size(); j++)
    {
      MethodInsnNode mnode= methods.get(j);
      // require to move NEW instruction
      int n= instructions.indexOf(mnode);
      Frame f= frames[n];
      Type[] args= Type.getArgumentTypes(mnode.desc);

      SourceValue v= (SourceValue) f.getStack(f.getStackSize() - args.length - 1);
      Set<AbstractInsnNode> insns= v.insns;
      for (final AbstractInsnNode ins : insns)
      {
        if (ins.getOpcode() == NEW)
        {
          movable.put(ins, mnode);
        }
        else
        {
          // other known patterns
          int n1= instructions.indexOf(ins);
          if (ins.getOpcode() == DUP)
          { // <init> with params
            AbstractInsnNode ins1= instructions.get(n1 - 1);
            if (ins1.getOpcode() == NEW)
            {
              movable.put(ins1, mnode);
            }
          }
          else if (ins.getOpcode() == SWAP)
          { // in exception handler
            AbstractInsnNode ins1= instructions.get(n1 - 1);
            AbstractInsnNode ins2= instructions.get(n1 - 2);
            if (ins1.getOpcode() == DUP_X1 && ins2.getOpcode() == NEW)
            {
              movable.put(ins2, mnode);
            }
          }
        }
      }
    }

    int updateMaxStack= 0;
    for (final Map.Entry<AbstractInsnNode, MethodInsnNode> e : movable.entrySet())
    {
      AbstractInsnNode node1= e.getKey();
      int n1= instructions.indexOf(node1);
      AbstractInsnNode node2= instructions.get(n1 + 1);
      AbstractInsnNode node3= instructions.get(n1 + 2);
      int producer= node2.getOpcode();

      instructions.remove(node1); // NEW
      boolean requireDup= false;
      if (producer == DUP)
      {
        instructions.remove(node2); // DUP
        requireDup= true;
      }
      else if (producer == DUP_X1)
      {
        instructions.remove(node2); // DUP_X1
        instructions.remove(node3); // SWAP
        requireDup= true;
      }

      MethodInsnNode mnode= (MethodInsnNode) e.getValue();
      AbstractInsnNode nm= mnode;

      int varOffset= stackRecorderVar + 1;
      Type[] args= Type.getArgumentTypes(mnode.desc);
View Full Code Here

            ParameterizedType returnType,
            List<ParameterizedType> parameterTypes
    )
    {
        instructionList.add(
                new MethodInsnNode(
                        INVOKESPECIAL,
                        type.getClassName(),
                        name,
                        methodDescription(returnType, parameterTypes)
                )
View Full Code Here

    }

    public MethodDefinition invokeStatic(Method method)
    {
        instructionList.add(
                new MethodInsnNode(
                        INVOKESTATIC,
                        Type.getInternalName(method.getDeclaringClass()),
                        method.getName(),
                        Type.getMethodDescriptor(method)
                )
View Full Code Here

    }

    public MethodDefinition invokeVirtual(Method method)
    {
        instructionList.add(
                new MethodInsnNode(
                        INVOKEVIRTUAL,
                        Type.getInternalName(method.getDeclaringClass()),
                        method.getName(),
                        Type.getMethodDescriptor(method)
                )
View Full Code Here

            Class<?> returnType,
            Class<?>... parameterTypes
    )
    {
        instructionList.add(
                new MethodInsnNode(
                        INVOKEVIRTUAL,
                        type(type).getClassName(),
                        name,
                        methodDescription(returnType, parameterTypes)
                )
View Full Code Here

            ParameterizedType returnType,
            ParameterizedType... parameterTypes
    )
    {
        instructionList.add(
                new MethodInsnNode(
                        INVOKEVIRTUAL,
                        type.getClassName(),
                        name,
                        methodDescription(returnType, parameterTypes)
                )
View Full Code Here

    JsonObject jsonObject = (JsonObject) json;
    int opcode = jsonObject.get("opcode").getAsInt();
    String owner = jsonObject.get("owner").getAsString();
    String name = jsonObject.get("name").getAsString();
    String desc = jsonObject.get("desc").getAsString();
    return new MethodInsnNode(opcode, owner, name, desc, opcode == Opcodes.INVOKEINTERFACE);
  }
View Full Code Here

TOP

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

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.