| 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 | 6 |
| 7 import 'package:front_end/file_system.dart'; | 7 import 'package:front_end/file_system.dart'; |
| 8 import 'package:front_end/src/base/api_signature.dart'; | 8 import 'package:front_end/src/base/api_signature.dart'; |
| 9 import 'package:front_end/src/base/performace_logger.dart'; | 9 import 'package:front_end/src/base/performace_logger.dart'; |
| 10 import 'package:front_end/src/base/processed_options.dart'; | 10 import 'package:front_end/src/base/processed_options.dart'; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 /// of the specified file and all files that it transitively depends on to | 41 /// of the specified file and all files that it transitively depends on to |
| 42 /// compute corresponding kernel files (or read them from the [ByteStore]). | 42 /// compute corresponding kernel files (or read them from the [ByteStore]). |
| 43 /// | 43 /// |
| 44 /// A call to [invalidate] removes the specified file from the current file | 44 /// A call to [invalidate] removes the specified file from the current file |
| 45 /// state, so that it will be reread before any following [getKernel] will | 45 /// state, so that it will be reread before any following [getKernel] will |
| 46 /// return a result. | 46 /// return a result. |
| 47 class KernelDriver { | 47 class KernelDriver { |
| 48 /// The version of data format, should be incremented on every format change. | 48 /// The version of data format, should be incremented on every format change. |
| 49 static const int DATA_VERSION = 1; | 49 static const int DATA_VERSION = 1; |
| 50 | 50 |
| 51 /// Options used by the kernel compiler. |
| 52 final ProcessedOptions _options; |
| 53 |
| 51 /// The logger to report compilation progress. | 54 /// The logger to report compilation progress. |
| 52 final PerformanceLog _logger; | 55 final PerformanceLog _logger; |
| 53 | 56 |
| 54 /// The [FileSystem] which should be used by the front end to access files. | 57 /// The [FileSystem] which should be used by the front end to access files. |
| 55 final FileSystem _fileSystem; | 58 final FileSystem _fileSystem; |
| 56 | 59 |
| 57 /// The byte storage to get and put serialized data. | 60 /// The byte storage to get and put serialized data. |
| 58 final ByteStore _byteStore; | 61 final ByteStore _byteStore; |
| 59 | 62 |
| 60 /// The object that knows how to resolve "package:" and "dart:" URIs. | 63 /// The object that knows how to resolve "package:" and "dart:" URIs. |
| 61 final UriTranslator _uriTranslator; | 64 final UriTranslator _uriTranslator; |
| 62 | 65 |
| 63 /// Options used by the kernel compiler. | |
| 64 final ProcessedOptions _options; | |
| 65 | |
| 66 /// The function that is invoked when a new file is about to be added to | 66 /// The function that is invoked when a new file is about to be added to |
| 67 /// the current file state. The [Future] that it returns is awaited before | 67 /// the current file state. The [Future] that it returns is awaited before |
| 68 /// reading the file contents. | 68 /// reading the file contents. |
| 69 final KernelDriverFileAddedFn _fileAddedFn; | 69 final KernelDriverFileAddedFn _fileAddedFn; |
| 70 | 70 |
| 71 /// The salt to mix into all hashes used as keys for serialized data. | 71 /// The salt to mix into all hashes used as keys for serialized data. |
| 72 List<int> _salt; | 72 List<int> _salt; |
| 73 | 73 |
| 74 /// The current file system state. | 74 /// The current file system state. |
| 75 FileSystemState _fsState; | 75 FileSystemState _fsState; |
| 76 | 76 |
| 77 /// The set of absolute file URIs that were reported through [invalidate] | 77 /// The set of absolute file URIs that were reported through [invalidate] |
| 78 /// and not checked for actual changes yet. | 78 /// and not checked for actual changes yet. |
| 79 final Set<Uri> _invalidatedFiles = new Set<Uri>(); | 79 final Set<Uri> _invalidatedFiles = new Set<Uri>(); |
| 80 | 80 |
| 81 /// The object that provides additional information for tests. | 81 /// The object that provides additional information for tests. |
| 82 final _TestView _testView = new _TestView(); | 82 final _TestView _testView = new _TestView(); |
| 83 | 83 |
| 84 KernelDriver(this._logger, this._fileSystem, this._byteStore, | 84 KernelDriver(this._options, this._uriTranslator, |
| 85 this._uriTranslator, this._options, | |
| 86 {KernelDriverFileAddedFn fileAddedFn}) | 85 {KernelDriverFileAddedFn fileAddedFn}) |
| 87 : _fileAddedFn = fileAddedFn { | 86 : _logger = _options.logger, |
| 87 _fileSystem = _options.fileSystem, |
| 88 _byteStore = _options.byteStore, |
| 89 _fileAddedFn = fileAddedFn { |
| 88 _computeSalt(); | 90 _computeSalt(); |
| 89 | 91 |
| 90 Future<Null> onFileAdded(Uri uri) { | 92 Future<Null> onFileAdded(Uri uri) { |
| 91 if (_fileAddedFn != null) { | 93 if (_fileAddedFn != null) { |
| 92 return _fileAddedFn(uri); | 94 return _fileAddedFn(uri); |
| 93 } | 95 } |
| 94 return new Future.value(); | 96 return new Future.value(); |
| 95 } | 97 } |
| 96 | 98 |
| 97 _fsState = new FileSystemState( | 99 _fsState = new FileSystemState( |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 | 381 |
| 380 LibraryCycleResult(this.cycle, this.signature, this.kernelLibraries); | 382 LibraryCycleResult(this.cycle, this.signature, this.kernelLibraries); |
| 381 } | 383 } |
| 382 | 384 |
| 383 @visibleForTesting | 385 @visibleForTesting |
| 384 class _TestView { | 386 class _TestView { |
| 385 /// The list of [LibraryCycle]s compiled for the last delta. | 387 /// The list of [LibraryCycle]s compiled for the last delta. |
| 386 /// It does not include libraries which were read from the cache. | 388 /// It does not include libraries which were read from the cache. |
| 387 final List<LibraryCycle> compiledCycles = []; | 389 final List<LibraryCycle> compiledCycles = []; |
| 388 } | 390 } |
| OLD | NEW |