visitWhile()

in lib/generator.js [1294:1319]


  visitWhile(ast, level, env) {
    assert.equal(ast.type, 'while');
    let argHasThrowFunc;
    if (ast.condition.type === 'not' && ast.condition.expr && ast.condition.expr.type === 'call') {
      argHasThrowFunc = this.visitFunctionNested(ast.condition.expr, level, env);
    } else if (ast.condition.type === 'call') {
      argHasThrowFunc = this.visitFunctionNested(ast.condition, level, env);
    }

    this.emit('for ', level);
    let setFunc;
    if(ast.condition && ast.condition.type === 'call') {
      let dealFunc = this.getVarDealFunc(ast.condition, true);
      setFunc = dealFunc && dealFunc(_name(ast.condition.inferred));
    }
    if(setFunc) {
      this.emit(`${setFunc}`);
    }
    this.visitExpr(ast.condition, level + 1, env, false, argHasThrowFunc);
    if(setFunc) {
      this.emit(')');
    }
    this.emit(' {\n');
    this.visitStmts(ast.stmts, level + 1, env);
    this.emit('}\n', level);
  }