Package com.google.gwt.dev.asm.commons

Examples of com.google.gwt.dev.asm.commons.Method


    }

    private JavaScriptHostInfo(Type returnType, String methodName,
        boolean requiresCast) {
      this.requiresCast = requiresCast;
      this.method = new Method(methodName, returnType,
          INVOKE_NATIVE_PARAM_TYPES);
      assert matchesRealMethod(methodName, returnType) : "JavaScriptHostInfo for '"
          + this + "' does not match real method";
    }
View Full Code Here


     * for example, {@code new Boolean} instead of using
     * {@link Boolean#valueOf(boolean)}.
     */
    @Override
    public void box(Type type) {
      Method method = Boxing.getBoxMethod(type);
      if (method != null) {
        invokeStatic(method.getReturnType(), method);
      }
    }
View Full Code Here

       * a common implementation far more awkward than the duplication of code.
       */
      for (String mangledName : toImplement(stubIntr)) {
         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

         /*
          * The local descriptor is the same as the descriptor from the abstract method in the
          * interface.
          */
         String localDescriptor = interfaceMethod.getDescriptor();
         Method localMethod = new Method(mangledName, localDescriptor);

         /*
          * We also use the first argument to know which type to statically dispatch to.
          */
         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

    logger = logger.setMethod(method);

    // Create a "translated" method declaration to search for
    // Request<BlahProxy> foo(int a, BarProxy bar) -> Blah foo(int a, Bar bar);
    Type returnType = getReturnType(logger, method);
    Method searchFor = createDomainMethod(logger, new Method(method.getName(),
        returnType, method.getArgumentTypes()));

    RFMethod found = findCompatibleServiceMethod(logger, domainServiceType,
        searchFor);
View Full Code Here

    Type[] args = clientMethod.getArgumentTypes();
    for (int i = 0, j = args.length; i < j; i++) {
      args[i] = getDomainType(logger, args[i]);
    }
    Type returnType = getDomainType(logger, clientMethod.getReturnType());
    return new Method(clientMethod.getName(), returnType, args);
  }
View Full Code Here

    logger = logger.setMethod(method);

    // Create a "translated" method declaration to search for
    // Request<BlahProxy> foo(int a, BarProxy bar) -> Blah foo(int a, Bar bar);
    Type returnType = getReturnType(logger, method);
    Method searchFor = createDomainMethod(logger, new Method(method.getName(),
        returnType, method.getArgumentTypes()));

    RFMethod found = findCompatibleServiceMethod(logger, domainServiceType,
        searchFor, !method.isValidationSkipped());
View Full Code Here

    Type[] args = clientMethod.getArgumentTypes();
    for (int i = 0, j = args.length; i < j; i++) {
      args[i] = getDomainType(logger, args[i]);
    }
    Type returnType = getDomainType(logger, clientMethod.getReturnType());
    return new Method(clientMethod.getName(), returnType, args);
  }
View Full Code Here

  /**
   * Produce a rebased method declaration, also visiting referenced types.
   */
  private Method processMethod(String sourceType, String name, String desc) {
    Method method = new Method(name, desc);
    Type[] argumentTypes = method.getArgumentTypes();
    for (int i = 0, j = argumentTypes.length; i < j; i++) {
      argumentTypes[i] = processType(sourceType, argumentTypes[i]);
    }
    method = new Method(name, processType(sourceType, method.getReturnType()),
        argumentTypes);
    return method;
  }
View Full Code Here

    }

    @Override
    public MethodVisitor visitMethod(int access, String name, String desc,
        String signature, String[] exceptions) {
      Method method = processMethod(sourceType, name, desc);
      desc = method.getDescriptor();
      if (exceptions != null) {
        for (int i = 0, j = exceptions.length; i < j; i++) {
          exceptions[i] = processInternalName(sourceType, exceptions[i]);
        }
      }
View Full Code Here

TOP

Related Classes of com.google.gwt.dev.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.