use of ast.Ast.Op in project L42 by ElvisResearchGroup.
the class Desugar method visit.
public Expression visit(BinOp s) {
Op op = s.getOp();
if (op == Op.ColonEqual) {
//TODO: set the right expect type?
return s.withRight(lift(s.getRight()));
}
if (op.kind == Ast.OpKind.EqOp) {
//go from, for example a++=b into a:=a ++b
Op op2 = Op.fromString(s.getOp().inner.substring(0, s.getOp().inner.length() - 1));
BinOp s2 = s.withOp(op2);
//NO!s2=s2.withLeft(getMCall(s.getP(),s.getLeft(),"#inner",getPs()));
return visit(new BinOp(s.getP(), s.getLeft(), Op.ColonEqual, Doc.empty(), s2));
}
if (op.negated) {
BinOp s2 = s.withOp(op.nonNegatedVersion());
return visit(getMCall(s.getP(), s2, desugarName(Op.Bang.inner), getPs()));
}
if (op.normalized) {
return visit(getMCall(s.getP(), s.getLeft(), desugarName(s.getOp().inner), getPs(s.getRight())));
}
String x = Functions.freshName("opNorm", usedVars);
BinOp s2 = new BinOp(s.getP(), s.getRight(), op.normalizedVersion(), s.getDoc(), new Expression.X(s.getP(), x));
return visit(getBlock(s.getP(), x, s.getLeft(), s2));
}
Aggregations