OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 (function(global, exports) { | 5 (function(global, exports) { |
6 | 6 |
7 "use strict"; | 7 "use strict"; |
8 | 8 |
9 %CheckIsBootstrapping(); | 9 %CheckIsBootstrapping(); |
10 | 10 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 var length = %_TypedArrayGetLength(this); | 127 var length = %_TypedArrayGetLength(this); |
128 | 128 |
129 if (IS_UNDEFINED(comparefn)) { | 129 if (IS_UNDEFINED(comparefn)) { |
130 comparefn = TypedArrayComparefn; | 130 comparefn = TypedArrayComparefn; |
131 } | 131 } |
132 | 132 |
133 return %_CallFunction(this, length, comparefn, $innerArraySort); | 133 return %_CallFunction(this, length, comparefn, $innerArraySort); |
134 } | 134 } |
135 | 135 |
136 | 136 |
| 137 // ES6 section 22.2.3.13 |
| 138 function TypedArrayIndexOf(element, index) { |
| 139 if (!%IsTypedArray(this)) throw MakeTypeError(kNotTypedArray); |
| 140 |
| 141 var length = %_TypedArrayGetLength(this); |
| 142 |
| 143 return %_CallFunction(this, element, index, length, $innerArrayIndexOf); |
| 144 } |
| 145 %FunctionSetLength(TypedArrayIndexOf, 1); |
| 146 |
| 147 |
| 148 // ES6 section 22.2.3.16 |
| 149 function TypedArrayLastIndexOf(element, index) { |
| 150 if (!%IsTypedArray(this)) throw MakeTypeError(kNotTypedArray); |
| 151 |
| 152 var length = %_TypedArrayGetLength(this); |
| 153 |
| 154 return %_CallFunction(this, element, index, length, |
| 155 %_ArgumentsLength(), $innerArrayLastIndexOf); |
| 156 } |
| 157 %FunctionSetLength(TypedArrayLastIndexOf, 1); |
| 158 |
| 159 |
137 // ES6 draft 08-24-14, section 22.2.2.2 | 160 // ES6 draft 08-24-14, section 22.2.2.2 |
138 function TypedArrayOf() { | 161 function TypedArrayOf() { |
139 var length = %_ArgumentsLength(); | 162 var length = %_ArgumentsLength(); |
140 var array = new this(length); | 163 var array = new this(length); |
141 for (var i = 0; i < length; i++) { | 164 for (var i = 0; i < length; i++) { |
142 array[i] = %_Arguments(i); | 165 array[i] = %_Arguments(i); |
143 } | 166 } |
144 return array; | 167 return array; |
145 } | 168 } |
146 | 169 |
(...skipping 30 matching lines...) Expand all Loading... |
177 ]); | 200 ]); |
178 | 201 |
179 // Set up non-enumerable functions on the prototype object. | 202 // Set up non-enumerable functions on the prototype object. |
180 $installFunctions(GlobalNAME.prototype, DONT_ENUM, [ | 203 $installFunctions(GlobalNAME.prototype, DONT_ENUM, [ |
181 "copyWithin", TypedArrayCopyWithin, | 204 "copyWithin", TypedArrayCopyWithin, |
182 "every", TypedArrayEvery, | 205 "every", TypedArrayEvery, |
183 "forEach", TypedArrayForEach, | 206 "forEach", TypedArrayForEach, |
184 "find", TypedArrayFind, | 207 "find", TypedArrayFind, |
185 "findIndex", TypedArrayFindIndex, | 208 "findIndex", TypedArrayFindIndex, |
186 "fill", TypedArrayFill, | 209 "fill", TypedArrayFill, |
| 210 "indexOf", TypedArrayIndexOf, |
| 211 "lastIndexOf", TypedArrayLastIndexOf, |
187 "reverse", TypedArrayReverse, | 212 "reverse", TypedArrayReverse, |
188 "sort", TypedArraySort | 213 "sort", TypedArraySort |
189 ]); | 214 ]); |
190 endmacro | 215 endmacro |
191 | 216 |
192 TYPED_ARRAYS(EXTEND_TYPED_ARRAY) | 217 TYPED_ARRAYS(EXTEND_TYPED_ARRAY) |
193 | 218 |
194 }) | 219 }) |
OLD | NEW |