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

Unified Diff: src/array.js

Issue 8124025: Fix issue 1361 - Implement ES5 Array.prototype.toString. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 2 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 | test/mjsunit/array-tostring.js » ('j') | test/mjsunit/array-tostring.js » ('J')
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 4dd23c8bb464b31b4171e7e671b9a8bb106f1951..7f179ed78b1d23704f342a5a332dfbc49f7e7d22 100644
--- a/src/array.js
+++ b/src/array.js
@@ -381,10 +381,22 @@ function SimpleMove(array, start_i, del_count, len, num_additional_args) {
function ArrayToString() {
- if (!IS_ARRAY(this)) {
- throw new $TypeError('Array.prototype.toString is not generic');
+ var array;
+ var func;
+ if (IS_ARRAY(this)) {
+ func = this.join;
+ if (func === ArrayJoin) {
+ return Join(this, this.length, ',', ConvertToString);
+ }
+ array = this;
+ } else {
+ array = ToObject(this);
+ func = array.join;
+ }
+ if (!IS_SPEC_FUNCTION(func)) {
+ return %_CallFunction(array, ObjectToString);
}
- return Join(this, this.length, ',', ConvertToString);
+ return %_CallFunction(array, func);
}
« no previous file with comments | « no previous file | test/mjsunit/array-tostring.js » ('j') | test/mjsunit/array-tostring.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698