Search in sources :

Example 1 with TypeAnnotation

use of abs.frontend.typechecker.TypeAnnotation in project abstools by abstools.

the class AnnotationTests method assertHasLocAnnotation.

private void assertHasLocAnnotation(Type t, String s) {
    List<TypeAnnotation> anns = t.getTypeAnnotations();
    TypeAnnotation a = anns.get(0);
    assertEquals("LocationType", a.getType().getSimpleName());
    assertEquals(s, ((DataConstructorExp) a.getValue()).getDecl().getName());
}
Also used : TypeAnnotation(abs.frontend.typechecker.TypeAnnotation) DataConstructorExp(abs.frontend.ast.DataConstructorExp)

Example 2 with TypeAnnotation

use of abs.frontend.typechecker.TypeAnnotation in project abstools by abstools.

the class LocationTypeExtension method getLocationTypeFromAnnotations.

public static LocationType getLocationTypeFromAnnotations(Type t, ASTNode<?> originatingNode) {
    LocationType res = null;
    for (TypeAnnotation an : t.getTypeAnnotations()) {
        if (an.getType().getQualifiedName().equals("ABS.StdLib.LocationType")) {
            DataConstructorExp de = (DataConstructorExp) an.getValue();
            String name = de.getDecl().getName();
            if (res != null) {
                throw new LocationTypeCheckerException(new TypeError(an.getValue(), ErrorMessage.LOCATION_TYPE_MULTIPLE, new String[0]));
            } else {
                res = LocationType.createFromName(name);
            }
        }
    }
    /*
        if (originatingNode != null && originatingNode instanceof ConstructorArg) {
            if (res == null || !res.isSomewhere()) {
                throw new LocationTypeCheckerException(new TypeError(originatingNode,ErrorMessage.LOCATION_TYPE_DATACONSTR_MUST_BE_SOMEWHERE, new String[0]));
            }
        }*/
    return res;
}
Also used : TypeAnnotation(abs.frontend.typechecker.TypeAnnotation) TypeError(abs.frontend.analyser.TypeError)

Aggregations

TypeAnnotation (abs.frontend.typechecker.TypeAnnotation)2 TypeError (abs.frontend.analyser.TypeError)1 DataConstructorExp (abs.frontend.ast.DataConstructorExp)1