use of org.abs_models.frontend.ast.DataTypeUse in project abstools by abstools.
the class AbsASTBuilderUtil method getType.
public static final DataTypeUse getType(String n, TypeUse... types) {
if (types.length > 0) {
ParametricDataTypeUse set = new ParametricDataTypeUse();
set.setName(n);
for (TypeUse d : types) {
set.addParam(d);
}
return set;
} else {
DataTypeUse set = new DataTypeUse();
set.setName(n);
return set;
}
}
use of org.abs_models.frontend.ast.DataTypeUse in project abstools by abstools.
the class DeadlockPreanalysis method processFieldDecl.
private void processFieldDecl(FieldDecl field) {
System.out.println("Processing Field Declaration: " + field.getName());
if (field.getChild(0) instanceof DataTypeUse) {
DataTypeUse type = (DataTypeUse) field.getChild(0);
dataFieldDecls.put(field, hasFutureVariables(type));
}
}
use of org.abs_models.frontend.ast.DataTypeUse in project abstools by abstools.
the class ASTBasedABSTestRunnerGenerator method generateWaitSyncAST.
private WhileStmt generateWaitSyncAST() {
WhileStmt ws = new WhileStmt();
ws.setCondition(getFnApp("hasNext", new VarUse(futs)));
Block body = new Block();
DataTypeUse u = getType("Pair", getType("Set", getType("Fut", getType("Unit"))), getType("Fut", getType("Unit")));
body.addStmtNoTransform(getVarDecl("nt", u, getFnApp("next", new VarUse(futs))));
body.addStmtNoTransform(getVAssign(fut, getFnApp("snd", new VarUse("nt"))));
body.addStmtNoTransform(getVAssign(futs, getFnApp("fst", new VarUse("nt"))));
body.addStmtNoTransform(getExpStmt(new GetExp(new VarUse("fut"))));
// Attach body at the end, since JastAdd will avoid touching ASTs without parents.
ws.setBody(body);
return ws;
}
use of org.abs_models.frontend.ast.DataTypeUse in project abstools by abstools.
the class ASTBasedABSTestRunnerGenerator method generateTestClassImplAST.
private Set<TypeUse> generateTestClassImplAST(InterfaceDecl inf, ClassDecl clazz, MainBlock block) {
Set<TypeUse> accesses = new HashSet<>();
TypeUse dataType = generateDataPointsAST(inf, clazz, accesses, block);
String namePrefix = clazz.getName();
int instance = 0;
for (MethodSig method : getTestMethods(inf)) {
Block thisBlock = block;
WhileStmt ws = null;
if (method.getNumParam() > 0) {
if (dataType == null) {
throw new IllegalStateException("Test method requires arguments but test class defines no data point");
}
/*
* a while loop over all data points
*/
String dataPointSet = dataPointSetName(clazz);
ws = new WhileStmt();
ws.setCondition(getFnApp("hasNext", new VarUse(dataPointSet)));
Block body = new Block();
thisBlock = body;
DataTypeUse u = getType("Pair", getType("Set", (TypeUse) dataType.copy()), (TypeUse) dataType.copy());
thisBlock.addStmtNoTransform(getVarDecl("nt", u, getFnApp("next", new VarUse(dataPointSet))));
thisBlock.addStmtNoTransform(getVarDecl(dataValue, (TypeUse) dataType.copy(), getFnApp("snd", new VarUse("nt"))));
thisBlock.addStmtNoTransform(getVAssign(dataPointSet, getFnApp("fst", new VarUse("nt"))));
ws.setBody(body);
}
/*
* Add those methods that are not ignored
*/
if (!isIgnored(clazz, method)) {
String objectRef = uncap(namePrefix) + instance;
thisBlock.addStmtNoTransform(newObj(inf, clazz, objectRef, false));
generateAsyncTestCallAST(thisBlock, objectRef, method);
}
if (ws != null) {
block.addStmtNoTransform(ws);
}
instance++;
}
return accesses;
}
Aggregations