Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(739)

Side by Side Diff: sdk/lib/_internal/compiler/implementation/helpers/helpers.dart

Issue 574683002: Use ConstExp for storing constants. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixes and further implementation. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 EventSink; 10 import 'dart:async' show EventSink;
11 import 'dart:collection'; 11 import 'dart:collection';
12 import 'dart:convert'; 12 import 'dart:convert';
13 13
14 import '../../compiler.dart'; 14 import '../../compiler.dart';
15 import '../dart2jslib.dart'; 15 import '../dart2jslib.dart';
16 import '../util/util.dart'; 16 import '../util/util.dart';
17 17
18 part 'debug_collection.dart'; 18 part 'debug_collection.dart';
19 part 'trace.dart'; 19 part 'trace.dart';
20 part 'expensive_map.dart'; 20 part 'expensive_map.dart';
21 part 'expensive_set.dart'; 21 part 'expensive_set.dart';
22 part 'stats.dart'; 22 part 'stats.dart';
23 part 'track_map.dart'; 23 part 'track_map.dart';
24 24
25 /// Global flag to enable [debugPrint]. This should always be `true` by default 25 /// Global flag to enable [debugPrint]. This should always be `true` by default
26 /// and be set to `false` as a means to temporarily turn off all debugging 26 /// and be set to `false` as a means to temporarily turn off all debugging
27 /// printouts. 27 /// printouts.
28 const bool DEBUG_PRINT_ENABLED = true; 28 const bool DEBUG_PRINT_ENABLED = true;
29 29
30 /// Enables debug mode.
karlklose 2014/09/25 08:43:25 Why do we need this mode? We already test that th
Johnni Winther 2014/09/29 08:24:44 See comment on Constant.toString()
31 ///
32 /// Sets the [DEBUG_MODE] to `true`.
33 void enableDebugMode() {
34 DEBUG_MODE = true;
35 }
36
30 class _DebugIndentation extends Indentation { 37 class _DebugIndentation extends Indentation {
31 final String indentationUnit = " "; 38 final String indentationUnit = " ";
32 } 39 }
33 _DebugIndentation _indentation = new _DebugIndentation(); 40 _DebugIndentation _indentation = new _DebugIndentation();
34 41
42 /// Function signature of [debugPrint].
43 typedef DebugPrint(s);
44
35 /// If [DEBUG_PRINT_ENABLED] is `true` print [s] using the current identation. 45 /// If [DEBUG_PRINT_ENABLED] is `true` print [s] using the current identation.
36 debugPrint(s) { 46 DebugPrint get debugPrint {
47 enableDebugMode();
48 return _debugPrint;
49 }
50
51 /// Implementation of [debugPrint].
52 _debugPrint(s) {
37 if (DEBUG_PRINT_ENABLED) print('${_indentation.indentation}$s'); 53 if (DEBUG_PRINT_ENABLED) print('${_indentation.indentation}$s');
38 } 54 }
39 55
56 /// Function signature of [debugWrapPrint].
57 typedef DebugWrapPrint(s, f());
58
40 /// Wraps the call to [f] with a print of 'start:$s' and 'end:$s' incrementing 59 /// Wraps the call to [f] with a print of 'start:$s' and 'end:$s' incrementing
41 /// the current indentation used by [debugPrint] during the execution of [f]. 60 /// the current indentation used by [debugPrint] during the execution of [f].
42 /// 61 ///
43 /// Use this to get a tree-like debug printout for nested calls. 62 /// Use this to get a tree-like debug printout for nested calls.
44 debugWrapPrint(s, f()) { 63 DebugWrapPrint get debugWrapPrint {
64 enableDebugMode();
65 return _debugWrapPrint;
66 }
67
68 /// Implementation of [debugWrapPrint].
69 DebugWrapPrint _debugWrapPrint(s, f()) {
45 debugPrint('start:$s'); 70 debugPrint('start:$s');
46 var result = _indentation.indentBlock(f); 71 var result = _indentation.indentBlock(f);
47 debugPrint('end:$s'); 72 debugPrint('end:$s');
48 return result; 73 return result;
49 } 74 }
50 75
51 /// Dummy method to mark breakpoints. 76 /// Dummy method to mark breakpoints.
52 debugBreak() {} 77 debugBreak() {
78 enableDebugMode();
79 }
80
81 /// Function signature of [reportHere].
82 typedef ReportHere(Compiler compiler, Spannable node, String debugMessage);
53 83
54 /// Print a message with a source location. 84 /// Print a message with a source location.
55 reportHere(Compiler compiler, Spannable node, String debugMessage) { 85 ReportHere get reportHere {
86 enableDebugMode();
sigurdm 2014/09/25 08:44:56 Maybe ensure that debug mode is disabled after deb
Johnni Winther 2014/09/29 08:24:44 TODO added.
87 return _reportHere;
88 }
89
90 /// Implementation of [reportHere]
91 _reportHere(Compiler compiler, Spannable node, String debugMessage) {
56 compiler.reportInfo(node, 92 compiler.reportInfo(node,
57 MessageKind.GENERIC, {'text': 'HERE: $debugMessage'}); 93 MessageKind.GENERIC, {'text': 'HERE: $debugMessage'});
58 } 94 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698