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

Unified 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: rebase 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/array.js ('k') | test/mjsunit/harmony/typedarray-indexing.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/harmony-typedarray.js
diff --git a/src/harmony-typedarray.js b/src/harmony-typedarray.js
index 025de55d582e6287833fd2f6f716e41a16021aa4..2e8499573bc5930cc0e7cb69fdc1c62323c576c4 100644
--- a/src/harmony-typedarray.js
+++ b/src/harmony-typedarray.js
@@ -134,6 +134,29 @@ function TypedArraySort(comparefn) {
}
+// ES6 section 22.2.3.13
+function TypedArrayIndexOf(element, index) {
+ if (!%IsTypedArray(this)) throw MakeTypeError(kNotTypedArray);
+
+ var length = %_TypedArrayGetLength(this);
+
+ return %_CallFunction(this, element, index, length, $innerArrayIndexOf);
+}
+%FunctionSetLength(TypedArrayIndexOf, 1);
+
+
+// ES6 section 22.2.3.16
+function TypedArrayLastIndexOf(element, index) {
+ if (!%IsTypedArray(this)) throw MakeTypeError(kNotTypedArray);
+
+ var length = %_TypedArrayGetLength(this);
+
+ return %_CallFunction(this, element, index, length,
+ %_ArgumentsLength(), $innerArrayLastIndexOf);
+}
+%FunctionSetLength(TypedArrayLastIndexOf, 1);
+
+
// ES6 draft 08-24-14, section 22.2.2.2
function TypedArrayOf() {
var length = %_ArgumentsLength();
@@ -184,6 +207,8 @@ macro EXTEND_TYPED_ARRAY(NAME)
"find", TypedArrayFind,
"findIndex", TypedArrayFindIndex,
"fill", TypedArrayFill,
+ "indexOf", TypedArrayIndexOf,
+ "lastIndexOf", TypedArrayLastIndexOf,
"reverse", TypedArrayReverse,
"sort", TypedArraySort
]);
« no previous file with comments | « src/array.js ('k') | test/mjsunit/harmony/typedarray-indexing.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698