Search in sources :

Example 6 with ClassB

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);
}
Also used : ClassB(ast.Expression.ClassB)

Example 7 with ClassB

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));
}
Also used : FieldDec(ast.Ast.FieldDec) Ast(ast.Ast) ArrayList(java.util.ArrayList) VarDecCE(ast.Ast.VarDecCE) NestedClass(ast.Expression.ClassB.NestedClass) ClassB(ast.Expression.ClassB)

Example 8 with ClassB

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;
}
Also used : NestedClass(ast.Expression.ClassB.NestedClass) Member(ast.Expression.ClassB.Member) ClassB(ast.Expression.ClassB) WalkBy(ast.Expression.WalkBy)

Example 9 with ClassB

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();
}
Also used : ExpCore(ast.ExpCore) InjectionOnSugar(coreVisitors.InjectionOnSugar) Expression(ast.Expression) ClassB(ast.Expression.ClassB) ArrayList(java.util.ArrayList) Member(ast.Expression.ClassB.Member) ClassB(ast.Expression.ClassB)

Example 10 with ClassB

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);
}
Also used : Ast(ast.Ast) TraitHeader(ast.Ast.TraitHeader) Doc(ast.Ast.Doc) ClassB(ast.Expression.ClassB)

Aggregations

ClassB (ast.Expression.ClassB)10 Member (ast.Expression.ClassB.Member)5 ArrayList (java.util.ArrayList)5 ExpCore (ast.ExpCore)4 Ast (ast.Ast)3 FieldDec (ast.Ast.FieldDec)3 Expression (ast.Expression)3 NestedClass (ast.Expression.ClassB.NestedClass)3 ClassReuse (ast.Expression.ClassReuse)3 ConcreteHeader (ast.Ast.ConcreteHeader)2 Doc (ast.Ast.Doc)2 Header (ast.Ast.Header)2 MethodType (ast.Ast.MethodType)2 Position (ast.Ast.Position)2 Type (ast.Ast.Type)2 VarDecCE (ast.Ast.VarDecCE)2 ErrorMessage (ast.ErrorMessage)2 Mdf (ast.Ast.Mdf)1 MethodSelector (ast.Ast.MethodSelector)1 MethodSelectorX (ast.Ast.MethodSelectorX)1