| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 library dart2js.library_loader; | 5 library dart2js.library_loader; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:io' show Platform; | 8 import 'dart:io' show Platform; |
| 9 | 9 |
| 10 import 'package:front_end/front_end.dart' as fe; | 10 import 'package:front_end/front_end.dart' as fe; |
| (...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 847 {bool skipFileWithPartOfTag: false}) { | 847 {bool skipFileWithPartOfTag: false}) { |
| 848 return measure(() async { | 848 return measure(() async { |
| 849 var isDill = resolvedUri.path.endsWith('.dill'); | 849 var isDill = resolvedUri.path.endsWith('.dill'); |
| 850 ir.Program program; | 850 ir.Program program; |
| 851 if (isDill) { | 851 if (isDill) { |
| 852 api.Input input = await compilerInput.readFromUri(resolvedUri, | 852 api.Input input = await compilerInput.readFromUri(resolvedUri, |
| 853 inputKind: api.InputKind.binary); | 853 inputKind: api.InputKind.binary); |
| 854 program = new ir.Program(); | 854 program = new ir.Program(); |
| 855 new BinaryBuilder(input.data).readProgram(program); | 855 new BinaryBuilder(input.data).readProgram(program); |
| 856 } else { | 856 } else { |
| 857 // TODO(sigmund): remove this hack. Ship platform.dill with the SDK |
| 858 // instead. |
| 859 // Note: this logic only works on development and bot configurations, |
| 860 // but will not work when using dart2js outside the repo. |
| 861 var executableUri = new Uri.file(Platform.resolvedExecutable); |
| 862 Uri platformFile = executableUri.path.endsWith('dart-sdk/bin/dart') |
| 863 ? executableUri.resolve('../../patched_dart2js_sdk/platform.dill') |
| 864 : executableUri.resolve('patched_dart2js_sdk/platform.dill'); |
| 857 var options = new fe.CompilerOptions() | 865 var options = new fe.CompilerOptions() |
| 858 ..fileSystem = new CompilerFileSystem(compilerInput) | 866 ..fileSystem = new CompilerFileSystem(compilerInput) |
| 859 ..target = new Dart2jsTarget(new TargetFlags()) | 867 ..target = new Dart2jsTarget(new TargetFlags()) |
| 860 ..compileSdk = true | 868 ..compileSdk = true |
| 861 ..linkedDependencies = [ | 869 ..linkedDependencies = [platformFile] |
| 862 // TODO(sigmund): infer the location of platform.dill | |
| 863 // once it is shipped as part of the sdk. | |
| 864 new Uri.file(Platform.resolvedExecutable) | |
| 865 .resolve('patched_dart2js_sdk/platform.dill') | |
| 866 ] | |
| 867 ..onError = (e) => reportFrontEndMessage(reporter, e); | 870 ..onError = (e) => reportFrontEndMessage(reporter, e); |
| 868 | 871 |
| 869 program = await fe.kernelForProgram(resolvedUri, options); | 872 program = await fe.kernelForProgram(resolvedUri, options); |
| 870 } | 873 } |
| 871 if (program == null) return null; | 874 if (program == null) return null; |
| 872 return createLoadedLibraries(program); | 875 return createLoadedLibraries(program); |
| 873 }); | 876 }); |
| 874 } | 877 } |
| 875 | 878 |
| 876 // Only visible for unit testing. | 879 // Only visible for unit testing. |
| (...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1692 } | 1695 } |
| 1693 | 1696 |
| 1694 /// API used by the library loader to synchronously scan a library or | 1697 /// API used by the library loader to synchronously scan a library or |
| 1695 /// compilation unit and ensure that their library tags are computed. | 1698 /// compilation unit and ensure that their library tags are computed. |
| 1696 abstract class ElementScanner { | 1699 abstract class ElementScanner { |
| 1697 void scanLibrary(LibraryElement library); | 1700 void scanLibrary(LibraryElement library); |
| 1698 void scanUnit(CompilationUnitElement unit); | 1701 void scanUnit(CompilationUnitElement unit); |
| 1699 } | 1702 } |
| 1700 | 1703 |
| 1701 const _reuseLibrarySubtaskName = "Reuse library"; | 1704 const _reuseLibrarySubtaskName = "Reuse library"; |
| OLD | NEW |