loopReplacer method

String loopReplacer(
  1. dynamic match,
  2. dynamic s,
  3. dynamic e,
  4. dynamic snippet,
)

Implementation

String loopReplacer(match, s, e, snippet) {
  String string = '';

  int start = int.parse(s);
  int end = int.parse(e);

  for (int i = start; i < end; i++) {
    snippet = snippet
      ..replaceAll(RegExp(r"\[\s*i\s*\]"), '[ $i ]')
      ..replaceAll(RegExp(r"UNROLLED_LOOP_INDEX"), i);

    string += snippet;
  }

  return string;
}