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 30 matching lines...) Expand all Loading... |
41 void run() { | 41 void run() { |
42 compiler.dumpInfoTask._constantToNode.forEach((constant, node) { | 42 compiler.dumpInfoTask._constantToNode.forEach((constant, node) { |
43 // TODO(sigmund): add dependencies on other constants | 43 // TODO(sigmund): add dependencies on other constants |
44 var size = compiler.dumpInfoTask._nodeToSize[node]; | 44 var size = compiler.dumpInfoTask._nodeToSize[node]; |
45 var code = jsAst.prettyPrint(node, compiler); | 45 var code = jsAst.prettyPrint(node, compiler); |
46 var info = new ConstantInfo( | 46 var info = new ConstantInfo( |
47 size: size, code: code, outputUnit: _unitInfoForConstant(constant)); | 47 size: size, code: code, outputUnit: _unitInfoForConstant(constant)); |
48 _constantToInfo[constant] = info; | 48 _constantToInfo[constant] = info; |
49 result.constants.add(info); | 49 result.constants.add(info); |
50 }); | 50 }); |
51 (compiler.libraryLoader.libraries as Iterable<LibraryElement>) | 51 compiler.libraryLoader.libraries.forEach(visit); |
52 .forEach(visit); | |
53 } | 52 } |
54 | 53 |
55 Info visit(Element e, [_]) => e.accept(this, null); | 54 Info visit(Element e, [_]) => e.accept(this, null); |
56 | 55 |
57 /// Whether to emit information about [element]. | 56 /// Whether to emit information about [element]. |
58 /// | 57 /// |
59 /// By default we emit information for any element that contributes to the | 58 /// By default we emit information for any element that contributes to the |
60 /// output size. Either because the it is a function being emitted or inlined, | 59 /// output size. Either because the it is a function being emitted or inlined, |
61 /// or because it is an element that holds dependencies to other elements. | 60 /// or because it is an element that holds dependencies to other elements. |
62 bool shouldKeep(Element element) { | 61 bool shouldKeep(Element element) { |
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 | 616 |
618 ChunkedConversionSink<Object> sink = encoder.startChunkedConversion( | 617 ChunkedConversionSink<Object> sink = encoder.startChunkedConversion( |
619 new StringConversionSink.fromStringSink(buffer)); | 618 new StringConversionSink.fromStringSink(buffer)); |
620 sink.add(new AllInfoJsonCodec().encode(result)); | 619 sink.add(new AllInfoJsonCodec().encode(result)); |
621 compiler.reporter.reportInfo(NO_LOCATION_SPANNABLE, MessageKind.GENERIC, { | 620 compiler.reporter.reportInfo(NO_LOCATION_SPANNABLE, MessageKind.GENERIC, { |
622 'text': "View the dumped .info.json file at " | 621 'text': "View the dumped .info.json file at " |
623 "https://dart-lang.github.io/dump-info-visualizer" | 622 "https://dart-lang.github.io/dump-info-visualizer" |
624 }); | 623 }); |
625 } | 624 } |
626 } | 625 } |
OLD | NEW |