Search in sources :

Example 16 with Decl

use of abs.frontend.ast.Decl 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 17 with Decl

use of abs.frontend.ast.Decl 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)

Aggregations

Decl (abs.frontend.ast.Decl)17 ClassDecl (abs.frontend.ast.ClassDecl)9 InterfaceDecl (abs.frontend.ast.InterfaceDecl)8 ModuleDecl (abs.frontend.ast.ModuleDecl)7 DataTypeDecl (abs.frontend.ast.DataTypeDecl)6 ParametricDataTypeDecl (abs.frontend.ast.ParametricDataTypeDecl)6 TypeSynDecl (abs.frontend.ast.TypeSynDecl)6 Test (org.junit.Test)6 FunctionDecl (abs.frontend.ast.FunctionDecl)5 Model (abs.frontend.ast.Model)4 AbsASTBuilderUtil.getDecl (abs.backend.tests.AbsASTBuilderUtil.getDecl)3 DeltaDecl (abs.frontend.ast.DeltaDecl)3 TypeParameterDecl (abs.frontend.ast.TypeParameterDecl)3 List (abs.frontend.ast.List)2 MainBlock (abs.frontend.ast.MainBlock)2 HasCogs (abs.frontend.analyser.HasCogs)1 Annotation (abs.frontend.ast.Annotation)1 Block (abs.frontend.ast.Block)1 CompilationUnit (abs.frontend.ast.CompilationUnit)1 DataTypeUse (abs.frontend.ast.DataTypeUse)1