| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import "dart:async"; | 5 import "dart:async"; |
| 6 import "dart:collection" show LinkedList, LinkedListEntry; | 6 import "dart:collection" show LinkedList, LinkedListEntry; |
| 7 import 'dart:convert' show ASCII, JSON; | 7 import 'dart:convert' show ASCII, JSON; |
| 8 import "dart:isolate"; | 8 import "dart:isolate"; |
| 9 import "dart:math"; | 9 import "dart:math"; |
| 10 import "dart:typed_data"; | 10 import "dart:typed_data"; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 final _SyncGeneratorCallback _moveNextFn; | 29 final _SyncGeneratorCallback _moveNextFn; |
| 30 | 30 |
| 31 const _SyncIterable(this._moveNextFn); | 31 const _SyncIterable(this._moveNextFn); |
| 32 | 32 |
| 33 get iterator { | 33 get iterator { |
| 34 return new _SyncIterator(_moveNextFn._clone()); | 34 return new _SyncIterator(_moveNextFn._clone()); |
| 35 } | 35 } |
| 36 } | 36 } |
| 37 | 37 |
| 38 class _SyncIterator implements Iterator { | 38 class _SyncIterator implements Iterator { |
| 39 bool isYieldEach; // Set by generated code for the yield* statement. | 39 bool isYieldEach; // Set by generated code for the yield* statement. |
| 40 Iterator yieldEachIterator; | 40 Iterator yieldEachIterator; |
| 41 var _current; // Set by generated code for the yield and yield* statement. | 41 var _current; // Set by generated code for the yield and yield* statement. |
| 42 _SyncGeneratorCallback _moveNextFn; | 42 _SyncGeneratorCallback _moveNextFn; |
| 43 | 43 |
| 44 get current => yieldEachIterator != null | 44 get current => |
| 45 ? yieldEachIterator.current | 45 yieldEachIterator != null ? yieldEachIterator.current : _current; |
| 46 : _current; | |
| 47 | 46 |
| 48 _SyncIterator(this._moveNextFn); | 47 _SyncIterator(this._moveNextFn); |
| 49 | 48 |
| 50 bool moveNext() { | 49 bool moveNext() { |
| 51 if (_moveNextFn == null) { | 50 if (_moveNextFn == null) { |
| 52 return false; | 51 return false; |
| 53 } | 52 } |
| 54 while(true) { | 53 while (true) { |
| 55 if (yieldEachIterator != null) { | 54 if (yieldEachIterator != null) { |
| 56 if (yieldEachIterator.moveNext()) { | 55 if (yieldEachIterator.moveNext()) { |
| 57 return true; | 56 return true; |
| 58 } | 57 } |
| 59 yieldEachIterator = null; | 58 yieldEachIterator = null; |
| 60 } | 59 } |
| 61 isYieldEach = false; | 60 isYieldEach = false; |
| 62 // _moveNextFn() will update the values of isYieldEach and _current. | 61 // _moveNextFn() will update the values of isYieldEach and _current. |
| 63 if (!_moveNextFn(this)) { | 62 if (!_moveNextFn(this)) { |
| 64 _moveNextFn = null; | 63 _moveNextFn = null; |
| 65 _current = null; | 64 _current = null; |
| 66 return false; | 65 return false; |
| 67 } | 66 } |
| 68 if (isYieldEach) { | 67 if (isYieldEach) { |
| 69 // Spec mandates: it is a dynamic error if the class of [the object | 68 // Spec mandates: it is a dynamic error if the class of [the object |
| 70 // returned by yield*] does not implement Iterable. | 69 // returned by yield*] does not implement Iterable. |
| 71 yieldEachIterator = (_current as Iterable).iterator; | 70 yieldEachIterator = (_current as Iterable).iterator; |
| 72 _current = null; | 71 _current = null; |
| 73 continue; | 72 continue; |
| 74 } | 73 } |
| 75 return true; | 74 return true; |
| 76 } | 75 } |
| 77 } | 76 } |
| 78 } | 77 } |
| 79 | 78 |
| 80 @patch class StackTrace { | 79 @patch |
| 81 @patch static StackTrace get current native "StackTrace_current"; | 80 class StackTrace { |
| 81 @patch |
| 82 static StackTrace get current native "StackTrace_current"; |
| 82 } | 83 } |
| OLD | NEW |