| 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 de6940a68793edc95de35615496c411542ccc6dd..c57b3d2be0819541eec1420696df3ba552fed7a8 100644
|
| --- a/sdk/lib/_internal/js_runtime/lib/async_patch.dart
|
| +++ b/sdk/lib/_internal/js_runtime/lib/async_patch.dart
|
| @@ -195,22 +195,28 @@ void _awaitOnObject(object, _WrappedAsyncBody bodyFunction) {
|
| typedef void _WrappedAsyncBody(int errorCode, dynamic result);
|
|
|
| _WrappedAsyncBody _wrapJsFunctionForAsync(dynamic /* js function */ function) {
|
| - var protected = JS('', """
|
| - // Invokes [function] with [errorCode] and [result].
|
| - //
|
| - // If (and as long as) the invocation throws, calls [function] again,
|
| - // with an error-code.
|
| - function(errorCode, result) {
|
| - while (true) {
|
| - try {
|
| - #(errorCode, result);
|
| - break;
|
| - } catch (error) {
|
| - result = error;
|
| - errorCode = #;
|
| - }
|
| - }
|
| - }""", function, async_error_codes.ERROR);
|
| + var protected = JS(
|
| + '',
|
| + """
|
| + (function (fn, ERROR) {
|
| + // Invokes [function] with [errorCode] and [result].
|
| + //
|
| + // If (and as long as) the invocation throws, calls [function] again,
|
| + // with an error-code.
|
| + return function(errorCode, result) {
|
| + while (true) {
|
| + try {
|
| + fn(errorCode, result);
|
| + break;
|
| + } catch (error) {
|
| + result = error;
|
| + errorCode = ERROR;
|
| + }
|
| + }
|
| + }
|
| + })(#, #)""",
|
| + function, async_error_codes.ERROR);
|
| +
|
| return Zone.current.registerBinaryCallback((int errorCode, dynamic result) {
|
| JS('', '#(#, #)', protected, errorCode, result);
|
| });
|
| @@ -444,22 +450,25 @@ class _SyncStarIterator implements Iterator {
|
| _SyncStarIterator(this._body);
|
|
|
| _runBody() {
|
| - return JS('', '''
|
| -// Invokes [body] with [errorCode] and [result].
|
| -//
|
| -// If (and as long as) the invocation throws, calls [function] again,
|
| -// with an error-code.
|
| -(function(body) {
|
| - var errorValue, errorCode = #;
|
| - while (true) {
|
| - try {
|
| - return body(errorCode, errorValue);
|
| - } catch (error) {
|
| - errorValue = error;
|
| - errorCode = #
|
| - }
|
| - }
|
| -})(#)''', async_error_codes.SUCCESS, async_error_codes.ERROR, _body);
|
| + // TODO(sra): Find a way to hard-wire SUCCESS and ERROR codes.
|
| + return JS('',
|
| + '''
|
| + // Invokes [body] with [errorCode] and [result].
|
| + //
|
| + // If (and as long as) the invocation throws, calls [function] again,
|
| + // with an error-code.
|
| + (function(body, SUCCESS, ERROR) {
|
| + var errorValue, errorCode = SUCCESS;
|
| + while (true) {
|
| + try {
|
| + return body(errorCode, errorValue);
|
| + } catch (error) {
|
| + errorValue = error;
|
| + errorCode = ERROR;
|
| + }
|
| + }
|
| + })(#, #, #)''',
|
| + _body, async_error_codes.SUCCESS, async_error_codes.ERROR);
|
| }
|
|
|
|
|
|
|