| 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 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 if (info is FieldInfo) info.closures = nestedClosures; | 322 if (info is FieldInfo) info.closures = nestedClosures; |
| 323 | 323 |
| 324 return size; | 324 return size; |
| 325 } | 325 } |
| 326 | 326 |
| 327 OutputUnitInfo _infoFromOutputUnit(OutputUnit outputUnit) { | 327 OutputUnitInfo _infoFromOutputUnit(OutputUnit outputUnit) { |
| 328 return _outputToInfo.putIfAbsent(outputUnit, () { | 328 return _outputToInfo.putIfAbsent(outputUnit, () { |
| 329 // Dump-info currently only works with the full emitter. If another | 329 // Dump-info currently only works with the full emitter. If another |
| 330 // emitter is used it will fail here. | 330 // emitter is used it will fail here. |
| 331 JavaScriptBackend backend = compiler.backend; | 331 JavaScriptBackend backend = compiler.backend; |
| 332 full.Emitter emitter = backend.emitter.emitter; | |
| 333 assert(outputUnit.name != null || outputUnit.isMainOutput); | 332 assert(outputUnit.name != null || outputUnit.isMainOutput); |
| 334 OutputUnitInfo info = new OutputUnitInfo( | 333 OutputUnitInfo info = new OutputUnitInfo( |
| 335 outputUnit.name, emitter.outputBuffers[outputUnit].length); | 334 outputUnit.name, backend.emitter.emitter.generatedSize(outputUnit)); |
| 336 info.imports.addAll(outputUnit.imports | 335 info.imports.addAll(outputUnit.imports |
| 337 .map((d) => compiler.deferredLoadTask.importDeferName[d])); | 336 .map((d) => compiler.deferredLoadTask.importDeferName[d])); |
| 338 result.outputUnits.add(info); | 337 result.outputUnits.add(info); |
| 339 return info; | 338 return info; |
| 340 }); | 339 }); |
| 341 } | 340 } |
| 342 | 341 |
| 343 OutputUnitInfo _unitInfoForElement(Element element) { | 342 OutputUnitInfo _unitInfoForElement(Element element) { |
| 344 return _infoFromOutputUnit( | 343 return _infoFromOutputUnit( |
| 345 compiler.deferredLoadTask.outputUnitForElement(element)); | 344 compiler.deferredLoadTask.outputUnitForElement(element)); |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 | 600 |
| 602 ChunkedConversionSink<Object> sink = encoder.startChunkedConversion( | 601 ChunkedConversionSink<Object> sink = encoder.startChunkedConversion( |
| 603 new StringConversionSink.fromStringSink(buffer)); | 602 new StringConversionSink.fromStringSink(buffer)); |
| 604 sink.add(new AllInfoJsonCodec().encode(result)); | 603 sink.add(new AllInfoJsonCodec().encode(result)); |
| 605 compiler.reporter.reportInfo(NO_LOCATION_SPANNABLE, MessageKind.GENERIC, { | 604 compiler.reporter.reportInfo(NO_LOCATION_SPANNABLE, MessageKind.GENERIC, { |
| 606 'text': "View the dumped .info.json file at " | 605 'text': "View the dumped .info.json file at " |
| 607 "https://dart-lang.github.io/dump-info-visualizer" | 606 "https://dart-lang.github.io/dump-info-visualizer" |
| 608 }); | 607 }); |
| 609 } | 608 } |
| 610 } | 609 } |
| OLD | NEW |