Search in sources :

Example 1 with VarDecl

use of org.abs_models.frontend.ast.VarDecl in project abstools by abstools.

the class VarResolutionTest method testLocalVar.

@Test
public void testLocalVar() {
    Exp e = getSecondExp("interface I { } { I i = null; i = i; }");
    VarUse u = (VarUse) e;
    VarDecl decl = (VarDecl) u.getDecl();
    assertEquals("i", decl.getName());
}
Also used : PatternVarDecl(org.abs_models.frontend.ast.PatternVarDecl) VarDecl(org.abs_models.frontend.ast.VarDecl) NegExp(org.abs_models.frontend.ast.NegExp) Exp(org.abs_models.frontend.ast.Exp) LetExp(org.abs_models.frontend.ast.LetExp) VarUse(org.abs_models.frontend.ast.VarUse) FrontendTest(org.abs_models.frontend.FrontendTest) Test(org.junit.Test)

Example 2 with VarDecl

use of org.abs_models.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(org.abs_models.frontend.ast.TypedVarOrFieldDecl) VarOrFieldDecl(org.abs_models.frontend.ast.VarOrFieldDecl) VarDecl(org.abs_models.frontend.ast.VarDecl) ParamDecl(org.abs_models.frontend.ast.ParamDecl) LetExp(org.abs_models.frontend.ast.LetExp) VarUse(org.abs_models.frontend.ast.VarUse)

Aggregations

LetExp (org.abs_models.frontend.ast.LetExp)2 VarDecl (org.abs_models.frontend.ast.VarDecl)2 VarUse (org.abs_models.frontend.ast.VarUse)2 FrontendTest (org.abs_models.frontend.FrontendTest)1 Exp (org.abs_models.frontend.ast.Exp)1 NegExp (org.abs_models.frontend.ast.NegExp)1 ParamDecl (org.abs_models.frontend.ast.ParamDecl)1 PatternVarDecl (org.abs_models.frontend.ast.PatternVarDecl)1 TypedVarOrFieldDecl (org.abs_models.frontend.ast.TypedVarOrFieldDecl)1 VarOrFieldDecl (org.abs_models.frontend.ast.VarOrFieldDecl)1 Test (org.junit.Test)1