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());
}
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;
}
Aggregations