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

Side by Side Diff: tool/input_sdk/private/debugger.dart

Issue 2101233004: maxspanlength setter (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « lib/runtime/dart_sdk.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 dart._debugger; 5 library dart._debugger;
6 6
7 import 'dart:_foreign_helper' show JS; 7 import 'dart:_foreign_helper' show JS;
8 import 'dart:_runtime' as dart; 8 import 'dart:_runtime' as dart;
9 import 'dart:core'; 9 import 'dart:core';
10 import 'dart:collection'; 10 import 'dart:collection';
(...skipping 12 matching lines...) Expand all
23 /// We'd like this to be an enum, but we can't because it's a dev_compiler bug. 23 /// We'd like this to be an enum, but we can't because it's a dev_compiler bug.
24 class JsonMLConfig { 24 class JsonMLConfig {
25 const JsonMLConfig(this.name); 25 const JsonMLConfig(this.name);
26 26
27 final String name; 27 final String name;
28 static const none = const JsonMLConfig("none"); 28 static const none = const JsonMLConfig("none");
29 static const skipDart = const JsonMLConfig("skipDart"); 29 static const skipDart = const JsonMLConfig("skipDart");
30 static const keyToString = const JsonMLConfig("keyToString"); 30 static const keyToString = const JsonMLConfig("keyToString");
31 } 31 }
32 32
33 int maxSpanLength = 100; 33 int _maxSpanLength = 100;
34 34
35 var _devtoolsFormatter = new JsonMLFormatter(new DartFormatter()); 35 var _devtoolsFormatter = new JsonMLFormatter(new DartFormatter());
36 36
37 String _typeof(object) => JS('String', 'typeof #', object); 37 String _typeof(object) => JS('String', 'typeof #', object);
38 38
39 List<String> getOwnPropertyNames(object) => JS('List<String>', 39 List<String> getOwnPropertyNames(object) => JS('List<String>',
40 'dart.list(Object.getOwnPropertyNames(#), #)', object, String); 40 'dart.list(Object.getOwnPropertyNames(#), #)', object, String);
41 41
42 List getOwnPropertySymbols(object) => 42 List getOwnPropertySymbols(object) =>
43 JS('List', 'Object.getOwnPropertySymbols(#)', object); 43 JS('List', 'Object.getOwnPropertySymbols(#)', object);
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 class JsonMLFormatter { 213 class JsonMLFormatter {
214 // TODO(jacobr): define a SimpleFormatter base class that DartFormatter 214 // TODO(jacobr): define a SimpleFormatter base class that DartFormatter
215 // implements if we decide to use this class elsewhere. We specify that the 215 // implements if we decide to use this class elsewhere. We specify that the
216 // type is DartFormatter here purely to get type checking benefits not because 216 // type is DartFormatter here purely to get type checking benefits not because
217 // this class is really intended to only support instances of type 217 // this class is really intended to only support instances of type
218 // DartFormatter. 218 // DartFormatter.
219 DartFormatter _simpleFormatter; 219 DartFormatter _simpleFormatter;
220 220
221 JsonMLFormatter(this._simpleFormatter); 221 JsonMLFormatter(this._simpleFormatter);
222 222
223 set maxSpanLength(int spanLength) => _maxSpanLength = spanLength;
Jacob 2016/06/28 18:59:11 why is this needed? Having a public field should h
bmilligan 2016/06/28 20:12:31 I don't have access to the debugger.dart file, but
Jacob 2016/06/28 20:36:37 Oh clever. I like this hack. I missed this was ins
bmilligan 2016/06/28 20:45:08 Done.
224
223 header(object, config) { 225 header(object, config) {
224 if (config == JsonMLConfig.skipDart || isNativeJavaScriptObject(object)) { 226 if (config == JsonMLConfig.skipDart || isNativeJavaScriptObject(object)) {
225 return null; 227 return null;
226 } 228 }
227 229
228 var c = _simpleFormatter.preview(object); 230 var c = _simpleFormatter.preview(object);
229 if (c == null) return null; 231 if (c == null) return null;
230 232
231 if (config == JsonMLConfig.keyToString) { 233 if (config == JsonMLConfig.keyToString) {
232 c = object.toString(); 234 c = object.toString();
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 } 628 }
627 629
628 bool hasChildren(object) => true; 630 bool hasChildren(object) => true;
629 631
630 List<NameValuePair> children(object) => childrenHelper(object); 632 List<NameValuePair> children(object) => childrenHelper(object);
631 } 633 }
632 634
633 List<NameValuePair> childrenHelper(IterableSpan span) { 635 List<NameValuePair> childrenHelper(IterableSpan span) {
634 var length = span.end - span.start; 636 var length = span.end - span.start;
635 var ret = new List<NameValuePair>(); 637 var ret = new List<NameValuePair>();
636 if (length <= maxSpanLength) { 638 if (length <= _maxSpanLength) {
637 for (var i = span.start; i < span.end; i++) { 639 for (var i = span.start; i < span.end; i++) {
638 /// TODO(bmilligan): Stop using elementAt if it becomes a performance 640 /// TODO(bmilligan): Stop using elementAt if it becomes a performance
639 /// bottleneck in the future. 641 /// bottleneck in the future.
640 ret.add(new NameValuePair( 642 ret.add(new NameValuePair(
641 name: i.toString(), value: span.iterable.elementAt(i))); 643 name: i.toString(), value: span.iterable.elementAt(i)));
642 } 644 }
643 } else { 645 } else {
644 /// Using length - .5, a list of length 10000 results in a 646 /// Using length - .5, a list of length 10000 results in a
645 /// maxPowerOfSubsetSize of 1, so the list will be broken up into 100, 647 /// maxPowerOfSubsetSize of 1, so the list will be broken up into 100,
646 /// 100-length subsets. A list of length 10001 results in a 648 /// 100-length subsets. A list of length 10001 results in a
647 /// maxPowerOfSubsetSize of 2, so the list will be broken up into 1 649 /// maxPowerOfSubsetSize of 2, so the list will be broken up into 1
648 /// 10000-length subset and 1 1-length subset. 650 /// 10000-length subset and 1 1-length subset.
649 var maxPowerOfSubsetSize = 651 var maxPowerOfSubsetSize =
650 (log(length - .5) / log(maxSpanLength)).truncate(); 652 (log(length - .5) / log(_maxSpanLength)).truncate();
651 var subsetSize = pow(maxSpanLength, maxPowerOfSubsetSize); 653 var subsetSize = pow(_maxSpanLength, maxPowerOfSubsetSize);
652 for (var i = span.start; i < span.end; i += subsetSize) { 654 for (var i = span.start; i < span.end; i += subsetSize) {
653 var endIndex = min(span.end, subsetSize + i); 655 var endIndex = min(span.end, subsetSize + i);
654 if (endIndex - i == 1) 656 if (endIndex - i == 1)
655 ret.add(new NameValuePair( 657 ret.add(new NameValuePair(
656 name: i.toString(), value: span.iterable.elementAt(i))); 658 name: i.toString(), value: span.iterable.elementAt(i)));
657 else { 659 else {
658 var entryWrapper = 660 var entryWrapper =
659 new IterableSpan(start: i, end: endIndex, iterable: span.iterable); 661 new IterableSpan(start: i, end: endIndex, iterable: span.iterable);
660 ret.add(new NameValuePair( 662 ret.add(new NameValuePair(
661 name: '[${i}...${endIndex - 1}]', 663 name: '[${i}...${endIndex - 1}]',
662 value: entryWrapper, 664 value: entryWrapper,
663 hideName: true)); 665 hideName: true));
664 } 666 }
665 } 667 }
666 } 668 }
667 return ret; 669 return ret;
668 } 670 }
669 671
670 /// This entry point is automatically invoked by the code generated by 672 /// This entry point is automatically invoked by the code generated by
671 /// Dart Dev Compiler 673 /// Dart Dev Compiler
672 registerDevtoolsFormatter() { 674 registerDevtoolsFormatter() {
673 var formatters = [_devtoolsFormatter]; 675 var formatters = [_devtoolsFormatter];
674 JS('', 'dart.global.devtoolsFormatters = #', formatters); 676 JS('', 'dart.global.devtoolsFormatters = #', formatters);
675 } 677 }
OLDNEW
« no previous file with comments | « lib/runtime/dart_sdk.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698