OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 for debugging helpers. The unittest analyze_unused_test checks that | 5 /// Library for debugging helpers. The unittest analyze_unused_test checks that |
6 /// the helper are not used in production code. | 6 /// the helper are not used in production code. |
7 | 7 |
8 library dart2js.helpers; | 8 library dart2js.helpers; |
9 | 9 |
10 import 'dart:async' show | 10 import 'dart:async' show |
11 EventSink; | 11 EventSink; |
12 import 'dart:collection'; | 12 import 'dart:collection'; |
13 import 'dart:convert'; | 13 import 'dart:convert'; |
14 | 14 |
15 import '../../compiler.dart'; | 15 import '../../compiler.dart'; |
16 import '../compiler.dart' show | 16 import '../compiler.dart' show |
17 Compiler; | 17 Compiler; |
| 18 import '../diagnostics/diagnostic_listener.dart' show |
| 19 DiagnosticReporter; |
18 import '../diagnostics/invariant.dart' show | 20 import '../diagnostics/invariant.dart' show |
19 DEBUG_MODE; | 21 DEBUG_MODE; |
20 import '../diagnostics/messages.dart' show | 22 import '../diagnostics/messages.dart' show |
21 MessageKind; | 23 MessageKind; |
22 import '../diagnostics/spannable.dart' show | 24 import '../diagnostics/spannable.dart' show |
23 Spannable; | 25 Spannable; |
24 import '../util/util.dart'; | 26 import '../util/util.dart'; |
25 | 27 |
26 part 'debug_collection.dart'; | 28 part 'debug_collection.dart'; |
27 part 'trace.dart'; | 29 part 'trace.dart'; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 debugPrint('end:$s'); | 83 debugPrint('end:$s'); |
82 return result; | 84 return result; |
83 } | 85 } |
84 | 86 |
85 /// Dummy method to mark breakpoints. | 87 /// Dummy method to mark breakpoints. |
86 debugBreak() { | 88 debugBreak() { |
87 enableDebugMode(); | 89 enableDebugMode(); |
88 } | 90 } |
89 | 91 |
90 /// Function signature of [reportHere]. | 92 /// Function signature of [reportHere]. |
91 typedef ReportHere(Compiler compiler, Spannable node, String debugMessage); | 93 typedef ReportHere(DiagnosticReporter reporter, |
| 94 Spannable node, |
| 95 String debugMessage); |
92 | 96 |
93 /// Print a message with a source location. | 97 /// Print a message with a source location. |
94 ReportHere get reportHere { | 98 ReportHere get reportHere { |
95 enableDebugMode(); | 99 enableDebugMode(); |
96 return _reportHere; | 100 return _reportHere; |
97 } | 101 } |
98 | 102 |
99 /// Implementation of [reportHere] | 103 /// Implementation of [reportHere] |
100 _reportHere(Compiler compiler, Spannable node, String debugMessage) { | 104 _reportHere(DiagnosticReporter reporter, Spannable node, String debugMessage) { |
101 compiler.reportInfo(node, | 105 reporter.reportInfo(node, |
102 MessageKind.GENERIC, {'text': 'HERE: $debugMessage'}); | 106 MessageKind.GENERIC, {'text': 'HERE: $debugMessage'}); |
103 } | 107 } |
104 | 108 |
105 /// Set of tracked objects used by [track] and [ifTracked]. | 109 /// Set of tracked objects used by [track] and [ifTracked]. |
106 var _trackedObjects = new Set(); | 110 var _trackedObjects = new Set(); |
107 | 111 |
108 /// Global default value for the `printTrace` option of [track] and [ifTracked]. | 112 /// Global default value for the `printTrace` option of [track] and [ifTracked]. |
109 bool trackWithTrace = false; | 113 bool trackWithTrace = false; |
110 | 114 |
111 /// If [doTrack] is `true`, add [object] to the set of tracked objects. | 115 /// If [doTrack] is `true`, add [object] to the set of tracked objects. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 if (printTrace) { | 147 if (printTrace) { |
144 trace(msg); | 148 trace(msg); |
145 } else { | 149 } else { |
146 debugPrint(msg); | 150 debugPrint(msg); |
147 } | 151 } |
148 } | 152 } |
149 return true; | 153 return true; |
150 } | 154 } |
151 return false; | 155 return false; |
152 } | 156 } |
OLD | NEW |