Search in sources :

Example 1 with NestedClass

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));
}
Also used : Type(ast.Ast.Type) MethodWithType(ast.Expression.ClassB.MethodWithType) MethodType(ast.Ast.MethodType) NestedClass(ast.Expression.ClassB.NestedClass) DocE(ast.Expression.DocE)

Example 2 with NestedClass

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));
}
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 3 with NestedClass

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

Aggregations

NestedClass (ast.Expression.ClassB.NestedClass)3 ClassB (ast.Expression.ClassB)2 Ast (ast.Ast)1 FieldDec (ast.Ast.FieldDec)1 MethodType (ast.Ast.MethodType)1 Type (ast.Ast.Type)1 VarDecCE (ast.Ast.VarDecCE)1 Member (ast.Expression.ClassB.Member)1 MethodWithType (ast.Expression.ClassB.MethodWithType)1 DocE (ast.Expression.DocE)1 WalkBy (ast.Expression.WalkBy)1 ArrayList (java.util.ArrayList)1