Chromium Code Reviews| 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, utils) { | 5 (function(global, utils) { | 
| 6 | 6 | 
| 7 "use strict"; | 7 "use strict"; | 
| 8 | 8 | 
| 9 %CheckIsBootstrapping(); | 9 %CheckIsBootstrapping(); | 
| 10 | 10 | 
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 | 33 | 
| 34 var ArrayFrom; | 34 var ArrayFrom; | 
| 35 var InnerArrayCopyWithin; | 35 var InnerArrayCopyWithin; | 
| 36 var InnerArrayEvery; | 36 var InnerArrayEvery; | 
| 37 var InnerArrayFill; | 37 var InnerArrayFill; | 
| 38 var InnerArrayFilter; | 38 var InnerArrayFilter; | 
| 39 var InnerArrayFind; | 39 var InnerArrayFind; | 
| 40 var InnerArrayFindIndex; | 40 var InnerArrayFindIndex; | 
| 41 var InnerArrayForEach; | 41 var InnerArrayForEach; | 
| 42 var InnerArrayIndexOf; | 42 var InnerArrayIndexOf; | 
| 43 var InnerArrayJoin; | |
| 43 var InnerArrayLastIndexOf; | 44 var InnerArrayLastIndexOf; | 
| 44 var InnerArrayMap; | 45 var InnerArrayMap; | 
| 45 var InnerArrayReverse; | 46 var InnerArrayReverse; | 
| 46 var InnerArraySome; | 47 var InnerArraySome; | 
| 47 var InnerArraySort; | 48 var InnerArraySort; | 
| 49 var InnerArrayToLocaleString; | |
| 48 var IsNaN; | 50 var IsNaN; | 
| 51 var ObjectToString; | |
| 49 | 52 | 
| 50 utils.Import(function(from) { | 53 utils.Import(function(from) { | 
| 51 ArrayFrom = from.ArrayFrom; | 54 ArrayFrom = from.ArrayFrom; | 
| 52 InnerArrayCopyWithin = from.InnerArrayCopyWithin; | 55 InnerArrayCopyWithin = from.InnerArrayCopyWithin; | 
| 53 InnerArrayEvery = from.InnerArrayEvery; | 56 InnerArrayEvery = from.InnerArrayEvery; | 
| 54 InnerArrayFill = from.InnerArrayFill; | 57 InnerArrayFill = from.InnerArrayFill; | 
| 55 InnerArrayFilter = from.InnerArrayFilter; | 58 InnerArrayFilter = from.InnerArrayFilter; | 
| 56 InnerArrayFind = from.InnerArrayFind; | 59 InnerArrayFind = from.InnerArrayFind; | 
| 57 InnerArrayFindIndex = from.InnerArrayFindIndex; | 60 InnerArrayFindIndex = from.InnerArrayFindIndex; | 
| 58 InnerArrayForEach = from.InnerArrayForEach; | 61 InnerArrayForEach = from.InnerArrayForEach; | 
| 59 InnerArrayIndexOf = from.InnerArrayIndexOf; | 62 InnerArrayIndexOf = from.InnerArrayIndexOf; | 
| 63 InnerArrayJoin = from.InnerArrayJoin; | |
| 60 InnerArrayLastIndexOf = from.InnerArrayLastIndexOf; | 64 InnerArrayLastIndexOf = from.InnerArrayLastIndexOf; | 
| 61 InnerArrayMap = from.InnerArrayMap; | 65 InnerArrayMap = from.InnerArrayMap; | 
| 62 InnerArrayReverse = from.InnerArrayReverse; | 66 InnerArrayReverse = from.InnerArrayReverse; | 
| 63 InnerArraySome = from.InnerArraySome; | 67 InnerArraySome = from.InnerArraySome; | 
| 64 InnerArraySort = from.InnerArraySort; | 68 InnerArraySort = from.InnerArraySort; | 
| 69 InnerArrayToLocaleString = from.InnerArrayToLocaleString; | |
| 65 IsNaN = from.IsNaN; | 70 IsNaN = from.IsNaN; | 
| 71 ObjectToString = from.ObjectToString; | |
| 66 }); | 72 }); | 
| 67 | 73 | 
| 68 // ------------------------------------------------------------------- | 74 // ------------------------------------------------------------------- | 
| 69 | 75 | 
| 70 function ConstructTypedArray(constructor, array) { | 76 function ConstructTypedArray(constructor, array) { | 
| 71 // TODO(littledan): This is an approximation of the spec, which requires | 77 // TODO(littledan): This is an approximation of the spec, which requires | 
| 72 // that only real TypedArray classes should be accepted (22.2.2.1.1) | 78 // that only real TypedArray classes should be accepted (22.2.2.1.1) | 
| 73 if (!%IsConstructor(constructor) || IS_UNDEFINED(constructor.prototype) || | 79 if (!%IsConstructor(constructor) || IS_UNDEFINED(constructor.prototype) || | 
| 74 !%HasOwnProperty(constructor.prototype, "BYTES_PER_ELEMENT")) { | 80 !%HasOwnProperty(constructor.prototype, "BYTES_PER_ELEMENT")) { | 
| 75 throw MakeTypeError(kNotTypedArray); | 81 throw MakeTypeError(kNotTypedArray); | 
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 243 function TypedArraySome(f, receiver) { | 249 function TypedArraySome(f, receiver) { | 
| 244 if (!%IsTypedArray(this)) throw MakeTypeError(kNotTypedArray); | 250 if (!%IsTypedArray(this)) throw MakeTypeError(kNotTypedArray); | 
| 245 | 251 | 
| 246 var length = %_TypedArrayGetLength(this); | 252 var length = %_TypedArrayGetLength(this); | 
| 247 | 253 | 
| 248 return InnerArraySome(f, receiver, this, length); | 254 return InnerArraySome(f, receiver, this, length); | 
| 249 } | 255 } | 
| 250 %FunctionSetLength(TypedArraySome, 1); | 256 %FunctionSetLength(TypedArraySome, 1); | 
| 251 | 257 | 
| 252 | 258 | 
| 259 // ES6 section 22.2.3.27 | |
| 260 function TypedArrayToLocaleString() { | |
| 261 if (!%IsTypedArray(this)) throw MakeTypeError(kNotTypedArray); | |
| 262 | |
| 263 var length = %_TypedArrayGetLength(this); | |
| 264 | |
| 265 return InnerArrayToLocaleString(this, length); | |
| 266 } | |
| 267 | |
| 268 | |
| 269 // ES6 section 22.2.3.28 | |
| 270 function TypedArrayToString() { | |
| 
 
adamk
2015/06/02 17:18:20
According to the spec this function doesn't exist:
 
 | |
| 271 if (!%IsTypedArray(this)) throw MakeTypeError(kNotTypedArray); | |
| 272 | |
| 273 var func = this.join; | |
| 274 if (!IS_SPEC_FUNCTION(func)) { | |
| 275 return %_CallFunction(this, ObjectToString); | |
| 276 } | |
| 277 return %_CallFunction(this, func); | |
| 278 } | |
| 279 | |
| 280 | |
| 281 // ES6 section 22.2.3.14 | |
| 282 function TypedArrayJoin(separator) { | |
| 283 if (!%IsTypedArray(this)) throw MakeTypeError(kNotTypedArray); | |
| 284 | |
| 285 var length = %_TypedArrayGetLength(this); | |
| 286 | |
| 287 return InnerArrayJoin(separator, this, length); | |
| 288 } | |
| 289 | |
| 290 | |
| 253 // ES6 draft 08-24-14, section 22.2.2.2 | 291 // ES6 draft 08-24-14, section 22.2.2.2 | 
| 254 function TypedArrayOf() { | 292 function TypedArrayOf() { | 
| 255 var length = %_ArgumentsLength(); | 293 var length = %_ArgumentsLength(); | 
| 256 var array = new this(length); | 294 var array = new this(length); | 
| 257 for (var i = 0; i < length; i++) { | 295 for (var i = 0; i < length; i++) { | 
| 258 array[i] = %_Arguments(i); | 296 array[i] = %_Arguments(i); | 
| 259 } | 297 } | 
| 260 return array; | 298 return array; | 
| 261 } | 299 } | 
| 262 | 300 | 
| (...skipping 16 matching lines...) Expand all Loading... | |
| 279 | 317 | 
| 280 // Set up non-enumerable functions on the prototype object. | 318 // Set up non-enumerable functions on the prototype object. | 
| 281 utils.InstallFunctions(GlobalNAME.prototype, DONT_ENUM, [ | 319 utils.InstallFunctions(GlobalNAME.prototype, DONT_ENUM, [ | 
| 282 "copyWithin", TypedArrayCopyWithin, | 320 "copyWithin", TypedArrayCopyWithin, | 
| 283 "every", TypedArrayEvery, | 321 "every", TypedArrayEvery, | 
| 284 "fill", TypedArrayFill, | 322 "fill", TypedArrayFill, | 
| 285 "filter", TypedArrayFilter, | 323 "filter", TypedArrayFilter, | 
| 286 "find", TypedArrayFind, | 324 "find", TypedArrayFind, | 
| 287 "findIndex", TypedArrayFindIndex, | 325 "findIndex", TypedArrayFindIndex, | 
| 288 "indexOf", TypedArrayIndexOf, | 326 "indexOf", TypedArrayIndexOf, | 
| 327 "join", TypedArrayJoin, | |
| 289 "lastIndexOf", TypedArrayLastIndexOf, | 328 "lastIndexOf", TypedArrayLastIndexOf, | 
| 290 "forEach", TypedArrayForEach, | 329 "forEach", TypedArrayForEach, | 
| 291 "map", TypedArrayMap, | 330 "map", TypedArrayMap, | 
| 292 "reverse", TypedArrayReverse, | 331 "reverse", TypedArrayReverse, | 
| 293 "some", TypedArraySome, | 332 "some", TypedArraySome, | 
| 294 "sort", TypedArraySort | 333 "sort", TypedArraySort, | 
| 334 "toString", TypedArrayToString, | |
| 335 "toLocaleString", TypedArrayToLocaleString | |
| 295 ]); | 336 ]); | 
| 296 endmacro | 337 endmacro | 
| 297 | 338 | 
| 298 TYPED_ARRAYS(EXTEND_TYPED_ARRAY) | 339 TYPED_ARRAYS(EXTEND_TYPED_ARRAY) | 
| 299 | 340 | 
| 300 }) | 341 }) | 
| OLD | NEW |