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 annotationData) {
    Type type = Type.getType(annotationData.getDesc());
    String binaryName = type.getClassName();
    try {
      Class<?> clazz =
          Class.forName(binaryName, false, Thread.currentThread().getContextClassLoader());
      if (!Annotation.class.isAssignableFrom(clazz)) {
        logger.log(TreeLogger.ERROR, "Type " + binaryName + " is not an annotation");
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 forName(valueType.getClassName());
        } 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 (fieldJType == null) {
        logger.log(TreeLogger.ERROR, "Unable to resolve type in field signature " + signature);
        return false;
      }
    } else {
      Type fieldType = Type.getType(field.getDesc());
      fieldJType = resolveType(fieldType);
      if (fieldJType == null) {
        logger.log(TreeLogger.ERROR, "Unable to resolve type " + fieldType.getInternalName()
            + " of field " + field.getName());
        return false;
      }
    }
    setFieldType(jfield, fieldJType);
View Full Code Here

        logger.log(TreeLogger.ERROR, "Failed to resolve.");
        return false;
      }
    } else {
      if (hasReturnType) {
        Type returnType = Type.getReturnType(methodData.getDesc());
        JType returnJType = resolveType(returnType);
        if (returnJType == null) {
          logger.log(TreeLogger.ERROR,
              "Unable to resolve return type " + returnType.getInternalName());
          return false;
        }
        setReturnType(method, returnJType);
      }
View Full Code Here

        argNamesAreReal = true;
      }
    }
    List<CollectAnnotationData>[] paramAnnot = methodData.getArgAnnotations();
    for (int i = 0; i < argTypes.length; ++i) {
      Type argType = argTypes[i];
      JType argJType = resolveType(argType);
      if (argJType == null) {
        logger.log(TreeLogger.ERROR, "Unable to resolve type " + argType.getInternalName()
            + " of argument " + methodData.getArgNames()[i]);
        return false;
      }
      // Try to resolve annotations, ignore any that fail.
      Map<Class<? extends Annotation>, Annotation> declaredAnnotations =
View Full Code Here

  private boolean resolveThrows(TreeLogger logger, JAbstractMethod method,
      CollectMethodData methodData) {
    if (method.getThrows().length == 0) {
      for (String exceptionName : methodData.getExceptions()) {
        Type exceptionType = Type.getObjectType(exceptionName);
        JType exceptionJType = resolveType(exceptionType);
        if (exceptionJType == null) {
          logger.log(TreeLogger.ERROR,
              "Unable to resolve type " + exceptionType.getInternalName() + " of thrown exception");
          return false;
        }
        addThrows(method, (JClassType) exceptionJType);
      }
    }
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

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.