use of ast.Expression.ClassB.NestedClass in project L42 by ElvisResearchGroup.
the class Desugar method visit.
public NestedClass visit(NestedClass nc) {
while (nc.getInner() instanceof Expression.DocE) {
nc = nc.withInner(((Expression.DocE) nc.getInner()).getInner());
}
//TODO: document stripping of comments and decide scope
NestedClass nc1 = nc;
this.usedVars = new HashSet<String>();
this.varEnv = new HashMap<String, Type>();
usedVars.addAll(CollectDeclaredVars.of(nc.getInner()));
return withExpectedType(Type.immLibrary, () -> super.visit(nc1));
}
use of ast.Expression.ClassB.NestedClass 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));
}
use of ast.Expression.ClassB.NestedClass in project L42 by ElvisResearchGroup.
the class ToFormattedText method ofCompact.
public static String ofCompact(Expression e, boolean inline) {
ToFormattedText tft = new ToFormattedText() {
public Void visit(ClassB cb) {
//String res="";
String wb = "";
for (Member m : cb.getMs()) {
if (m instanceof NestedClass) {
NestedClass nc = (NestedClass) m;
if (nc.getInner() instanceof WalkBy) {
wb = nc.getName() + ":##";
}
}
}
return c("{.." + wb + "..}");
}
};
e.accept(tft);
String res = tft.result.toString();
if (inline) {
res = res.replace("\n", " ");
}
//if(res.length()>80){ res=res.substring(0, 34)+" ... "+res.substring(res.length()-34); }
return res;
}
Aggregations