| 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 dump_info; | 5 library dump_info; |
| 6 | 6 |
| 7 import 'dart:convert' show | 7 import 'dart:convert' show |
| 8 HtmlEscape, | 8 HtmlEscape, |
| 9 JsonEncoder, | 9 JsonEncoder, |
| 10 StringConversionSink, | 10 StringConversionSink, |
| 11 ChunkedConversionSink; | 11 ChunkedConversionSink; |
| 12 | 12 |
| 13 import 'elements/elements.dart'; | 13 import 'elements/elements.dart'; |
| 14 import 'elements/visitor.dart'; | 14 import 'elements/visitor.dart'; |
| 15 import 'dart2jslib.dart' show | 15 import 'dart2jslib.dart' show |
| 16 Backend, | 16 Backend, |
| 17 CodeBuffer, | 17 CodeBuffer, |
| 18 Compiler, | 18 Compiler, |
| 19 CompilerTask, | 19 CompilerTask, |
| 20 MessageKind; | 20 MessageKind; |
| 21 import 'types/types.dart' show TypeMask; | 21 import 'types/types.dart' show TypeMask; |
| 22 import 'deferred_load.dart' show OutputUnit; | 22 import 'deferred_load.dart' show OutputUnit; |
| 23 import 'js_backend/js_backend.dart' show JavaScriptBackend; | 23 import 'js_backend/js_backend.dart' show JavaScriptBackend; |
| 24 import 'js_emitter/js_emitter.dart' show OldEmitter; | 24 import 'js_emitter/full_emitter/emitter.dart' as full show Emitter; |
| 25 import 'js/js.dart' as jsAst; | 25 import 'js/js.dart' as jsAst; |
| 26 import 'universe/universe.dart' show Selector, UniverseSelector; | 26 import 'universe/universe.dart' show Selector, UniverseSelector; |
| 27 import 'util/util.dart' show NO_LOCATION_SPANNABLE; | 27 import 'util/util.dart' show NO_LOCATION_SPANNABLE; |
| 28 | 28 |
| 29 /// Maps objects to an id. Supports lookups in | 29 /// Maps objects to an id. Supports lookups in |
| 30 /// both directions. | 30 /// both directions. |
| 31 class IdMapper<T>{ | 31 class IdMapper<T>{ |
| 32 Map<int, T> _idToElement = {}; | 32 Map<int, T> _idToElement = {}; |
| 33 Map<T, int> _elementToId = {}; | 33 Map<T, int> _elementToId = {}; |
| 34 int _idCounter = 0; | 34 int _idCounter = 0; |
| (...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 } | 592 } |
| 593 } | 593 } |
| 594 } | 594 } |
| 595 | 595 |
| 596 List<Map<String, dynamic>> outputUnits = | 596 List<Map<String, dynamic>> outputUnits = |
| 597 new List<Map<String, dynamic>>(); | 597 new List<Map<String, dynamic>>(); |
| 598 | 598 |
| 599 JavaScriptBackend backend = compiler.backend; | 599 JavaScriptBackend backend = compiler.backend; |
| 600 // Dump-info currently only works with the full emitter. If another | 600 // Dump-info currently only works with the full emitter. If another |
| 601 // emitter is used it will fail here. | 601 // emitter is used it will fail here. |
| 602 OldEmitter fullEmitter = backend.emitter.emitter; | 602 full.Emitter fullEmitter = backend.emitter.emitter; |
| 603 | 603 |
| 604 for (OutputUnit outputUnit in | 604 for (OutputUnit outputUnit in |
| 605 infoCollector.mapper._outputUnit._elementToId.keys) { | 605 infoCollector.mapper._outputUnit._elementToId.keys) { |
| 606 String id = infoCollector.mapper._outputUnit.add(outputUnit); | 606 String id = infoCollector.mapper._outputUnit.add(outputUnit); |
| 607 outputUnits.add(<String, dynamic> { | 607 outputUnits.add(<String, dynamic> { |
| 608 'id': id, | 608 'id': id, |
| 609 'name': outputUnit.name, | 609 'name': outputUnit.name, |
| 610 'size': fullEmitter.outputBuffers[outputUnit].length, | 610 'size': fullEmitter.outputBuffers[outputUnit].length, |
| 611 }); | 611 }); |
| 612 } | 612 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 638 ChunkedConversionSink<Object> sink = | 638 ChunkedConversionSink<Object> sink = |
| 639 encoder.startChunkedConversion( | 639 encoder.startChunkedConversion( |
| 640 new StringConversionSink.fromStringSink(buffer)); | 640 new StringConversionSink.fromStringSink(buffer)); |
| 641 sink.add(outJson); | 641 sink.add(outJson); |
| 642 compiler.reportInfo(NO_LOCATION_SPANNABLE, | 642 compiler.reportInfo(NO_LOCATION_SPANNABLE, |
| 643 const MessageKind( | 643 const MessageKind( |
| 644 "View the dumped .info.json file at " | 644 "View the dumped .info.json file at " |
| 645 "https://dart-lang.github.io/dump-info-visualizer")); | 645 "https://dart-lang.github.io/dump-info-visualizer")); |
| 646 } | 646 } |
| 647 } | 647 } |
| OLD | NEW |