use of abs.frontend.ast.Call in project abstools by abstools.
the class AbsASTBuilderUtil method getCall.
public static final Call getCall(PureExp who, String method, boolean sync, PureExp... exps) {
Call call;
if (sync) {
call = new SyncCall();
} else {
call = new AsyncCall();
}
call.setCallee(who);
call.setMethod(method);
for (int i = 0; i < exps.length; i++) {
call.setParam(exps[i], i);
}
return call;
}
use of abs.frontend.ast.Call in project abstools by abstools.
the class ABSUnitTestCaseBuilder method makeSetStatements.
void makeSetStatements(Map<String, String> typeHierarchy, Map<String, List<Stmt>> initialisations, List<String> initialisationsOrders, String testName, Set<String> heapNames, Map<ABSRef, ABSObject> initialHeap, Map<String, InterfaceTypeUse> objectsInHeap, ABSRef ref, ABSObject state, ClassDecl testClass) {
String rn = heapRefBuilder.heapReferenceForTest(testName, getABSDataValue(ref));
String concreteTypeName = getABSObjectType(state);
ClassDecl concreteType = getDecl(model, ClassDecl.class, new DeclNamePredicate<ClassDecl>(concreteTypeName));
if (concreteType == null) {
throw new IllegalStateException("Cannot find class: " + concreteTypeName);
}
List<Stmt> statements = new ArrayList<Stmt>();
initialisations.put(rn, statements);
if (!initialisationsOrders.contains(rn)) {
initialisationsOrders.add(rn);
}
Map<String, ABSData> fields = getABSObjectFields(state);
abs.frontend.ast.List<ParamDecl> params = concreteType.getParamList();
PureExp[] constructorArgs = new PureExp[params.getNumChild()];
for (int i = 0; i < params.getNumChild(); i++) {
ParamDecl param = params.getChild(i);
String name = param.getName();
assert fields.containsKey(name);
ABSData d = fields.remove(name);
objectsInHeap.putAll(getTypesFromABSData(testName, d));
PureExp exp = pureExpBuilder.createPureExpression(rn, initialisationsOrders, testName, heapNames, d);
constructorArgs[i] = exp;
}
statements.add(getVAssign(rn, newObj(concreteType, false, constructorArgs)));
for (String fn : fields.keySet()) {
ABSData d = fields.get(fn);
objectsInHeap.putAll(getTypesFromABSData(testName, d));
PureExp exp = pureExpBuilder.createPureExpression(rn, initialisationsOrders, testName, heapNames, d);
Call call = getCall(new VarUse(rn), testCaseNameBuilder.setterMethodName(fn), true, exp);
statements.add(getExpStmt(call));
}
// ADD getter and setter
deltaBuilder.updateDelta(typeHierarchy, objectsInHeap.get(rn), getDecl(model, ClassDecl.class, new DeclNamePredicate<ClassDecl>(concreteTypeName)));
}
use of abs.frontend.ast.Call 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;
}
Aggregations