use of ast.Expression.Signal in project L42 by ElvisResearchGroup.
the class DesugarW method castT.
private VarDecXE castT(Position pos, Type t, String y, String x) {
assert t instanceof Type;
Type nt = t;
String z = Functions.freshName("casted", usedVars);
List<Catch> ks = new ArrayList<>();
Type t2 = new Type(nt.getMdf(), Path.Any(), Doc.empty());
ks.add(new //case return captured
Expression.Catch1(//case return captured
pos, //case return captured
SignalKind.Return, //case return captured
t, //case return captured
z, //return it
new X(pos, z)));
ks.add(new //else
Expression.Catch1(//else
pos, //else
SignalKind.Return, //else
t2, //else
z, // exception void
new Signal(SignalKind.Exception, Expression._void.instance)));
RoundBlock block = Desugar.getBlock(pos, new Signal(SignalKind.Return, new X(pos, x)), ks, Desugar.errorMsg("CastT-Should be unreachable code"));
return new VarDecXE(false, Optional.of(t), y, block);
}
use of ast.Expression.Signal in project L42 by ElvisResearchGroup.
the class DesugarW method withDesugarGetDefaultCatch.
private Catch withDesugarGetDefaultCatch(Position pos, SignalKind kind, Expression eClose) {
String propagated1 = Functions.freshName("propagated", usedVars);
Expression blockPropagate1 = Desugar.getBlock(pos, eClose, new Signal(kind, new X(pos, propagated1)));
Type t = Type.immAny;
Expression.Catch1 k1 = new Expression.Catch1(pos, kind, t, propagated1, blockPropagate1);
return new DesugarCatchDefault.CatchToComplete(k1);
}
use of ast.Expression.Signal in project L42 by ElvisResearchGroup.
the class DesugarW method withNext.
private static Expression.BlockContent withNext(Position pos, int index, List<String> xs) {
Expression eStart = Desugar.getMCall(pos, new X(pos, xs.get(index)), "#next", Desugar.getPs());
List<VarDec> decs = new ArrayList<>();
for (String x : xs.subList(index + 1, xs.size())) {
Expression ei = Desugar.getMCall(pos, new X(pos, x), "#next", Desugar.getPs());
ei = withE1CatchExceptionOnVoidE2elseE3(pos, ei, Expression._void.instance, Expression._void.instance);
decs.add(new VarDecE(ei));
}
for (String x : xs) {
Expression ei = Desugar.getMCall(pos, new X(pos, x), "#checkEnd", Desugar.getPs());
ei = withE1CatchExceptionOnVoidE2elseE3(pos, ei, Expression._void.instance, Expression._void.instance);
decs.add(new VarDecE(ei));
}
Expression eCatch = Desugar.getBlock(pos, decs, new Signal(SignalKind.Exception, Expression._void.instance));
Expression.Catch k = Desugar.getK(pos, SignalKind.Exception, "", Type.immVoid, eCatch);
return Desugar.getBlockContent(eStart, k);
}
Aggregations