Line data Source code
1 : // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 : // for details. All rights reserved. Use of this source code is governed by a
3 : // BSD-style license that can be found in the LICENSE file.
4 :
5 : import 'frame.dart';
6 :
7 : /// An implementation of [StackTrace] that emulates the behavior of the VM's
8 : /// implementation.
9 : ///
10 : /// In particular, when [toString] is called, this returns a string in the VM's
11 : /// stack trace format.
12 : class VMTrace implements StackTrace {
13 : /// The stack frames that comprise this stack trace.
14 : final List<Frame> frames;
15 :
16 0 : VMTrace(this.frames);
17 :
18 : String toString() {
19 : var i = 1;
20 0 : return frames.map((frame) {
21 0 : var number = "#${i++}".padRight(8);
22 0 : var member = frame.member
23 0 : .replaceAllMapped(new RegExp(r"[^.]+\.<async>"),
24 0 : (match) => "${match[1]}.<${match[1]}_async_body>")
25 0 : .replaceAll("<fn>", "<anonymous closure>");
26 0 : var line = frame.line == null ? 0 : frame.line;
27 0 : var column = frame.column == null ? 0 : frame.column;
28 0 : return "$number$member (${frame.uri}:$line:$column)\n";
29 0 : }).join();
30 : }
31 : }
|