Search in sources :

Example 1 with VarDecl

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

the class JavaGeneratorHelper method isLocalVarUse.

/**
 * checks if astNode is a use of a local variable or parameter
 */
private static boolean isLocalVarUse(ASTNode<?> astNode) {
    if (astNode instanceof VarUse) {
        VarUse v = (VarUse) astNode;
        VarOrFieldDecl decl = v.getDecl();
        if (decl instanceof VarDecl || decl instanceof ParamDecl) {
            return !(decl.getParent() instanceof LetExp);
        }
    }
    return false;
}
Also used : TypedVarOrFieldDecl(abs.frontend.ast.TypedVarOrFieldDecl) VarOrFieldDecl(abs.frontend.ast.VarOrFieldDecl) VarDecl(abs.frontend.ast.VarDecl) ParamDecl(abs.frontend.ast.ParamDecl) LetExp(abs.frontend.ast.LetExp) VarUse(abs.frontend.ast.VarUse)

Example 2 with VarDecl

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

Aggregations

VarDecl (abs.frontend.ast.VarDecl)2 ClassDecl (abs.frontend.ast.ClassDecl)1 Decl (abs.frontend.ast.Decl)1 FieldDecl (abs.frontend.ast.FieldDecl)1 InterfaceDecl (abs.frontend.ast.InterfaceDecl)1 InterfaceTypeUse (abs.frontend.ast.InterfaceTypeUse)1 LetExp (abs.frontend.ast.LetExp)1 ParamDecl (abs.frontend.ast.ParamDecl)1 TypedVarOrFieldDecl (abs.frontend.ast.TypedVarOrFieldDecl)1 VarOrFieldDecl (abs.frontend.ast.VarOrFieldDecl)1 VarUse (abs.frontend.ast.VarUse)1