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

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: setter for testing 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 void setMaxSpanLengthForTestingOnly(int spanLength) {
224 _maxSpanLength = spanLength;
225 }
226
223 header(object, config) { 227 header(object, config) {
224 if (config == JsonMLConfig.skipDart || isNativeJavaScriptObject(object)) { 228 if (config == JsonMLConfig.skipDart || isNativeJavaScriptObject(object)) {
225 return null; 229 return null;
226 } 230 }
227 231
228 var c = _simpleFormatter.preview(object); 232 var c = _simpleFormatter.preview(object);
229 if (c == null) return null; 233 if (c == null) return null;
230 234
231 if (config == JsonMLConfig.keyToString) { 235 if (config == JsonMLConfig.keyToString) {
232 c = object.toString(); 236 c = object.toString();
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 } 630 }
627 631
628 bool hasChildren(object) => true; 632 bool hasChildren(object) => true;
629 633
630 List<NameValuePair> children(object) => childrenHelper(object); 634 List<NameValuePair> children(object) => childrenHelper(object);
631 } 635 }
632 636
633 List<NameValuePair> childrenHelper(IterableSpan span) { 637 List<NameValuePair> childrenHelper(IterableSpan span) {
634 var length = span.end - span.start; 638 var length = span.end - span.start;
635 var ret = new List<NameValuePair>(); 639 var ret = new List<NameValuePair>();
636 if (length <= maxSpanLength) { 640 if (length <= _maxSpanLength) {
637 for (var i = span.start; i < span.end; i++) { 641 for (var i = span.start; i < span.end; i++) {
638 /// TODO(bmilligan): Stop using elementAt if it becomes a performance 642 /// TODO(bmilligan): Stop using elementAt if it becomes a performance
639 /// bottleneck in the future. 643 /// bottleneck in the future.
640 ret.add(new NameValuePair( 644 ret.add(new NameValuePair(
641 name: i.toString(), value: span.iterable.elementAt(i))); 645 name: i.toString(), value: span.iterable.elementAt(i)));
642 } 646 }
643 } else { 647 } else {
644 /// Using length - .5, a list of length 10000 results in a 648 /// Using length - .5, a list of length 10000 results in a
645 /// maxPowerOfSubsetSize of 1, so the list will be broken up into 100, 649 /// maxPowerOfSubsetSize of 1, so the list will be broken up into 100,
646 /// 100-length subsets. A list of length 10001 results in a 650 /// 100-length subsets. A list of length 10001 results in a
647 /// maxPowerOfSubsetSize of 2, so the list will be broken up into 1 651 /// maxPowerOfSubsetSize of 2, so the list will be broken up into 1
648 /// 10000-length subset and 1 1-length subset. 652 /// 10000-length subset and 1 1-length subset.
649 var maxPowerOfSubsetSize = 653 var maxPowerOfSubsetSize =
650 (log(length - .5) / log(maxSpanLength)).truncate(); 654 (log(length - .5) / log(_maxSpanLength)).truncate();
651 var subsetSize = pow(maxSpanLength, maxPowerOfSubsetSize); 655 var subsetSize = pow(_maxSpanLength, maxPowerOfSubsetSize);
652 for (var i = span.start; i < span.end; i += subsetSize) { 656 for (var i = span.start; i < span.end; i += subsetSize) {
653 var endIndex = min(span.end, subsetSize + i); 657 var endIndex = min(span.end, subsetSize + i);
654 if (endIndex - i == 1) 658 if (endIndex - i == 1)
655 ret.add(new NameValuePair( 659 ret.add(new NameValuePair(
656 name: i.toString(), value: span.iterable.elementAt(i))); 660 name: i.toString(), value: span.iterable.elementAt(i)));
657 else { 661 else {
658 var entryWrapper = 662 var entryWrapper =
659 new IterableSpan(start: i, end: endIndex, iterable: span.iterable); 663 new IterableSpan(start: i, end: endIndex, iterable: span.iterable);
660 ret.add(new NameValuePair( 664 ret.add(new NameValuePair(
661 name: '[${i}...${endIndex - 1}]', 665 name: '[${i}...${endIndex - 1}]',
662 value: entryWrapper, 666 value: entryWrapper,
663 hideName: true)); 667 hideName: true));
664 } 668 }
665 } 669 }
666 } 670 }
667 return ret; 671 return ret;
668 } 672 }
669 673
670 /// This entry point is automatically invoked by the code generated by 674 /// This entry point is automatically invoked by the code generated by
671 /// Dart Dev Compiler 675 /// Dart Dev Compiler
672 registerDevtoolsFormatter() { 676 registerDevtoolsFormatter() {
673 var formatters = [_devtoolsFormatter]; 677 var formatters = [_devtoolsFormatter];
674 JS('', 'dart.global.devtoolsFormatters = #', formatters); 678 JS('', 'dart.global.devtoolsFormatters = #', formatters);
675 } 679 }
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