Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'dart:io'; | 6 import 'dart:io'; |
| 7 | 7 |
| 8 import 'package:front_end/file_system.dart'; | 8 import 'package:front_end/file_system.dart'; |
| 9 import 'package:front_end/incremental_kernel_generator.dart'; | 9 import 'package:front_end/incremental_kernel_generator.dart'; |
| 10 import 'package:front_end/src/base/api_signature.dart'; | 10 import 'package:front_end/src/base/api_signature.dart'; |
| 11 import 'package:front_end/src/base/performace_logger.dart'; | 11 import 'package:front_end/src/base/performace_logger.dart'; |
| 12 import 'package:front_end/src/base/processed_options.dart'; | 12 import 'package:front_end/src/base/processed_options.dart'; |
| 13 import 'package:front_end/src/fasta/dill/dill_library_builder.dart'; | 13 import 'package:front_end/src/fasta/dill/dill_library_builder.dart'; |
| 14 import 'package:front_end/src/fasta/dill/dill_target.dart'; | 14 import 'package:front_end/src/fasta/dill/dill_target.dart'; |
| 15 import 'package:front_end/src/fasta/kernel/kernel_target.dart'; | 15 import 'package:front_end/src/fasta/kernel/kernel_target.dart'; |
| 16 import 'package:front_end/src/fasta/ticker.dart'; | 16 import 'package:front_end/src/fasta/ticker.dart'; |
| 17 import 'package:front_end/src/fasta/translate_uri.dart'; | 17 import 'package:front_end/src/fasta/translate_uri.dart'; |
| 18 import 'package:front_end/src/incremental/byte_store.dart'; | 18 import 'package:front_end/src/incremental/byte_store.dart'; |
| 19 import 'package:front_end/src/incremental/file_state.dart'; | 19 import 'package:front_end/src/incremental/file_state.dart'; |
| 20 import 'package:kernel/ast.dart'; | |
| 20 import 'package:kernel/binary/ast_from_binary.dart'; | 21 import 'package:kernel/binary/ast_from_binary.dart'; |
| 21 import 'package:kernel/binary/ast_to_binary.dart'; | 22 import 'package:kernel/binary/ast_to_binary.dart'; |
| 22 import 'package:kernel/kernel.dart' hide Source; | 23 import 'package:kernel/kernel.dart' hide Source; |
| 24 import 'package:kernel/transformations/continuation.dart' as transformAsync; | |
| 25 import 'package:kernel/transformations/erasure.dart' as transformErasure; | |
| 26 import 'package:kernel/transformations/mixin_full_resolution.dart' | |
| 27 as transformMixin; | |
| 23 | 28 |
| 24 dynamic unimplemented() { | 29 dynamic unimplemented() { |
| 25 // TODO(paulberry): get rid of this. | 30 // TODO(paulberry): get rid of this. |
| 26 throw new UnimplementedError(); | 31 throw new UnimplementedError(); |
| 27 } | 32 } |
| 28 | 33 |
| 29 class ByteSink implements Sink<List<int>> { | 34 class ByteSink implements Sink<List<int>> { |
| 30 final BytesBuilder builder = new BytesBuilder(); | 35 final BytesBuilder builder = new BytesBuilder(); |
| 31 | 36 |
| 32 void add(List<int> data) { | 37 void add(List<int> data) { |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 196 var reader = new BinaryBuilder(bytes); | 201 var reader = new BinaryBuilder(bytes); |
| 197 reader.readProgram(program); | 202 reader.readProgram(program); |
| 198 | 203 |
| 199 await appendNewDillLibraries(program); | 204 await appendNewDillLibraries(program); |
| 200 | 205 |
| 201 return new _LibraryCycleResult(cycle, signature, program.libraries); | 206 return new _LibraryCycleResult(cycle, signature, program.libraries); |
| 202 }); | 207 }); |
| 203 } | 208 } |
| 204 | 209 |
| 205 // Create KernelTarget and configure it for compiling the cycle URIs. | 210 // Create KernelTarget and configure it for compiling the cycle URIs. |
| 206 KernelTarget kernelTarget = new KernelTarget(_fsState.fileSystemView, | 211 var kernelTarget = new _IncrementalKernelTarget(_fsState.fileSystemView, |
| 207 dillTarget, _uriTranslator, _options.strongMode); | 212 dillTarget, _uriTranslator, _options.strongMode); |
| 208 for (FileState library in cycle.libraries) { | 213 for (FileState library in cycle.libraries) { |
| 209 kernelTarget.read(library.uri); | 214 kernelTarget.read(library.uri); |
| 210 } | 215 } |
| 211 | 216 |
| 212 // Compile the cycle libraries into a new full program. | 217 // Compile the cycle libraries into a new full program. |
| 213 Program program = await _logger | 218 Program program = await _logger |
| 214 .runAsync('Compile ${cycle.libraries.length} libraries', () async { | 219 .runAsync('Compile ${cycle.libraries.length} libraries', () async { |
| 215 await kernelTarget.buildOutlines(nameRoot: nameRoot); | 220 await kernelTarget.buildOutlines(nameRoot: nameRoot); |
| 216 return await kernelTarget.buildProgram(); | 221 return await kernelTarget.buildProgram(); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 283 } | 288 } |
| 284 | 289 |
| 285 List<int> _writeProgramBytes(Program program, bool filter(Library library)) { | 290 List<int> _writeProgramBytes(Program program, bool filter(Library library)) { |
| 286 ByteSink byteSink = new ByteSink(); | 291 ByteSink byteSink = new ByteSink(); |
| 287 new LibraryFilteringBinaryPrinter(byteSink, filter) | 292 new LibraryFilteringBinaryPrinter(byteSink, filter) |
| 288 .writeProgramFile(program); | 293 .writeProgramFile(program); |
| 289 return byteSink.builder.takeBytes(); | 294 return byteSink.builder.takeBytes(); |
| 290 } | 295 } |
| 291 } | 296 } |
| 292 | 297 |
| 298 class _IncrementalKernelTarget extends KernelTarget { | |
| 299 _IncrementalKernelTarget(FileSystem fileSystem, DillTarget dillTarget, | |
| 300 TranslateUri uriTranslator, bool strongMode) | |
| 301 : super(fileSystem, dillTarget, uriTranslator, strongMode); | |
| 302 | |
| 303 @override | |
| 304 void runBuildTransformations() { | |
|
Siggi Cherem (dart-lang)
2017/05/23 22:06:17
Not sure if we need this subclass: even outside th
| |
| 305 // TODO(scheglov) apply only to source libraries | |
| 306 new transformMixin.MixinFullResolution(backendTarget).transform(program); | |
| 307 if (!strongMode) { | |
| 308 program.accept(new transformErasure.Erasure()); | |
| 309 } | |
| 310 // Transform only source libraries. | |
| 311 // Dill libraries have already been transformed. | |
| 312 transformAsync.transformProgram(program, libraryFilter: isSourceLibrary); | |
| 313 } | |
| 314 } | |
| 315 | |
| 293 /// Compilation result for a library cycle. | 316 /// Compilation result for a library cycle. |
| 294 class _LibraryCycleResult { | 317 class _LibraryCycleResult { |
| 295 final LibraryCycle cycle; | 318 final LibraryCycle cycle; |
| 296 | 319 |
| 297 /// The signature of the result. | 320 /// The signature of the result. |
| 298 /// | 321 /// |
| 299 /// Currently it is based on the full content of the transitive closure of | 322 /// Currently it is based on the full content of the transitive closure of |
| 300 /// the [cycle] files and all its dependencies. | 323 /// the [cycle] files and all its dependencies. |
| 301 /// TODO(scheglov) Not used yet. | 324 /// TODO(scheglov) Not used yet. |
| 302 /// TODO(scheglov) Use API signatures. | 325 /// TODO(scheglov) Use API signatures. |
| 303 /// TODO(scheglov) Or use tree shaking and compute signatures of outlines. | 326 /// TODO(scheglov) Or use tree shaking and compute signatures of outlines. |
| 304 final String signature; | 327 final String signature; |
| 305 | 328 |
| 306 /// Kernel libraries for libraries in the [cycle]. Bodies of dependencies | 329 /// Kernel libraries for libraries in the [cycle]. Bodies of dependencies |
| 307 /// are not included, but but references to those dependencies are included. | 330 /// are not included, but but references to those dependencies are included. |
| 308 final List<Library> kernelLibraries; | 331 final List<Library> kernelLibraries; |
| 309 | 332 |
| 310 _LibraryCycleResult(this.cycle, this.signature, this.kernelLibraries); | 333 _LibraryCycleResult(this.cycle, this.signature, this.kernelLibraries); |
| 311 } | 334 } |
| OLD | NEW |