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

Side by Side Diff: pkg/fasta/lib/src/compile_platform.dart

Issue 2650733003: Use a real program when compiling platform.dill. (Closed)
Patch Set: Rebased on d90b7e967a5e328ae61fb69fcfe7469fff35218a. Created 3 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 fasta.compile_platform; 5 library fasta.compile_platform;
6 6
7 import 'dart:async' show 7 import 'dart:async' show
8 Future; 8 Future;
9 9
10 import 'dart:io' show 10 import 'dart:io' show
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 main(List<String> arguments) async { 84 main(List<String> arguments) async {
85 Uri output = Uri.base.resolveUri(new Uri.file(arguments.single)); 85 Uri output = Uri.base.resolveUri(new Uri.file(arguments.single));
86 DartOptions options = new DartOptions( 86 DartOptions options = new DartOptions(
87 strongMode: false, sdk: await dartAotSdk.value, packagePath: null); 87 strongMode: false, sdk: await dartAotSdk.value, packagePath: null);
88 Repository repository = new Repository(); 88 Repository repository = new Repository();
89 DartLoader loader = new DartLoader(repository, options, null, 89 DartLoader loader = new DartLoader(repository, options, null,
90 ignoreRedirectingFactories: false, 90 ignoreRedirectingFactories: false,
91 dartSdk: createDartSdk(options.sdk, strongMode: options.strongMode)); 91 dartSdk: createDartSdk(options.sdk, strongMode: options.strongMode));
92 Target target = getTarget( 92 Target target = getTarget(
93 "vm", new TargetFlags(strongMode: options.strongMode)); 93 "vm", new TargetFlags(strongMode: options.strongMode));
94 Library dummyLibrary = repository.getLibraryReference(Uri.parse("dummy:")) 94 Program program = loader.loadProgram(
95 ..isExternal = false; 95 Uri.base.resolve("pkg/fasta/test/platform.dart"), target: target);
96 Program program = 96 if (loader.errors.isNotEmpty) {
97 loader.loadProgram(dummyLibrary.importUri, target: target); 97 inputError(null, null, loader.errors.join("\n"));
98 }
99 Library mainLibrary = program.mainMethod.enclosingLibrary;
100 program.uriToSource.remove(mainLibrary.fileUri);
98 program = new Program( 101 program = new Program(
99 program.libraries.where( 102 program.libraries.where(
100 (Library l) => l.importUri.scheme == "dart").toList(), 103 (Library l) => l.importUri.scheme == "dart").toList(),
101 program.uriToSource); 104 program.uriToSource);
102 if (loader.errors.isNotEmpty) {
103 inputError(null, null, loader.errors.join("\n"));
104 }
105 target.transformProgram(program); 105 target.transformProgram(program);
106 for (LibraryElement analyzerLibrary in loader.libraryElements) { 106 for (LibraryElement analyzerLibrary in loader.libraryElements) {
107 Library library = loader.getLibraryReference(analyzerLibrary); 107 Library library = loader.getLibraryReference(analyzerLibrary);
108 StringBuffer sb = new StringBuffer(); 108 StringBuffer sb = new StringBuffer();
109 if (analyzerLibrary.exports.isNotEmpty) { 109 if (analyzerLibrary.exports.isNotEmpty) {
110 Source source; 110 Source source;
111 int offset; 111 int offset;
112 for (ExportElement export in analyzerLibrary.exports) { 112 for (ExportElement export in analyzerLibrary.exports) {
113 source ??= export.source; 113 source ??= export.source;
114 offset ??= export.nameOffset; 114 offset ??= export.nameOffset;
(...skipping 13 matching lines...) Expand all
128 library.addMember(new Field(exports, isStatic: true, isConst: true, 128 library.addMember(new Field(exports, isStatic: true, isConst: true,
129 initializer: literal, fileUri: "${new Uri.file(source.fullName)}") 129 initializer: literal, fileUri: "${new Uri.file(source.fullName)}")
130 ..fileOffset = offset); 130 ..fileOffset = offset);
131 } 131 }
132 } 132 }
133 133
134 IOSink sink = new File.fromUri(output).openWrite(); 134 IOSink sink = new File.fromUri(output).openWrite();
135 new BinaryPrinter(sink).writeProgramFile(program); 135 new BinaryPrinter(sink).writeProgramFile(program);
136 await sink.close(); 136 await sink.close();
137 } 137 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698