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..1827adb2fe618ae35e44e98ac7849ef32ea9ea0b 100644 |
| --- a/sdk/lib/_internal/compiler/js_lib/js_helper.dart |
| +++ b/sdk/lib/_internal/compiler/js_lib/js_helper.dart |
| @@ -3589,8 +3589,20 @@ dynamic asyncHelper(dynamic object, |
| Function _wrapJsFunctionForAsync(dynamic /* js function */ function, |
| int errorCode) { |
| + var protected = JS('', """ |
| + function(errorCode, result) { |
| + while (true) { |
|
floitsch
2015/02/18 12:42:45
Add comment.
// Invokes [function] with [errorCode
sigurdm
2015/02/19 09:14:02
Done.
|
| + try { |
| + #(errorCode, result); |
| + break; |
| + } catch (error) { |
| + result = error; |
| + errorCode = #; |
| + } |
| + } while (false); |
|
floitsch
2015/02/18 12:42:45
while (false); ?
sigurdm
2015/02/19 09:14:02
I started out with
do {
try {
....
} catch
|
| + }""", function, async_error_codes.ERROR); |
| return (result) { |
| - JS('', '#(#, #)', function, errorCode, result); |
| + JS('', '#(#, #)', protected, errorCode, result); |
| }; |
| } |
| @@ -3760,7 +3772,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 +3781,23 @@ class SyncStarIterator implements Iterator { |
| get current => _runningNested ? _current.current : _current; |
| - SyncStarIterator(body) |
| - : _body = (() => JS('', '#()', body)); |
| + SyncStarIterator(this._body); |
| + |
| + runBody() { |
| + return JS('', ''' |
| + (function(body) { |
| + var errorValue, errorCode = #; |
| + while (true) { |
|
floitsch
2015/02/18 12:42:45
ditto.
sigurdm
2015/02/19 09:14:02
Done.
|
| + 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 +3807,7 @@ class SyncStarIterator implements Iterator { |
| _runningNested = false; |
| } |
| } |
| - _current = _body(); |
| + _current = runBody(); |
| if (_current is IterationMarker) { |
| if (_current.state == IterationMarker.ITERATION_ENDED) { |
| _current = null; |