use of ast.Expression.RoundBlock in project L42 by ElvisResearchGroup.
the class Desugar method visit.
public Expression visit(While s) {
Expression cond = Desugar.getMCall(s.getP(), s.getCond(), "#checkTrue", Desugar.getPs());
RoundBlock b = Desugar.getBlock(s.getP(), cond, s.getThen());
Loop l = new Loop(b);
Type _void = Type.immVoid;
Expression.Catch k = Desugar.getK(s.getP(), SignalKind.Exception, "", _void, Expression._void.instance);
RoundBlock b2 = Desugar.getBlock(s.getP(), l, Collections.singletonList(k), Expression._void.instance);
return b2.accept(this);
}
use of ast.Expression.RoundBlock 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.RoundBlock in project L42 by ElvisResearchGroup.
the class DesugarW method withDeclareIts.
private RoundBlock withDeclareIts(List<VarDecXE> is, RoundBlock inner) {
if (is.isEmpty()) {
return inner;
}
VarDecXE i0 = is.get(0);
List<VarDecXE> is2 = is.subList(1, is.size());
List<VarDec> decs = new ArrayList<VarDec>();
decs.add(i0.withVar(false));
RoundBlock conclusive = withDeclareItsNestedBlock(inner, i0, is2);
return Desugar.getBlock(inner.getP(), decs, conclusive);
}
use of ast.Expression.RoundBlock in project L42 by ElvisResearchGroup.
the class DesugarW method with_E_handleIs.
private Expression with_E_handleIs(Position pos, List<VarDecXE> is, Expression b) {
//case e in 6 pages
//xs is dom(Is)
List<String> xs = new ArrayList<>();
for (VarDecXE i : is) {
xs.add(i.getX());
}
//di ki is block content =nexti(xs)
List<BlockContent> bc = new ArrayList<>();
for (int i = 0; i < xs.size(); i++) {
bc.add(withNext(pos, i, xs));
}
//inner =di ki s b[xs:=xs.#inner()]
for (String xi : xs) {
b = XInE.of(new X(pos, xi), Desugar.getMCall(pos, new X(pos, xi), "#inner", Desugar.getPs()), b);
}
RoundBlock inner = new RoundBlock(pos, Doc.empty(), b, bc);
Catch k = Desugar.getK(pos, SignalKind.Exception, "", Type.immVoid, Expression._void.instance);
inner = Desugar.getBlock(pos, new Loop(inner), Collections.singletonList(k), Expression._void.instance);
Expression result = withDeclareIts(is, inner);
//accept
return result;
}
use of ast.Expression.RoundBlock in project L42 by ElvisResearchGroup.
the class DesugarVars method getFakeBlock.
private RoundBlock getFakeBlock(X x, X z, RoundBlock s, List<VarDec> varDecs, int d3First) {
Position pos = Desugar.getPosition(s);
List<Expression.BlockContent> fakeContent = new ArrayList<>();
List<VarDec> fakeDecs = new ArrayList<VarDec>();
if (d3First != -1) {
//d3 not empty
fakeDecs.addAll(varDecs.subList(d3First, varDecs.size()));
}
fakeContent.add(new Expression.BlockContent(fakeDecs, s.getContents().get(0).get_catch()));
RoundBlock fake = s.withContents(fakeContent);
fake = (RoundBlock) XEqOpInZEqOp.of(x, z, fake);
fake = (RoundBlock) XInE.of(x, Desugar.getMCall(pos, z, "#inner", Desugar.getPs()), fake);
return fake;
}
Aggregations