| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 leg_apiimpl; | 5 library leg_apiimpl; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import '../compiler.dart' as api; | 9 import '../compiler.dart' as api; |
| 10 import 'dart2jslib.dart' as leg; | 10 import 'dart2jslib.dart' as leg; |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 void reportReadError(exception) { | 166 void reportReadError(exception) { |
| 167 withCurrentElement(element, () { | 167 withCurrentElement(element, () { |
| 168 reportError(node, | 168 reportError(node, |
| 169 leg.MessageKind.READ_SCRIPT_ERROR, | 169 leg.MessageKind.READ_SCRIPT_ERROR, |
| 170 {'uri': readableUri, 'exception': exception}); | 170 {'uri': readableUri, 'exception': exception}); |
| 171 }); | 171 }); |
| 172 } | 172 } |
| 173 | 173 |
| 174 Uri resourceUri = translateUri(readableUri, node); | 174 Uri resourceUri = translateUri(readableUri, node); |
| 175 // TODO(johnniwinther): Wrap the result from [provider] in a specialized | 175 // TODO(johnniwinther): Wrap the result from [provider] in a specialized |
| 176 // [Future] to ensure that we never execute an asynchronous action without s
etting | 176 // [Future] to ensure that we never execute an asynchronous action without |
| 177 // up the current element of the compiler. | 177 // setting up the current element of the compiler. |
| 178 return new Future.sync(() => callUserProvider(resourceUri)) | 178 return new Future.sync(() => callUserProvider(resourceUri)).then((data) { |
| 179 .then((data) { | |
| 180 SourceFile sourceFile; | 179 SourceFile sourceFile; |
| 181 String resourceUriString = resourceUri.toString(); | 180 String resourceUriString = resourceUri.toString(); |
| 182 if (data is List<int>) { | 181 if (data is List<int>) { |
| 183 sourceFile = new Utf8BytesSourceFile(resourceUriString, data); | 182 sourceFile = new Utf8BytesSourceFile(resourceUriString, data); |
| 184 } else if (data is String) { | 183 } else if (data is String) { |
| 185 sourceFile = new StringSourceFile(resourceUriString, data); | 184 sourceFile = new StringSourceFile(resourceUriString, data); |
| 186 } else { | 185 } else { |
| 187 String message = "Expected a 'String' or a 'List<int>' from the input " | 186 String message = "Expected a 'String' or a 'List<int>' from the input " |
| 188 "provider, but got: ${Error.safeToString(data)}."; | 187 "provider, but got: ${Error.safeToString(data)}."; |
| 189 reportReadError(message); | 188 reportReadError(message); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 rethrow; | 323 rethrow; |
| 325 } | 324 } |
| 326 } | 325 } |
| 327 | 326 |
| 328 void diagnoseCrashInUserCode(String message, exception, stackTrace) { | 327 void diagnoseCrashInUserCode(String message, exception, stackTrace) { |
| 329 hasCrashed = true; | 328 hasCrashed = true; |
| 330 print('$message: ${tryToString(exception)}'); | 329 print('$message: ${tryToString(exception)}'); |
| 331 print(tryToString(stackTrace)); | 330 print(tryToString(stackTrace)); |
| 332 } | 331 } |
| 333 } | 332 } |
| OLD | NEW |