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 |
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
710 while (k < final) { | 710 while (k < final) { |
711 var kValue = this[k]; | 711 var kValue = this[k]; |
712 array[n] = kValue; | 712 array[n] = kValue; |
713 k++; | 713 k++; |
714 n++; | 714 n++; |
715 } | 715 } |
716 return array; | 716 return array; |
717 } | 717 } |
718 | 718 |
719 | 719 |
720 // ES2016 draft, section 22.2.3.14 | |
721 function TypedArrayIncludes(searchElement, fromIndex) { | |
722 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); | |
723 | |
724 var length = %_TypedArrayGetLength(this); | |
725 | |
726 if (length === 0) return false; | |
727 var n = TO_INTEGER(fromIndex); | |
728 | |
729 var k; | |
730 if (n >= 0) { | |
731 k = n; | |
732 } else { | |
733 k = length + n; | |
734 if (k < 0) { | |
735 k = 0; | |
736 } | |
737 } | |
738 | |
739 while (k < length) { | |
740 var elementK = this[k]; | |
741 if (%SameValueZero(searchElement, elementK)) { | |
742 return true; | |
743 } | |
744 | |
745 ++k; | |
746 } | |
747 | |
748 return false; | |
749 } | |
750 %FunctionSetLength(TypedArrayIncludes, 1); | |
751 | |
752 | |
753 // ES6 draft 08-24-14, section 22.2.2.2 | 720 // ES6 draft 08-24-14, section 22.2.2.2 |
754 function TypedArrayOf() { | 721 function TypedArrayOf() { |
755 var length = arguments.length; | 722 var length = arguments.length; |
756 var array = TypedArrayCreate(this, length); | 723 var array = TypedArrayCreate(this, length); |
757 for (var i = 0; i < length; i++) { | 724 for (var i = 0; i < length; i++) { |
758 array[i] = arguments[i]; | 725 array[i] = arguments[i]; |
759 } | 726 } |
760 return array; | 727 return array; |
761 } | 728 } |
762 | 729 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
823 utils.InstallGetter(GlobalTypedArray.prototype, toStringTagSymbol, | 790 utils.InstallGetter(GlobalTypedArray.prototype, toStringTagSymbol, |
824 TypedArrayGetToStringTag); | 791 TypedArrayGetToStringTag); |
825 utils.InstallFunctions(GlobalTypedArray.prototype, DONT_ENUM, [ | 792 utils.InstallFunctions(GlobalTypedArray.prototype, DONT_ENUM, [ |
826 "subarray", TypedArraySubArray, | 793 "subarray", TypedArraySubArray, |
827 "set", TypedArraySet, | 794 "set", TypedArraySet, |
828 "every", TypedArrayEvery, | 795 "every", TypedArrayEvery, |
829 "fill", TypedArrayFill, | 796 "fill", TypedArrayFill, |
830 "filter", TypedArrayFilter, | 797 "filter", TypedArrayFilter, |
831 "find", TypedArrayFind, | 798 "find", TypedArrayFind, |
832 "findIndex", TypedArrayFindIndex, | 799 "findIndex", TypedArrayFindIndex, |
833 "includes", TypedArrayIncludes, | |
834 "indexOf", TypedArrayIndexOf, | 800 "indexOf", TypedArrayIndexOf, |
835 "join", TypedArrayJoin, | 801 "join", TypedArrayJoin, |
836 "lastIndexOf", TypedArrayLastIndexOf, | 802 "lastIndexOf", TypedArrayLastIndexOf, |
837 "forEach", TypedArrayForEach, | 803 "forEach", TypedArrayForEach, |
838 "map", TypedArrayMap, | 804 "map", TypedArrayMap, |
839 "reduce", TypedArrayReduce, | 805 "reduce", TypedArrayReduce, |
840 "reduceRight", TypedArrayReduceRight, | 806 "reduceRight", TypedArrayReduceRight, |
841 "reverse", TypedArrayReverse, | 807 "reverse", TypedArrayReverse, |
842 "slice", TypedArraySlice, | 808 "slice", TypedArraySlice, |
843 "some", TypedArraySome, | 809 "some", TypedArraySome, |
(...skipping 17 matching lines...) Expand all Loading... |
861 %AddNamedProperty(GlobalNAME.prototype, | 827 %AddNamedProperty(GlobalNAME.prototype, |
862 "constructor", global.NAME, DONT_ENUM); | 828 "constructor", global.NAME, DONT_ENUM); |
863 %AddNamedProperty(GlobalNAME.prototype, | 829 %AddNamedProperty(GlobalNAME.prototype, |
864 "BYTES_PER_ELEMENT", ELEMENT_SIZE, | 830 "BYTES_PER_ELEMENT", ELEMENT_SIZE, |
865 READ_ONLY | DONT_ENUM | DONT_DELETE); | 831 READ_ONLY | DONT_ENUM | DONT_DELETE); |
866 endmacro | 832 endmacro |
867 | 833 |
868 TYPED_ARRAYS(SETUP_TYPED_ARRAY) | 834 TYPED_ARRAYS(SETUP_TYPED_ARRAY) |
869 | 835 |
870 }) | 836 }) |
OLD | NEW |