Chromium Code Reviews| Index: frog/lib/corelib_impl.dart |
| =================================================================== |
| --- frog/lib/corelib_impl.dart (revision 2921) |
| +++ frog/lib/corelib_impl.dart (working copy) |
| @@ -72,7 +72,28 @@ |
| List<E> getRange(int start, int length) native |
| "return this.slice(start, start + length);"; |
| - void setRange(int start, int length, List<E> from, [int startFrom]) native; |
| + void setRange(int start, int length, List<E> from, [int startFrom]) { |
| + // length of 0 prevails and should not throw exceptions. |
| + if (length == 0) |
|
Jennifer Messerly
2012/01/05 17:59:33
style nit: we generally put these on one line, or
dominich
2012/01/05 18:19:57
Done.
|
| + return; |
| + |
| + if (length < 0) |
| + throw new IllegalArgumentException('length is negative in setRange'); |
| + |
| + if (start < 0) |
| + throw new IndexOutOfRangeException(start); |
| + if (start + length > this.length) |
| + throw new IndexOutOfRangeException(start + length); |
| + startFrom = (startFrom == null ? 0 : startFrom); |
| + if (startFrom < 0) |
| + throw new IndexOutOfRangeException(startFrom); |
| + if (startFrom + length > from.length) |
| + throw new IndexOutOfRangeException(startFrom + length); |
| + |
| + for (var i = 0; i < length; ++i) |
| + this[start + i] = from[startFrom + i]; |
| + } |
| + |
| void removeRange(int start, int length) native "this.splice(start, length);"; |
| void insertRange(int start, int length, [E initialValue]) native |