Search in sources :

Example 1 with BoundedType

use of org.abs_models.frontend.typechecker.BoundedType in project abstools by abstools.

the class JavaBackend method getQualifiedString.

public static String getQualifiedString(Type absType) {
    String res = null;
    if (absType.isDataType()) {
        DataTypeType dt = (DataTypeType) absType;
        res = dataTypeMap.get(dt.getDecl().getName());
        if (res != null)
            return res;
        StringBuilder sb = new StringBuilder();
        if (dt.hasTypeArgs() && !containsUnboundedType(dt.getTypeArgs())) {
            sb.append("<");
            boolean first = true;
            for (Type t : dt.getTypeArgs()) {
                if (first)
                    first = false;
                else
                    sb.append(',');
                sb.append(getQualifiedString(t));
            }
            sb.append(">");
        }
        return getQualifiedString(dt.getDecl()) + sb.toString();
    /*
             * if (dt.hasTypeArgs() && !containsUnboundedType(dt.getTypeArgs()))
             * {
             *
             * sb.append("<"); boolean first = true; for (Type t :
             * dt.getTypeArgs()) { if (first) first = false; else
             * sb.append(','); sb.append(getQualifiedString(t)); }
             * sb.append(">"); }
             */
    } else if (absType.isInterfaceType()) {
        InterfaceType it = (InterfaceType) absType;
        return getQualifiedString(it.getDecl());
    } else if (absType.isTypeParameter()) {
        TypeParameter tp = (TypeParameter) absType;
        return tp.getDecl().getName();
    } else if (absType.isBoundedType()) {
        BoundedType bt = (BoundedType) absType;
        if (bt.hasBoundType())
            return getQualifiedString(bt.getBoundType());
        return "?";
    } else if (absType.isAnyType()) {
        return "java.lang.Object";
    } else if (absType.isUnionType()) {
        return getQualifiedString(((UnionType) absType).getOriginatingClass());
    }
    throw new RuntimeException("Type " + absType.getClass().getName() + " not yet supported by Java backend");
}
Also used : BoundedType(org.abs_models.frontend.typechecker.BoundedType) UnionType(org.abs_models.frontend.typechecker.UnionType) Type(org.abs_models.frontend.typechecker.Type) InterfaceType(org.abs_models.frontend.typechecker.InterfaceType) DataTypeType(org.abs_models.frontend.typechecker.DataTypeType) BoundedType(org.abs_models.frontend.typechecker.BoundedType) UnionType(org.abs_models.frontend.typechecker.UnionType) InterfaceType(org.abs_models.frontend.typechecker.InterfaceType) TypeParameter(org.abs_models.frontend.typechecker.TypeParameter) DataTypeType(org.abs_models.frontend.typechecker.DataTypeType) ABSString(org.abs_models.backend.java.lib.types.ABSString)

Aggregations

ABSString (org.abs_models.backend.java.lib.types.ABSString)1 BoundedType (org.abs_models.frontend.typechecker.BoundedType)1 DataTypeType (org.abs_models.frontend.typechecker.DataTypeType)1 InterfaceType (org.abs_models.frontend.typechecker.InterfaceType)1 Type (org.abs_models.frontend.typechecker.Type)1 TypeParameter (org.abs_models.frontend.typechecker.TypeParameter)1 UnionType (org.abs_models.frontend.typechecker.UnionType)1