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

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

Issue 2696513003: Add output_type_test (Closed)
Patch Set: 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 | « pkg/compiler/lib/src/inferrer/debug.dart ('k') | pkg/compiler/lib/src/tracer.dart » ('j') | 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 source_file_provider; 5 library source_file_provider;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:convert'; 8 import 'dart:convert';
9 import 'dart:io'; 9 import 'dart:io';
10 import 'dart:math' as math; 10 import 'dart:math' as math;
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 return out.resolve('$outPath.$extension'); 254 return out.resolve('$outPath.$extension');
255 } else { 255 } else {
256 return out.resolve(extension); 256 return out.resolve(extension);
257 } 257 }
258 } 258 }
259 259
260 EventSink<String> call(String name, String extension) { 260 EventSink<String> call(String name, String extension) {
261 return createEventSink(name, extension); 261 return createEventSink(name, extension);
262 } 262 }
263 263
264 EventSink<String> createEventSink(String name, String extension) { 264 Uri createUri(String name, String extension) {
265 Uri uri; 265 Uri uri;
266 bool isPrimaryOutput = false;
267 // TODO (johnniwinther, sigurdm): Make a better interface for
268 // output-providers.
269 if (extension == "deferred_map") { 266 if (extension == "deferred_map") {
270 uri = out.resolve(name); 267 uri = out.resolve(name);
271 } else if (name == '') { 268 } else if (name == '') {
272 if (extension == 'js' || extension == 'dart') { 269 if (extension == 'js' || extension == 'dart') {
273 isPrimaryOutput = true;
274 uri = out; 270 uri = out;
275 } else if (extension == 'precompiled.js') { 271 } else if (extension == 'precompiled.js') {
276 uri = computePrecompiledUri(out); 272 uri = computePrecompiledUri(out);
277 onInfo("File ($uri) is compatible with header" 273 onInfo("File ($uri) is compatible with header"
278 " \"Content-Security-Policy: script-src 'self'\""); 274 " \"Content-Security-Policy: script-src 'self'\"");
279 } else if (extension == 'js.map' || extension == 'dart.map') { 275 } else if (extension == 'js.map' || extension == 'dart.map') {
280 uri = sourceMapOut; 276 uri = sourceMapOut;
281 } else if (extension == 'info.json') { 277 } else if (extension == 'info.json') {
282 String outName = out.path.substring(out.path.lastIndexOf('/') + 1); 278 String outName = out.path.substring(out.path.lastIndexOf('/') + 1);
283 uri = out.resolve('$outName.$extension'); 279 uri = out.resolve('$outName.$extension');
284 } else if (extension == 'data') { 280 } else if (extension == 'data') {
285 if (resolutionOutput == null) { 281 if (resolutionOutput == null) {
286 onFailure('Serialization target unspecified.'); 282 onFailure('Serialization target unspecified.');
287 } 283 }
288 uri = resolutionOutput; 284 uri = resolutionOutput;
289 } else { 285 } else {
290 onFailure('Unknown extension: $extension'); 286 onFailure('Unknown extension: $extension');
291 } 287 }
292 } else { 288 } else {
293 uri = out.resolve('$name.$extension'); 289 uri = out.resolve('$name.$extension');
294 } 290 }
291 return uri;
292 }
293
294 EventSink<String> createEventSink(String name, String extension) {
295 // TODO (johnniwinther, sigurdm): Make a better interface for
296 // output-providers.
297 Uri uri = createUri(name, extension);
298 bool isPrimaryOutput = uri == out;
295 299
296 if (uri.scheme != 'file') { 300 if (uri.scheme != 'file') {
297 onFailure('Unhandled scheme ${uri.scheme} in $uri.'); 301 onFailure('Unhandled scheme ${uri.scheme} in $uri.');
298 } 302 }
299 303
300 RandomAccessFile output; 304 RandomAccessFile output;
301 try { 305 try {
302 output = new File(uri.toFilePath()).openSync(mode: FileMode.WRITE); 306 output = new File(uri.toFilePath()).openSync(mode: FileMode.WRITE);
303 } on FileSystemException catch (e) { 307 } on FileSystemException catch (e) {
304 onFailure('$e'); 308 onFailure('$e');
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 resolvedUri = file; 403 resolvedUri = file;
400 break; 404 break;
401 } 405 }
402 } 406 }
403 } 407 }
404 var result = await readUtf8BytesFromUri(resolvedUri); 408 var result = await readUtf8BytesFromUri(resolvedUri);
405 sourceFiles[uri] = sourceFiles[resolvedUri]; 409 sourceFiles[uri] = sourceFiles[resolvedUri];
406 return result; 410 return result;
407 } 411 }
408 } 412 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/inferrer/debug.dart ('k') | pkg/compiler/lib/src/tracer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698