| 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:math"; | 5 import "dart:math"; |
| 6 import "dart:typed_data"; | 6 import "dart:typed_data"; |
| 7 | 7 |
| 8 // Equivalent of calling FATAL from C++ code. | 8 // Equivalent of calling FATAL from C++ code. |
| 9 _fatal(msg) native "DartCore_fatal"; | 9 _fatal(msg) native "DartCore_fatal"; |
| 10 | 10 |
| 11 // The members of this class are cloned and added to each class that | 11 // The members of this class are cloned and added to each class that |
| 12 // represents an enum type. | 12 // represents an enum type. |
| 13 class _EnumHelper { | 13 class _EnumHelper { |
| 14 // Declare the list of enum value names private. When this field is | 14 // Declare the list of enum value names private. When this field is |
| 15 // cloned into a user-defined enum class, the field will be inaccessible | 15 // cloned into a user-defined enum class, the field will be inaccessible |
| 16 // because of the library-specific name suffix. The toString() function | 16 // because of the library-specific name suffix. The toString() function |
| 17 // below can access it because it uses the same name suffix. | 17 // below can access it because it uses the same name suffix. |
| 18 static const List<String> _enum_names = null; | 18 static const List<String> _enum_names = null; |
| 19 String toString() => _enum_names[index]; | 19 String toString() => _enum_names[index]; |
| 20 int get hashCode => _enum_names[index].hashCode; | 20 int get hashCode => _enum_names[index].hashCode; |
| 21 } | 21 } |
| 22 | 22 |
| 23 // _SyncIterable and _syncIterator are used by the compiler to | 23 // _SyncIterable and _syncIterator are used by the compiler to |
| 24 // implement sync* generator functions. A sync* generator allocates | 24 // implement sync* generator functions. A sync* generator allocates |
| 25 // and returns a new _SyncIterable object. | 25 // and returns a new _SyncIterable object. |
| 26 | 26 |
| 27 typedef bool SyncGeneratorCallback(Iterator iterator); | 27 typedef bool _SyncGeneratorCallback(Iterator iterator); |
| 28 | 28 |
| 29 class _SyncIterable extends IterableBase { | 29 class _SyncIterable extends IterableBase { |
| 30 // moveNextFn is the closurized body of the generator function. | 30 // moveNextFn is the closurized body of the generator function. |
| 31 final SyncGeneratorCallback moveNextFn; | 31 final _SyncGeneratorCallback moveNextFn; |
| 32 | 32 |
| 33 const _SyncIterable(this.moveNextFn); | 33 const _SyncIterable(this.moveNextFn); |
| 34 | 34 |
| 35 get iterator { | 35 get iterator { |
| 36 return new _SyncIterator(moveNextFn._clone()); | 36 return new _SyncIterator(moveNextFn._clone()); |
| 37 } | 37 } |
| 38 } | 38 } |
| 39 | 39 |
| 40 class _SyncIterator implements Iterator { | 40 class _SyncIterator implements Iterator { |
| 41 bool isYieldEach; // Set by generated code for the yield* statement. | 41 bool isYieldEach; // Set by generated code for the yield* statement. |
| 42 Iterator yieldEachIterator; | 42 Iterator yieldEachIterator; |
| 43 var _current; // Set by generated code for the yield and yield* statement. | 43 var _current; // Set by generated code for the yield and yield* statement. |
| 44 SyncGeneratorCallback moveNextFn; | 44 _SyncGeneratorCallback moveNextFn; |
| 45 | 45 |
| 46 get current => yieldEachIterator != null | 46 get current => yieldEachIterator != null |
| 47 ? yieldEachIterator.current | 47 ? yieldEachIterator.current |
| 48 : _current; | 48 : _current; |
| 49 | 49 |
| 50 _SyncIterator(this.moveNextFn); | 50 _SyncIterator(this.moveNextFn); |
| 51 | 51 |
| 52 bool moveNext() { | 52 bool moveNext() { |
| 53 if (moveNextFn == null) { | 53 if (moveNextFn == null) { |
| 54 return false; | 54 return false; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 75 continue; | 75 continue; |
| 76 } | 76 } |
| 77 return true; | 77 return true; |
| 78 } | 78 } |
| 79 } | 79 } |
| 80 } | 80 } |
| 81 | 81 |
| 82 patch class StackTrace { | 82 patch class StackTrace { |
| 83 /* patch */ static StackTrace get current native "StackTrace_current"; | 83 /* patch */ static StackTrace get current native "StackTrace_current"; |
| 84 } | 84 } |
| OLD | NEW |