use of ast.Expression.RoundBlock in project L42 by ElvisResearchGroup.
the class DesugarVars method visit.
public Expression visit(CurlyBlock s) {
Expression inner;
if (s.getContents().size() == 1 && s.getContents().get(0).get_catch().isEmpty() && s.getContents().get(0).getDecs().size() == 1 && s.getContents().get(0).getDecs().get(0) instanceof VarDecE) {
inner = ((VarDecE) s.getContents().get(0).getDecs().get(0)).getInner();
} else {
inner = new RoundBlock(s.getP(), s.getDoc(), Expression._void.instance, s.getContents());
}
inner = inner.accept(this);
List<VarDec> vd = Collections.singletonList((VarDec) new VarDecE(inner));
BlockContent o = new BlockContent(vd, Collections.emptyList());
return new CurlyBlock(s.getP(), Doc.empty(), Collections.singletonList(o));
}
use of ast.Expression.RoundBlock 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.RoundBlock 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.RoundBlock in project L42 by ElvisResearchGroup.
the class Desugar method blockEtoXE.
private RoundBlock blockEtoXE(RoundBlock s) {
if (s.getContents().isEmpty()) {
return s;
}
List<VarDec> decs = s.getContents().get(0).getDecs();
List<VarDec> newDecs = new ArrayList<VarDec>();
for (VarDec _dec : decs) {
if (!(_dec instanceof VarDecE)) {
newDecs.add(_dec);
continue;
}
VarDecE dec = (VarDecE) _dec;
String x = Functions.freshName("unused", usedVars);
//usedVars.add(x);
VarDecXE newXE = new VarDecXE(false, Optional.of(Type.immVoid), x, dec.getInner());
newDecs.add(newXE);
}
RoundBlock result = blockWithDec(s, newDecs);
//assert L42.checkWellFormedness(result);
return result;
}
use of ast.Expression.RoundBlock 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);
}
Aggregations