| OLD | NEW |
| 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 /// An entrypoint used to run portions of dart2js and measure its performance. | 5 /// An entrypoint used to run portions of dart2js and measure its performance. |
| 6 library compiler.tool.perf; | 6 library compiler.tool.perf; |
| 7 | 7 |
| 8 import 'dart:async'; | 8 import 'dart:async'; |
| 9 import 'dart:io'; | 9 import 'dart:io'; |
| 10 | 10 |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 Uri resourceUri = _translateUri(uri); | 287 Uri resourceUri = _translateUri(uri); |
| 288 if (resourceUri == null || resourceUri.scheme == 'dart-ext') { | 288 if (resourceUri == null || resourceUri.scheme == 'dart-ext') { |
| 289 throw '$uri not resolved or unsupported.'; | 289 throw '$uri not resolved or unsupported.'; |
| 290 } | 290 } |
| 291 var file = _cache[resourceUri]; | 291 var file = _cache[resourceUri]; |
| 292 if (file != null) return _cache[resourceUri]; | 292 if (file != null) return _cache[resourceUri]; |
| 293 return _cache[resourceUri] = await _readFile(resourceUri); | 293 return _cache[resourceUri] = await _readFile(resourceUri); |
| 294 } | 294 } |
| 295 | 295 |
| 296 Future<SourceFile> _readFile(Uri uri) async { | 296 Future<SourceFile> _readFile(Uri uri) async { |
| 297 var data = await inputProvider.readFromUri(uri); | 297 return await inputProvider.readFromUri(uri, inputKind: InputKind.utf8); |
| 298 if (data is List<int>) return new Utf8BytesSourceFile(uri, data); | |
| 299 if (data is String) return new StringSourceFile.fromUri(uri, data); | |
| 300 // TODO(sigmund): properly handle errors, just report, return null, wrap | |
| 301 // above and continue... | |
| 302 throw "Expected a 'String' or a 'List<int>' from the input " | |
| 303 "provider, but got: ${data.runtimeType}."; | |
| 304 } | 298 } |
| 305 | 299 |
| 306 Uri _translateUri(Uri uri) { | 300 Uri _translateUri(Uri uri) { |
| 307 if (uri.scheme == 'dart') return sdkLibraries[uri.path]; | 301 if (uri.scheme == 'dart') return sdkLibraries[uri.path]; |
| 308 if (uri.scheme == 'package') return _translatePackageUri(uri); | 302 if (uri.scheme == 'package') return _translatePackageUri(uri); |
| 309 return uri; | 303 return uri; |
| 310 } | 304 } |
| 311 | 305 |
| 312 Uri _translatePackageUri(Uri uri) { | 306 Uri _translatePackageUri(Uri uri) { |
| 313 checkValidPackageUri(uri); | 307 checkValidPackageUri(uri); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 print('compilation failed!'); | 376 print('compilation failed!'); |
| 383 exit(1); | 377 exit(1); |
| 384 } | 378 } |
| 385 | 379 |
| 386 backend.onResolutionEnd(); | 380 backend.onResolutionEnd(); |
| 387 closeResolution(); | 381 closeResolution(); |
| 388 var program = (backend as dynamic).kernelTask.program; | 382 var program = (backend as dynamic).kernelTask.program; |
| 389 print('total libraries: ${program.libraries.length}'); | 383 print('total libraries: ${program.libraries.length}'); |
| 390 }); | 384 }); |
| 391 } | 385 } |
| OLD | NEW |