@Override public void visit(While whileStm) { System.out.print("while ("); if (whileStm.getCondExp() != null) whileStm.getCondExp().accept(this); System.out.print(")"); if (whileStm.getStm() != null) whileStm.getStm().accept(this); }
/** Desugar a generalized While clause. */ @Override public Node forWhile(While w) { GeneratorClause g = w.getTestExpr(); if (g.getBind().size() > 0) { // while binds <- expr do body end // desugars to // while __whileCond(expr, fn (binds) => body) do end ArrayList<Expr> args = new ArrayList<Expr>(2); args.add(g.getInit()); args.add(bindsAndBody(g, w.getBody())); Expr cond = ExprFactory.make_RewriteFnApp( NodeUtil.getSpan(g), WHILECOND_NAME, ExprFactory.makeTupleExpr(NodeUtil.getSpan(w), args)); w = ExprFactory.makeWhile(NodeUtil.getSpan(w), cond); } return (Expr) super.forWhile(w); }