Package org.deuce.objectweb.asm.commons

Examples of org.deuce.objectweb.asm.commons.Method


      super.visitMethodInsn(opcode, owner, name, desc); // ... = foo( ...
    }
    else
    {//Changing the foo(arg) to foo(arg, context);
      super.visitVarInsn(Opcodes.ALOAD, argumentsSize - 1); // load context
      Method newMethod = ClassTransformer.createNewMethod(name, desc);
      super.visitMethodInsn(opcode, owner, name, newMethod.getDescriptor()); // ... = foo( ...
    }
  }
View Full Code Here


      if(name.equals("get"+getUpperCaseName(fnm.fD.VarName)))
        fnm.gttrXst=true;       
    }
   
    //Add context variable for copy method arguments
    Method newMethod = createNewMethod(name, desc);

    MethodVisitor copyMethod =  super.visitMethod(access | Opcodes.ACC_SYNTHETIC, name, newMethod.getDescriptor(),
        signature, exceptions);

    return new MethodTransformer( originalMethod, copyMethod, className,
        access, name, desc, newMethod, fieldsHolder);
  }
View Full Code Here

  /**
   * Build a dummy method that delegates the call to the native method
   */
  private void createNativeMethod(int access, String name, String desc,
      String signature, String[] exceptions) {
    Method newMethod = createNewMethod(name, desc);
    final int newAccess = access & ~Opcodes.ACC_NATIVE;
    MethodVisitor copyMethod =  super.visitMethod(newAccess | Opcodes.ACC_SYNTHETIC, name, newMethod.getDescriptor(),
        signature, exceptions);
    copyMethod.visitCode();
   
    // load the arguments before calling the original method
    final boolean isStatic = (access & ~Opcodes.ACC_STATIC) != 0;
    int place = 0; // place on the stack
    if(!isStatic){
      copyMethod.visitVarInsn(Opcodes.ALOAD, 0); // load this
      place = 1;
    }
   
    Type[] argumentTypes = newMethod.getArgumentTypes();
    for(int i=0 ; i<(argumentTypes.length-1) ; ++i){
      Type type = argumentTypes[i];
      copyMethod.visitVarInsn(type.getOpcode(Opcodes.ILOAD), place);
      place += type.getSize();
    }
   
    // call the original method
    copyMethod.visitMethodInsn(isStatic ? Opcodes.INVOKESTATIC : Opcodes.INVOKEVIRTUAL, className, name, desc);
    TypeCodeResolver returnReolver = TypeCodeResolverFactory.getReolver(newMethod.getReturnType());
    if( returnReolver == null) {
      copyMethod.visitInsn( Opcodes.RETURN); // return;
    }else {
      copyMethod.visitInsn(returnReolver.returnCode());
    }
View Full Code Here

    return new StaticMethodTransformer( originalMethod, staticMethod, fields, staticField,
        className, fieldsHolder.getFieldsHolderName(className));
  }
 
  public static Method createNewMethod(String name, String desc) {
    Method method = new Method( name, desc);
    Type[] arguments = method.getArgumentTypes();

    Type[] newArguments = new Type[ arguments.length + 1];
    System.arraycopy( arguments, 0, newArguments, 0, arguments.length);
    newArguments[newArguments.length - 1] = Context.CONTEXT_TYPE; // add as a constant

    return new Method( name, method.getReturnType(), newArguments);
  }
View Full Code Here

TOP

Related Classes of org.deuce.objectweb.asm.commons.Method

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.