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' | 7 import 'dart:convert' |
8 show ChunkedConversionSink, JsonEncoder, StringConversionSink; | 8 show ChunkedConversionSink, JsonEncoder, StringConversionSink; |
9 | 9 |
10 import 'package:dart2js_info/info.dart'; | 10 import 'package:dart2js_info/info.dart'; |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 } | 547 } |
548 | 548 |
549 void dumpInfoJson(StringSink buffer, ClosedWorld closedWorld) { | 549 void dumpInfoJson(StringSink buffer, ClosedWorld closedWorld) { |
550 JsonEncoder encoder = const JsonEncoder.withIndent(' '); | 550 JsonEncoder encoder = const JsonEncoder.withIndent(' '); |
551 Stopwatch stopwatch = new Stopwatch(); | 551 Stopwatch stopwatch = new Stopwatch(); |
552 stopwatch.start(); | 552 stopwatch.start(); |
553 | 553 |
554 AllInfo result = infoCollector.result; | 554 AllInfo result = infoCollector.result; |
555 | 555 |
556 // Recursively build links to function uses | 556 // Recursively build links to function uses |
557 Iterable<Element> functionElements = | 557 Iterable<Entity> functionElements = |
558 infoCollector._elementToInfo.keys.where((k) => k is FunctionElement); | 558 infoCollector._elementToInfo.keys.where((k) => k is FunctionElement); |
559 for (FunctionElement element in functionElements) { | 559 for (FunctionElement element in functionElements) { |
560 FunctionInfo info = infoCollector._elementToInfo[element]; | 560 FunctionInfo info = infoCollector._elementToInfo[element]; |
561 Iterable<Selection> uses = getRetaining(element, closedWorld); | 561 Iterable<Selection> uses = getRetaining(element, closedWorld); |
562 // Don't bother recording an empty list of dependencies. | 562 // Don't bother recording an empty list of dependencies. |
563 for (Selection selection in uses) { | 563 for (Selection selection in uses) { |
564 // Don't register dart2js builtin functions that are not recorded. | 564 // Don't register dart2js builtin functions that are not recorded. |
565 Info useInfo = infoCollector._elementToInfo[selection.selectedElement]; | 565 Info useInfo = infoCollector._elementToInfo[selection.selectedElement]; |
566 if (useInfo == null) continue; | 566 if (useInfo == null) continue; |
567 info.uses.add(new DependencyInfo(useInfo, '${selection.mask}')); | 567 info.uses.add(new DependencyInfo(useInfo, '${selection.mask}')); |
568 } | 568 } |
569 } | 569 } |
570 | 570 |
571 // Recursively build links to field uses | 571 // Recursively build links to field uses |
572 Iterable<Element> fieldElements = | 572 Iterable<Entity> fieldElements = |
573 infoCollector._elementToInfo.keys.where((k) => k is FieldElement); | 573 infoCollector._elementToInfo.keys.where((k) => k is FieldElement); |
574 for (FieldElement element in fieldElements) { | 574 for (FieldElement element in fieldElements) { |
575 FieldInfo info = infoCollector._elementToInfo[element]; | 575 FieldInfo info = infoCollector._elementToInfo[element]; |
576 Iterable<Selection> uses = getRetaining(element, closedWorld); | 576 Iterable<Selection> uses = getRetaining(element, closedWorld); |
577 // Don't bother recording an empty list of dependencies. | 577 // Don't bother recording an empty list of dependencies. |
578 for (Selection selection in uses) { | 578 for (Selection selection in uses) { |
579 Info useInfo = infoCollector._elementToInfo[selection.selectedElement]; | 579 Info useInfo = infoCollector._elementToInfo[selection.selectedElement]; |
580 if (useInfo == null) continue; | 580 if (useInfo == null) continue; |
581 info.uses.add(new DependencyInfo(useInfo, '${selection.mask}')); | 581 info.uses.add(new DependencyInfo(useInfo, '${selection.mask}')); |
582 } | 582 } |
(...skipping 30 matching lines...) Expand all Loading... |
613 | 613 |
614 ChunkedConversionSink<Object> sink = encoder.startChunkedConversion( | 614 ChunkedConversionSink<Object> sink = encoder.startChunkedConversion( |
615 new StringConversionSink.fromStringSink(buffer)); | 615 new StringConversionSink.fromStringSink(buffer)); |
616 sink.add(new AllInfoJsonCodec().encode(result)); | 616 sink.add(new AllInfoJsonCodec().encode(result)); |
617 compiler.reporter.reportInfo(NO_LOCATION_SPANNABLE, MessageKind.GENERIC, { | 617 compiler.reporter.reportInfo(NO_LOCATION_SPANNABLE, MessageKind.GENERIC, { |
618 'text': "View the dumped .info.json file at " | 618 'text': "View the dumped .info.json file at " |
619 "https://dart-lang.github.io/dump-info-visualizer" | 619 "https://dart-lang.github.io/dump-info-visualizer" |
620 }); | 620 }); |
621 } | 621 } |
622 } | 622 } |
OLD | NEW |