use of abs.frontend.ast.Annotation in project abstools by abstools.
the class JavaGeneratorHelper method generateAwaitAsyncCall.
public static void generateAwaitAsyncCall(PrintStream stream, AwaitAsyncCall call) {
final PureExp callee = call.getCallee();
final List<PureExp> params = call.getParams();
final MethodSig sig = call.getMethodSig();
final List<Annotation> annotations = call.getAnnotations();
// FIXME: implement await, assignment afterwards
// OutputStream exprOStream = new ByteArrayOutputStream();
// PrintStream exprStream = new PrintStream(exprOStream);
// ClaimGuard guard = new ClaimGuard();
// // Necessary temporary variables are written to "stream" and the
// // await-expression is written to exprStream
//
// // FIXME: implement await, assignment afterwards
// guard.generateJavaGuard(stream, exprStream);
// stream.print(JavaBackendConstants.ABSRUNTIME + ".await(");
// stream.print(exprOStream.toString());
// stream.println(");");
generateAsyncCall(stream, null, callee, callee.getType(), params, null, sig, annotations);
}
use of abs.frontend.ast.Annotation in project abstools by abstools.
the class DeltaForGetSetFieldsBuilder method addGetter.
AddMethodModifier addGetter(Exp returnValue, String fieldName, Access returnType) {
MethodSig sig = new MethodSig(testCaseNameBuilder.getterMethodName(fieldName), new abs.frontend.ast.List<Annotation>(), returnType, new abs.frontend.ast.List<ParamDecl>());
Block block = new Block();
ReturnStmt rs = new ReturnStmt();
rs.setRetExp(new FieldUse(fieldName));
block.addStmtNoTransform(rs);
MethodImpl method = new MethodImpl(sig, block, false);
AddMethodModifier modifier = new AddMethodModifier(method);
return modifier;
}
use of abs.frontend.ast.Annotation 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.Annotation 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);
}
use of abs.frontend.ast.Annotation in project abstools by abstools.
the class AnnotationUtil method getExpansionId.
/**
* Gets the expansion ID of a function declaration. If the function declaration is not an expansion, -1 is
* returned.
*
* @param decl a function declaration
* @return an expansion ID, or -1
* @throws NullPointerException if decl is null
*/
public static int getExpansionId(FunctionDecl decl) {
Objects.requireNonNull(decl);
Annotation annotation = getAnnotation(decl.getAnnotationsNoTransform(), expansionType());
if (annotation == null) {
return -1;
}
PureExp value = annotation.getValue();
if (value instanceof IntLiteral) {
IntLiteral intValue = (IntLiteral) value;
try {
int result = Integer.parseInt(intValue.getContent());
return result < 0 ? -1 : result;
} catch (NumberFormatException e) {
return -1;
}
} else {
return -1;
}
}
Aggregations