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;
}
Aggregations