Search in sources :

Example 1 with Loop

use of ast.Expression.Loop in project L42 by ElvisResearchGroup.

the class Desugar method visit.

public Expression visit(While s) {
    Expression cond = Desugar.getMCall(s.getP(), s.getCond(), "#checkTrue", Desugar.getPs());
    RoundBlock b = Desugar.getBlock(s.getP(), cond, s.getThen());
    Loop l = new Loop(b);
    Type _void = Type.immVoid;
    Expression.Catch k = Desugar.getK(s.getP(), SignalKind.Exception, "", _void, Expression._void.instance);
    RoundBlock b2 = Desugar.getBlock(s.getP(), l, Collections.singletonList(k), Expression._void.instance);
    return b2.accept(this);
}
Also used : Loop(ast.Expression.Loop) Type(ast.Ast.Type) MethodWithType(ast.Expression.ClassB.MethodWithType) MethodType(ast.Ast.MethodType) Expression(ast.Expression) RoundBlock(ast.Expression.RoundBlock) Catch(ast.Expression.Catch)

Example 2 with Loop

use of ast.Expression.Loop in project L42 by ElvisResearchGroup.

the class DesugarW method with_E_handleIs.

private Expression with_E_handleIs(Position pos, List<VarDecXE> is, Expression b) {
    //case e in 6 pages
    //xs is dom(Is)
    List<String> xs = new ArrayList<>();
    for (VarDecXE i : is) {
        xs.add(i.getX());
    }
    //di ki is block content =nexti(xs)
    List<BlockContent> bc = new ArrayList<>();
    for (int i = 0; i < xs.size(); i++) {
        bc.add(withNext(pos, i, xs));
    }
    //inner =di ki s b[xs:=xs.#inner()]
    for (String xi : xs) {
        b = XInE.of(new X(pos, xi), Desugar.getMCall(pos, new X(pos, xi), "#inner", Desugar.getPs()), b);
    }
    RoundBlock inner = new RoundBlock(pos, Doc.empty(), b, bc);
    Catch k = Desugar.getK(pos, SignalKind.Exception, "", Type.immVoid, Expression._void.instance);
    inner = Desugar.getBlock(pos, new Loop(inner), Collections.singletonList(k), Expression._void.instance);
    Expression result = withDeclareIts(is, inner);
    //accept
    return result;
}
Also used : Loop(ast.Expression.Loop) Expression(ast.Expression) Catch(ast.Expression.Catch) ArrayList(java.util.ArrayList) BlockContent(ast.Expression.BlockContent) X(ast.Expression.X) RoundBlock(ast.Expression.RoundBlock) VarDecXE(ast.Ast.VarDecXE)

Aggregations

Expression (ast.Expression)2 Catch (ast.Expression.Catch)2 Loop (ast.Expression.Loop)2 RoundBlock (ast.Expression.RoundBlock)2 MethodType (ast.Ast.MethodType)1 Type (ast.Ast.Type)1 VarDecXE (ast.Ast.VarDecXE)1 BlockContent (ast.Expression.BlockContent)1 MethodWithType (ast.Expression.ClassB.MethodWithType)1 X (ast.Expression.X)1 ArrayList (java.util.ArrayList)1