| 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'; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 /// The set of absolute file URIs that were reported through [invalidate] | 72 /// The set of absolute file URIs that were reported through [invalidate] |
| 73 /// and not checked for actual changes yet. | 73 /// and not checked for actual changes yet. |
| 74 final Set<Uri> _invalidatedFiles = new Set<Uri>(); | 74 final Set<Uri> _invalidatedFiles = new Set<Uri>(); |
| 75 | 75 |
| 76 IncrementalKernelGeneratorImpl( | 76 IncrementalKernelGeneratorImpl( |
| 77 this._options, this._uriTranslator, this._entryPoint, | 77 this._options, this._uriTranslator, this._entryPoint, |
| 78 {WatchUsedFilesFn watch}) | 78 {WatchUsedFilesFn watch}) |
| 79 : _logger = _options.logger, | 79 : _logger = _options.logger, |
| 80 _byteStore = _options.byteStore { | 80 _byteStore = _options.byteStore { |
| 81 _computeSalt(); | 81 _computeSalt(); |
| 82 |
| 83 Future<Null> onFileAdded(Uri uri) { |
| 84 if (watch != null) { |
| 85 return watch(uri, true); |
| 86 } |
| 87 return new Future.value(); |
| 88 } |
| 89 |
| 82 _fsState = new FileSystemState( | 90 _fsState = new FileSystemState( |
| 83 _options.fileSystem, _uriTranslator, _salt, (uri) => watch(uri, true)); | 91 _options.fileSystem, _uriTranslator, _salt, onFileAdded); |
| 84 } | 92 } |
| 85 | 93 |
| 86 @override | 94 @override |
| 87 Future<DeltaProgram> computeDelta() async { | 95 Future<DeltaProgram> computeDelta() async { |
| 88 return await _logger.runAsync('Compute delta', () async { | 96 return await _logger.runAsync('Compute delta', () async { |
| 89 await _refreshInvalidatedFiles(); | 97 await _refreshInvalidatedFiles(); |
| 90 | 98 |
| 91 // Ensure that the graph starting at the entry point is ready. | 99 // Ensure that the graph starting at the entry point is ready. |
| 92 FileState entryLibrary = | 100 FileState entryLibrary = |
| 93 await _logger.runAsync('Build graph of files', () async { | 101 await _logger.runAsync('Build graph of files', () async { |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 _invalidatedFiles.clear(); | 305 _invalidatedFiles.clear(); |
| 298 | 306 |
| 299 // Refresh the files. | 307 // Refresh the files. |
| 300 for (var fileUri in invalidatedFiles) { | 308 for (var fileUri in invalidatedFiles) { |
| 301 var file = _fsState.getFileByFileUri(fileUri); | 309 var file = _fsState.getFileByFileUri(fileUri); |
| 302 if (file != null) { | 310 if (file != null) { |
| 303 _logger.writeln('Refresh $fileUri'); | 311 _logger.writeln('Refresh $fileUri'); |
| 304 await file.refresh(); | 312 await file.refresh(); |
| 305 } | 313 } |
| 306 } | 314 } |
| 315 |
| 316 // The file graph might have changed, perform GC. |
| 317 _fsState.gc(_entryPoint); |
| 307 }); | 318 }); |
| 308 } | 319 } |
| 309 | 320 |
| 310 List<int> _writeProgramBytes(Program program, bool filter(Library library)) { | 321 List<int> _writeProgramBytes(Program program, bool filter(Library library)) { |
| 311 ByteSink byteSink = new ByteSink(); | 322 ByteSink byteSink = new ByteSink(); |
| 312 new LimitedBinaryPrinter(byteSink, filter).writeProgramFile(program); | 323 new LimitedBinaryPrinter(byteSink, filter).writeProgramFile(program); |
| 313 return byteSink.builder.takeBytes(); | 324 return byteSink.builder.takeBytes(); |
| 314 } | 325 } |
| 315 } | 326 } |
| 316 | 327 |
| 317 /// Compilation result for a library cycle. | 328 /// Compilation result for a library cycle. |
| 318 class _LibraryCycleResult { | 329 class _LibraryCycleResult { |
| 319 final LibraryCycle cycle; | 330 final LibraryCycle cycle; |
| 320 | 331 |
| 321 /// The signature of the result. | 332 /// The signature of the result. |
| 322 /// | 333 /// |
| 323 /// Currently it is based on the full content of the transitive closure of | 334 /// Currently it is based on the full content of the transitive closure of |
| 324 /// the [cycle] files and all its dependencies. | 335 /// the [cycle] files and all its dependencies. |
| 325 /// TODO(scheglov) Not used yet. | 336 /// TODO(scheglov) Not used yet. |
| 326 /// TODO(scheglov) Use API signatures. | 337 /// TODO(scheglov) Use API signatures. |
| 327 /// TODO(scheglov) Or use tree shaking and compute signatures of outlines. | 338 /// TODO(scheglov) Or use tree shaking and compute signatures of outlines. |
| 328 final String signature; | 339 final String signature; |
| 329 | 340 |
| 330 /// Kernel libraries for libraries in the [cycle]. Bodies of dependencies | 341 /// Kernel libraries for libraries in the [cycle]. Bodies of dependencies |
| 331 /// are not included, but but references to those dependencies are included. | 342 /// are not included, but but references to those dependencies are included. |
| 332 final List<Library> kernelLibraries; | 343 final List<Library> kernelLibraries; |
| 333 | 344 |
| 334 _LibraryCycleResult(this.cycle, this.signature, this.kernelLibraries); | 345 _LibraryCycleResult(this.cycle, this.signature, this.kernelLibraries); |
| 335 } | 346 } |
| OLD | NEW |