Frame.parseFirefox constructor

Frame.parseFirefox(
  1. String frame
)

Parses a string representation of a Firefox or Safari stack frame.

Implementation

factory Frame.parseFirefox(String frame) => _catchFormatException(frame, () {
      var match = _firefoxSafariJSFrame.firstMatch(frame);
      if (match != null) {
        if (match[3]!.contains(' line ')) {
          return Frame._parseFirefoxEval(frame);
        }

        // Normally this is a URI, but in a jsshell trace it can be a path.
        var uri = _uriOrPathToUri(match[3]!);

        var member = match[1];
        if (member != null) {
          member +=
              List.filled('/'.allMatches(match[2]!).length, '.<fn>').join();
          if (member == '') member = '<fn>';

          // Some Firefox members have initial dots. We remove them for
          // consistency with other platforms.
          member = member.replaceFirst(_initialDot, '');
        } else {
          member = '<fn>';
        }

        var line = match[4] == '' ? null : int.parse(match[4]!);
        var column =
            match[5] == null || match[5] == '' ? null : int.parse(match[5]!);
        return Frame(uri, line, column, member);
      }

      match = _firefoxWasmFrame.firstMatch(frame);
      if (match != null) {
        final member = match.namedGroup('member')!;
        final uri = _uriOrPathToUri(match.namedGroup('uri')!);
        final functionIndex = match.namedGroup('index')!;
        final functionOffset =
            int.parse(match.namedGroup('offset')!, radix: 16);
        return Frame(uri, 1, functionOffset + 1,
            member.isNotEmpty ? member : functionIndex);
      }

      match = _safariWasmFrame.firstMatch(frame);
      if (match != null) {
        final member = match.namedGroup('member')!;
        return Frame(Uri(path: 'wasm code'), null, null, member);
      }

      return UnparsedFrame(frame);
    });