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

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

Issue 2893563003: Rename buildOutline() and separate 'build' and 'writeProgram()'. (Closed)
Patch Set: Created 3 years, 7 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) 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; 5 library fasta;
6 6
7 import 'dart:async' show Future; 7 import 'dart:async' show Future;
8 8
9 import 'dart:convert' show JSON; 9 import 'dart:convert' show JSON;
10 10
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 _appendDillForUri(dillTarget, platform); 137 _appendDillForUri(dillTarget, platform);
138 } 138 }
139 String argument = c.options.arguments.first; 139 String argument = c.options.arguments.first;
140 Uri uri = Uri.base.resolve(argument); 140 Uri uri = Uri.base.resolve(argument);
141 String path = uriTranslator.translate(uri)?.path ?? argument; 141 String path = uriTranslator.translate(uri)?.path ?? argument;
142 if (path.endsWith(".dart")) { 142 if (path.endsWith(".dart")) {
143 kernelTarget.read(uri); 143 kernelTarget.read(uri);
144 } else { 144 } else {
145 inputError(uri, -1, "Unexpected input: $uri"); 145 inputError(uri, -1, "Unexpected input: $uri");
146 } 146 }
147 await dillTarget.computeOutline(); 147 await dillTarget.buildOutlines();
148 await kernelTarget.computeOutline(); 148 await kernelTarget.buildOutlines();
149 await kernelTarget.writeOutline(output); 149 await kernelTarget.writeOutline(output);
150 if (c.options.dumpIr && output != null) { 150 if (c.options.dumpIr && output != null) {
151 kernelTarget.dumpIr(); 151 kernelTarget.dumpIr();
152 } 152 }
153 return kernelTarget; 153 return kernelTarget;
154 } 154 }
155 155
156 Future<Uri> compile() async { 156 Future<Uri> compile() async {
157 KernelTarget kernelTarget = await buildOutline(); 157 KernelTarget kernelTarget = await buildOutline();
158 if (exitCode != 0) return null; 158 if (exitCode != 0) return null;
159 Uri uri = c.options.output; 159 Uri uri = c.options.output;
160 await kernelTarget.buildProgram();
160 await kernelTarget.writeProgram(uri, 161 await kernelTarget.writeProgram(uri,
161 dumpIr: c.options.dumpIr, verify: c.options.verify); 162 dumpIr: c.options.dumpIr, verify: c.options.verify);
162 return uri; 163 return uri;
163 } 164 }
164 } 165 }
165 166
166 Future<CompilationResult> parseScript( 167 Future<CompilationResult> parseScript(
167 Uri fileName, Uri packages, Uri patchedSdk, 168 Uri fileName, Uri packages, Uri patchedSdk,
168 {bool verbose: false, bool strongMode: false}) async { 169 {bool verbose: false, bool strongMode: false}) async {
169 return parseScriptInFileSystem( 170 return parseScriptInFileSystem(
(...skipping 17 matching lines...) Expand all
187 Program program; 188 Program program;
188 try { 189 try {
189 TranslateUri uriTranslator = 190 TranslateUri uriTranslator =
190 await TranslateUri.parse(fileSystem, null, packages); 191 await TranslateUri.parse(fileSystem, null, packages);
191 final Ticker ticker = new Ticker(isVerbose: verbose); 192 final Ticker ticker = new Ticker(isVerbose: verbose);
192 final DillTarget dillTarget = new DillTarget(ticker, uriTranslator); 193 final DillTarget dillTarget = new DillTarget(ticker, uriTranslator);
193 _appendDillForUri(dillTarget, patchedSdk.resolve('platform.dill')); 194 _appendDillForUri(dillTarget, patchedSdk.resolve('platform.dill'));
194 final KernelTarget kernelTarget = 195 final KernelTarget kernelTarget =
195 new KernelTarget(fileSystem, dillTarget, uriTranslator, strongMode); 196 new KernelTarget(fileSystem, dillTarget, uriTranslator, strongMode);
196 kernelTarget.read(fileName); 197 kernelTarget.read(fileName);
197 await dillTarget.computeOutline(); 198 await dillTarget.buildOutlines();
198 await kernelTarget.computeOutline(); 199 await kernelTarget.buildOutlines();
199 program = await kernelTarget.writeProgram(null); 200 program = await kernelTarget.buildProgram();
200 if (kernelTarget.errors.isNotEmpty) { 201 if (kernelTarget.errors.isNotEmpty) {
201 return new CompilationResult.errors(kernelTarget.errors 202 return new CompilationResult.errors(kernelTarget.errors
202 .map((err) => err.toString()) 203 .map((err) => err.toString())
203 .toList(growable: false)); 204 .toList(growable: false));
204 } 205 }
205 } on InputError catch (e) { 206 } on InputError catch (e) {
206 return new CompilationResult.error(e.format()); 207 return new CompilationResult.error(e.format());
207 } 208 }
208 209
209 if (program.mainMethod == null) { 210 if (program.mainMethod == null) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 261
261 TranslateUri uriTranslator = await TranslateUri.parse( 262 TranslateUri uriTranslator = await TranslateUri.parse(
262 c.fileSystem, c.options.sdk, c.options.packages); 263 c.fileSystem, c.options.sdk, c.options.packages);
263 ticker.logMs("Read packages file"); 264 ticker.logMs("Read packages file");
264 DillTarget dillTarget = new DillTarget(ticker, uriTranslator); 265 DillTarget dillTarget = new DillTarget(ticker, uriTranslator);
265 _appendDillForUri(dillTarget, platform); 266 _appendDillForUri(dillTarget, platform);
266 KernelTarget kernelTarget = new KernelTarget(PhysicalFileSystem.instance, 267 KernelTarget kernelTarget = new KernelTarget(PhysicalFileSystem.instance,
267 dillTarget, uriTranslator, false, c.uriToSource); 268 dillTarget, uriTranslator, false, c.uriToSource);
268 269
269 kernelTarget.read(script); 270 kernelTarget.read(script);
270 await dillTarget.computeOutline(); 271 await dillTarget.buildOutlines();
271 await kernelTarget.loader.buildOutlines(); 272 await kernelTarget.loader.buildOutlines();
272 await kernelTarget.writeDepsFile(output, depsFile, 273 await kernelTarget.writeDepsFile(output, depsFile,
273 extraDependencies: extraDependencies); 274 extraDependencies: extraDependencies);
274 }); 275 });
275 } 276 }
276 277
277 /// Load the [Program] from the given [uri] and append its libraries 278 /// Load the [Program] from the given [uri] and append its libraries
278 /// to the [dillTarget]. 279 /// to the [dillTarget].
279 void _appendDillForUri(DillTarget dillTarget, Uri uri) { 280 void _appendDillForUri(DillTarget dillTarget, Uri uri) {
280 var bytes = new File.fromUri(uri).readAsBytesSync(); 281 var bytes = new File.fromUri(uri).readAsBytesSync();
281 var platformProgram = loadProgramFromBytes(bytes); 282 var platformProgram = loadProgramFromBytes(bytes);
282 platformProgram.unbindCanonicalNames(); 283 platformProgram.unbindCanonicalNames();
283 dillTarget.loader.appendLibraries(platformProgram); 284 dillTarget.loader.appendLibraries(platformProgram);
284 } 285 }
285 286
286 // TODO(ahe): https://github.com/dart-lang/sdk/issues/28316 287 // TODO(ahe): https://github.com/dart-lang/sdk/issues/28316
287 class ByteSink implements Sink<List<int>> { 288 class ByteSink implements Sink<List<int>> {
288 final BytesBuilder builder = new BytesBuilder(); 289 final BytesBuilder builder = new BytesBuilder();
289 290
290 void add(List<int> data) { 291 void add(List<int> data) {
291 builder.add(data); 292 builder.add(data);
292 } 293 }
293 294
294 void close() { 295 void close() {
295 // Nothing to do. 296 // Nothing to do.
296 } 297 }
297 } 298 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/dill/dill_target.dart ('k') | pkg/front_end/lib/src/fasta/kernel/kernel_target.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698