Search in sources :

Example 71 with ClassDecl

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

the class InferMain method shouldBeConsidered.

private boolean shouldBeConsidered(LocationTypeVariable ltv) {
    ASTNode<?> node = ltv.getNode();
    Decl contextDecl = node.getContextDecl();
    if (contextDecl != null) {
        // Don't print interface annotations in "implements/extends" clauses:
        if (node instanceof InterfaceTypeUse && (contextDecl instanceof ClassDecl || contextDecl instanceof InterfaceDecl))
            return false;
        if (contextDecl.isClass() && !config.contains(Config.CLASSES))
            return false;
        if (contextDecl.isInterface() && !config.contains(Config.INTERFACES))
            return false;
        if (contextDecl.isFunction() && !config.contains(Config.FUNCTIONS))
            return false;
    }
    if (node instanceof VarDecl && !config.contains(Config.LOCAL_VAR_DECLS))
        return false;
    if (node instanceof FieldDecl && !config.contains(Config.FIELDS))
        return false;
    if (ltv.getAnnotatedType() != null) {
        return false;
    }
    return true;
}
Also used : FieldDecl(abs.frontend.ast.FieldDecl) ClassDecl(abs.frontend.ast.ClassDecl) VarDecl(abs.frontend.ast.VarDecl) InterfaceTypeUse(abs.frontend.ast.InterfaceTypeUse) InterfaceDecl(abs.frontend.ast.InterfaceDecl) ClassDecl(abs.frontend.ast.ClassDecl) FieldDecl(abs.frontend.ast.FieldDecl) VarDecl(abs.frontend.ast.VarDecl) Decl(abs.frontend.ast.Decl) InterfaceDecl(abs.frontend.ast.InterfaceDecl)

Example 72 with ClassDecl

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

the class LocationTypeInferrerExtension method getFarTypes.

private List<LocationType> getFarTypes(ASTNode<?> originatingNode) {
    HasCogs node = null;
    String prefix = "";
    if (precision == LocationTypingPrecision.GLOBAL_FAR) {
        node = originatingNode.getCompilationUnit().getModel();
        prefix = "G";
    }
    if (precision == LocationTypingPrecision.COMPILATION_UNIT_LOCAL_FAR) {
        node = originatingNode.getCompilationUnit();
        prefix = "U";
    }
    if (precision == LocationTypingPrecision.MODULE_LOCAL_FAR) {
        node = originatingNode.getModuleDecl();
        prefix = "M";
    }
    if (precision == LocationTypingPrecision.CLASS_LOCAL_FAR) {
        Decl d = originatingNode.getContextDecl();
        if (d instanceof ClassDecl) {
            node = d;
            prefix = "C";
        }
        Block b = originatingNode.getContextBlock();
        if (b instanceof MainBlock) {
            node = b;
            prefix = "C";
        }
    }
    if (precision == LocationTypingPrecision.METHOD_LOCAL_FAR) {
        Block b = originatingNode.getContextBlock();
        if (b != null) {
            node = b;
            prefix = "M";
        }
    }
    if (node == null) {
        return Collections.emptyList();
    }
    final List<LocationType> e = farTypes.get(node);
    if (e != null) {
        return e;
    } else {
        List<LocationType> result = new ArrayList<>();
        int numberOfNewCogs = node.getNumberOfNewCogExpr();
        if (numberOfNewCogs > THRESHOLD) {
            numberOfNewCogs = THRESHOLD;
        }
        for (int i = 0; i < numberOfNewCogs; i++) {
            result.add(LocationType.createParametricFar(prefix + i));
        }
        farTypes.put(node, result);
        return result;
    }
}
Also used : ClassDecl(abs.frontend.ast.ClassDecl) HasCogs(abs.frontend.analyser.HasCogs) Block(abs.frontend.ast.Block) MainBlock(abs.frontend.ast.MainBlock) ClassDecl(abs.frontend.ast.ClassDecl) Decl(abs.frontend.ast.Decl) MainBlock(abs.frontend.ast.MainBlock) LocationType(abs.frontend.typechecker.locationtypes.LocationType)

Example 73 with ClassDecl

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

the class ReachabilityInformation method isReachable.

/**
 * checks if the method is reachable. It looks at the class name
 * and all the interface names that are directly or indirectly
 * implemented by the method's class
 * @param method
 * @return true if method is reachable, false otherwise
 */
public boolean isReachable(MethodImpl method) {
    ClassDecl clazz = obtainOwnerClass(method);
    boolean reachable = false;
    if (clazz != null) {
        abs.frontend.ast.List<InterfaceTypeUse> interfaces = clazz.getImplementedInterfaceUseList();
        Iterator<InterfaceTypeUse> it = interfaces.iterator();
        // checks if the method is reachable with its class name
        reachable = reachableMethods.contains(getMethodId(clazz, method.getMethodSig()));
        // implemented by its class
        while (!reachable && it.hasNext()) reachable = isReachable(it.next(), method.getMethodSig());
        return reachable;
    } else
        return false;
}
Also used : ClassDecl(abs.frontend.ast.ClassDecl) InterfaceTypeUse(abs.frontend.ast.InterfaceTypeUse)

Example 74 with ClassDecl

use of abs.frontend.ast.ClassDecl 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 75 with ClassDecl

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

the class ASTBasedABSTestRunnerGenerator method generateImportsAST.

private List<Import> generateImportsAST() {
    List<Import> imports = new List<>();
    Set<String> mn = new HashSet<>();
    Set<String> qn = new HashSet<>();
    for (InterfaceDecl key : tests.keySet()) {
        getImportsFrom(mn, qn, key.getModuleDecl());
        for (ClassDecl clazz : tests.get(key)) {
            getImportsFrom(mn, qn, clazz.getModuleDecl());
        }
    }
    for (String m : mn) {
        imports.add(new StarImport(m));
    }
    if (!qn.isEmpty()) {
        List<Name> names = new List<>();
        for (String q : qn) {
            names.add(new Name(q));
        }
        imports.add(new NamedImport(names));
    }
    return imports;
}
Also used : NamedImport(abs.frontend.ast.NamedImport) StarImport(abs.frontend.ast.StarImport) FromImport(abs.frontend.ast.FromImport) Import(abs.frontend.ast.Import) ClassDecl(abs.frontend.ast.ClassDecl) StarImport(abs.frontend.ast.StarImport) List(abs.frontend.ast.List) InterfaceDecl(abs.frontend.ast.InterfaceDecl) HashSet(java.util.HashSet) Name(abs.frontend.ast.Name) NamedImport(abs.frontend.ast.NamedImport)

Aggregations

ClassDecl (abs.frontend.ast.ClassDecl)75 Test (org.junit.Test)59 Model (abs.frontend.ast.Model)57 DeltaDecl (abs.frontend.ast.DeltaDecl)22 FrontendTest (abs.frontend.FrontendTest)12 ModifyClassModifier (abs.frontend.ast.ModifyClassModifier)12 SkipStmt (abs.frontend.ast.SkipStmt)11 DeltaTraitModifier (abs.frontend.ast.DeltaTraitModifier)7 InterfaceDecl (abs.frontend.ast.InterfaceDecl)7 MethodImpl (abs.frontend.ast.MethodImpl)7 ModifyMethodModifier (abs.frontend.ast.ModifyMethodModifier)7 TraitExpr (abs.frontend.ast.TraitExpr)7 MethodSig (abs.frontend.ast.MethodSig)6 ReturnStmt (abs.frontend.ast.ReturnStmt)6 AddMethodModifier (abs.frontend.ast.AddMethodModifier)5 Decl (abs.frontend.ast.Decl)5 DeltaAccess (abs.frontend.ast.DeltaAccess)5 List (abs.frontend.ast.List)5 TraitSetExpr (abs.frontend.ast.TraitSetExpr)5 CompilationUnit (abs.frontend.ast.CompilationUnit)4