visitForStmt method

  1. @override
void visitForStmt(
  1. For stmt
)
override

Implementation

@override
void visitForStmt(Stmt.For stmt) {
  if (stmt.initializer != null) {
    execute(stmt.initializer!);
  }

  while (stmt.condition == null || isTruthy(evaluate(stmt.condition!))) {
    try {
      execute(stmt.body);
    } on ContinueException {
      // If we continue, we still need to run the increment.
      if (stmt.increment != null) {
        evaluate(stmt.increment!);
      }
      continue;
    } on BreakException {
      break;
    }

    if (stmt.increment != null) {
      evaluate(stmt.increment!);
    }
  }
}