use of abs.frontend.ast.TypedAnnotation in project abstools by abstools.
the class AnnotationUtil method addToAnnotations.
private static void addToAnnotations(List<Annotation> annotations, Access annotationType, int expansionId) {
IntLiteral indexLiteral = new IntLiteral(Integer.toString(expansionId));
Annotation toAdd = getAnnotation(annotations, annotationType);
if (toAdd == null) {
toAdd = new TypedAnnotation(new ListLiteral(new List<>()), annotationType);
annotations.add(toAdd);
}
PureExp value = toAdd.getValue();
if (value instanceof ListLiteral) {
ListLiteral list = (ListLiteral) value;
for (PureExp exp : list.getPureExps()) {
if (exp instanceof IntLiteral) {
IntLiteral intLiteral = (IntLiteral) exp;
if (intLiteral.getContent().equals(indexLiteral.getContent())) {
return;
}
}
}
list.addPureExp(indexLiteral);
} else {
throw new IllegalArgumentException("Annotation list contains invalid expansion annotation");
}
}
use of abs.frontend.ast.TypedAnnotation in project abstools by abstools.
the class AnnotationUtil method annotateExpansion.
public static void annotateExpansion(FunctionDecl expansion, int expansionId) {
IntLiteral indexLiteral = new IntLiteral(Integer.toString(expansionId));
Annotation annotation = new TypedAnnotation(indexLiteral, expansionType());
expansion.addAnnotation(annotation);
}
Aggregations