Frame.parseV8 constructor
Parses a string representation of a Chrome/V8 stack frame.
Implementation
factory Frame.parseV8(String frame) => _catchFormatException(frame, () {
var match = _v8Frame.firstMatch(frame);
if (match == null) return new UnparsedFrame(frame);
// v8 location strings can be arbitrarily-nested, since it adds a layer of
// nesting for each eval performed on that line.
parseLocation(location, member) {
var evalMatch = _v8EvalLocation.firstMatch(location);
while (evalMatch != null) {
location = evalMatch[1];
evalMatch = _v8EvalLocation.firstMatch(location);
}
if (location == 'native') {
return new Frame(Uri.parse('native'), null, null, member);
}
var urlMatch = _v8UrlLocation.firstMatch(location);
if (urlMatch == null) return new UnparsedFrame(frame);
return new Frame(_uriOrPathToUri(urlMatch[1]), int.parse(urlMatch[2]),
int.parse(urlMatch[3]), member);
}
// V8 stack frames can be in two forms.
if (match[2] != null) {
// The first form looks like " at FUNCTION (LOCATION)". V8 proper lists
// anonymous functions within eval as "<anonymous>", while IE10 lists them
// as "Anonymous function".
return parseLocation(
match[2],
match[1]
.replaceAll("<anonymous>", "<fn>")
.replaceAll("Anonymous function", "<fn>")
.replaceAll("(anonymous function)", "<fn>"));
} else {
// The second form looks like " at LOCATION", and is used for anonymous
// functions.
return parseLocation(match[3], "<fn>");
}
});