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

Unified Diff: src/array.js

Issue 1166623004: Implement %TypedArray%.prototype.{toString,toLocaleString,join} (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix toString 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 | « no previous file | src/harmony-typedarray.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/array.js
diff --git a/src/array.js b/src/array.js
index 55c59eb4a12ec9aa3af47ecc232bcce2df901b94..4fec4b3d1bc96e52e62eec3643bb99e29c05829a 100644
--- a/src/array.js
+++ b/src/array.js
@@ -398,20 +398,21 @@ function ArrayToString() {
}
-function ArrayToLocaleString() {
- var array = $toObject(this);
- var arrayLen = array.length;
- var len = TO_UINT32(arrayLen);
+function InnerArrayToLocaleString(array, length) {
+ var len = TO_UINT32(length);
if (len === 0) return "";
return Join(array, len, ',', ConvertToLocaleString);
}
-function ArrayJoin(separator) {
- CHECK_OBJECT_COERCIBLE(this, "Array.prototype.join");
+function ArrayToLocaleString() {
+ var array = $toObject(this);
+ var arrayLen = array.length;
+ return InnerArrayToLocaleString(array, arrayLen);
+}
- var array = TO_OBJECT_INLINE(this);
- var length = TO_UINT32(array.length);
+
+function InnerArrayJoin(separator, array, length) {
if (IS_UNDEFINED(separator)) {
separator = ',';
} else if (!IS_STRING(separator)) {
@@ -433,6 +434,16 @@ function ArrayJoin(separator) {
}
+function ArrayJoin(separator) {
+ CHECK_OBJECT_COERCIBLE(this, "Array.prototype.join");
+
+ var array = TO_OBJECT_INLINE(this);
+ var length = TO_UINT32(array.length);
+
+ return InnerArrayJoin(separator, array, length);
+}
+
+
function ObservedArrayPop(n) {
n--;
var value = this[n];
@@ -1654,15 +1665,18 @@ utils.SetUpLockedPrototype(InternalPackedArray, GlobalArray(), [
utils.Export(function(to) {
to.ArrayJoin = ArrayJoin;
+ to.ArrayToString = ArrayToString;
to.InnerArrayEvery = InnerArrayEvery;
to.InnerArrayFilter = InnerArrayFilter;
to.InnerArrayForEach = InnerArrayForEach;
to.InnerArrayIndexOf = InnerArrayIndexOf;
+ to.InnerArrayJoin = InnerArrayJoin;
to.InnerArrayLastIndexOf = InnerArrayLastIndexOf;
to.InnerArrayMap = InnerArrayMap;
to.InnerArrayReverse = InnerArrayReverse;
to.InnerArraySome = InnerArraySome;
to.InnerArraySort = InnerArraySort;
+ to.InnerArrayToLocaleString = InnerArrayToLocaleString;
});
$arrayConcat = ArrayConcatJS;
« no previous file with comments | « no previous file | src/harmony-typedarray.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698