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 var ArrayFrom; | 14 var ArrayFrom; |
15 var ArrayToString; | 15 var ArrayToString; |
16 var ArrayValues; | 16 var ArrayValues; |
17 var GlobalArray = global.Array; | 17 var GlobalArray = global.Array; |
18 var GlobalArrayBuffer = global.ArrayBuffer; | 18 var GlobalArrayBuffer = global.ArrayBuffer; |
19 var GlobalDataView = global.DataView; | 19 var GlobalDataView = global.DataView; |
20 var GlobalObject = global.Object; | 20 var GlobalObject = global.Object; |
21 var InnerArrayCopyWithin; | 21 var InnerArrayCopyWithin; |
22 var InnerArrayEvery; | 22 var InnerArrayEvery; |
23 var InnerArrayFill; | 23 var InnerArrayFill; |
24 var InnerArrayFilter; | 24 var InnerArrayFilter; |
25 var InnerArrayFind; | 25 var InnerArrayFind; |
26 var InnerArrayFindIndex; | 26 var InnerArrayFindIndex; |
27 var InnerArrayForEach; | 27 var InnerArrayForEach; |
| 28 var InnerArrayIncludes; |
28 var InnerArrayIndexOf; | 29 var InnerArrayIndexOf; |
29 var InnerArrayJoin; | 30 var InnerArrayJoin; |
30 var InnerArrayLastIndexOf; | 31 var InnerArrayLastIndexOf; |
31 var InnerArrayMap; | 32 var InnerArrayMap; |
32 var InnerArrayReduce; | 33 var InnerArrayReduce; |
33 var InnerArrayReduceRight; | 34 var InnerArrayReduceRight; |
34 var InnerArraySome; | 35 var InnerArraySome; |
35 var InnerArraySort; | 36 var InnerArraySort; |
36 var InnerArrayToLocaleString; | 37 var InnerArrayToLocaleString; |
37 var InternalArray = utils.InternalArray; | 38 var InternalArray = utils.InternalArray; |
(...skipping 30 matching lines...) Expand all Loading... |
68 ArrayFrom = from.ArrayFrom; | 69 ArrayFrom = from.ArrayFrom; |
69 ArrayToString = from.ArrayToString; | 70 ArrayToString = from.ArrayToString; |
70 ArrayValues = from.ArrayValues; | 71 ArrayValues = from.ArrayValues; |
71 InnerArrayCopyWithin = from.InnerArrayCopyWithin; | 72 InnerArrayCopyWithin = from.InnerArrayCopyWithin; |
72 InnerArrayEvery = from.InnerArrayEvery; | 73 InnerArrayEvery = from.InnerArrayEvery; |
73 InnerArrayFill = from.InnerArrayFill; | 74 InnerArrayFill = from.InnerArrayFill; |
74 InnerArrayFilter = from.InnerArrayFilter; | 75 InnerArrayFilter = from.InnerArrayFilter; |
75 InnerArrayFind = from.InnerArrayFind; | 76 InnerArrayFind = from.InnerArrayFind; |
76 InnerArrayFindIndex = from.InnerArrayFindIndex; | 77 InnerArrayFindIndex = from.InnerArrayFindIndex; |
77 InnerArrayForEach = from.InnerArrayForEach; | 78 InnerArrayForEach = from.InnerArrayForEach; |
| 79 InnerArrayIncludes = from.InnerArrayIncludes; |
78 InnerArrayIndexOf = from.InnerArrayIndexOf; | 80 InnerArrayIndexOf = from.InnerArrayIndexOf; |
79 InnerArrayJoin = from.InnerArrayJoin; | 81 InnerArrayJoin = from.InnerArrayJoin; |
80 InnerArrayLastIndexOf = from.InnerArrayLastIndexOf; | 82 InnerArrayLastIndexOf = from.InnerArrayLastIndexOf; |
81 InnerArrayMap = from.InnerArrayMap; | 83 InnerArrayMap = from.InnerArrayMap; |
82 InnerArrayReduce = from.InnerArrayReduce; | 84 InnerArrayReduce = from.InnerArrayReduce; |
83 InnerArrayReduceRight = from.InnerArrayReduceRight; | 85 InnerArrayReduceRight = from.InnerArrayReduceRight; |
84 InnerArraySome = from.InnerArraySome; | 86 InnerArraySome = from.InnerArraySome; |
85 InnerArraySort = from.InnerArraySort; | 87 InnerArraySort = from.InnerArraySort; |
86 InnerArrayToLocaleString = from.InnerArrayToLocaleString; | 88 InnerArrayToLocaleString = from.InnerArrayToLocaleString; |
87 IsNaN = from.IsNaN; | 89 IsNaN = from.IsNaN; |
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
680 // TODO(littledan): The spec says to throw on an error in setting; | 682 // TODO(littledan): The spec says to throw on an error in setting; |
681 // does this throw? | 683 // does this throw? |
682 array[n] = kValue; | 684 array[n] = kValue; |
683 k++; | 685 k++; |
684 n++; | 686 n++; |
685 } | 687 } |
686 return array; | 688 return array; |
687 } | 689 } |
688 | 690 |
689 | 691 |
| 692 // ES2016 draft, section 22.2.3.14 |
| 693 function TypedArrayIncludes(searchElement, fromIndex) { |
| 694 if (!%_IsTypedArray(this)) throw MakeTypeError(kNotTypedArray); |
| 695 |
| 696 var length = %_TypedArrayGetLength(this); |
| 697 |
| 698 return InnerArrayIncludes(searchElement, fromIndex, this, length); |
| 699 } |
| 700 %FunctionSetLength(TypedArrayIncludes, 1); |
| 701 |
| 702 |
690 // ES6 draft 08-24-14, section 22.2.2.2 | 703 // ES6 draft 08-24-14, section 22.2.2.2 |
691 function TypedArrayOf() { | 704 function TypedArrayOf() { |
692 var length = %_ArgumentsLength(); | 705 var length = %_ArgumentsLength(); |
693 var array = new this(length); | 706 var array = new this(length); |
694 for (var i = 0; i < length; i++) { | 707 for (var i = 0; i < length; i++) { |
695 array[i] = %_Arguments(i); | 708 array[i] = %_Arguments(i); |
696 } | 709 } |
697 return array; | 710 return array; |
698 } | 711 } |
699 | 712 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
737 TypedArrayGetToStringTag); | 750 TypedArrayGetToStringTag); |
738 utils.InstallFunctions(GlobalNAME.prototype, DONT_ENUM, [ | 751 utils.InstallFunctions(GlobalNAME.prototype, DONT_ENUM, [ |
739 "subarray", NAMESubArray, | 752 "subarray", NAMESubArray, |
740 "set", TypedArraySet, | 753 "set", TypedArraySet, |
741 "copyWithin", TypedArrayCopyWithin, | 754 "copyWithin", TypedArrayCopyWithin, |
742 "every", TypedArrayEvery, | 755 "every", TypedArrayEvery, |
743 "fill", TypedArrayFill, | 756 "fill", TypedArrayFill, |
744 "filter", TypedArrayFilter, | 757 "filter", TypedArrayFilter, |
745 "find", TypedArrayFind, | 758 "find", TypedArrayFind, |
746 "findIndex", TypedArrayFindIndex, | 759 "findIndex", TypedArrayFindIndex, |
| 760 "includes", TypedArrayIncludes, |
747 "indexOf", TypedArrayIndexOf, | 761 "indexOf", TypedArrayIndexOf, |
748 "join", TypedArrayJoin, | 762 "join", TypedArrayJoin, |
749 "lastIndexOf", TypedArrayLastIndexOf, | 763 "lastIndexOf", TypedArrayLastIndexOf, |
750 "forEach", TypedArrayForEach, | 764 "forEach", TypedArrayForEach, |
751 "map", TypedArrayMap, | 765 "map", TypedArrayMap, |
752 "reduce", TypedArrayReduce, | 766 "reduce", TypedArrayReduce, |
753 "reduceRight", TypedArrayReduceRight, | 767 "reduceRight", TypedArrayReduceRight, |
754 "reverse", TypedArrayReverse, | 768 "reverse", TypedArrayReverse, |
755 "slice", TypedArraySlice, | 769 "slice", TypedArraySlice, |
756 "some", TypedArraySome, | 770 "some", TypedArraySome, |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
889 "setUint32", DataViewSetUint32JS, | 903 "setUint32", DataViewSetUint32JS, |
890 | 904 |
891 "getFloat32", DataViewGetFloat32JS, | 905 "getFloat32", DataViewGetFloat32JS, |
892 "setFloat32", DataViewSetFloat32JS, | 906 "setFloat32", DataViewSetFloat32JS, |
893 | 907 |
894 "getFloat64", DataViewGetFloat64JS, | 908 "getFloat64", DataViewGetFloat64JS, |
895 "setFloat64", DataViewSetFloat64JS | 909 "setFloat64", DataViewSetFloat64JS |
896 ]); | 910 ]); |
897 | 911 |
898 }) | 912 }) |
OLD | NEW |