| 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 _interceptors; | 5 part of _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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 } | 98 } |
| 99 } | 99 } |
| 100 | 100 |
| 101 void add(E value) { | 101 void add(E value) { |
| 102 checkGrowable('add'); | 102 checkGrowable('add'); |
| 103 JS('void', r'#.push(#)', this, value); | 103 JS('void', r'#.push(#)', this, value); |
| 104 } | 104 } |
| 105 | 105 |
| 106 E removeAt(int index) { | 106 E removeAt(int index) { |
| 107 checkGrowable('removeAt'); | 107 checkGrowable('removeAt'); |
| 108 if (index is !int) throw new ArgumentError(index); | 108 if (index is !int) throw argumentErrorValue(index); |
| 109 if (index < 0 || index >= length) { | 109 if (index < 0 || index >= length) { |
| 110 throw new RangeError.value(index); | 110 throw new RangeError.value(index); |
| 111 } | 111 } |
| 112 return JS('var', r'#.splice(#, 1)[0]', this, index); | 112 return JS('var', r'#.splice(#, 1)[0]', this, index); |
| 113 } | 113 } |
| 114 | 114 |
| 115 void insert(int index, E value) { | 115 void insert(int index, E value) { |
| 116 checkGrowable('insert'); | 116 checkGrowable('insert'); |
| 117 if (index is !int) throw new ArgumentError(index); | 117 if (index is !int) throw argumentErrorValue(index); |
| 118 if (index < 0 || index > length) { | 118 if (index < 0 || index > length) { |
| 119 throw new RangeError.value(index); | 119 throw new RangeError.value(index); |
| 120 } | 120 } |
| 121 JS('void', r'#.splice(#, 0, #)', this, index, value); | 121 JS('void', r'#.splice(#, 0, #)', this, index, value); |
| 122 } | 122 } |
| 123 | 123 |
| 124 void insertAll(int index, Iterable<E> iterable) { | 124 void insertAll(int index, Iterable<E> iterable) { |
| 125 checkGrowable('insertAll'); | 125 checkGrowable('insertAll'); |
| 126 RangeError.checkValueInInterval(index, 0, this.length, "index"); | 126 RangeError.checkValueInInterval(index, 0, this.length, "index"); |
| 127 if (iterable is! EfficientLength) { | 127 if (iterable is! EfficientLength) { |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 if (matchFound) return match; | 334 if (matchFound) return match; |
| 335 throw IterableElementError.noElement(); | 335 throw IterableElementError.noElement(); |
| 336 } | 336 } |
| 337 | 337 |
| 338 E elementAt(int index) { | 338 E elementAt(int index) { |
| 339 return this[index]; | 339 return this[index]; |
| 340 } | 340 } |
| 341 | 341 |
| 342 List<E> sublist(int start, [int end]) { | 342 List<E> sublist(int start, [int end]) { |
| 343 checkNull(start); // TODO(ahe): This is not specified but co19 tests it. | 343 checkNull(start); // TODO(ahe): This is not specified but co19 tests it. |
| 344 if (start is !int) throw new ArgumentError(start); | 344 if (start is !int) throw argumentErrorValue(start); |
| 345 if (start < 0 || start > length) { | 345 if (start < 0 || start > length) { |
| 346 throw new RangeError.range(start, 0, length); | 346 throw new RangeError.range(start, 0, length); |
| 347 } | 347 } |
| 348 if (end == null) { | 348 if (end == null) { |
| 349 end = length; | 349 end = length; |
| 350 } else { | 350 } else { |
| 351 if (end is !int) throw new ArgumentError(end); | 351 if (end is !int) throw argumentErrorValue(end); |
| 352 if (end < start || end > length) { | 352 if (end < start || end > length) { |
| 353 throw new RangeError.range(end, start, length); | 353 throw new RangeError.range(end, start, length); |
| 354 } | 354 } |
| 355 } | 355 } |
| 356 if (start == end) return <E>[]; | 356 if (start == end) return <E>[]; |
| 357 return new JSArray<E>.markGrowable( | 357 return new JSArray<E>.markGrowable( |
| 358 JS('', r'#.slice(#, #)', this, start, end)); | 358 JS('', r'#.slice(#, #)', this, start, end)); |
| 359 } | 359 } |
| 360 | 360 |
| 361 | 361 |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 | 647 |
| 648 if (_index >= length) { | 648 if (_index >= length) { |
| 649 _current = null; | 649 _current = null; |
| 650 return false; | 650 return false; |
| 651 } | 651 } |
| 652 _current = _iterable[_index]; | 652 _current = _iterable[_index]; |
| 653 _index++; | 653 _index++; |
| 654 return true; | 654 return true; |
| 655 } | 655 } |
| 656 } | 656 } |
| OLD | NEW |