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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 checkNull(length); // TODO(ahe): This is not specified but co19 tests it. | 71 checkNull(length); // TODO(ahe): This is not specified but co19 tests it. |
72 if (start is !int) throw new ArgumentError(start); | 72 if (start is !int) throw new ArgumentError(start); |
73 if (length is !int) throw new ArgumentError(length); | 73 if (length is !int) throw new ArgumentError(length); |
74 if (length < 0) throw new ArgumentError(length); | 74 if (length < 0) throw new ArgumentError(length); |
75 if (start < 0) throw new RangeError.value(start); | 75 if (start < 0) throw new RangeError.value(start); |
76 int end = start + length; | 76 int end = start + length; |
77 if (end > this.length) { | 77 if (end > this.length) { |
78 throw new RangeError.value(length); | 78 throw new RangeError.value(length); |
79 } | 79 } |
80 if (length < 0) throw new ArgumentError(length); | 80 if (length < 0) throw new ArgumentError(length); |
81 return JS('List', r'#.slice(#, #)', this, start, end); | 81 return JS('=List', r'#.slice(#, #)', this, start, end); |
82 } | 82 } |
83 | 83 |
84 void insertRange(int start, int length, [E initialValue]) { | 84 void insertRange(int start, int length, [E initialValue]) { |
85 return listInsertRange(this, start, length, initialValue); | 85 return listInsertRange(this, start, length, initialValue); |
86 } | 86 } |
87 | 87 |
88 E get last => this[length - 1]; | 88 E get last => this[length - 1]; |
89 | 89 |
90 E get first => this[0]; | 90 E get first => this[0]; |
91 | 91 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 bool get isEmpty => length == 0; | 162 bool get isEmpty => length == 0; |
163 | 163 |
164 String toString() => Collections.collectionToString(this); | 164 String toString() => Collections.collectionToString(this); |
165 | 165 |
166 ListIterator iterator() => new ListIterator(this); | 166 ListIterator iterator() => new ListIterator(this); |
167 | 167 |
168 int get hashCode => Primitives.objectHashCode(receiver); | 168 int get hashCode => Primitives.objectHashCode(receiver); |
169 | 169 |
170 Type get runtimeType => createRuntimeType('List'); | 170 Type get runtimeType => createRuntimeType('List'); |
171 } | 171 } |
OLD | NEW |