Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/harmony-typedarray.js

Issue 1141763004: Implement %TypedArray%.{lastI,i}ndexOf (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: minor style fix Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 function TypedArrayFindIndex(predicate, thisArg) { 84 function TypedArrayFindIndex(predicate, thisArg) {
85 if (!%IsTypedArray(this)) throw MakeTypeError(kNotTypedArray); 85 if (!%IsTypedArray(this)) throw MakeTypeError(kNotTypedArray);
86 86
87 var length = %_TypedArrayGetLength(this); 87 var length = %_TypedArrayGetLength(this);
88 88
89 return $innerArrayFindIndex(predicate, thisArg, this, length); 89 return $innerArrayFindIndex(predicate, thisArg, this, length);
90 } 90 }
91 %FunctionSetLength(TypedArrayFindIndex, 1); 91 %FunctionSetLength(TypedArrayFindIndex, 1);
92 92
93 93
94 // ES6 draft 05-18-15 section 22.2.3.13
arv (Not doing code reviews) 2015/05/19 15:10:41 At this point you can just refer to it as ES6
95 function TypedArrayIndexOf(element, index) {
96 if (!%IsTypedArray(this)) throw MakeTypeError(kNotTypedArray);
97
98 var length = %_TypedArrayGetLength(this);
99
100 return %_CallFunction(this, element, index, length, $innerArrayIndexOf);
101 }
102 %FunctionSetLength(TypedArrayIndexOf, 1);
103
104
105 // ES6 draft 05-18-15 section 22.2.3.16
106 function TypedArrayLastIndexOf(element, index) {
107 if (!%IsTypedArray(this)) throw MakeTypeError(kNotTypedArray);
108
109 var length = %_TypedArrayGetLength(this);
110
111 return %_CallFunction(this, element, index, length,
112 %_ArgumentsLength(), $innerArrayLastIndexOf);
113 }
114 %FunctionSetLength(TypedArrayLastIndexOf, 1);
115
116
94 // ES6 draft 08-24-14, section 22.2.2.2 117 // ES6 draft 08-24-14, section 22.2.2.2
95 function TypedArrayOf() { 118 function TypedArrayOf() {
96 var length = %_ArgumentsLength(); 119 var length = %_ArgumentsLength();
97 var array = new this(length); 120 var array = new this(length);
98 for (var i = 0; i < length; i++) { 121 for (var i = 0; i < length; i++) {
99 array[i] = %_Arguments(i); 122 array[i] = %_Arguments(i);
100 } 123 }
101 return array; 124 return array;
102 } 125 }
103 126
(...skipping 29 matching lines...) Expand all
133 "of", TypedArrayOf 156 "of", TypedArrayOf
134 ]); 157 ]);
135 158
136 // Set up non-enumerable functions on the prototype object. 159 // Set up non-enumerable functions on the prototype object.
137 $installFunctions(GlobalNAME.prototype, DONT_ENUM, [ 160 $installFunctions(GlobalNAME.prototype, DONT_ENUM, [
138 "copyWithin", TypedArrayCopyWithin, 161 "copyWithin", TypedArrayCopyWithin,
139 "every", TypedArrayEvery, 162 "every", TypedArrayEvery,
140 "forEach", TypedArrayForEach, 163 "forEach", TypedArrayForEach,
141 "find", TypedArrayFind, 164 "find", TypedArrayFind,
142 "findIndex", TypedArrayFindIndex, 165 "findIndex", TypedArrayFindIndex,
143 "fill", TypedArrayFill 166 "fill", TypedArrayFill,
167 "indexOf", TypedArrayIndexOf,
168 "lastIndexOf", TypedArrayLastIndexOf
144 ]); 169 ]);
145 endmacro 170 endmacro
146 171
147 TYPED_ARRAYS(EXTEND_TYPED_ARRAY) 172 TYPED_ARRAYS(EXTEND_TYPED_ARRAY)
148 173
149 }) 174 })
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698