| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 /** | 5 /** |
| 6 * Specialized integers and floating point numbers, | 6 * Specialized integers and floating point numbers, |
| 7 * with SIMD support and efficient lists. | 7 * with SIMD support and efficient lists. |
| 8 */ | 8 */ |
| 9 library dart.typed_data.implementation; | 9 library dart.typed_data.implementation; |
| 10 | 10 |
| (...skipping 1867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1878 } | 1878 } |
| 1879 | 1879 |
| 1880 /// Checks that the value is a Uint32. If not, it's not valid as an array | 1880 /// Checks that the value is a Uint32. If not, it's not valid as an array |
| 1881 /// index or offset. Also ensures that the value is non-negative. | 1881 /// index or offset. Also ensures that the value is non-negative. |
| 1882 bool _isInvalidArrayIndex(int index) { | 1882 bool _isInvalidArrayIndex(int index) { |
| 1883 return (JS('bool', '(# >>> 0 !== #)', index, index)); | 1883 return (JS('bool', '(# >>> 0 !== #)', index, index)); |
| 1884 } | 1884 } |
| 1885 | 1885 |
| 1886 /// Checks that [index] is a valid index into [list] which has length [length]. | 1886 /// Checks that [index] is a valid index into [list] which has length [length]. |
| 1887 /// | 1887 /// |
| 1888 /// That is, [index] is an insteger in the range `0..length - 1`. | 1888 /// That is, [index] is an integer in the range `0..length - 1`. |
| 1889 void _checkValidIndex(int index, List list, int length) { | 1889 void _checkValidIndex(int index, List list, int length) { |
| 1890 if (_isInvalidArrayIndex(index) || JS('int', '#', index) >= length) { | 1890 if (_isInvalidArrayIndex(index) || JS('int', '#', index) >= length) { |
| 1891 throw diagnoseIndexError(list, index); | 1891 throw diagnoseIndexError(list, index); |
| 1892 } | 1892 } |
| 1893 } | 1893 } |
| 1894 | 1894 |
| 1895 /// Checks that [start] and [end] form a range of a list of length [length]. | 1895 /// Checks that [start] and [end] form a range of a list of length [length]. |
| 1896 /// | 1896 /// |
| 1897 /// That is: `start` and `end` are integers with `0 <= start <= end <= length`. | 1897 /// That is: `start` and `end` are integers with `0 <= start <= end <= length`. |
| 1898 /// If `end` is `null` in which case it is considered to be `length` | 1898 /// If `end` is `null` in which case it is considered to be `length` |
| 1899 /// | 1899 /// |
| 1900 /// Returns the actual value of `end`, which is `length` if `end` is `null`, and | 1900 /// Returns the actual value of `end`, which is `length` if `end` is `null`, and |
| 1901 /// the original value of `end` otherwise. | 1901 /// the original value of `end` otherwise. |
| 1902 int _checkValidRange(int start, int end, int length) { | 1902 int _checkValidRange(int start, int end, int length) { |
| 1903 if (_isInvalidArrayIndex(start) || // Ensures start is non-negative int. | 1903 if (_isInvalidArrayIndex(start) || // Ensures start is non-negative int. |
| 1904 ((end == null) | 1904 ((end == null) |
| 1905 ? start > length | 1905 ? start > length |
| 1906 : (_isInvalidArrayIndex(end) || start > end || end > length))) { | 1906 : (_isInvalidArrayIndex(end) || start > end || end > length))) { |
| 1907 throw diagnoseRangeError(start, end, length); | 1907 throw diagnoseRangeError(start, end, length); |
| 1908 } | 1908 } |
| 1909 if (end == null) return length; | 1909 if (end == null) return length; |
| 1910 return end; | 1910 return end; |
| 1911 } | 1911 } |
| OLD | NEW |