Package org.deuce.objectweb.asm

Examples of org.deuce.objectweb.asm.Type


        final PrintWriter pw)
    {
        ClassNode cn = new ClassNode();
        cr.accept(new CheckClassAdapter(cn, false), ClassReader.SKIP_DEBUG);

        Type syperType = cn.superName == null
                ? null
                : Type.getObjectType(cn.superName);
        List methods = cn.methods;

        List interfaces = new ArrayList();
View Full Code Here


          name + ATOMIC_METHOD_POST, desc);
    }
  }

  private void returnMethod( MethodVisitor methodVisitor) {
    Type type = Type.getReturnType(desc);
    switch( type.getSort()) {
    case Type.VOID:
      mv.visitInsn(Opcodes.RETURN);
      break;
    case Type.BOOLEAN:
    case Type.BYTE:
View Full Code Here

        }
        firstLocal = nextLocal;
    }

    public void visitVarInsn(final int opcode, final int var) {
        Type type;
        switch (opcode) {
            case Opcodes.LLOAD:
            case Opcodes.LSTORE:
                type = Type.LONG_TYPE;
                break;
View Full Code Here

                locals.add(owner);
            }
        }
        Type[] types = Type.getArgumentTypes(desc);
        for (int i = 0; i < types.length; ++i) {
            Type type = types[i];
            switch (type.getSort()) {
                case Type.BOOLEAN:
                case Type.CHAR:
                case Type.BYTE:
                case Type.SHORT:
                case Type.INT:
View Full Code Here

    super.visitFieldInsn(opcode, owner, name, desc);
    Label l2 = new Label();
    mv.visitJumpInsn(Opcodes.GOTO, l2);
    mv.visitLabel(l1);
   
    final Type type = Type.getType(desc);
    switch( opcode) {
    case Opcodes.GETFIELD:  //  ALOAD 0: this (stack status)
     
      addBeforeReadCall(fieldsHolderName, name);
     
      super.visitInsn(Opcodes.DUP);
      super.visitFieldInsn(opcode, owner, name, desc);
      super.visitFieldInsn( Opcodes.GETSTATIC, fieldsHolderName, Util.getAddressField(name) , "J");
      super.visitVarInsn(Opcodes.ALOAD, argumentsSize - 1); // load context
      super.visitMethodInsn( Opcodes.INVOKESTATIC, ContextDelegator.CONTEXT_DELEGATOR_INTERNAL,
          ContextDelegator.READ_METHOD_NAME, ContextDelegator.getReadMethodDesc(type));
     
      if( type.getSort() >= Type.ARRAY) // non primitive
        super.visitTypeInsn( Opcodes.CHECKCAST, Type.getType(desc).getInternalName());
      break;
    case Opcodes.PUTFIELD:
      super.visitFieldInsn( Opcodes.GETSTATIC, fieldsHolderName, Util.getAddressField(name) , "J");
      super.visitVarInsn(Opcodes.ALOAD, argumentsSize - 1); // load context
      super.visitMethodInsn( Opcodes.INVOKESTATIC, ContextDelegator.CONTEXT_DELEGATOR_INTERNAL,
          ContextDelegator.WRITE_METHOD_NAME, ContextDelegator.getWriteMethodDesc(type));
      break;
    case Opcodes.GETSTATIC: // check support for static fields
      super.visitFieldInsn(Opcodes.GETSTATIC, fieldsHolderName,
          StaticMethodTransformer.CLASS_BASE, "Ljava/lang/Object;");
     
      addBeforeReadCall(fieldsHolderName, name);
     
      super.visitFieldInsn(opcode, owner, name, desc);
      super.visitFieldInsn(Opcodes.GETSTATIC, fieldsHolderName, Util.getAddressField(name) , "J");
      super.visitVarInsn(Opcodes.ALOAD, argumentsSize - 1); // load context
      super.visitMethodInsn( Opcodes.INVOKESTATIC, ContextDelegator.CONTEXT_DELEGATOR_INTERNAL,
          ContextDelegator.READ_METHOD_NAME, ContextDelegator.getReadMethodDesc(type));
     
      if( type.getSort() >= Type.ARRAY) // non primitive
        super.visitTypeInsn( Opcodes.CHECKCAST, Type.getType(desc).getInternalName());
      break;
    case Opcodes.PUTSTATIC:
      super.visitFieldInsn(Opcodes.GETSTATIC, fieldsHolderName,
          StaticMethodTransformer.CLASS_BASE, "Ljava/lang/Object;");
View Full Code Here

      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());
View Full Code Here

    mv.visitLabel(l0);
    //Get the Field
    mv.visitVarInsn(Opcodes.ALOAD, 0);   
    mv.visitFieldInsn(Opcodes.GETFIELD, className, gSD.fD.VarName, gSD.fD.VarDesc);
    //Return the field value depending on Return type
    Type returnType = Type.getType(gSD.fD.VarDesc);
    {
      if (returnType.equals(Type.CHAR_TYPE)
          || returnType.equals(Type.INT_TYPE)
          || returnType.equals(Type.SHORT_TYPE)
          || returnType.equals(Type.BYTE_TYPE)
          || returnType.equals(Type.BOOLEAN_TYPE))
        mv.visitInsn(IRETURN);
      else if(returnType.equals(Type.DOUBLE_TYPE))
        mv.visitInsn(DRETURN);
      else if(returnType.equals(Type.FLOAT_TYPE))
        mv.visitInsn(FRETURN);
      else if(returnType.equals(Type.LONG_TYPE))
        mv.visitInsn(LRETURN);
      else if(returnType.equals(Type.VOID_TYPE))
        mv.visitInsn(RETURN);
      else
        mv.visitInsn(ARETURN);
    }
View Full Code Here

    Label l0 = new Label();
    mv.visitLabel(l0);

    mv.visitVarInsn(Opcodes.ALOAD, 0);
    //Load the Argument Depending upon variable type
    Type arg = Type.getType(gSD.fD.VarDesc);
    {
      if (arg.equals(Type.CHAR_TYPE) || arg.equals(Type.INT_TYPE)
          || arg.equals(Type.SHORT_TYPE)
          || arg.equals(Type.BYTE_TYPE)
          || arg.equals(Type.BOOLEAN_TYPE))
        mv.visitVarInsn(ILOAD, 1);
      else if(arg.equals(Type.DOUBLE_TYPE))
        mv.visitVarInsn(DLOAD, 1);
      else if(arg.equals(Type.LONG_TYPE))
        mv.visitVarInsn(LLOAD  , 1);
      else if(arg.equals(Type.FLOAT_TYPE))
        mv.visitVarInsn(FLOAD, 1);
      else
        mv.visitVarInsn(ALOAD, 1);       
    }
    mv.visitFieldInsn(Opcodes.PUTFIELD, className, gSD.fD.VarName, gSD.fD.VarDesc);
View Full Code Here

    else{
      for(Object md : rmdtl){
        MethodDetails mD = (MethodDetails) md;
        //Get new Arguments
        Type[] src = Type.getArgumentTypes(mD.desc);
        Type rType = Type.getReturnType(mD.desc);
        Type[] mdesc = new Type[src.length + 2];
        mdesc[0] = Type.getType(Object.class);
        mdesc[1] = Type.getType(ControlContext.class);
        System.arraycopy(src, 0, mdesc, 2, src.length);
       
View Full Code Here

  public static void addCode(MethodVisitor mv, String className, Method method, int argumentsSize, boolean isStatic) {
    int pos = className.lastIndexOf('/')+1;
    String proxyIname = className.substring(0,pos)+"$HY$_I"+className.substring(pos);
    Type[] src = Type.getArgumentTypes(method.desc);
    Type returnType = method.getReturnType();
    Type[] arguements = new Type[src.length+1];
   
    arguements[0]= Type.getType(Object.class);
    System.arraycopy(src, 0, arguements, 1, src.length);
    String desc = Type.getMethodDescriptor(method.getReturnType(), arguements);
   
    Label l0 = new Label();
    Label l1 = new Label();
    Label l2 = new Label();
    mv.visitTryCatchBlock(l0, l1, l2, "java/rmi/RemoteException");
    //If Statement
    Label l3 = new Label();
    mv.visitLabel(l3);
    mv.visitVarInsn(ALOAD, 0);
    mv.visitFieldInsn(GETFIELD, className, "$HY$_proxy", "L"+proxyIname+";")//
    Label l4 = new Label();
    mv.visitJumpInsn(IFNULL, l4);    //Go to start of method
    //Start try block
    mv.visitLabel(l0);   
    mv.visitVarInsn(ALOAD, 0);
    mv.visitFieldInsn(GETFIELD, className, "$HY$_proxy", "L"+proxyIname+";");
   
    //Get Id
    mv.visitVarInsn(ALOAD, 0);
    mv.visitFieldInsn(GETFIELD, className, "$HY$_id", Type.getDescriptor(Object.class));
    //Load other arguments
    int i;
    if(isStatic)
      i=0;
    else
      i=1;
    for(Type arg : src)
    {
      if(i < argumentsSize-1){
        if (arg.equals(Type.CHAR_TYPE) || arg.equals(Type.INT_TYPE)
            || arg.equals(Type.SHORT_TYPE)
            || arg.equals(Type.BYTE_TYPE)
            || arg.equals(Type.BOOLEAN_TYPE))
          mv.visitVarInsn(ILOAD, i);
        else if(arg.equals(Type.DOUBLE_TYPE))
          mv.visitVarInsn(DLOAD, i);
        else if(arg.equals(Type.LONG_TYPE))
          mv.visitVarInsn(LLOAD  , i);
        else if(arg.equals(Type.FLOAT_TYPE))
          mv.visitVarInsn(FLOAD, i);
        else
          mv.visitVarInsn(ALOAD, i);           
      }
      i++;
    }
    //Load Last Argument Context
    mv.visitVarInsn(ALOAD, argumentsSize-1);    //Load Context
    mv.visitTypeInsn(CHECKCAST, "edu/vt/rt/hyflow/core/tm/control/ControlContext");
    //Call the method
    mv.visitMethodInsn(INVOKEINTERFACE, proxyIname, method.name, desc);
    //End the try block
    mv.visitLabel(l1);
    //Provide specific Return type
    {
      if (returnType.equals(Type.CHAR_TYPE)
          || returnType.equals(Type.INT_TYPE)
          || returnType.equals(Type.SHORT_TYPE)
          || returnType.equals(Type.BYTE_TYPE)
          || returnType.equals(Type.BOOLEAN_TYPE))
        mv.visitInsn(IRETURN);
      else if(returnType.equals(Type.DOUBLE_TYPE))
        mv.visitInsn(DRETURN);
      else if(returnType.equals(Type.FLOAT_TYPE))
        mv.visitInsn(FRETURN);
      else if(returnType.equals(Type.LONG_TYPE))
        mv.visitInsn(LRETURN);
      else if(returnType.equals(Type.VOID_TYPE))
        mv.visitInsn(RETURN);
      else
        mv.visitInsn(ARETURN);
    }     
    mv.visitLabel(l2);
View Full Code Here

TOP

Related Classes of org.deuce.objectweb.asm.Type

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.