use of ast.Ast.VarDecCE in project L42 by ElvisResearchGroup.
the class DesugarVars method _blockVarClass.
private RoundBlock _blockVarClass(RoundBlock s) {
if (s.getContents().isEmpty()) {
return s;
}
List<VarDec> varDecs = new ArrayList<VarDec>(s.getContents().get(0).getDecs());
int pos = firstVar(varDecs);
if (pos == -1) {
return s;
}
VarDecXE varDec = (VarDecXE) varDecs.get(pos);
varDecs.set(pos, varDec.withVar(false));
VarDecCE ce = getClassBForVar(varDec);
VarDecXE d = getDecForVar(ce.getInner().getName(), varDec);
X x = new X(s.getP(), varDec.getX());
X z = new X(s.getP(), d.getX());
int d3First = findD2(x, pos, varDecs);
RoundBlock fake = getFakeBlock(x, z, s, varDecs, d3First);
List<VarDec> trueDecs = new ArrayList<VarDec>();
trueDecs.add(ce);
if (d3First != -1) {
trueDecs.addAll(varDecs.subList(0, d3First));
} else {
trueDecs.addAll(varDecs);
}
trueDecs.add(d);
trueDecs.addAll(fake.getContents().get(0).getDecs());
List<Expression.BlockContent> trueContent = new ArrayList<>();
trueContent.add(new Expression.BlockContent(trueDecs, fake.getContents().get(0).get_catch()));
return fake.withContents(trueContent);
}
use of ast.Ast.VarDecCE in project L42 by ElvisResearchGroup.
the class DesugarVars method getClassBForVar.
private VarDecCE getClassBForVar(VarDecXE varDec) {
List<FieldDec> fs = new ArrayList<FieldDec>();
fs.add(new FieldDec(true, _computeTypeForClassBForVar(varDec), "inner", Doc.empty()));
ClassB cb = new ClassB(Doc.empty(), new Ast.ConcreteHeader(Mdf.Mutable, "", fs, Position.noInfo), Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), Position.noInfo);
String nameC = Functions.freshName("Var" + varDec.getX(), L42.usedNames);
//usedCnames.add(nameC);
return new VarDecCE(new NestedClass(Doc.empty(), C.of(nameC).withUniqueNum(L42.freshPrivate()), cb, null));
}
Aggregations