Search in sources :

Example 1 with PureExp

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

the class JavaGeneratorHelper method generateAwaitAsyncCall.

public static void generateAwaitAsyncCall(PrintStream stream, AwaitAsyncCall call) {
    final PureExp callee = call.getCallee();
    final List<PureExp> params = call.getParams();
    final MethodSig sig = call.getMethodSig();
    final List<Annotation> annotations = call.getAnnotations();
    // FIXME: implement await, assignment afterwards
    // OutputStream exprOStream = new ByteArrayOutputStream();
    // PrintStream exprStream = new PrintStream(exprOStream);
    // ClaimGuard guard = new ClaimGuard();
    // // Necessary temporary variables are written to "stream" and the
    // // await-expression is written to exprStream
    // 
    // // FIXME: implement await, assignment afterwards
    // guard.generateJavaGuard(stream, exprStream);
    // stream.print(JavaBackendConstants.ABSRUNTIME + ".await(");
    // stream.print(exprOStream.toString());
    // stream.println(");");
    generateAsyncCall(stream, null, callee, callee.getType(), params, null, sig, annotations);
}
Also used : MethodSig(org.abs_models.frontend.ast.MethodSig) PureExp(org.abs_models.frontend.ast.PureExp) Annotation(org.abs_models.frontend.ast.Annotation)

Example 2 with PureExp

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

the class JavaGeneratorHelper method generateArgs.

public static void generateArgs(PrintStream stream, String firstArg, List<PureExp> args, java.util.List<Type> types) {
    stream.print("(");
    boolean first = true;
    if (firstArg != null) {
        stream.print(firstArg);
        first = false;
    }
    for (int i = 0; i < args.getNumChild(); i++) {
        PureExp e = args.getChild(i);
        if (!first)
            stream.print(", ");
        e.generateJava(stream);
        if (types.get(i).isIntType() && e.getType().isRatType())
            stream.print(".truncate()");
        first = false;
    }
    stream.print(")");
}
Also used : PureExp(org.abs_models.frontend.ast.PureExp)

Example 3 with PureExp

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

the class JavaGeneratorHelper method generateExprGuard.

public static void generateExprGuard(ExpGuard expGuard, PrintStream beforeAwaitStream, PrintStream stream) {
    PureExp expr = expGuard.getPureExp();
    replaceLocalVariables((PureExp) expr.copy(), beforeAwaitStream);
    stream.print("new " + JavaBackendConstants.EXPGUARD + "() { public " + ABSBool.class.getName() + " evaluateExp() { return ");
    expGuard.getPureExp().generateJava(stream);
    stream.print("; }}");
}
Also used : ABSBool(org.abs_models.backend.java.lib.types.ABSBool) PureExp(org.abs_models.frontend.ast.PureExp)

Example 4 with PureExp

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

the class TreeUtilsTest method findChildrenListLazy.

@Test
public void findChildrenListLazy() {
    Model model = assertParse("def Int test(Int i) = test(1);");
    FunctionDecl functionDecl = getLastFunctionDecl(model);
    assertEquals("test", functionDecl.getName());
    List<PureExp> children = functionDecl.getFunctionDef().findChildren(PureExp.class, true);
    assertEquals(1, children.size());
    assertTrue(children.get(0) instanceof FnApp);
}
Also used : FnApp(org.abs_models.frontend.ast.FnApp) Model(org.abs_models.frontend.ast.Model) PureExp(org.abs_models.frontend.ast.PureExp) FunctionDecl(org.abs_models.frontend.ast.FunctionDecl) FrontendTest(org.abs_models.frontend.FrontendTest) Test(org.junit.Test)

Example 5 with PureExp

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

the class TreeUtilsTest method findChildrenList.

@Test
public void findChildrenList() {
    Model model = assertParse("def Int test(Int i) = test(1);");
    FunctionDecl functionDecl = getLastFunctionDecl(model);
    assertEquals("test", functionDecl.getName());
    List<PureExp> children = functionDecl.getFunctionDef().findChildren(PureExp.class);
    assertEquals(2, children.size());
}
Also used : Model(org.abs_models.frontend.ast.Model) 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