Search in sources :

Example 1 with TypedAnnotation

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");
    }
}
Also used : ListLiteral(abs.frontend.ast.ListLiteral) IntLiteral(abs.frontend.ast.IntLiteral) TypedAnnotation(abs.frontend.ast.TypedAnnotation) PureExp(abs.frontend.ast.PureExp) Annotation(abs.frontend.ast.Annotation) TypedAnnotation(abs.frontend.ast.TypedAnnotation)

Example 2 with TypedAnnotation

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);
}
Also used : IntLiteral(abs.frontend.ast.IntLiteral) TypedAnnotation(abs.frontend.ast.TypedAnnotation) Annotation(abs.frontend.ast.Annotation) TypedAnnotation(abs.frontend.ast.TypedAnnotation)

Aggregations

Annotation (abs.frontend.ast.Annotation)2 IntLiteral (abs.frontend.ast.IntLiteral)2 TypedAnnotation (abs.frontend.ast.TypedAnnotation)2 ListLiteral (abs.frontend.ast.ListLiteral)1 PureExp (abs.frontend.ast.PureExp)1