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;
}
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);
}
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;
}
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;
}
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;
}
Aggregations