Chromium Code Reviews| Index: sdk/lib/_internal/compiler/js_lib/js_helper.dart |
| diff --git a/sdk/lib/_internal/compiler/js_lib/js_helper.dart b/sdk/lib/_internal/compiler/js_lib/js_helper.dart |
| index f948cab8dd5c94e9a5db82c77f11ff53d8cf7dfa..c448cf5a389c53bc67e3ade9a5683cce0900432b 100644 |
| --- a/sdk/lib/_internal/compiler/js_lib/js_helper.dart |
| +++ b/sdk/lib/_internal/compiler/js_lib/js_helper.dart |
| @@ -3589,8 +3589,24 @@ dynamic asyncHelper(dynamic object, |
| Function _wrapJsFunctionForAsync(dynamic /* js function */ function, |
| int errorCode) { |
| + 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); |
| return (result) { |
| - JS('', '#(#, #)', function, errorCode, result); |
| + JS('', '#(#, #)', protected, errorCode, result); |
| }; |
| } |
| @@ -3760,7 +3776,7 @@ class IterationMarker { |
| } |
| class SyncStarIterator implements Iterator { |
| - final Function _body; |
| + final dynamic _body; |
| // If [runningNested] this is the nested iterator, otherwise it is the |
| // current value. |
| @@ -3769,8 +3785,27 @@ class SyncStarIterator implements Iterator { |
| get current => _runningNested ? _current.current : _current; |
| - SyncStarIterator(body) |
| - : _body = (() => JS('', '#()', body)); |
| + SyncStarIterator(this._body); |
| + |
| + runBody() { |
|
sra1
2015/02/27 20:34:51
Make this private, otherwise I can call it from us
sigurdm
2015/03/02 09:14:47
Good point. Thanks
|
| + 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); |
| + } |
| + |
| bool moveNext() { |
| if (_runningNested) { |
| @@ -3780,7 +3815,7 @@ class SyncStarIterator implements Iterator { |
| _runningNested = false; |
| } |
| } |
| - _current = _body(); |
| + _current = runBody(); |
| if (_current is IterationMarker) { |
| if (_current.state == IterationMarker.ITERATION_ENDED) { |
| _current = null; |