Package com.google.gwt.dev.asm

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


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


      try {
        java.lang.reflect.Method method = JavaScriptHost.class.getDeclaredMethod(
            methodName, INVOKE_NATIVE_PARAM_CLASSES);
        assert (method.getModifiers() & Modifier.STATIC) != 0 : "Was expecting method '"
            + method + "' to be static";
        Type realReturnType = Type.getType(method.getReturnType());
        return realReturnType.getDescriptor().equals(returnType.getDescriptor());
      } catch (SecurityException e) {
      } catch (NoSuchMethodException e) {
      }
      return false;
    }
View Full Code Here

      // 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

      /*
       * 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

      try {
        java.lang.reflect.Method method = JavaScriptHost.class.getDeclaredMethod(
            methodName, INVOKE_NATIVE_PARAM_CLASSES);
        assert (method.getModifiers() & Modifier.STATIC) != 0 : "Was expecting method '"
            + method + "' to be static";
        Type realReturnType = Type.getType(method.getReturnType());
        return realReturnType.getDescriptor().equals(returnType.getDescriptor());
      } catch (SecurityException e) {
      } catch (NoSuchMethodException e) {
      }
      return false;
    }
View Full Code Here

      // 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

  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

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.