/**
   * Visits a primitive type, dispatching to the visit method for the specific {@linkplain TypeKind
   * kind} of primitive type: {@code BOOLEAN}, {@code BYTE}, etc.
   *
   * @param t {@inheritDoc}
   * @param p {@inheritDoc}
   * @return the result of the kind-specific visit method
   */
  @Override
  public R visitPrimitive(PrimitiveType t, P p) {
    TypeKind k = t.getKind();
    switch (k) {
      case BOOLEAN:
        return visitPrimitiveAsBoolean(t, p);

      case BYTE:
        return visitPrimitiveAsByte(t, p);

      case SHORT:
        return visitPrimitiveAsShort(t, p);

      case INT:
        return visitPrimitiveAsInt(t, p);

      case LONG:
        return visitPrimitiveAsLong(t, p);

      case CHAR:
        return visitPrimitiveAsChar(t, p);

      case FLOAT:
        return visitPrimitiveAsFloat(t, p);

      case DOUBLE:
        return visitPrimitiveAsDouble(t, p);

      default:
        throw new AssertionError("Bad kind " + k + " for PrimitiveType" + t);
    }
  }
Example #2
0
 private static Class<?> box(PrimitiveType primitiveType) {
   switch (primitiveType.getKind()) {
     case BYTE:
       return Byte.class;
     case SHORT:
       return Short.class;
     case INT:
       return Integer.class;
     case LONG:
       return Long.class;
     case FLOAT:
       return Float.class;
     case DOUBLE:
       return Double.class;
     case BOOLEAN:
       return Boolean.class;
     case CHAR:
       return Character.class;
     case VOID:
       return Void.class;
     default:
       throw new AssertionError();
   }
 }
 @Override
 public ASTType visitPrimitive(PrimitiveType primitiveType, Void v) {
   return ASTPrimitiveType.valueOf(primitiveType.getKind().name());
 }