Chromium Code Reviews| 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"; |
| 11 import 'dart:_internal' as internal; | 11 import 'dart:_internal' as internal; |
| 12 | 12 |
| 13 // Equivalent of calling FATAL from C++ code. | 13 // Equivalent of calling FATAL from C++ code. |
| 14 _fatal(msg) native "DartCore_fatal"; | 14 _fatal(msg) native "DartCore_fatal"; |
| 15 | 15 |
| 16 // The members of this class are cloned and added to each class that | 16 // The members of this class are cloned and added to each class that |
| 17 // represents an enum type. | 17 // represents an enum type. |
| 18 class _EnumHelper { | 18 class _EnumHelper { |
| 19 String _name; | 19 String _name; |
| 20 String toString() => _name; | 20 String toString() => _name; |
| 21 int get hashCode => _name.hashCode; | 21 int get hashCode => _name.hashCode; |
| 22 } | 22 } |
| 23 | 23 |
| 24 // _SyncIterable and _syncIterator are used by the compiler to | 24 // _SyncIterable and _syncIterator are used by the compiler to |
| 25 // implement sync* generator functions. A sync* generator allocates | 25 // implement sync* generator functions. A sync* generator allocates |
| 26 // and returns a new _SyncIterable object. | 26 // and returns a new _SyncIterable object. |
| 27 | 27 |
| 28 typedef bool SyncGeneratorCallback(Iterator iterator); | 28 typedef bool _SyncGeneratorCallback(Iterator iterator); |
| 29 | 29 |
| 30 class _SyncIterable extends IterableBase { | 30 class _SyncIterable extends IterableBase { |
| 31 // moveNextFn is the closurized body of the generator function. | 31 // moveNextFn is the closurized body of the generator function. |
| 32 final SyncGeneratorCallback moveNextFn; | 32 final _SyncGeneratorCallback moveNextFn; |
|
Lasse Reichstein Nielsen
2016/12/08 12:25:32
Not your CL, but ...
I don't think this field shou
Kevin Millikin (Google)
2016/12/09 08:38:59
That should be noncontroversial, so I'll just chan
| |
| 33 | 33 |
| 34 const _SyncIterable(this.moveNextFn); | 34 const _SyncIterable(this.moveNextFn); |
| 35 | 35 |
| 36 get iterator { | 36 get iterator { |
| 37 return new _SyncIterator(moveNextFn._clone()); | 37 return new _SyncIterator(moveNextFn._clone()); |
| 38 } | 38 } |
| 39 } | 39 } |
| 40 | 40 |
| 41 class _SyncIterator implements Iterator { | 41 class _SyncIterator implements Iterator { |
| 42 bool isYieldEach; // Set by generated code for the yield* statement. | 42 bool isYieldEach; // Set by generated code for the yield* statement. |
| 43 Iterator yieldEachIterator; | 43 Iterator yieldEachIterator; |
| 44 var _current; // Set by generated code for the yield and yield* statement. | 44 var _current; // Set by generated code for the yield and yield* statement. |
| 45 SyncGeneratorCallback moveNextFn; | 45 _SyncGeneratorCallback moveNextFn; |
|
Lasse Reichstein Nielsen
2016/12/08 12:25:32
All of these should be private, the user gets acce
| |
| 46 | 46 |
| 47 get current => yieldEachIterator != null | 47 get current => yieldEachIterator != null |
| 48 ? yieldEachIterator.current | 48 ? yieldEachIterator.current |
| 49 : _current; | 49 : _current; |
| 50 | 50 |
| 51 _SyncIterator(this.moveNextFn); | 51 _SyncIterator(this.moveNextFn); |
| 52 | 52 |
| 53 bool moveNext() { | 53 bool moveNext() { |
| 54 if (moveNextFn == null) { | 54 if (moveNextFn == null) { |
| 55 return false; | 55 return false; |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 76 continue; | 76 continue; |
| 77 } | 77 } |
| 78 return true; | 78 return true; |
| 79 } | 79 } |
| 80 } | 80 } |
| 81 } | 81 } |
| 82 | 82 |
| 83 @patch class StackTrace { | 83 @patch class StackTrace { |
| 84 @patch static StackTrace get current native "StackTrace_current"; | 84 @patch static StackTrace get current native "StackTrace_current"; |
| 85 } | 85 } |
| OLD | NEW |