use of org.abs_models.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 org.abs_models.frontend.typechecker.TypeAnnotation in project abstools by abstools.
the class NullCheckerExtension method getNullableTypeFromAnnotation.
public static NullableType getNullableTypeFromAnnotation(Type t) {
NullableType res = null;
for (TypeAnnotation an : t.getTypeAnnotations()) {
if (an.getType().getQualifiedName().equals("ABS.StdLib.NullableType")) {
DataConstructorExp de = (DataConstructorExp) an.getValue();
String name = de.getDecl().getName();
if (res != null) {
throw new NullCheckerException(new TypeError(an.getValue(), ErrorMessage.NULLABLE_TYPE_MULTIPLE, new String[0]));
} else {
if (!shouldHaveNullableType(t)) {
throw new NullCheckerException(new TypeError(an.getValue(), ErrorMessage.NULLABLE_TYPE_ONLY_REF_OR_FUT, t.toString()));
}
res = NullableType.fromName(name);
}
}
}
return res;
}
use of org.abs_models.frontend.typechecker.TypeAnnotation in project abstools by abstools.
the class LocationTypeExtension method getLocationTypeFromAnnotations.
public static LocationType getLocationTypeFromAnnotations(Type t) {
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);
}
}
}
return res;
}
Aggregations