Search in sources :

Example 1 with Catch1

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

the class Desugar method liftKs.

protected List<Catch> liftKs(List<Catch> ks) {
    List<Catch> result = new ArrayList<>();
    String x = Functions.freshName("catched", usedVars);
    for (Catch k : ks) {
        if (k instanceof DesugarCatchDefault.CatchToComplete) {
            Catch k2 = this.liftK(((DesugarCatchDefault.CatchToComplete) k).catch1);
            result.add(new DesugarCatchDefault.CatchToComplete((Catch1) k2));
            continue;
        }
        k.match(k1 -> result.add(liftK(k1)), kM -> {
            for (Type t : kM.getTs()) {
                result.add(liftK(new Expression.Catch1(kM.getP(), kM.getKind(), t, x, kM.getInner())));
            }
            return false;
        }, kP -> {
            for (Type t : kP.getTs()) {
                Expression inner = kP.getInner();
                inner = new Expression.FCall(kP.getP(), inner, Doc.empty(), new ast.Ast.Parameters(Optional.of(new X(kP.getP(), x)), Collections.emptyList(), Collections.emptyList()));
                inner = new Expression.Signal(kP.getKind(), inner);
                result.add(liftK(new Expression.Catch1(kP.getP(), SignalKind.Exception, t, x, inner)));
            }
            return false;
        });
    }
    return result;
}
Also used : Parameters(ast.Ast.Parameters) Catch(ast.Expression.Catch) ArrayList(java.util.ArrayList) Type(ast.Ast.Type) MethodWithType(ast.Expression.ClassB.MethodWithType) MethodType(ast.Ast.MethodType) Expression(ast.Expression) Catch1(ast.Expression.Catch1) FCall(ast.Expression.FCall) X(ast.Expression.X) MethodSelectorX(ast.Ast.MethodSelectorX)

Aggregations

MethodSelectorX (ast.Ast.MethodSelectorX)1 MethodType (ast.Ast.MethodType)1 Parameters (ast.Ast.Parameters)1 Type (ast.Ast.Type)1 Expression (ast.Expression)1 Catch (ast.Expression.Catch)1 Catch1 (ast.Expression.Catch1)1 MethodWithType (ast.Expression.ClassB.MethodWithType)1 FCall (ast.Expression.FCall)1 X (ast.Expression.X)1 ArrayList (java.util.ArrayList)1