Index: sdk/lib/_internal/js_runtime/lib/async_patch.dart |
diff --git a/sdk/lib/_internal/js_runtime/lib/async_patch.dart b/sdk/lib/_internal/js_runtime/lib/async_patch.dart |
index 893a2ebb044f27f7f7de91f19bafdfc1be420b97..cd590cd31d57644f8626901d14a72684dd1c6bd1 100644 |
--- a/sdk/lib/_internal/js_runtime/lib/async_patch.dart |
+++ b/sdk/lib/_internal/js_runtime/lib/async_patch.dart |
@@ -130,40 +130,41 @@ class Timer { |
} |
} |
-/// Runtime support for async-await transformation. |
-/// |
-/// This function is called by a transformed function on each await and return |
-/// in the untransformed function, and before starting. |
-/// |
-/// If [object] is not a future it will be wrapped in a `new Future.value`. |
-/// |
-/// If [asyncBody] is [async_error_codes.SUCCESS]/[async_error_codes.ERROR] it |
-/// indicates a return or throw from the async function, and |
-/// complete/completeError is called on [completer] with [object]. |
-/// |
-/// Otherwise [asyncBody] is set up to be called when the future is completed |
-/// with a code [async_error_codes.SUCCESS]/[async_error_codes.ERROR] depending |
-/// on the success of the future. |
-/// |
-/// Returns the future of the completer for convenience of the first call. |
-dynamic _asyncHelper( |
- dynamic object, |
- dynamic /* int | _WrappedAsyncBody */ bodyFunctionOrErrorCode, |
- Completer completer) { |
- if (identical(bodyFunctionOrErrorCode, async_error_codes.SUCCESS)) { |
- completer.complete(object); |
- return; |
- } else if (identical(bodyFunctionOrErrorCode, async_error_codes.ERROR)) { |
- // The error is a js-error. |
- completer.completeError( |
- unwrapException(object), getTraceFromException(object)); |
- return; |
- } |
- |
- _awaitOnObject(object, bodyFunctionOrErrorCode); |
+/// Runtime support for the async-await transformation. Initiates the |
floitsch
2017/05/03 10:14:25
The first sentence should say what the function do
sra1
2017/05/03 17:12:20
Done.
|
+/// asynchronous computation of [bodyFunction]. Returns the future of the |
+/// completer for convenience of the transformed code. |
+dynamic _asyncStart(_WrappedAsyncBody bodyFunction, Completer completer) { |
+ // Expansion and specialization of `await null`. |
+ Function thenCallback = |
+ (result) => bodyFunction(async_error_codes.SUCCESS, result); |
+ // We can skip the zone registration, since the bodyFunction is already |
+ // registered (see [_wrapJsFunctionForAsync]). |
+ Future._nullFuture._thenNoZoneRegistration(thenCallback, null); |
return completer.future; |
} |
+/// Runtime support for 'await' on [object] in the async-await transformation. |
+/// Sets up [bodyFunction] to be called when the future is completed with a code |
+/// [async_error_codes.SUCCESS]/[async_error_codes.ERROR] depending on the |
+/// success of the future. |
+dynamic _asyncAwait(dynamic object, _WrappedAsyncBody bodyFunction) { |
+ _awaitOnObject(object, bodyFunction); |
+} |
+ |
+/// Runtime support for the async-await transformation. Returns [object] from |
floitsch
2017/05/03 10:14:25
Starting a sentence with "Returns" in a dartdoc pu
sra1
2017/05/03 17:12:20
Done.
|
+/// the async function. |
+dynamic _asyncReturn(dynamic object, Completer completer) { |
+ completer.complete(object); |
+} |
+ |
+/// Runtime support for the async-await transformation. Throws from the async |
+/// function. [object] is a JavaScript Error object. |
+dynamic _asyncRethrow(dynamic object, Completer completer) { |
+ // The error is a js-error. |
+ completer.completeError( |
+ unwrapException(object), getTraceFromException(object)); |
+} |
+ |
/// Awaits on the given [object]. |
/// |
/// If the [object] is a Future, registers on it, otherwise wraps it into a |