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