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

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

Issue 2897683002: Move code for instantiating Invocation to Target. (Closed)
Patch Set: Rename vmTarget to targetInfo. 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 } 107 }
108 } 108 }
109 109
110 class CompileTask { 110 class CompileTask {
111 final CompilerContext c; 111 final CompilerContext c;
112 final Ticker ticker; 112 final Ticker ticker;
113 113
114 CompileTask(this.c, this.ticker); 114 CompileTask(this.c, this.ticker);
115 115
116 DillTarget createDillTarget(TranslateUri uriTranslator) { 116 DillTarget createDillTarget(TranslateUri uriTranslator) {
117 return new DillTarget(ticker, uriTranslator); 117 return new DillTarget(ticker, uriTranslator, c.options.target);
118 } 118 }
119 119
120 KernelTarget createKernelTarget( 120 KernelTarget createKernelTarget(
121 DillTarget dillTarget, TranslateUri uriTranslator, bool strongMode) { 121 DillTarget dillTarget, TranslateUri uriTranslator, bool strongMode) {
122 return new KernelTarget( 122 return new KernelTarget(
123 c.fileSystem, dillTarget, uriTranslator, strongMode, c.uriToSource); 123 c.fileSystem, dillTarget, uriTranslator, strongMode, c.uriToSource);
124 } 124 }
125 125
126 Future<KernelTarget> buildOutline([Uri output]) async { 126 Future<KernelTarget> buildOutline([Uri output]) async {
127 TranslateUri uriTranslator = await TranslateUri.parse( 127 TranslateUri uriTranslator = await TranslateUri.parse(
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 Future<CompilationResult> parseScript( 172 Future<CompilationResult> parseScript(
173 Uri fileName, Uri packages, Uri patchedSdk, 173 Uri fileName, Uri packages, Uri patchedSdk,
174 {bool verbose: false, bool strongMode: false}) async { 174 {bool verbose: false, bool strongMode: false}) async {
175 return parseScriptInFileSystem( 175 return parseScriptInFileSystem(
176 fileName, PhysicalFileSystem.instance, packages, patchedSdk, 176 fileName, PhysicalFileSystem.instance, packages, patchedSdk,
177 verbose: verbose, strongMode: strongMode); 177 verbose: verbose, strongMode: strongMode);
178 } 178 }
179 179
180 Future<CompilationResult> parseScriptInFileSystem( 180 Future<CompilationResult> parseScriptInFileSystem(
181 Uri fileName, FileSystem fileSystem, Uri packages, Uri patchedSdk, 181 Uri fileName, FileSystem fileSystem, Uri packages, Uri patchedSdk,
182 {bool verbose: false, bool strongMode: false}) async { 182 {bool verbose: false, bool strongMode: false, String backendTarget}) async {
183 backendTarget ??= "vm";
183 try { 184 try {
184 if (!await fileSystem.entityForUri(fileName).exists()) { 185 if (!await fileSystem.entityForUri(fileName).exists()) {
185 return new CompilationResult.error( 186 return new CompilationResult.error(
186 formatUnexpected(fileName, -1, "No such file.")); 187 formatUnexpected(fileName, -1, "No such file."));
187 } 188 }
188 if (!await new Directory.fromUri(patchedSdk).exists()) { 189 if (!await new Directory.fromUri(patchedSdk).exists()) {
189 return new CompilationResult.error( 190 return new CompilationResult.error(
190 formatUnexpected(patchedSdk, -1, "Patched sdk directory not found.")); 191 formatUnexpected(patchedSdk, -1, "Patched sdk directory not found."));
191 } 192 }
192 193
193 Program program; 194 Program program;
194 try { 195 try {
195 TranslateUri uriTranslator = 196 TranslateUri uriTranslator =
196 await TranslateUri.parse(fileSystem, null, packages); 197 await TranslateUri.parse(fileSystem, null, packages);
197 final Ticker ticker = new Ticker(isVerbose: verbose); 198 final Ticker ticker = new Ticker(isVerbose: verbose);
198 final DillTarget dillTarget = new DillTarget(ticker, uriTranslator); 199 final DillTarget dillTarget =
200 new DillTarget(ticker, uriTranslator, backendTarget);
199 _appendDillForUri(dillTarget, patchedSdk.resolve('platform.dill')); 201 _appendDillForUri(dillTarget, patchedSdk.resolve('platform.dill'));
200 final KernelTarget kernelTarget = 202 final KernelTarget kernelTarget =
201 new KernelTarget(fileSystem, dillTarget, uriTranslator, strongMode); 203 new KernelTarget(fileSystem, dillTarget, uriTranslator, strongMode);
202 kernelTarget.read(fileName); 204 kernelTarget.read(fileName);
203 await dillTarget.buildOutlines(); 205 await dillTarget.buildOutlines();
204 await kernelTarget.buildOutlines(); 206 await kernelTarget.buildOutlines();
205 program = await kernelTarget.buildProgram(); 207 program = await kernelTarget.buildProgram();
206 if (kernelTarget.errors.isNotEmpty) { 208 if (kernelTarget.errors.isNotEmpty) {
207 return new CompilationResult.errors(kernelTarget.errors); 209 return new CompilationResult.errors(kernelTarget.errors);
208 } 210 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 } 248 }
247 return compilePlatformInternal( 249 return compilePlatformInternal(
248 c, ticker, patchedSdk, fullOutput, outlineOutput); 250 c, ticker, patchedSdk, fullOutput, outlineOutput);
249 }); 251 });
250 } 252 }
251 253
252 Future writeDepsFile(Uri script, Uri depsFile, Uri output, 254 Future writeDepsFile(Uri script, Uri depsFile, Uri output,
253 {Uri packages, 255 {Uri packages,
254 Uri platform, 256 Uri platform,
255 Iterable<Uri> extraDependencies, 257 Iterable<Uri> extraDependencies,
256 bool verbose: false}) async { 258 bool verbose: false,
259 String backendTarget}) async {
260 backendTarget ??= "vm";
257 Ticker ticker = new Ticker(isVerbose: verbose); 261 Ticker ticker = new Ticker(isVerbose: verbose);
258 await CompilerCommandLine.withGlobalOptions("", [""], 262 await CompilerCommandLine.withGlobalOptions("", [""],
259 (CompilerContext c) async { 263 (CompilerContext c) async {
260 c.options.options["--packages"] = packages; 264 c.options.options["--packages"] = packages;
261 if (verbose) { 265 if (verbose) {
262 c.options.options["--verbose"] = true; 266 c.options.options["--verbose"] = true;
263 } 267 }
264 268
265 TranslateUri uriTranslator = await TranslateUri.parse( 269 TranslateUri uriTranslator = await TranslateUri.parse(
266 c.fileSystem, c.options.sdk, c.options.packages); 270 c.fileSystem, c.options.sdk, c.options.packages);
267 ticker.logMs("Read packages file"); 271 ticker.logMs("Read packages file");
268 DillTarget dillTarget = new DillTarget(ticker, uriTranslator); 272 DillTarget dillTarget =
273 new DillTarget(ticker, uriTranslator, backendTarget);
269 _appendDillForUri(dillTarget, platform); 274 _appendDillForUri(dillTarget, platform);
270 KernelTarget kernelTarget = new KernelTarget(PhysicalFileSystem.instance, 275 KernelTarget kernelTarget = new KernelTarget(PhysicalFileSystem.instance,
271 dillTarget, uriTranslator, false, c.uriToSource); 276 dillTarget, uriTranslator, false, c.uriToSource);
272 277
273 kernelTarget.read(script); 278 kernelTarget.read(script);
274 await dillTarget.buildOutlines(); 279 await dillTarget.buildOutlines();
275 await kernelTarget.loader.buildOutlines(); 280 await kernelTarget.loader.buildOutlines();
276 await kernelTarget.writeDepsFile(output, depsFile, 281 await kernelTarget.writeDepsFile(output, depsFile,
277 extraDependencies: extraDependencies); 282 extraDependencies: extraDependencies);
278 }); 283 });
(...skipping 13 matching lines...) Expand all
292 final BytesBuilder builder = new BytesBuilder(); 297 final BytesBuilder builder = new BytesBuilder();
293 298
294 void add(List<int> data) { 299 void add(List<int> data) {
295 builder.add(data); 300 builder.add(data);
296 } 301 }
297 302
298 void close() { 303 void close() {
299 // Nothing to do. 304 // Nothing to do.
300 } 305 }
301 } 306 }
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