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