Search in sources :

Example 1 with TypeUse

use of abs.frontend.ast.TypeUse in project abstools by abstools.

the class AbsASTBuilderUtil method generateImportAST.

public static final Set<Import> generateImportAST(TypeUse t) {
    Set<Import> imports = new HashSet<>();
    imports.add(generateImportAST(t.getName(), t.getModuleDecl().getName()));
    if (t instanceof ParametricDataTypeUse) {
        for (TypeUse st : ((ParametricDataTypeUse) t).getParams()) {
            imports.addAll(generateImportAST(st));
        }
    }
    return imports;
}
Also used : TypeUse(abs.frontend.ast.TypeUse) ParametricDataTypeUse(abs.frontend.ast.ParametricDataTypeUse) DataTypeUse(abs.frontend.ast.DataTypeUse) InterfaceTypeUse(abs.frontend.ast.InterfaceTypeUse) FromImport(abs.frontend.ast.FromImport) Import(abs.frontend.ast.Import) HashSet(java.util.HashSet) ParametricDataTypeUse(abs.frontend.ast.ParametricDataTypeUse)

Example 2 with TypeUse

use of abs.frontend.ast.TypeUse 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;
    }
}
Also used : TypeUse(abs.frontend.ast.TypeUse) ParametricDataTypeUse(abs.frontend.ast.ParametricDataTypeUse) DataTypeUse(abs.frontend.ast.DataTypeUse) InterfaceTypeUse(abs.frontend.ast.InterfaceTypeUse) ParametricDataTypeUse(abs.frontend.ast.ParametricDataTypeUse) DataTypeUse(abs.frontend.ast.DataTypeUse) ParametricDataTypeUse(abs.frontend.ast.ParametricDataTypeUse)

Example 3 with TypeUse

use of abs.frontend.ast.TypeUse in project abstools by abstools.

the class PureExpressionBuilder method resolveTypeSynonym.

/**
 * Resolve the type synonyms to its raw type (interface or data type)
 * @param d
 * @return
 */
Decl resolveTypeSynonym(TypeSynDecl d) {
    TypeUse use = d.getValue();
    Decl decl = getDecl(model, Decl.class, namePred(use.getName()));
    if (decl instanceof TypeSynDecl) {
        return resolveTypeSynonym((TypeSynDecl) decl);
    }
    return decl;
}
Also used : TypeUse(abs.frontend.ast.TypeUse) DataTypeUse(abs.frontend.ast.DataTypeUse) 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) TypeSynDecl(abs.frontend.ast.TypeSynDecl)

Example 4 with TypeUse

use of abs.frontend.ast.TypeUse in project abstools by abstools.

the class ASTBasedABSTestRunnerGenerator method generateMainBlockAST.

private MainBlock generateMainBlockAST(List<Import> list) {
    final MainBlock block = new MainBlock();
    DataConstructorExp empty = new DataConstructorExp("EmptySet", new List<>());
    VarDeclStmt futsStatement = getVarDecl(futs, getType("Set", getFutUnitType()), empty);
    block.addStmtNoTransform(futsStatement);
    VarDeclStmt futStatement = getVarDecl(fut, getFutUnitType(), null);
    block.addStmtNoTransform(futStatement);
    Set<TypeUse> use = new HashSet<>();
    for (InterfaceDecl key : tests.keySet()) {
        for (ClassDecl clazz : tests.get(key)) {
            use.addAll(generateTestClassImplAST(key, clazz, block));
        }
    }
    block.addStmtNoTransform(generateWaitSyncAST());
    return block;
}
Also used : DataConstructorExp(abs.frontend.ast.DataConstructorExp) TypeUse(abs.frontend.ast.TypeUse) ParametricDataTypeUse(abs.frontend.ast.ParametricDataTypeUse) DataTypeUse(abs.frontend.ast.DataTypeUse) ClassDecl(abs.frontend.ast.ClassDecl) VarDeclStmt(abs.frontend.ast.VarDeclStmt) InterfaceDecl(abs.frontend.ast.InterfaceDecl) MainBlock(abs.frontend.ast.MainBlock) HashSet(java.util.HashSet)

Example 5 with TypeUse

use of abs.frontend.ast.TypeUse 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;
}
Also used : MethodSig(abs.frontend.ast.MethodSig) TypeUse(abs.frontend.ast.TypeUse) ParametricDataTypeUse(abs.frontend.ast.ParametricDataTypeUse) DataTypeUse(abs.frontend.ast.DataTypeUse) WhileStmt(abs.frontend.ast.WhileStmt) ParametricDataTypeUse(abs.frontend.ast.ParametricDataTypeUse) DataTypeUse(abs.frontend.ast.DataTypeUse) Block(abs.frontend.ast.Block) MainBlock(abs.frontend.ast.MainBlock) VarUse(abs.frontend.ast.VarUse) HashSet(java.util.HashSet)

Aggregations

DataTypeUse (abs.frontend.ast.DataTypeUse)6 TypeUse (abs.frontend.ast.TypeUse)6 ParametricDataTypeUse (abs.frontend.ast.ParametricDataTypeUse)5 HashSet (java.util.HashSet)3 InterfaceDecl (abs.frontend.ast.InterfaceDecl)2 InterfaceTypeUse (abs.frontend.ast.InterfaceTypeUse)2 MainBlock (abs.frontend.ast.MainBlock)2 MethodSig (abs.frontend.ast.MethodSig)2 VarUse (abs.frontend.ast.VarUse)2 AbsASTBuilderUtil.getDecl (abs.backend.tests.AbsASTBuilderUtil.getDecl)1 Access (abs.frontend.ast.Access)1 Block (abs.frontend.ast.Block)1 ClassDecl (abs.frontend.ast.ClassDecl)1 DataConstructorExp (abs.frontend.ast.DataConstructorExp)1 DataTypeDecl (abs.frontend.ast.DataTypeDecl)1 Decl (abs.frontend.ast.Decl)1 FromImport (abs.frontend.ast.FromImport)1 Import (abs.frontend.ast.Import)1 ParametricDataTypeDecl (abs.frontend.ast.ParametricDataTypeDecl)1 SyncCall (abs.frontend.ast.SyncCall)1