| Index: sdk/lib/_internal/compiler/implementation/apiimpl.dart
|
| diff --git a/sdk/lib/_internal/compiler/implementation/apiimpl.dart b/sdk/lib/_internal/compiler/implementation/apiimpl.dart
|
| index abb492c7d4fa80274a3e7047fad46981b241b8d8..32a892d24acc3b6bbec5514e3b55f929061f871d 100644
|
| --- a/sdk/lib/_internal/compiler/implementation/apiimpl.dart
|
| +++ b/sdk/lib/_internal/compiler/implementation/apiimpl.dart
|
| @@ -137,12 +137,10 @@ class Compiler extends leg.Compiler {
|
| return "lib/$path";
|
| }
|
|
|
| - elements.LibraryElement scanBuiltinLibrary(String path) {
|
| + Future<elements.LibraryElement> scanBuiltinLibrary(String path) {
|
| Uri uri = libraryRoot.resolve(lookupLibraryPath(path));
|
| Uri canonicalUri = new Uri(scheme: "dart", path: path);
|
| - elements.LibraryElement library =
|
| - libraryLoader.loadLibrary(uri, null, canonicalUri);
|
| - return library;
|
| + return libraryLoader.loadLibrary(uri, null, canonicalUri);
|
| }
|
|
|
| void log(message) {
|
| @@ -161,32 +159,29 @@ class Compiler extends leg.Compiler {
|
| /**
|
| * Reads the script designated by [readableUri].
|
| */
|
| - leg.Script readScript(Uri readableUri, [tree.Node node]) {
|
| + Future<leg.Script> readScript(Uri readableUri, [tree.Node node]) {
|
| if (!readableUri.isAbsolute) {
|
| internalError('Relative uri $readableUri provided to readScript(Uri)',
|
| node: node);
|
| }
|
| - return fileReadingTask.measure(() {
|
| +
|
| + return fileReadingTask.measureAsync(() {
|
| Uri resourceUri = translateUri(readableUri, node);
|
| - String text = "";
|
| - try {
|
| - // TODO(ahe): We expect the future to be complete and call value
|
| - // directly. In effect, we don't support truly asynchronous API.
|
| - text = deprecatedFutureValue(provider(resourceUri));
|
| - } catch (exception) {
|
| + return provider(resourceUri).then((text) {
|
| + SourceFile sourceFile = new SourceFile(resourceUri.toString(), text);
|
| + // We use [readableUri] as the URI for the script since need to preserve
|
| + // the scheme in the script because [Script.uri] is used for resolving
|
| + // relative URIs mentioned in the script. See the comment on
|
| + // [LibraryLoader] for more details.
|
| + return new leg.Script(readableUri, sourceFile);
|
| + }).catchError((error) {
|
| if (node != null) {
|
| - cancel("$exception", node: node);
|
| + cancel("$error", node: node);
|
| } else {
|
| - reportDiagnostic(null, "$exception", api.Diagnostic.ERROR);
|
| - throw new leg.CompilerCancelledException("$exception");
|
| + reportDiagnostic(null, "$error", api.Diagnostic.ERROR);
|
| + throw new leg.CompilerCancelledException("$error");
|
| }
|
| - }
|
| - SourceFile sourceFile = new SourceFile(resourceUri.toString(), text);
|
| - // We use [readableUri] as the URI for the script since need to preserve
|
| - // the scheme in the script because [Script.uri] is used for resolving
|
| - // relative URIs mentioned in the script. See the comment on
|
| - // [LibraryLoader] for more details.
|
| - return new leg.Script(readableUri, sourceFile);
|
| + });
|
| });
|
| }
|
|
|
| @@ -257,18 +252,19 @@ class Compiler extends leg.Compiler {
|
|
|
| translatePackageUri(Uri uri, tree.Node node) => packageRoot.resolve(uri.path);
|
|
|
| - bool run(Uri uri) {
|
| + Future<bool> run(Uri uri) {
|
| log('Allowed library categories: $allowedLibraryCategories');
|
| - bool success = super.run(uri);
|
| - int cumulated = 0;
|
| - for (final task in tasks) {
|
| - cumulated += task.timing;
|
| - log('${task.name} took ${task.timing}msec');
|
| - }
|
| - int total = totalCompileTime.elapsedMilliseconds;
|
| - log('Total compile-time ${total}msec;'
|
| - ' unaccounted ${total - cumulated}msec');
|
| - return success;
|
| + return super.run(uri).then((success) {
|
| + int cumulated = 0;
|
| + for (final task in tasks) {
|
| + cumulated += task.timing;
|
| + log('${task.name} took ${task.timing}msec');
|
| + }
|
| + int total = totalCompileTime.elapsedMilliseconds;
|
| + log('Total compile-time ${total}msec;'
|
| + ' unaccounted ${total - cumulated}msec');
|
| + return success;
|
| + });
|
| }
|
|
|
| void reportDiagnostic(leg.SourceSpan span, String message,
|
|
|