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

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

Issue 2781423003: Start preparing tests to accept binary compiler input. (Closed)
Patch Set: .. Created 3 years, 8 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 | pkg/compiler/lib/src/use_unused_api.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';
9 import 'dart:io'; 8 import 'dart:io';
10 import 'dart:math' as math; 9 import 'dart:math' as math;
11 import 'dart:typed_data'; 10 import 'dart:typed_data';
12 11
13 import '../compiler.dart' as api show Diagnostic; 12 import '../compiler.dart' as api show Diagnostic;
14 import '../compiler_new.dart' as api; 13 import '../compiler_new.dart' as api;
15 import '../compiler_new.dart'; 14 import '../compiler_new.dart';
16 import 'colors.dart' as colors; 15 import 'colors.dart' as colors;
17 import 'dart2js.dart' show AbortLeg; 16 import 'dart2js.dart' show AbortLeg;
18 import 'filenames.dart'; 17 import 'filenames.dart';
19 import 'io/source_file.dart'; 18 import 'io/source_file.dart';
20 import 'util/uri_extras.dart'; 19 import 'util/uri_extras.dart';
21 20
22 abstract class SourceFileProvider implements CompilerInput { 21 abstract class SourceFileProvider implements CompilerInput {
23 bool isWindows = (Platform.operatingSystem == 'windows'); 22 bool isWindows = (Platform.operatingSystem == 'windows');
24 Uri cwd = currentDirectory; 23 Uri cwd = currentDirectory;
25 Map<Uri, SourceFile> sourceFiles = <Uri, SourceFile>{}; 24 Map<Uri, SourceFile> sourceFiles = <Uri, SourceFile>{};
26 int dartCharactersRead = 0; 25 int dartCharactersRead = 0;
27 26
28 Future<String> readStringFromUri(Uri resourceUri) {
29 return readUtf8BytesFromUri(resourceUri).then(UTF8.decode);
30 }
31
32 Future<List<int>> readUtf8BytesFromUri(Uri resourceUri) { 27 Future<List<int>> readUtf8BytesFromUri(Uri resourceUri) {
33 if (resourceUri.scheme == 'file') { 28 if (resourceUri.scheme == 'file') {
34 return _readFromFile(resourceUri); 29 return _readFromFile(resourceUri);
35 } else if (resourceUri.scheme == 'http' || resourceUri.scheme == 'https') { 30 } else if (resourceUri.scheme == 'http' || resourceUri.scheme == 'https') {
36 return _readFromHttp(resourceUri); 31 return _readFromHttp(resourceUri);
37 } else { 32 } else {
38 throw new ArgumentError("Unknown scheme in uri '$resourceUri'"); 33 throw new ArgumentError("Unknown scheme in uri '$resourceUri'");
39 } 34 }
40 } 35 }
41 36
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 if (path.startsWith('/bazel-root')) { 404 if (path.startsWith('/bazel-root')) {
410 path = path.substring('/bazel-root/'.length); 405 path = path.substring('/bazel-root/'.length);
411 for (var dir in dirs) { 406 for (var dir in dirs) {
412 var file = dir.resolve(path); 407 var file = dir.resolve(path);
413 if (await new File.fromUri(file).exists()) { 408 if (await new File.fromUri(file).exists()) {
414 resolvedUri = file; 409 resolvedUri = file;
415 break; 410 break;
416 } 411 }
417 } 412 }
418 } 413 }
419 var result = await readUtf8BytesFromUri(resolvedUri); 414 List<int> result = await readUtf8BytesFromUri(resolvedUri);
420 sourceFiles[uri] = sourceFiles[resolvedUri]; 415 sourceFiles[uri] = sourceFiles[resolvedUri];
421 return result; 416 return result;
422 } 417 }
423 } 418 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/use_unused_api.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698