Examples of JEnumType


Examples of com.google.gwt.dev.jjs.ast.JEnumType

     * Use the classForEnum() constructor even for enum subtypes to aid in
     * pruning supertype data.
     */
    boolean isEnumOrSubclass = false;
    if (type instanceof JClassType) {
      JEnumType maybeEnum = ((JClassType) type).isEnumOrSubclass();
      if (maybeEnum != null) {
        isEnumOrSubclass = true;
        method = program.getIndexedMethod(maybeEnum.getClassLiteralFactoryMethod());
      }
    }

    assert method != null;

    JMethodCall call = new JMethodCall(info, null, method);
    JStringLiteral packageName = program.getLiteralString(info, getPackageName(typeName));
    JStringLiteral className = program.getLiteralString(info, getClassName(typeName));
    call.addArgs(packageName, className);

    if (type instanceof JArrayType) {
      // There's only one seed function for all arrays
      JDeclaredType arrayType = program.getIndexedType("Array");
      call.addArg(new JNameOf(info, className.getType(), arrayType));

    } else if (type instanceof JClassType) {
      // Add the name of the seed function for concrete types
      call.addArg(new JNameOf(info, className.getType(), type));

    } else if (type instanceof JPrimitiveType) {
      // And give primitive types an illegal, though meaningful, value
      call.addArg(program.getLiteralString(info, " " + type.getJavahSignatureName()));
    }

    if (type instanceof JClassType) {
      /*
       * For non-array classes and enums, determine the class literal of the
       * supertype, if there is one. Arrays are excluded because they always
       * have Object as their superclass.
       */
      JClassType classType = (JClassType) type;

      JLiteral superclassLiteral;
      if (classType.getSuperClass() != null) {
        superclassLiteral = createDependentClassLiteral(info, classType.getSuperClass());
      } else {
        superclassLiteral = JNullLiteral.INSTANCE;
      }

      call.addArg(superclassLiteral);

      if (classType instanceof JEnumType) {
        JEnumType enumType = (JEnumType) classType;
        JMethod valuesMethod = null;
        JMethod valueOfMethod = null;
        for (JMethod methodIt : enumType.getMethods()) {
          if ("values".equals(methodIt.getName())) {
            if (methodIt.getParams().size() != 0) {
              continue;
            }
            valuesMethod = methodIt;
View Full Code Here

Examples of com.google.gwt.dev.jjs.ast.JEnumType

      } else if (binding.isEnum()) {
        if (binding.isAnonymousType()) {
          // Don't model an enum subclass as a JEnumType.
          type = new JClassType(info, name, false, true);
        } else {
          type = new JEnumType(info, name, binding.isAbstract());
        }
      } else {
        throw new InternalCompilerException("ReferenceBinding is not a class, interface, or enum.");
      }
      typeMap.setSourceType(binding, type);
View Full Code Here

Examples of com.google.gwt.dev.jjs.ast.JEnumType

    } else if (binding.isEnum()) {
      if (binding.isAnonymousType()) {
        // Don't model an enum subclass as a JEnumType.
        return new JClassType(info, name, false, true);
      } else {
        return new JEnumType(info, name, binding.isAbstract());
      }
    } else {
      throw new InternalCompilerException("ReferenceBinding is not a class, interface, or enum.");
    }
  }
View Full Code Here

Examples of com.google.gwt.dev.jjs.ast.JEnumType

     * After program is visited, post-process remaining tasks from accumulated data.
     */
    public void afterVisitor() {
      // black-list any Jsni enum ClassLiteralsVisited
      for (String classLiteralName : jsniClassLiteralsVisited) {
        JEnumType enumFromLiteral = enumsVisited.get(classLiteralName);
        if (enumFromLiteral != null) {
          addToBlackList(enumFromLiteral);
        }
      }
    }
View Full Code Here

Examples of com.google.gwt.dev.jjs.ast.JEnumType

       *
       * Note: we won't get here for class literals that occur in the
       * ClassLiteralHolder class, or within the getClass method of an
       * enum class (see comments above).
       */
      JEnumType type = getEnumType(x.getRefType());
      if (type != null) {
        blackListIfEnum(type);
      }
    }
View Full Code Here

Examples of com.google.gwt.dev.jjs.ast.JEnumType

          }
        }
      }
     
      // keep track of all enum classes visited
      JEnumType maybeEnum = x.isEnumOrSubclass();
      if (maybeEnum != null) {
        enumsVisited.put(program.getClassLiteralName(maybeEnum), maybeEnum);
      }
    }
View Full Code Here

Examples of com.google.gwt.dev.jjs.ast.JEnumType

      if (x.getField() == enumOrdinalField) {
        if (x.getInstance() != null &&
            x.getInstance() instanceof JCastOperation) {
          JCastOperation castOp = (JCastOperation) x.getInstance();
          if (getPossiblyUnderlyingType(castOp.getCastType()) == enumType) {
            JEnumType fromType = getEnumType(castOp.getExpr().getType());
            if (fromType != null) {
              castOpsToIgnore.push(castOp);
            }
          }
        }
View Full Code Here

Examples of com.google.gwt.dev.jjs.ast.JEnumType

      if (x.getTarget() == enumOrdinalMethod) {
        if (x.getInstance() != null &&
            x.getInstance() instanceof JCastOperation) {
          JCastOperation castOp = (JCastOperation) x.getInstance();
          if (getPossiblyUnderlyingType(castOp.getCastType()) == enumType) {
            JEnumType fromType = getEnumType(castOp.getExpr().getType());
            if (fromType != null) {
              castOpsToIgnore.push(castOp);
            }
          }
        }
View Full Code Here

Examples of com.google.gwt.dev.jjs.ast.JEnumType

    private void addToBlackList(JEnumType enumType) {
      ordinalizationBlackList.add(enumType);
    }
   
    private void blackListIfEnum(JType maybeEnum) {
      JEnumType actualEnum = getEnumType(maybeEnum);
      if (actualEnum != null) {
        addToBlackList(actualEnum);
      }
    }
View Full Code Here

Examples of com.google.gwt.dev.jjs.ast.JEnumType

        addToBlackList(actualEnum);
      }
    }
   
    private void blackListIfEnumCast(JType maybeEnum, JType destType) {
      JEnumType actualEnum = getEnumType(maybeEnum);
      JEnumType actualDestType = getEnumType(destType);
      if (actualEnum != null) {
        if (actualDestType != actualEnum) {
          addToBlackList(actualEnum);
        }
        return;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.