Index: runtime/lib/async_patch.dart |
diff --git a/runtime/lib/async_patch.dart b/runtime/lib/async_patch.dart |
index 682ee8b10a4ec2d6b8496a5f06496f428819a00e..99c02eeb05cd72c736f398389fc9566fefd11e16 100644 |
--- a/runtime/lib/async_patch.dart |
+++ b/runtime/lib/async_patch.dart |
@@ -4,3 +4,28 @@ |
import "dart:_internal"; |
+// We need to pass the value as first argument and leave the second and third |
+// arguments empty (used for error handling). |
+// See vm/ast_transformer.cc for usage. |
+Function _asyncThenWrapperHelper(continuation) { |
+ return Zone.current.registerUnaryCallback((x) => continuation(x, null, null)); |
+} |
+ |
+// We need to pass the exception and stack trace objects as second and third |
+// parameter to the continuation. See vm/ast_transformer.cc for usage. |
+Function _asyncErrorWrapperHelper(continuation) { |
+ return Zone.current.registerBinaryCallback( |
+ (e, s) => continuation(null, e, s)); |
+} |
+ |
+Future _awaitHelper( |
+ var future, Function thenCallback, Function errorCallback) { |
Lasse Reichstein Nielsen
2015/08/06 14:19:58
remove the "var", rename "future" to "result" (it
floitsch
2015/08/11 15:27:50
changed to 'expression'. "Result" would be the res
floitsch
2015/08/11 15:28:37
Actually changed to "object".
|
+ if (future is! Future) { |
+ future = new Future.value(future); |
+ } |
Lasse Reichstein Nielsen
2015/08/06 14:19:58
if (result is! Future) {
result = new _Future(
floitsch
2015/08/11 15:27:50
Done.
|
+ if (future is _Future) { |
+ return future._thenNoZoneRegistration(thenCallback, errorCallback); |
+ } else { |
+ return future.then(thenCallback, onError: errorCallback); |
+ } |
+} |