Search in sources :

Example 1 with ABSTerm

use of apet.testCases.ABSTerm in project abstools by abstools.

the class ABSUnitTestCaseBuilder method getTypesFromABSData.

Map<String, InterfaceTypeUse> getTypesFromABSData(String testName, ABSData data) {
    Map<String, InterfaceTypeUse> map = new HashMap<String, InterfaceTypeUse>();
    if (data instanceof ABSRef) {
        String type = getABSDataType(data);
        String value = getABSDataValue(data);
        if (!value.equals(NULL)) {
            map.put(heapRefBuilder.heapReferenceForTest(testName, value), new InterfaceTypeUse(type, new abs.frontend.ast.List<abs.frontend.ast.Annotation>()));
        }
    } else if (data instanceof ABSTerm) {
        ABSTerm term = (ABSTerm) data;
        for (ABSData t : getABSTermArgs(term)) {
            map.putAll(getTypesFromABSData(testName, t));
        }
    }
    return map;
}
Also used : ABSTerm(apet.testCases.ABSTerm) HashMap(java.util.HashMap) ABSRef(apet.testCases.ABSRef) InterfaceTypeUse(abs.frontend.ast.InterfaceTypeUse) List(java.util.List) ArrayList(java.util.ArrayList) ABSData(apet.testCases.ABSData)

Example 2 with ABSTerm

use of apet.testCases.ABSTerm in project abstools by abstools.

the class PureExpressionBuilder method createPureExpression.

/**
 * @param currentHeapReference
 * @param initialisationsOrders
 * @param heapNames
 * @param dataValue
 * @return
 */
PureExp createPureExpression(String currentHeapReference, List<String> initialisationsOrders, String testName, Set<String> heapNames, ABSData dataValue) {
    String type = getABSDataType(dataValue);
    String value = getABSDataValue(dataValue);
    if (type.contains("(") && dataValue instanceof ABSTerm) {
        ABSTerm term = (ABSTerm) dataValue;
        type = getABSTermTypeName(term);
    }
    // import type
    Decl decl = getDecl(model, Decl.class, namePred(type));
    importType(decl);
    if (dataValue instanceof ABSTerm) {
        ABSTerm term = (ABSTerm) dataValue;
        return makeDataTermValue(currentHeapReference, initialisationsOrders, testName, heapNames, term, decl);
    } else if (dataValue instanceof ABSRef) {
        if (heapNames.contains(value)) {
            String ref = heapRefBuilder.heapReferenceForTest(testName, value);
            if (currentHeapReference != null) {
                // we need to consider initialisation order!
                updateInitialisationOrder(initialisationsOrders, currentHeapReference, ref);
            }
            return new VarUse(ref);
        } else {
            return new NullExp();
        }
    } else {
        throw new IllegalStateException("Cannot handle ABSData that is not " + "either a ABSRef or a ABSTerm");
    }
}
Also used : ABSTerm(apet.testCases.ABSTerm) ABSRef(apet.testCases.ABSRef) NullExp(abs.frontend.ast.NullExp) AbsASTBuilderUtil.getDecl(abs.backend.tests.AbsASTBuilderUtil.getDecl) DataTypeDecl(abs.frontend.ast.DataTypeDecl) InterfaceDecl(abs.frontend.ast.InterfaceDecl) Decl(abs.frontend.ast.Decl) TypeParameterDecl(abs.frontend.ast.TypeParameterDecl) TypeSynDecl(abs.frontend.ast.TypeSynDecl) ParametricDataTypeDecl(abs.frontend.ast.ParametricDataTypeDecl) VarUse(abs.frontend.ast.VarUse)

Aggregations

ABSRef (apet.testCases.ABSRef)2 ABSTerm (apet.testCases.ABSTerm)2 AbsASTBuilderUtil.getDecl (abs.backend.tests.AbsASTBuilderUtil.getDecl)1 DataTypeDecl (abs.frontend.ast.DataTypeDecl)1 Decl (abs.frontend.ast.Decl)1 InterfaceDecl (abs.frontend.ast.InterfaceDecl)1 InterfaceTypeUse (abs.frontend.ast.InterfaceTypeUse)1 NullExp (abs.frontend.ast.NullExp)1 ParametricDataTypeDecl (abs.frontend.ast.ParametricDataTypeDecl)1 TypeParameterDecl (abs.frontend.ast.TypeParameterDecl)1 TypeSynDecl (abs.frontend.ast.TypeSynDecl)1 VarUse (abs.frontend.ast.VarUse)1 ABSData (apet.testCases.ABSData)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1