Package com.google.gwt.dev.asm

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


      // Fourth argument - all the arguments boxed into an Object[]
      loadArgArray();
      // Stack is at 4; reaches 7 or 8 internally (long/double takes 2)

      // Invoke the matching JavaScriptHost.invokeNative* method
      Type returnType = Type.getReturnType(descriptor);
      JavaScriptHostInfo info = JavaScriptHostInfo.get(returnType.getSort());
      invokeStatic(JavaScriptHostInfo.TYPE, info.getMethod());
      // Stack is at 1
      if (info.requiresCast()) {
        checkCast(returnType);
      }
View Full Code Here


    return realClassType;
  }

  private Class<? extends Annotation> getAnnotationClass(TreeLogger logger,
      AnnotationData annotData) {
    Type type = Type.getType(annotData.getDesc());
    String typeName = type.getClassName();
    try {
      Class<?> clazz = Class.forName(typeName, false,
          Thread.currentThread().getContextClassLoader());
      if (!Annotation.class.isAssignableFrom(clazz)) {
        logger.log(TreeLogger.ERROR, "Type " + typeName
View Full Code Here

        if (!(value instanceof Type)) {
          logger.log(TreeLogger.WARN, "Annotation error: expected a class "
              + "literal, but received " + value);
          return null;
        }
        Type valueType = (Type) value;
        // See if we can use a binary only class here
        try {
          return Class.forName(valueType.getClassName(), false,
              Thread.currentThread().getContextClassLoader());
        } catch (ClassNotFoundException e) {
          logger.log(TreeLogger.ERROR, "Annotation error: cannot resolve "
              + valueType.getClassName(), e);
          return null;
        }
      }
      // TODO(jat) asserts about other acceptable types
      return value;
View Full Code Here

      if (!methodResolver.finish()) {
        return false;
      }
    } else {
      if (hasReturnType) {
        Type returnType = Type.getReturnType(methodData.getDesc());
        JType returnJType = resolveType(returnType);
        if (returnJType == null) {
          return false;
        }
        setReturnType(method, returnJType);
View Full Code Here

         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

  public void validateProxy(String binaryName) {
    /*
     * Don't call fastFail() here or the proxy may not be validated, since
     * validateXProxy delegates to validateProxy() which would re-check.
     */
    Type proxyType = Type.getObjectType(BinaryName.toInternalName(binaryName));
    if (isAssignable(parentLogger, entityProxyIntf, proxyType)) {
      validateEntityProxy(binaryName);
    } else if (isAssignable(parentLogger, valueProxyIntf, proxyType)) {
      validateValueProxy(binaryName);
    } else {
View Full Code Here

  public void validateRequestContext(String binaryName) {
    if (fastFail(binaryName)) {
      return;
    }

    Type requestContextType = Type.getObjectType(BinaryName.toInternalName(binaryName));
    final ErrorContext logger = parentLogger.setType(requestContextType);

    // Quick sanity check for calling code
    if (!isAssignable(logger, requestContextIntf, requestContextType)) {
      logger.poison("%s is not a %s", print(requestContextType),
          RequestContext.class.getSimpleName());
      return;
    }

    Type domainServiceType = getDomainType(logger, requestContextType);
    if (domainServiceType == errorType) {
      logger.poison(
          "The type %s must be annotated with a @%s or @%s annotation",
          BinaryName.toSourceName(binaryName), Service.class.getSimpleName(),
          ServiceName.class.getSimpleName());
View Full Code Here

  public void validateRequestFactory(String binaryName) {
    if (fastFail(binaryName)) {
      return;
    }

    Type requestFactoryType = Type.getObjectType(BinaryName.toInternalName(binaryName));
    ErrorContext logger = parentLogger.setType(requestFactoryType);

    // Quick sanity check for calling code
    if (!isAssignable(logger, Type.getType(RequestFactory.class),
        requestFactoryType)) {
      logger.poison("%s is not a %s", print(requestFactoryType),
          RequestFactory.class.getSimpleName());
      return;
    }

    // Validate each RequestContext method in the RF
    for (Method contextMethod : getMethodsInHierarchy(logger,
        requestFactoryType)) {
      Type returnType = contextMethod.getReturnType();
      if (isAssignable(logger, requestContextIntf, returnType)) {
        validateRequestContext(returnType.getClassName());
      }
    }
  }
View Full Code Here

   * {@code domainTypeBinaryName} and assignable to {@code clientTypeBinaryName}
   * , the first matching type will be returned.
   */
  String getEntityProxyTypeName(String domainTypeBinaryName,
      String clientTypeBinaryName) {
    Type key = Type.getObjectType(BinaryName.toInternalName(domainTypeBinaryName));
    List<Type> found = domainToClientType.get(key);

    /*
     * If nothing was found look for proxyable supertypes the domain object can
     * be upcast to.
     */
    if (found == null || found.isEmpty()) {
      List<Type> types = getSupertypes(parentLogger, key);
      for (Type type : types) {
        if (objectType.equals(type)) {
          break;
        }

        found = domainToClientType.get(type);
        if (found != null && !found.isEmpty()) {
          break;
        }
      }
    }

    if (found == null || found.isEmpty()) {
      return null;
    }

    Type typeToReturn = null;

    // Common case
    if (found.size() == 1) {
      typeToReturn = found.get(0);
    } else {
      // Search for the first assignable type
      Type assignableTo = Type.getObjectType(BinaryName.toInternalName(clientTypeBinaryName));
      for (Type t : found) {
        if (isAssignable(parentLogger, assignableTo, t)) {
          typeToReturn = t;
          break;
        }
View Full Code Here

      Type domainServiceType, boolean requireStaticMethodsForRequestType) {
    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

TOP

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