use of ast.Expression.ClassB in project L42 by ElvisResearchGroup.
the class DesugarPaths method visit.
public Expression visit(ClassReuse s) {
//lift(s.getInner());
ClassB res = s.getInner();
ArrayList<ClassB> oldP = this.p;
this.p = new ArrayList<ClassB>();
try {
res = (ClassB) res.accept(this);
} finally {
this.p = oldP;
}
return s.withInner(res);
}
use of ast.Expression.ClassB 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 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;
}
use of ast.Expression.ClassB in project L42 by ElvisResearchGroup.
the class ToFormattedText method of.
public static String of(ExpCore.ClassB.Member m) {
List<ExpCore.ClassB.Member> ms = new ArrayList<>();
ms.add(m);
ExpCore e = ExpCore.ClassB.membersClass(ms, m.getP(), Phase.None);
Expression.ClassB es = (ClassB) e.accept(new InjectionOnSugar());
ToFormattedText tft = new ToFormattedText();
//for the injection
tft.formatMembers(es.getMs());
return tft.result.toString();
}
use of ast.Expression.ClassB in project L42 by ElvisResearchGroup.
the class ToAst method visitClassBReuse.
@Override
public Expression visitClassBReuse(ClassBReuseContext ctx) {
Doc doc1 = Doc.empty();
if (ctx.docsOpt().size() >= 1) {
doc1 = parseDoc(ctx.docsOpt().get(0));
}
//Note: if exists ctx.docsOpt().get(1)) it is ignored.
assert ctx.getChild(0).getText().equals("{");
assert ctx.getChild(2).getText().startsWith("reuse");
String url = ctx.getChild(2).getText();
url = url.trim();
List<Member> ms = visitMembers(ctx.member());
ClassB inner = new ClassB(doc1, new Ast.TraitHeader(), Collections.emptyList(), Collections.emptyList(), ms, position(ctx));
return new Expression.ClassReuse(inner, url, null);
}
Aggregations