Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(363)

Side by Side Diff: pkg/compiler/lib/src/library_loader.dart

Issue 3007443002: Use memory source files in compile_from_dill* (Closed)
Patch Set: Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 8
9 import 'package:front_end/front_end.dart' as fe; 9 import 'package:front_end/front_end.dart' as fe;
10 import 'package:kernel/ast.dart' as ir; 10 import 'package:kernel/ast.dart' as ir;
(...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 /// A loader that builds a kernel IR representation of the program (or set of 817 /// A loader that builds a kernel IR representation of the program (or set of
818 /// libraries). 818 /// libraries).
819 /// 819 ///
820 /// It supports loading both .dart source files or pre-compiled .dill files. 820 /// It supports loading both .dart source files or pre-compiled .dill files.
821 /// When given .dart source files, it invokes the shared frontend 821 /// When given .dart source files, it invokes the shared frontend
822 /// (`package:front_end`) to produce the corresponding kernel IR representation. 822 /// (`package:front_end`) to produce the corresponding kernel IR representation.
823 // TODO(sigmund): move this class to a new file under src/kernel/. 823 // TODO(sigmund): move this class to a new file under src/kernel/.
824 class KernelLibraryLoaderTask extends CompilerTask 824 class KernelLibraryLoaderTask extends CompilerTask
825 implements LibraryLoaderTask { 825 implements LibraryLoaderTask {
826 final Uri sdkRoot; 826 final Uri sdkRoot;
827 final Uri _packageConfig;
827 828
828 final DiagnosticReporter reporter; 829 final DiagnosticReporter reporter;
829 830
830 final api.CompilerInput compilerInput; 831 final api.CompilerInput compilerInput;
831 832
832 /// Holds the mapping of Kernel IR to KElements that is constructed as a 833 /// Holds the mapping of Kernel IR to KElements that is constructed as a
833 /// result of loading a program. 834 /// result of loading a program.
834 final KernelToElementMapForImpactImpl _elementMap; 835 final KernelToElementMapForImpactImpl _elementMap;
835 836
836 List<LibraryEntity> _allLoadedLibraries; 837 List<LibraryEntity> _allLoadedLibraries;
837 838
838 KernelLibraryLoaderTask(this.sdkRoot, this._elementMap, this.compilerInput, 839 KernelLibraryLoaderTask(this.sdkRoot, this._packageConfig, this._elementMap,
839 this.reporter, Measurer measurer) 840 this.compilerInput, this.reporter, Measurer measurer)
840 : _allLoadedLibraries = new List<LibraryEntity>(), 841 : _allLoadedLibraries = new List<LibraryEntity>(),
841 super(measurer); 842 super(measurer);
842 843
843 /// Loads an entire Kernel [Program] from a file on disk (note, not just a 844 /// Loads an entire Kernel [Program] from a file on disk (note, not just a
844 /// library, so this name is actually a bit of a misnomer). 845 /// library, so this name is actually a bit of a misnomer).
845 // TODO(efortuna): Rename this once the Element library loader class goes 846 // TODO(efortuna): Rename this once the Element library loader class goes
846 // away. 847 // away.
847 Future<LoadedLibraries> loadLibrary(Uri resolvedUri, 848 Future<LoadedLibraries> loadLibrary(Uri resolvedUri,
848 {bool skipFileWithPartOfTag: false}) { 849 {bool skipFileWithPartOfTag: false}) {
849 return measure(() async { 850 return measure(() async {
850 var isDill = resolvedUri.path.endsWith('.dill'); 851 var isDill = resolvedUri.path.endsWith('.dill');
851 ir.Program program; 852 ir.Program program;
852 if (isDill) { 853 if (isDill) {
853 api.Input input = await compilerInput.readFromUri(resolvedUri, 854 api.Input input = await compilerInput.readFromUri(resolvedUri,
854 inputKind: api.InputKind.binary); 855 inputKind: api.InputKind.binary);
855 program = new ir.Program(); 856 program = new ir.Program();
856 new BinaryBuilder(input.data).readProgram(program); 857 new BinaryBuilder(input.data).readProgram(program);
857 } else { 858 } else {
858 var options = new fe.CompilerOptions() 859 var options = new fe.CompilerOptions()
859 ..fileSystem = new CompilerFileSystem(compilerInput) 860 ..fileSystem = new CompilerFileSystem(compilerInput)
860 ..target = new Dart2jsTarget(new TargetFlags()) 861 ..target = new Dart2jsTarget(new TargetFlags())
861 ..linkedDependencies = [ 862 ..linkedDependencies = [
862 sdkRoot.resolve('_internal/dart2js_platform.dill') 863 sdkRoot.resolve('_internal/dart2js_platform.dill')
863 ] 864 ]
865 ..packagesFileUri = _packageConfig
864 ..onError = (e) => reportFrontEndMessage(reporter, e); 866 ..onError = (e) => reportFrontEndMessage(reporter, e);
865 867
866 program = await fe.kernelForProgram(resolvedUri, options); 868 program = await fe.kernelForProgram(resolvedUri, options);
867 } 869 }
868 if (program == null) return null; 870 if (program == null) return null;
869 return createLoadedLibraries(program); 871 return createLoadedLibraries(program);
870 }); 872 });
871 } 873 }
872 874
873 // Only visible for unit testing. 875 // Only visible for unit testing.
(...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after
1712 } 1714 }
1713 1715
1714 /// API used by the library loader to synchronously scan a library or 1716 /// API used by the library loader to synchronously scan a library or
1715 /// compilation unit and ensure that their library tags are computed. 1717 /// compilation unit and ensure that their library tags are computed.
1716 abstract class ElementScanner { 1718 abstract class ElementScanner {
1717 void scanLibrary(LibraryElement library); 1719 void scanLibrary(LibraryElement library);
1718 void scanUnit(CompilationUnitElement unit); 1720 void scanUnit(CompilationUnitElement unit);
1719 } 1721 }
1720 1722
1721 const _reuseLibrarySubtaskName = "Reuse library"; 1723 const _reuseLibrarySubtaskName = "Reuse library";
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698