Search in sources :

Example 1 with Call

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;
}
Also used : Call(abs.frontend.ast.Call) AsyncCall(abs.frontend.ast.AsyncCall) SyncCall(abs.frontend.ast.SyncCall) SyncCall(abs.frontend.ast.SyncCall) AsyncCall(abs.frontend.ast.AsyncCall)

Example 2 with 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)));
}
Also used : Call(abs.frontend.ast.Call) AbsASTBuilderUtil.getCall(abs.backend.tests.AbsASTBuilderUtil.getCall) PreviousCall(apet.testCases.PreviousCall) DeclNamePredicate(abs.backend.tests.AbsASTBuilderUtil.DeclNamePredicate) ArrayList(java.util.ArrayList) PureExp(abs.frontend.ast.PureExp) VarUse(abs.frontend.ast.VarUse) AbsASTBuilderUtil.getExpStmt(abs.backend.tests.AbsASTBuilderUtil.getExpStmt) Stmt(abs.frontend.ast.Stmt) ClassDecl(abs.frontend.ast.ClassDecl) ParamDecl(abs.frontend.ast.ParamDecl) ABSData(apet.testCases.ABSData)

Example 3 with Call

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;
}
Also used : Call(abs.frontend.ast.Call) PreviousCall(apet.testCases.PreviousCall) AbsASTBuilderUtil.getCall(abs.backend.tests.AbsASTBuilderUtil.getCall) ABSRef(apet.testCases.ABSRef) ABSData(apet.testCases.ABSData) PureExp(abs.frontend.ast.PureExp) VarUse(abs.frontend.ast.VarUse)

Aggregations

Call (abs.frontend.ast.Call)3 AbsASTBuilderUtil.getCall (abs.backend.tests.AbsASTBuilderUtil.getCall)2 PureExp (abs.frontend.ast.PureExp)2 VarUse (abs.frontend.ast.VarUse)2 ABSData (apet.testCases.ABSData)2 PreviousCall (apet.testCases.PreviousCall)2 DeclNamePredicate (abs.backend.tests.AbsASTBuilderUtil.DeclNamePredicate)1 AbsASTBuilderUtil.getExpStmt (abs.backend.tests.AbsASTBuilderUtil.getExpStmt)1 AsyncCall (abs.frontend.ast.AsyncCall)1 ClassDecl (abs.frontend.ast.ClassDecl)1 ParamDecl (abs.frontend.ast.ParamDecl)1 Stmt (abs.frontend.ast.Stmt)1 SyncCall (abs.frontend.ast.SyncCall)1 ABSRef (apet.testCases.ABSRef)1 ArrayList (java.util.ArrayList)1