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 |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 if (!growable) markFixedList(list); | 291 if (!growable) markFixedList(list); |
292 return new JSArray<E>.typed(list); | 292 return new JSArray<E>.typed(list); |
293 } | 293 } |
294 | 294 |
295 Set<E> toSet() => new Set<E>.from(this); | 295 Set<E> toSet() => new Set<E>.from(this); |
296 | 296 |
297 Iterator<E> get iterator => new ListIterator<E>(this); | 297 Iterator<E> get iterator => new ListIterator<E>(this); |
298 | 298 |
299 int get hashCode => Primitives.objectHashCode(this); | 299 int get hashCode => Primitives.objectHashCode(this); |
300 | 300 |
301 int get length => JS('JSUInt32', r'#.length', this); | 301 int get length => JS('int', r'#.length', this); |
302 | 302 |
303 void set length(int newLength) { | 303 void set length(int newLength) { |
304 if (newLength is !int) throw new ArgumentError(newLength); | 304 if (newLength is !int) throw new ArgumentError(newLength); |
305 if (newLength < 0) throw new RangeError.value(newLength); | 305 if (newLength < 0) throw new RangeError.value(newLength); |
306 checkGrowable('set length'); | 306 checkGrowable('set length'); |
307 JS('void', r'#.length = #', this, newLength); | 307 JS('void', r'#.length = #', this, newLength); |
308 } | 308 } |
309 | 309 |
310 E operator [](int index) { | 310 E operator [](int index) { |
311 if (index is !int) throw new ArgumentError(index); | 311 if (index is !int) throw new ArgumentError(index); |
(...skipping 13 matching lines...) Expand all Loading... |
325 } | 325 } |
326 | 326 |
327 /** | 327 /** |
328 * Dummy subclasses that allow the backend to track more precise | 328 * Dummy subclasses that allow the backend to track more precise |
329 * information about arrays through their type. The CPA type inference | 329 * information about arrays through their type. The CPA type inference |
330 * relies on the fact that these classes do not override [] nor []=. | 330 * relies on the fact that these classes do not override [] nor []=. |
331 */ | 331 */ |
332 class JSMutableArray<E> extends JSArray<E> implements JSMutableIndexable {} | 332 class JSMutableArray<E> extends JSArray<E> implements JSMutableIndexable {} |
333 class JSFixedArray<E> extends JSMutableArray<E> {} | 333 class JSFixedArray<E> extends JSMutableArray<E> {} |
334 class JSExtendableArray<E> extends JSMutableArray<E> {} | 334 class JSExtendableArray<E> extends JSMutableArray<E> {} |
OLD | NEW |