visitWhileLoop method

  1. @override
StringSink visitWhileLoop(
  1. WhileLoop loop, [
  2. StringSink? output
])
inherited

Implementation

@override
StringSink visitWhileLoop(WhileLoop loop, [StringSink? output]) {
  output ??= StringBuffer();
  if (loop.label != null) {
    output.writeln('${loop.label}:');
  }
  if (loop.doWhile) {
    output.writeln('do {');
    if (loop.body != null) {
      loop.body!.accept(this, output);
    }
    output.write(' } while (');
    loop.condition.accept(this, output);
    output.write(');');
  } else {
    output.write('while (');
    loop.condition.accept(this, output);
    output.writeln(') {');
    if (loop.body != null) {
      loop.body!.accept(this, output);
    }
    output.write(' }');
  }
  return output;
}