use of abs.frontend.ast.PureExp in project abstools by abstools.
the class MethodTestCaseBuilder method makeMethodCall.
private Call makeMethodCall(String testName, Set<String> heapNames, String methodName, List<ABSData> inArgs, boolean sync) {
if (inArgs.size() == 0) {
throw new IllegalStateException("Inputs for a method must at least have a reference");
}
ABSData r = inArgs.get(0);
if (!(r instanceof ABSRef)) {
throw new IllegalStateException("Inputs for a method must at least have a reference");
}
PureExp[] ps = new PureExp[inArgs.size() - 1];
for (int i = 1; i < inArgs.size(); i++) {
ABSData d = inArgs.get(i);
PureExp exp = pureExpBuilder.createPureExpression(testName, heapNames, d);
ps[i - 1] = exp;
}
String rn = getABSDataValue(r);
VarUse var = new VarUse(heapRefBuilder.heapReferenceForTest(testName, rn));
Call call = getCall(var, methodName, sync, ps);
return call;
}
use of abs.frontend.ast.PureExp in project abstools by abstools.
the class PureExpressionBuilder method parseValue.
DataConstructorExp parseValue(String currentHeapReference, List<String> initialisationsOrders, String testName, Set<String> heap, ABSTerm term) {
final DataConstructorExp result = new DataConstructorExp();
String fn = getABSTermFunctor(term);
result.setConstructor(fn);
result.setParamList(new abs.frontend.ast.List<PureExp>());
List<ABSData> vs = getABSTermArgs(term);
for (int i = 0; i < vs.size(); i++) {
result.setParam(createPureExpression(currentHeapReference, initialisationsOrders, testName, heap, vs.get(i)), i);
}
return result;
}
use of abs.frontend.ast.PureExp in project abstools by abstools.
the class ASTBasedABSTestRunnerGenerator method generateAsyncTestCallAST.
private void generateAsyncTestCallAST(Block block, String objectRef, MethodSig method) {
List<PureExp> args = new List<>();
if (method.getNumParam() > 0) {
args.add(new VarUse(dataValue));
}
block.addStmtNoTransform(getVAssign(fut, new AsyncCall(new VarUse(objectRef), method.getName(), args)));
block.addStmtNoTransform(getVAssign(futs, getFnApp("Insert", new VarUse(fut), new VarUse(futs))));
}
use of abs.frontend.ast.PureExp 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.PureExp 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