OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 part of dart._interceptors; | 5 part of dart._interceptors; |
6 | 6 |
7 /** | 7 /** |
8 * The interceptor class for [List]. The compiler recognizes this | 8 * The interceptor class for [List]. The compiler recognizes this |
9 * class as an interceptor, and changes references to [:this:] to | 9 * class as an interceptor, and changes references to [:this:] to |
10 * actually use the receiver of the method, which is generated as an extra | 10 * actually use the receiver of the method, which is generated as an extra |
11 * argument added to each member. | 11 * argument added to each member. |
12 */ | 12 */ |
13 @JsPeerInterface(name: 'Array') | 13 @JsPeerInterface(name: 'Array') |
14 class JSArray<E> implements List<E>, JSIndexable<E> { | 14 class JSArray<E> implements List<E>, JSIndexable<E> { |
15 const JSArray(); | 15 const JSArray(); |
16 | 16 |
17 /** | 17 /** |
18 * Constructor for adding type parameters to an existing JavaScript | 18 * Constructor for adding type parameters to an existing JavaScript |
19 * Array. Used for creating literal lists. | 19 * Array. Used for creating literal lists. |
20 */ | 20 */ |
21 factory JSArray.of(allocation) { | 21 factory JSArray.of(allocation) { |
22 // TODO(sra): Move this to core.List for better readability. | 22 // TODO(sra): Move this to core.List for better readability. |
23 // Capture the parameterized ES6 'JSArray' class. | 23 // Capture the parameterized ES6 'JSArray' class. |
24 return dart.setType(allocation, JS('', 'JSArray')); | 24 return JS('-dynamic', '#', dart.setType(allocation, JS('', 'JSArray'))); |
25 } | 25 } |
26 | 26 |
27 // TODO(jmesserly): consider a fixed array subclass instead. | 27 // TODO(jmesserly): consider a fixed array subclass instead. |
28 factory JSArray.markFixed(allocation) => | 28 factory JSArray.markFixed(allocation) => |
29 new JSArray<E>.of(markFixedList(allocation)); | 29 new JSArray<E>.of(markFixedList(allocation)); |
30 | 30 |
31 factory JSArray.markGrowable(allocation) = JSArray<E>.of; | 31 factory JSArray.markGrowable(allocation) = JSArray<E>.of; |
32 | 32 |
33 static List markFixedList(List list) { | 33 static List markFixedList(List list) { |
34 // Functions are stored in the hidden class and not as properties in | 34 // Functions are stored in the hidden class and not as properties in |
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 | 626 |
627 if (_index >= length) { | 627 if (_index >= length) { |
628 _current = null; | 628 _current = null; |
629 return false; | 629 return false; |
630 } | 630 } |
631 _current = _iterable[_index]; | 631 _current = _iterable[_index]; |
632 _index++; | 632 _index++; |
633 return true; | 633 return true; |
634 } | 634 } |
635 } | 635 } |
OLD | NEW |