Search in sources :

Example 21 with PureExp

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

the class SchedulerChecker method checkClassDecl.

@Override
public void checkClassDecl(ClassDecl decl) {
    PureExp sched = AnnotationHelper.getAnnotationValueFromName(decl.getAnnotations(), "ABS.Scheduler.Scheduler");
    checkScheduleExp(sched, decl, decl);
}
Also used : PureExp(org.abs_models.frontend.ast.PureExp)

Example 22 with PureExp

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

the class TreeUtilsTest method recurseForSome.

@Test
public void recurseForSome() {
    Model model = assertParse("def Int test(Int i) = 1 + test(2);");
    FunctionDecl functionDecl = getLastFunctionDecl(model);
    assertEquals("test", functionDecl.getName());
    FunctionDef def = functionDecl.getFunctionDef();
    Stream<PureExp> children = def.findChildren(cast(PureExp.class), AddExp.class::isInstance);
    assertNotNull(children);
    List<PureExp> result = children.distinct().collect(Collectors.toList());
    // expecting AddExp, IntLiteral(1), FnApp, NOT IntLiteral(2)
    assertEquals(3, result.size());
    for (PureExp exp : result) {
        assertFalse(exp instanceof IntLiteral && ((IntLiteral) exp).getContent().equals("2"));
    }
}
Also used : AddExp(org.abs_models.frontend.ast.AddExp) Model(org.abs_models.frontend.ast.Model) ExpFunctionDef(org.abs_models.frontend.ast.ExpFunctionDef) FunctionDef(org.abs_models.frontend.ast.FunctionDef) IntLiteral(org.abs_models.frontend.ast.IntLiteral) PureExp(org.abs_models.frontend.ast.PureExp) FunctionDecl(org.abs_models.frontend.ast.FunctionDecl) FrontendTest(org.abs_models.frontend.FrontendTest) Test(org.junit.Test)

Aggregations

PureExp (org.abs_models.frontend.ast.PureExp)22 FunctionDecl (org.abs_models.frontend.ast.FunctionDecl)8 FrontendTest (org.abs_models.frontend.FrontendTest)7 Model (org.abs_models.frontend.ast.Model)7 Test (org.junit.Test)7 ExpFunctionDef (org.abs_models.frontend.ast.ExpFunctionDef)5 FnApp (org.abs_models.frontend.ast.FnApp)5 IntLiteral (org.abs_models.frontend.ast.IntLiteral)5 Annotation (org.abs_models.frontend.ast.Annotation)4 Type (org.abs_models.frontend.typechecker.Type)3 ABSBool (org.abs_models.backend.java.lib.types.ABSBool)2 TypeError (org.abs_models.frontend.analyser.TypeError)2 FunctionDef (org.abs_models.frontend.ast.FunctionDef)2 List (org.abs_models.frontend.ast.List)2 MethodSig (org.abs_models.frontend.ast.MethodSig)2 TypedAnnotation (org.abs_models.frontend.ast.TypedAnnotation)2 VarUse (org.abs_models.frontend.ast.VarUse)2 AddExp (org.abs_models.frontend.ast.AddExp)1 AsyncCall (org.abs_models.frontend.ast.AsyncCall)1 ClassDecl (org.abs_models.frontend.ast.ClassDecl)1