| 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/incremental_resolved_ast_generator.dart'; | 10 import 'package:front_end/incremental_resolved_ast_generator.dart'; | 
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 166         Uri uri = library.uri; | 166         Uri uri = library.uri; | 
| 167         libraryUris.add(uri); | 167         libraryUris.add(uri); | 
| 168         libraryUriToFile[uri] = library; | 168         libraryUriToFile[uri] = library; | 
| 169       } | 169       } | 
| 170 | 170 | 
| 171       Future<Null> appendNewDillLibraries(Program program) async { | 171       Future<Null> appendNewDillLibraries(Program program) async { | 
| 172         List<DillLibraryBuilder> libraryBuilders = dillTarget.loader | 172         List<DillLibraryBuilder> libraryBuilders = dillTarget.loader | 
| 173             .appendLibraries(program, (uri) => libraryUris.contains(uri)); | 173             .appendLibraries(program, (uri) => libraryUris.contains(uri)); | 
| 174 | 174 | 
| 175         // Compute local scopes. | 175         // Compute local scopes. | 
| 176         await dillTarget.computeOutline(); | 176         await dillTarget.buildOutlines(); | 
| 177 | 177 | 
| 178         // Compute export scopes. | 178         // Compute export scopes. | 
| 179         _computeExportScopes(dillTarget, libraryUriToFile, libraryBuilders); | 179         _computeExportScopes(dillTarget, libraryUriToFile, libraryBuilders); | 
| 180       } | 180       } | 
| 181 | 181 | 
| 182       // Check if there is already a bundle with these libraries. | 182       // Check if there is already a bundle with these libraries. | 
| 183       List<int> bytes = _byteStore.get(kernelKey); | 183       List<int> bytes = _byteStore.get(kernelKey); | 
| 184       if (bytes != null) { | 184       if (bytes != null) { | 
| 185         return _logger.runAsync('Read serialized libraries', () async { | 185         return _logger.runAsync('Read serialized libraries', () async { | 
| 186           var program = new Program(nameRoot: nameRoot); | 186           var program = new Program(nameRoot: nameRoot); | 
| 187           var reader = new BinaryBuilder(bytes); | 187           var reader = new BinaryBuilder(bytes); | 
| 188           reader.readProgram(program); | 188           reader.readProgram(program); | 
| 189 | 189 | 
| 190           await appendNewDillLibraries(program); | 190           await appendNewDillLibraries(program); | 
| 191 | 191 | 
| 192           return new _LibraryCycleResult(cycle, signature, program.libraries); | 192           return new _LibraryCycleResult(cycle, signature, program.libraries); | 
| 193         }); | 193         }); | 
| 194       } | 194       } | 
| 195 | 195 | 
| 196       // Create KernelTarget and configure it for compiling the cycle URIs. | 196       // Create KernelTarget and configure it for compiling the cycle URIs. | 
| 197       KernelTarget kernelTarget = new KernelTarget(_fsState.fileSystemView, | 197       KernelTarget kernelTarget = new KernelTarget(_fsState.fileSystemView, | 
| 198           dillTarget, _uriTranslator, _options.strongMode); | 198           dillTarget, _uriTranslator, _options.strongMode); | 
| 199       for (FileState library in cycle.libraries) { | 199       for (FileState library in cycle.libraries) { | 
| 200         kernelTarget.read(library.uri); | 200         kernelTarget.read(library.uri); | 
| 201       } | 201       } | 
| 202 | 202 | 
| 203       // Compile the cycle libraries into a new full program. | 203       // Compile the cycle libraries into a new full program. | 
| 204       Program program = await _logger | 204       Program program = await _logger | 
| 205           .runAsync('Compile ${cycle.libraries.length} libraries', () async { | 205           .runAsync('Compile ${cycle.libraries.length} libraries', () async { | 
| 206         await kernelTarget.computeOutline(nameRoot: nameRoot); | 206         await kernelTarget.buildOutlines(nameRoot: nameRoot); | 
| 207         return await kernelTarget.writeProgram(null); | 207         return await kernelTarget.buildProgram(); | 
| 208       }); | 208       }); | 
| 209 | 209 | 
| 210       // Add newly compiled libraries into DILL. | 210       // Add newly compiled libraries into DILL. | 
| 211       await appendNewDillLibraries(program); | 211       await appendNewDillLibraries(program); | 
| 212 | 212 | 
| 213       List<Library> kernelLibraries = program.libraries | 213       List<Library> kernelLibraries = program.libraries | 
| 214           .where((library) => libraryUris.contains(library.importUri)) | 214           .where((library) => libraryUris.contains(library.importUri)) | 
| 215           .toList(); | 215           .toList(); | 
| 216 | 216 | 
| 217       _logger.run('Serialize ${kernelLibraries.length} libraries', () { | 217       _logger.run('Serialize ${kernelLibraries.length} libraries', () { | 
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 284   /// TODO(scheglov) Use API signatures. | 284   /// TODO(scheglov) Use API signatures. | 
| 285   /// TODO(scheglov) Or use tree shaking and compute signatures of outlines. | 285   /// TODO(scheglov) Or use tree shaking and compute signatures of outlines. | 
| 286   final String signature; | 286   final String signature; | 
| 287 | 287 | 
| 288   /// Kernel libraries for libraries in the [cycle].  Bodies of dependencies | 288   /// Kernel libraries for libraries in the [cycle].  Bodies of dependencies | 
| 289   /// are not included, but but references to those dependencies are included. | 289   /// are not included, but but references to those dependencies are included. | 
| 290   final List<Library> kernelLibraries; | 290   final List<Library> kernelLibraries; | 
| 291 | 291 | 
| 292   _LibraryCycleResult(this.cycle, this.signature, this.kernelLibraries); | 292   _LibraryCycleResult(this.cycle, this.signature, this.kernelLibraries); | 
| 293 } | 293 } | 
| OLD | NEW | 
|---|