Search in sources :

Example 6 with VarDec

use of ast.Ast.VarDec in project L42 by ElvisResearchGroup.

the class FlatFirstLevelLocalNestedClasses method liftVarDecs.

protected List<ast.Ast.VarDec> liftVarDecs(List<ast.Ast.VarDec> ds) {
    List<ast.Ast.VarDec> result = new ArrayList<>();
    for (VarDec d : ds) {
        if (!(d instanceof ast.Ast.VarDecCE)) {
            result.add(d);
            continue;
        }
        NestedClass nc = ((ast.Ast.VarDecCE) d).getInner();
        collected.add(nc);
    }
    return super.liftVarDecs(result);
}
Also used : VarDec(ast.Ast.VarDec) ArrayList(java.util.ArrayList)

Example 7 with VarDec

use of ast.Ast.VarDec in project L42 by ElvisResearchGroup.

the class DesugarCatchDefault method liftBC.

protected BlockContent liftBC(BlockContent c) {
    if (c.get_catch().isEmpty()) {
        return super.liftBC(c);
    }
    List<Catch> ks = Map.of(this::liftK, c.get_catch());
    Type oldR = this.lastReturn;
    this.lastReturn = newR(ks);
    try {
        List<VarDec> liftVarDecs = liftVarDecs(c.getDecs());
        return new BlockContent(liftVarDecs, ks);
    } finally {
        this.lastReturn = oldR;
    }
}
Also used : Type(ast.Ast.Type) Catch(ast.Expression.Catch) VarDec(ast.Ast.VarDec) BlockContent(ast.Expression.BlockContent)

Example 8 with VarDec

use of ast.Ast.VarDec in project L42 by ElvisResearchGroup.

the class DesugarVars method getFakeBlock.

private RoundBlock getFakeBlock(X x, X z, RoundBlock s, List<VarDec> varDecs, int d3First) {
    Position pos = Desugar.getPosition(s);
    List<Expression.BlockContent> fakeContent = new ArrayList<>();
    List<VarDec> fakeDecs = new ArrayList<VarDec>();
    if (d3First != -1) {
        //d3 not empty
        fakeDecs.addAll(varDecs.subList(d3First, varDecs.size()));
    }
    fakeContent.add(new Expression.BlockContent(fakeDecs, s.getContents().get(0).get_catch()));
    RoundBlock fake = s.withContents(fakeContent);
    fake = (RoundBlock) XEqOpInZEqOp.of(x, z, fake);
    fake = (RoundBlock) XInE.of(x, Desugar.getMCall(pos, z, "#inner", Desugar.getPs()), fake);
    return fake;
}
Also used : Position(ast.Ast.Position) Expression(ast.Expression) VarDec(ast.Ast.VarDec) ArrayList(java.util.ArrayList) BlockContent(ast.Expression.BlockContent) RoundBlock(ast.Expression.RoundBlock) BlockContent(ast.Expression.BlockContent)

Example 9 with VarDec

use of ast.Ast.VarDec in project L42 by ElvisResearchGroup.

the class Desugar method getBlock.

static RoundBlock getBlock(Position p, String x, Expression xe, Expression inner) {
    List<Expression.BlockContent> bc = new ArrayList<>();
    List<VarDec> decs = new ArrayList<VarDec>();
    decs.add(new VarDecXE(false, Optional.empty(), x, xe));
    bc.add(new Expression.BlockContent(decs, Collections.emptyList()));
    return new RoundBlock(p, Doc.empty(), inner, bc);
}
Also used : Expression(ast.Expression) VarDec(ast.Ast.VarDec) ArrayList(java.util.ArrayList) RoundBlock(ast.Expression.RoundBlock) VarDecXE(ast.Ast.VarDecXE)

Example 10 with VarDec

use of ast.Ast.VarDec in project L42 by ElvisResearchGroup.

the class Desugar method getBlockContent.

public static Expression.BlockContent getBlockContent(Expression e, Expression.Catch k) {
    List<VarDec> single = new ArrayList<VarDec>();
    single.add(new VarDecE(e));
    return new Expression.BlockContent(single, Collections.singletonList(k));
}
Also used : VarDec(ast.Ast.VarDec) ArrayList(java.util.ArrayList) VarDecE(ast.Ast.VarDecE)

Aggregations

VarDec (ast.Ast.VarDec)25 ArrayList (java.util.ArrayList)17 Expression (ast.Expression)16 VarDecE (ast.Ast.VarDecE)10 VarDecXE (ast.Ast.VarDecXE)9 RoundBlock (ast.Expression.RoundBlock)9 BlockContent (ast.Expression.BlockContent)7 X (ast.Expression.X)6 Catch (ast.Expression.Catch)5 Type (ast.Ast.Type)4 Doc (ast.Ast.Doc)3 Parameters (ast.Ast.Parameters)3 MethodSelectorX (ast.Ast.MethodSelectorX)2 MethodType (ast.Ast.MethodType)2 MethodWithType (ast.Expression.ClassB.MethodWithType)2 Ast (ast.Ast)1 Position (ast.Ast.Position)1 VarDecCE (ast.Ast.VarDecCE)1 ErrorMessage (ast.ErrorMessage)1 BinOp (ast.Expression.BinOp)1