| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 |
| 11 // ------------------------------------------------------------------- | 11 // ------------------------------------------------------------------- |
| 12 // Imports | 12 // Imports |
| 13 | 13 |
| 14 // array.js has to come before typedarray.js for this to work | 14 // array.js has to come before typedarray.js for this to work |
| 15 var ArrayToString = utils.ImportNow("ArrayToString"); | 15 var ArrayToString = utils.ImportNow("ArrayToString"); |
| 16 var ArrayValues; | 16 var ArrayValues; |
| 17 var GetIterator; | 17 var GetIterator; |
| 18 var GetMethod; | 18 var GetMethod; |
| 19 var GlobalArray = global.Array; | 19 var GlobalArray = global.Array; |
| 20 var GlobalArrayBuffer = global.ArrayBuffer; | 20 var GlobalArrayBuffer = global.ArrayBuffer; |
| 21 var GlobalArrayBufferPrototype = GlobalArrayBuffer.prototype; | 21 var GlobalArrayBufferPrototype = GlobalArrayBuffer.prototype; |
| 22 var GlobalObject = global.Object; | 22 var GlobalObject = global.Object; |
| 23 var InnerArrayEvery; | 23 var InnerArrayEvery; |
| 24 var InnerArrayFill; | |
| 25 var InnerArrayFilter; | 24 var InnerArrayFilter; |
| 26 var InnerArrayFind; | 25 var InnerArrayFind; |
| 27 var InnerArrayFindIndex; | 26 var InnerArrayFindIndex; |
| 28 var InnerArrayForEach; | 27 var InnerArrayForEach; |
| 29 var InnerArrayJoin; | 28 var InnerArrayJoin; |
| 30 var InnerArrayReduce; | 29 var InnerArrayReduce; |
| 31 var InnerArrayReduceRight; | 30 var InnerArrayReduceRight; |
| 32 var InnerArraySome; | 31 var InnerArraySome; |
| 33 var InnerArraySort; | 32 var InnerArraySort; |
| 34 var InnerArrayToLocaleString; | 33 var InnerArrayToLocaleString; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 61 | 60 |
| 62 TYPED_ARRAYS(DECLARE_GLOBALS) | 61 TYPED_ARRAYS(DECLARE_GLOBALS) |
| 63 | 62 |
| 64 var GlobalTypedArray = %object_get_prototype_of(GlobalUint8Array); | 63 var GlobalTypedArray = %object_get_prototype_of(GlobalUint8Array); |
| 65 | 64 |
| 66 utils.Import(function(from) { | 65 utils.Import(function(from) { |
| 67 ArrayValues = from.ArrayValues; | 66 ArrayValues = from.ArrayValues; |
| 68 GetIterator = from.GetIterator; | 67 GetIterator = from.GetIterator; |
| 69 GetMethod = from.GetMethod; | 68 GetMethod = from.GetMethod; |
| 70 InnerArrayEvery = from.InnerArrayEvery; | 69 InnerArrayEvery = from.InnerArrayEvery; |
| 71 InnerArrayFill = from.InnerArrayFill; | |
| 72 InnerArrayFilter = from.InnerArrayFilter; | 70 InnerArrayFilter = from.InnerArrayFilter; |
| 73 InnerArrayFind = from.InnerArrayFind; | 71 InnerArrayFind = from.InnerArrayFind; |
| 74 InnerArrayFindIndex = from.InnerArrayFindIndex; | 72 InnerArrayFindIndex = from.InnerArrayFindIndex; |
| 75 InnerArrayForEach = from.InnerArrayForEach; | 73 InnerArrayForEach = from.InnerArrayForEach; |
| 76 InnerArrayJoin = from.InnerArrayJoin; | 74 InnerArrayJoin = from.InnerArrayJoin; |
| 77 InnerArrayReduce = from.InnerArrayReduce; | 75 InnerArrayReduce = from.InnerArrayReduce; |
| 78 InnerArrayReduceRight = from.InnerArrayReduceRight; | 76 InnerArrayReduceRight = from.InnerArrayReduceRight; |
| 79 InnerArraySome = from.InnerArraySome; | 77 InnerArraySome = from.InnerArraySome; |
| 80 InnerArraySort = from.InnerArraySort; | 78 InnerArraySort = from.InnerArraySort; |
| 81 InnerArrayToLocaleString = from.InnerArrayToLocaleString; | 79 InnerArrayToLocaleString = from.InnerArrayToLocaleString; |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 function TypedArrayForEach(f, receiver) { | 387 function TypedArrayForEach(f, receiver) { |
| 390 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); | 388 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); |
| 391 | 389 |
| 392 var length = %_TypedArrayGetLength(this); | 390 var length = %_TypedArrayGetLength(this); |
| 393 | 391 |
| 394 InnerArrayForEach(f, receiver, this, length); | 392 InnerArrayForEach(f, receiver, this, length); |
| 395 } | 393 } |
| 396 %FunctionSetLength(TypedArrayForEach, 1); | 394 %FunctionSetLength(TypedArrayForEach, 1); |
| 397 | 395 |
| 398 | 396 |
| 399 // ES6 draft 04-05-14 section 22.2.3.8 | |
| 400 function TypedArrayFill(value, start, end) { | |
| 401 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); | |
| 402 | |
| 403 var length = %_TypedArrayGetLength(this); | |
| 404 | |
| 405 return InnerArrayFill(value, start, end, this, length); | |
| 406 } | |
| 407 %FunctionSetLength(TypedArrayFill, 1); | |
| 408 | |
| 409 | |
| 410 // ES6 draft 07-15-13, section 22.2.3.9 | 397 // ES6 draft 07-15-13, section 22.2.3.9 |
| 411 function TypedArrayFilter(f, thisArg) { | 398 function TypedArrayFilter(f, thisArg) { |
| 412 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); | 399 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); |
| 413 | 400 |
| 414 var length = %_TypedArrayGetLength(this); | 401 var length = %_TypedArrayGetLength(this); |
| 415 if (!IS_CALLABLE(f)) throw %make_type_error(kCalledNonCallable, f); | 402 if (!IS_CALLABLE(f)) throw %make_type_error(kCalledNonCallable, f); |
| 416 var result = new InternalArray(); | 403 var result = new InternalArray(); |
| 417 InnerArrayFilter(f, thisArg, this, length, result); | 404 InnerArrayFilter(f, thisArg, this, length, result); |
| 418 var captured = result.length; | 405 var captured = result.length; |
| 419 var output = TypedArraySpeciesCreate(this, captured); | 406 var output = TypedArraySpeciesCreate(this, captured); |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 utils.InstallFunctions(GlobalTypedArray, DONT_ENUM, [ | 638 utils.InstallFunctions(GlobalTypedArray, DONT_ENUM, [ |
| 652 "from", TypedArrayFrom, | 639 "from", TypedArrayFrom, |
| 653 "of", TypedArrayOf | 640 "of", TypedArrayOf |
| 654 ]); | 641 ]); |
| 655 utils.InstallGetter(GlobalTypedArray.prototype, toStringTagSymbol, | 642 utils.InstallGetter(GlobalTypedArray.prototype, toStringTagSymbol, |
| 656 TypedArrayGetToStringTag); | 643 TypedArrayGetToStringTag); |
| 657 utils.InstallFunctions(GlobalTypedArray.prototype, DONT_ENUM, [ | 644 utils.InstallFunctions(GlobalTypedArray.prototype, DONT_ENUM, [ |
| 658 "subarray", TypedArraySubArray, | 645 "subarray", TypedArraySubArray, |
| 659 "set", TypedArraySet, | 646 "set", TypedArraySet, |
| 660 "every", TypedArrayEvery, | 647 "every", TypedArrayEvery, |
| 661 "fill", TypedArrayFill, | |
| 662 "filter", TypedArrayFilter, | 648 "filter", TypedArrayFilter, |
| 663 "find", TypedArrayFind, | 649 "find", TypedArrayFind, |
| 664 "findIndex", TypedArrayFindIndex, | 650 "findIndex", TypedArrayFindIndex, |
| 665 "join", TypedArrayJoin, | 651 "join", TypedArrayJoin, |
| 666 "forEach", TypedArrayForEach, | 652 "forEach", TypedArrayForEach, |
| 667 "map", TypedArrayMap, | 653 "map", TypedArrayMap, |
| 668 "reduce", TypedArrayReduce, | 654 "reduce", TypedArrayReduce, |
| 669 "reduceRight", TypedArrayReduceRight, | 655 "reduceRight", TypedArrayReduceRight, |
| 670 "reverse", TypedArrayReverse, | 656 "reverse", TypedArrayReverse, |
| 671 "slice", TypedArraySlice, | 657 "slice", TypedArraySlice, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 690 %AddNamedProperty(GlobalNAME.prototype, | 676 %AddNamedProperty(GlobalNAME.prototype, |
| 691 "constructor", global.NAME, DONT_ENUM); | 677 "constructor", global.NAME, DONT_ENUM); |
| 692 %AddNamedProperty(GlobalNAME.prototype, | 678 %AddNamedProperty(GlobalNAME.prototype, |
| 693 "BYTES_PER_ELEMENT", ELEMENT_SIZE, | 679 "BYTES_PER_ELEMENT", ELEMENT_SIZE, |
| 694 READ_ONLY | DONT_ENUM | DONT_DELETE); | 680 READ_ONLY | DONT_ENUM | DONT_DELETE); |
| 695 endmacro | 681 endmacro |
| 696 | 682 |
| 697 TYPED_ARRAYS(SETUP_TYPED_ARRAY) | 683 TYPED_ARRAYS(SETUP_TYPED_ARRAY) |
| 698 | 684 |
| 699 }) | 685 }) |
| OLD | NEW |