use of ast.Expression in project L42 by ElvisResearchGroup.
the class DesugarW method with_C_A.
private Expression with_C_A(Position pos, List<String> xs, With.On on0, Expression continuation) {
List<String> ys = new ArrayList<String>();
for (String x : xs) {
ys.add(Functions.freshName(x, usedVars));
}
//(
List<VarDec> decs = new ArrayList<>();
//TODO:?? now is very strange and requires the mdf to propagate it to the locally introduced var?
//casts: every cast is a block content e+catch
{
int i = -1;
for (Type ti : on0.getTs()) {
i += 1;
String xi = xs.get(i);
String yi = ys.get(i);
decs.add(castT(pos, ti, yi, xi));
}
}
//catch exception Void recursive call
Catch k = Desugar.getK(pos, SignalKind.Exception, "", Type.immVoid, continuation);
//main expression with 'T' renaming
Expression e0 = on0.getInner();
{
int i = -1;
for (Type ti : on0.getTs()) {
i += 1;
String xi = xs.get(i);
String yi = ys.get(i);
e0 = renameT(e0, new Expression.X(pos, xi), ti, new Expression.X(pos, yi));
}
}
BlockContent content = new BlockContent(decs, Collections.singletonList(k));
List<BlockContent> contents = new ArrayList<BlockContent>();
contents.add(content);
contents.add(Desugar.getBlockContent(e0));
//void)
return new RoundBlock(pos, Doc.empty(), Expression._void.instance, contents);
}
use of ast.Expression in project L42 by ElvisResearchGroup.
the class DesugarW method withE1CatchExceptionOnVoidE2elseE3.
private static RoundBlock withE1CatchExceptionOnVoidE2elseE3(Position pos, Expression e1, Expression e2, Expression e3) {
Expression.Catch k = Desugar.getK(pos, SignalKind.Exception, "", Type.immVoid, e2);
List<Expression.BlockContent> cs = new ArrayList<>();
cs.add(Desugar.getBlockContent(e1, k));
return new RoundBlock(pos, Doc.empty(), e3, cs);
}
use of ast.Expression in project L42 by ElvisResearchGroup.
the class Desugar method visit.
public Expression visit(If s) {
if (!s.get_else().isPresent()) {
return visit(s.with_else(Optional.of(Expression._void.instance)));
}
Position p = s.getP();
if (!(s.getCond() instanceof Ast.Atom)) {
String x = Functions.freshName("cond", usedVars);
return visit(getBlock(p, x, s.getCond(), s.withCond(new X(p, x))));
}
MCall check = getMCall(p, s.getCond(), "#checkTrue", getPs());
Expression.Catch k = getK(p, SignalKind.Exception, "", Type.immVoid, s.get_else().get());
return visit(getBlock(p, check, Collections.singletonList(k), s.getThen()));
}
use of ast.Expression in project L42 by ElvisResearchGroup.
the class Desugar method getBlock.
static RoundBlock getBlock(Position p, Expression xe, Expression inner) {
List<Expression.BlockContent> bc = new ArrayList<>();
List<VarDec> decs = new ArrayList<VarDec>();
decs.add(new VarDecE(xe));
bc.add(new Expression.BlockContent(decs, Collections.emptyList()));
return new RoundBlock(p, Doc.empty(), inner, bc);
}
use of ast.Expression in project L42 by ElvisResearchGroup.
the class PlgWrapperGenerator method parseAndDesugar.
private static ExpCore parseAndDesugar(String s) {
Expression code1 = Parser.parse("PlgWrapperGenerator", s);
Expression code2 = Desugar.of(code1);
return code2.accept(new InjectionOnCore());
}
Aggregations