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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 var saltBuilder = new ApiSignature(); | 275 var saltBuilder = new ApiSignature(); |
276 saltBuilder.addInt(DATA_VERSION); | 276 saltBuilder.addInt(DATA_VERSION); |
277 saltBuilder.addBool(_options.strongMode); | 277 saltBuilder.addBool(_options.strongMode); |
278 saltBuilder.addString(_entryPoint.toString()); | 278 saltBuilder.addString(_entryPoint.toString()); |
279 _salt = saltBuilder.toByteList(); | 279 _salt = saltBuilder.toByteList(); |
280 } | 280 } |
281 | 281 |
282 /// Refresh all the invalidated files and update dependencies. | 282 /// Refresh all the invalidated files and update dependencies. |
283 Future<Null> _refreshInvalidatedFiles() async { | 283 Future<Null> _refreshInvalidatedFiles() async { |
284 await _logger.runAsync('Refresh invalidated files', () async { | 284 await _logger.runAsync('Refresh invalidated files', () async { |
285 for (var fileUri in _invalidatedFiles) { | 285 // Create a copy to avoid concurrent modifications. |
| 286 var invalidatedFiles = _invalidatedFiles.toList(); |
| 287 _invalidatedFiles.clear(); |
| 288 |
| 289 // Refresh the files. |
| 290 for (var fileUri in invalidatedFiles) { |
286 var file = _fsState.getFileByFileUri(fileUri); | 291 var file = _fsState.getFileByFileUri(fileUri); |
287 if (file != null) { | 292 if (file != null) { |
288 _logger.writeln('Refresh $fileUri'); | 293 _logger.writeln('Refresh $fileUri'); |
289 await file.refresh(); | 294 await file.refresh(); |
290 } | 295 } |
291 } | 296 } |
292 _invalidatedFiles.clear(); | |
293 }); | 297 }); |
294 } | 298 } |
295 | 299 |
296 List<int> _writeProgramBytes(Program program, bool filter(Library library)) { | 300 List<int> _writeProgramBytes(Program program, bool filter(Library library)) { |
297 ByteSink byteSink = new ByteSink(); | 301 ByteSink byteSink = new ByteSink(); |
298 new LimitedBinaryPrinter(byteSink, filter).writeProgramFile(program); | 302 new LimitedBinaryPrinter(byteSink, filter).writeProgramFile(program); |
299 return byteSink.builder.takeBytes(); | 303 return byteSink.builder.takeBytes(); |
300 } | 304 } |
301 } | 305 } |
302 | 306 |
303 /// Compilation result for a library cycle. | 307 /// Compilation result for a library cycle. |
304 class _LibraryCycleResult { | 308 class _LibraryCycleResult { |
305 final LibraryCycle cycle; | 309 final LibraryCycle cycle; |
306 | 310 |
307 /// The signature of the result. | 311 /// The signature of the result. |
308 /// | 312 /// |
309 /// Currently it is based on the full content of the transitive closure of | 313 /// Currently it is based on the full content of the transitive closure of |
310 /// the [cycle] files and all its dependencies. | 314 /// the [cycle] files and all its dependencies. |
311 /// TODO(scheglov) Not used yet. | 315 /// TODO(scheglov) Not used yet. |
312 /// TODO(scheglov) Use API signatures. | 316 /// TODO(scheglov) Use API signatures. |
313 /// TODO(scheglov) Or use tree shaking and compute signatures of outlines. | 317 /// TODO(scheglov) Or use tree shaking and compute signatures of outlines. |
314 final String signature; | 318 final String signature; |
315 | 319 |
316 /// Kernel libraries for libraries in the [cycle]. Bodies of dependencies | 320 /// Kernel libraries for libraries in the [cycle]. Bodies of dependencies |
317 /// are not included, but but references to those dependencies are included. | 321 /// are not included, but but references to those dependencies are included. |
318 final List<Library> kernelLibraries; | 322 final List<Library> kernelLibraries; |
319 | 323 |
320 _LibraryCycleResult(this.cycle, this.signature, this.kernelLibraries); | 324 _LibraryCycleResult(this.cycle, this.signature, this.kernelLibraries); |
321 } | 325 } |
OLD | NEW |