Package com.google.gwt.dev.asm

Examples of com.google.gwt.dev.asm.MethodVisitor


      String signature, String[] exceptions) {

    boolean isNative = (access & Opcodes.ACC_NATIVE) != 0;
    access &= ~Opcodes.ACC_NATIVE;

    MethodVisitor mv = super.visitMethod(access, name, desc, signature,
        exceptions);

    if (isNative) {
      mv = new MyMethodAdapter(mv, access, name, desc);
    }
View Full Code Here


   }

   @Override
   public MethodVisitor visitMethod(int access, String name, String desc, String signature,
            String[] exceptions) {
      MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions);
      if (mv == null) {
         return null;
      }
      return new MethodInterceptor(mv, className);
   }
View Full Code Here

      if (inSingleJsoImplInterfaceType && !"<clinit>".equals(name)) {
         name = currentTypeName.replace('/', '_') + "_" + name;
         implementedMethods.add(name);
      }

      MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions);
      if (mv == null) {
         return null;
      }

      return new MyMethodVisitor(mv);
View Full Code Here

      }
      return toReturn;
   }

   private void writeEmptyMethod(String mangledMethodName, Method declMethod) {
      MethodVisitor mv = super.visitMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_ABSTRACT,
               mangledMethodName, declMethod.getDescriptor(), null, null);
      mv.visitEnd();
   }
View Full Code Here

         for (Method method : jsoData.getDeclarations(mangledName)) {

            Method toCall = new Method(method.getName(), method.getDescriptor());

            // Must not be final
            MethodVisitor mv = super.visitMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_SYNTHETIC,
                     mangledName, method.getDescriptor(), null, null);
            if (mv != null) {
               mv.visitCode();

               /*
                * It just so happens that the stack and local variable sizes are the same, but
                * they're kept distinct to aid in clarity should the dispatch logic change.
                *
                * These start at 1 because we need to load "this" onto the stack
                */
               int var = 1;
               int size = 1;

               // load this
               mv.visitVarInsn(Opcodes.ALOAD, 0);

               // then the rest of the arguments
               for (Type t : toCall.getArgumentTypes()) {
                  size += t.getSize();
                  mv.visitVarInsn(t.getOpcode(Opcodes.ILOAD), var);
                  var += t.getSize();
               }

               // Make sure there's enough room for the return value
               size = Math.max(size, toCall.getReturnType().getSize());

               mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, currentTypeName, toCall.getName(),
                        toCall.getDescriptor());
               mv.visitInsn(toCall.getReturnType().getOpcode(Opcodes.IRETURN));
               mv.visitMaxs(size, var);
               mv.visitEnd();
            }
         }
      }
   }
View Full Code Here

   @Override
   public MethodVisitor visitMethod(int access, String name, String desc, String signature,
            String[] exceptions) {
      // Wrap the returned method visitor in my own.
      MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions);
      return new MyMethodAdapter(mv);
   }
View Full Code Here

          */
         Type implementingType = Type.getType("L"
                  + implementingMethod.getArgumentTypes()[0].getInternalName() + "$;");

         // Maybe create the method. This is marked final as a sanity check
         MethodVisitor mv = visitMethodNoRewrite(Opcodes.ACC_PUBLIC | Opcodes.ACC_FINAL
                  | Opcodes.ACC_SYNTHETIC, localMethod.getName(), localMethod.getDescriptor(),
                  null, null);

         if (mv != null) {
            mv.visitCode();

            /*
             * It just so happens that the stack and local variable sizes are the same, but they're
             * kept distinct to aid in clarity should the dispatch logic change.
             */
            int var = 0;
            int size = 0;

            for (Type t : implementingMethod.getArgumentTypes()) {
               size += t.getSize();
               mv.visitVarInsn(t.getOpcode(Opcodes.ILOAD), var);
               var += t.getSize();
            }

            // Make sure there's enough room for the return value
            size = Math.max(size, implementingMethod.getReturnType().getSize());

            mv.visitMethodInsn(Opcodes.INVOKESTATIC, implementingType.getInternalName(),
                     implementingMethod.getName(), implementingMethod.getDescriptor());
            mv.visitInsn(localMethod.getReturnType().getOpcode(Opcodes.IRETURN));
            mv.visitMaxs(size, var);
            mv.visitEnd();
         }
      }
View Full Code Here

    @Override
    public MethodVisitor visitMethod(int access, String name, String desc,
        String signature, String[] exceptions) {
      if ((access & Opcodes.ACC_NATIVE) != 0) {
        MethodVisitor mv = super.visitMethod(access & ~Opcodes.ACC_NATIVE,
            name, desc, signature, exceptions);
        if (mv != null) {
          mv.visitCode();
          String exceptionName = Type.getInternalName(RuntimeException.class);
          // <empty>
          mv.visitTypeInsn(Opcodes.NEW, exceptionName);
          // obj
          mv.visitInsn(Opcodes.DUP);
          // obj, obj
          mv.visitLdcInsn(NATIVE_METHOD_ERROR);
          // obj, obj, string
          mv.visitMethodInsn(Opcodes.INVOKESPECIAL, exceptionName, "<init>",
              "(Ljava/lang/String;)V");
          // obj
          mv.visitInsn(Opcodes.ATHROW);

          // Count argument slots - long and double arguments each take up 2 slots
          int numSlots = 0;
          for (Type t : Type.getArgumentTypes(desc)) {
            numSlots += t.getSize();
          }
          if ((access & Opcodes.ACC_STATIC) == 0) {
            // Add one for 'this' reference
            numSlots++;
          }
          mv.visitMaxs(3, numSlots);
          mv.visitEnd();
        }
        return null;
      } else {
        return super.visitMethod(access, name, desc, signature, exceptions);
      }
View Full Code Here

      if (exceptions != null) {
        for (int i = 0, j = exceptions.length; i < j; i++) {
          exceptions[i] = processInternalName(sourceType, exceptions[i]);
        }
      }
      MethodVisitor mv = super.visitMethod(access, name, desc, signature,
          exceptions);
      if (mv != null) {
        mv = new MethodProcessor(sourceType, mv);
      }
      return mv;
View Full Code Here

       */
      Type implementingType = Type.getType("L"
          + implementingMethod.getArgumentTypes()[0].getInternalName() + "$;");

      // Maybe create the method. This is marked final as a sanity check
      MethodVisitor mv = visitMethodNoRewrite(Opcodes.ACC_PUBLIC
          | Opcodes.ACC_FINAL | Opcodes.ACC_SYNTHETIC, localMethod.getName(),
          localMethod.getDescriptor(), null, null);

      if (mv != null) {
        mv.visitCode();

        /*
         * It just so happens that the stack and local variable sizes are the
         * same, but they're kept distinct to aid in clarity should the dispatch
         * logic change.
         */
        int var = 0;
        int size = 0;

        for (Type t : implementingMethod.getArgumentTypes()) {
          size += t.getSize();
          mv.visitVarInsn(t.getOpcode(Opcodes.ILOAD), var);
          var += t.getSize();
        }

        // Make sure there's enough room for the return value
        size = Math.max(size, implementingMethod.getReturnType().getSize());

        mv.visitMethodInsn(Opcodes.INVOKESTATIC,
            implementingType.getInternalName(), implementingMethod.getName(),
            implementingMethod.getDescriptor());
        mv.visitInsn(localMethod.getReturnType().getOpcode(Opcodes.IRETURN));
        mv.visitMaxs(size, var);
        mv.visitEnd();
      }
    }
View Full Code Here

TOP

Related Classes of com.google.gwt.dev.asm.MethodVisitor

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.