Search in sources :

Example 46 with Expression

use of ast.Expression in project L42 by ElvisResearchGroup.

the class Desugar method of.

public static Expression of(Expression e) {
    long max = RefreshUniqueNames.maxUnique(e);
    assert max >= 0L;
    L42.setFreshPrivateCap(max + 1);
    if (L42.path != null) {
        e = ReplaceDots.of(L42.path, e);
    }
    Desugar d = new Desugar();
    d.usedVars.addAll(CollectDeclaredVars.of(e));
    e = DesugarPaths.of(e);
    e = DesugarNormalizeReceiver.of(d.usedVars, e);
    e = DesugarContext.of(d.usedVars, e);
    assert DesugarContext.checkRemoved(e);
    e = DesugarW.of(d.usedVars, e);
    e = DesugarVars.of(d.usedVars, e);
    //assert DesugarVars.assertVarsRemoved(e);
    //understand what is the current folder
    //replace ... recursively
    //replaceDots(currentFolder,e)-> clone visitor
    //collect all classBreuse in a map url->core version
    d.collectAllUsedLibs(e);
    L42.usedNames.addAll(CollectDeclaredClassNamesAndMethodNames.of(e));
    d.renameAllPrivatesInUsedLibs();
    Expression result = e.accept(d);
    assert Functions.checkCore(result);
    return result;
}
Also used : Expression(ast.Expression)

Example 47 with Expression

use of ast.Expression in project L42 by ElvisResearchGroup.

the class Desugar method visit.

public Expression visit(CurlyBlock s) {
    assert s.getContents().size() == 1;
    assert s.getContents().get(0).get_catch().isEmpty();
    assert s.getContents().get(0).getDecs().size() == 1;
    assert s.getContents().get(0).getDecs().get(0) instanceof VarDecE;
    Expression inner = ((VarDecE) s.getContents().get(0).getDecs().get(0)).getInner();
    String y = Functions.freshName("result", this.usedVars);
    Expression.Catch k = getK(s.getP(), SignalKind.Return, y, this.t, new X(s.getP(), y));
    Expression termination = Desugar.errorMsg("CurlyBlock-Should be unreachable code");
    RoundBlock outer = getBlock(s.getP(), inner, Collections.singletonList(k), termination);
    return visit(outer);
}
Also used : Expression(ast.Expression) X(ast.Expression.X) MethodSelectorX(ast.Ast.MethodSelectorX) RoundBlock(ast.Expression.RoundBlock) VarDecE(ast.Ast.VarDecE) Catch(ast.Expression.Catch)

Example 48 with Expression

use of ast.Expression in project L42 by ElvisResearchGroup.

the class DesugarPaths method of.

public static Expression of(Expression e) {
    DesugarPaths d = new DesugarPaths();
    Expression result = e.accept(d);
    return result;
}
Also used : Expression(ast.Expression)

Example 49 with Expression

use of ast.Expression in project L42 by ElvisResearchGroup.

the class DesugarVars method visit.

public Expression visit(RoundBlock s) {
    s = blockContentSepare(s);
    //s=blockVarClass(s);
    Expression result = super.visit(s);
    return result;
}
Also used : Expression(ast.Expression)

Example 50 with Expression

use of ast.Expression in project L42 by ElvisResearchGroup.

the class DesugarVars method findD2.

private int findD2(X x, int pos, List<VarDec> decs) {
    for (VarDec _dec : decs.subList(pos + 1, decs.size())) {
        pos += 1;
        Expression[] inner = { null };
        _dec.match(xe -> inner[0] = xe.getInner(), e -> inner[0] = e.getInner(), ce -> null);
        if (inner[0] == null) {
            continue;
        }
        boolean isAssigned = Exists.of(inner[0], e -> {
            if (!(e instanceof BinOp)) {
                return false;
            }
            BinOp bo = (BinOp) e;
            if (bo.getOp().kind != Ast.OpKind.EqOp) {
                return false;
            }
            return bo.getLeft().equals(x);
        });
        if (isAssigned) {
            return pos;
        }
    }
    return -1;
}
Also used : Expression(ast.Expression) VarDec(ast.Ast.VarDec) BinOp(ast.Expression.BinOp)

Aggregations

Expression (ast.Expression)66 ArrayList (java.util.ArrayList)24 VarDec (ast.Ast.VarDec)14 X (ast.Expression.X)13 Type (ast.Ast.Type)11 VarDecXE (ast.Ast.VarDecXE)11 ExpCore (ast.ExpCore)11 Catch (ast.Expression.Catch)11 RoundBlock (ast.Expression.RoundBlock)11 VarDecE (ast.Ast.VarDecE)10 Doc (ast.Ast.Doc)8 Position (ast.Ast.Position)8 MethodSelectorX (ast.Ast.MethodSelectorX)7 Parameters (ast.Ast.Parameters)7 MethodWithType (ast.Expression.ClassB.MethodWithType)7 MethodType (ast.Ast.MethodType)6 ClassB (ast.ExpCore.ClassB)6 InjectionOnCore (sugarVisitors.InjectionOnCore)6 Ast (ast.Ast)5 Path (ast.Ast.Path)4