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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 if (index is !int) throw argumentErrorValue(index); | 86 if (index is !int) throw argumentErrorValue(index); |
87 if (index < 0 || index > length) { | 87 if (index < 0 || index > length) { |
88 throw new RangeError.value(index); | 88 throw new RangeError.value(index); |
89 } | 89 } |
90 JS('void', r'#.splice(#, 0, #)', this, index, value); | 90 JS('void', r'#.splice(#, 0, #)', this, index, value); |
91 } | 91 } |
92 | 92 |
93 void insertAll(int index, Iterable<E> iterable) { | 93 void insertAll(int index, Iterable<E> iterable) { |
94 checkGrowable('insertAll'); | 94 checkGrowable('insertAll'); |
95 RangeError.checkValueInInterval(index, 0, this.length, "index"); | 95 RangeError.checkValueInInterval(index, 0, this.length, "index"); |
96 if (iterable is! EfficientLength) { | 96 if (iterable is! EfficientLengthIterable) { |
97 iterable = iterable.toList(); | 97 iterable = iterable.toList(); |
98 } | 98 } |
99 int insertionLength = iterable.length; | 99 int insertionLength = iterable.length; |
100 this.length += insertionLength; | 100 this.length += insertionLength; |
101 int end = index + insertionLength; | 101 int end = index + insertionLength; |
102 this.setRange(end, this.length, this, index); | 102 this.setRange(end, this.length, this, index); |
103 this.setRange(index, end, iterable); | 103 this.setRange(index, end, iterable); |
104 } | 104 } |
105 | 105 |
106 void setAll(int index, Iterable<E> iterable) { | 106 void setAll(int index, Iterable<E> iterable) { |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 RangeError.checkValidRange(start, end, this.length); | 404 RangeError.checkValidRange(start, end, this.length); |
405 for (int i = start; i < end; i++) { | 405 for (int i = start; i < end; i++) { |
406 // Store is safe since [fillValue] type has been checked as parameter. | 406 // Store is safe since [fillValue] type has been checked as parameter. |
407 JS('', '#[#] = #', this, i, fillValue); | 407 JS('', '#[#] = #', this, i, fillValue); |
408 } | 408 } |
409 } | 409 } |
410 | 410 |
411 void replaceRange(int start, int end, Iterable<E> replacement) { | 411 void replaceRange(int start, int end, Iterable<E> replacement) { |
412 checkGrowable('replace range'); | 412 checkGrowable('replace range'); |
413 RangeError.checkValidRange(start, end, this.length); | 413 RangeError.checkValidRange(start, end, this.length); |
414 if (replacement is! EfficientLength) { | 414 if (replacement is! EfficientLengthIterable) { |
415 replacement = replacement.toList(); | 415 replacement = replacement.toList(); |
416 } | 416 } |
417 int removeLength = end - start; | 417 int removeLength = end - start; |
418 int insertLength = replacement.length; | 418 int insertLength = replacement.length; |
419 if (removeLength >= insertLength) { | 419 if (removeLength >= insertLength) { |
420 int delta = removeLength - insertLength; | 420 int delta = removeLength - insertLength; |
421 int insertEnd = start + insertLength; | 421 int insertEnd = start + insertLength; |
422 int newLength = this.length - delta; | 422 int newLength = this.length - delta; |
423 this.setRange(start, insertEnd, replacement); | 423 this.setRange(start, insertEnd, replacement); |
424 if (delta != 0) { | 424 if (delta != 0) { |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 | 618 |
619 if (_index >= length) { | 619 if (_index >= length) { |
620 _current = null; | 620 _current = null; |
621 return false; | 621 return false; |
622 } | 622 } |
623 _current = _iterable[_index]; | 623 _current = _iterable[_index]; |
624 _index++; | 624 _index++; |
625 return true; | 625 return true; |
626 } | 626 } |
627 } | 627 } |
OLD | NEW |