Index: src/harmony-tostring.js |
diff --git a/src/harmony-tostring.js b/src/harmony-tostring.js |
index 0336456bb2827c13c75bd5f823731a2223e65540..e36ef0d111d7e4015a16327e4b4ef0ceb05d296a 100644 |
--- a/src/harmony-tostring.js |
+++ b/src/harmony-tostring.js |
@@ -33,13 +33,25 @@ function ObjectToStringHarmony() { |
if (IS_UNDEFINED(tag)) { |
tag = builtinTag; |
} else if (!IS_STRING(tag)) { |
- return "[object ???]" |
+ return "[object ???]"; |
} else if (tag !== builtinTag && kBuiltinStringTags[tag]) { |
return "[object ~" + tag + "]"; |
} |
return "[object " + tag + "]"; |
} |
+// ES6 draft 12-06-14, section 22.1.3.27 |
+function ArrayToStringHarmony() { |
+ if (IS_ARRAY(this) && this.join === ArrayJoin) { |
arv (Not doing code reviews)
2015/01/12 15:46:40
It looks like we are doing Get(object, 'join') twi
|
+ return Join(this, this.length, ',', ConvertToString); |
+ } |
+ |
+ var O = ToObject(this); |
+ var join = O.join; |
+ if (IS_SPEC_FUNCTION(join)) return %_CallFunction(O, join); |
+ return %_CallFunction(O, ObjectToStringHarmony); |
arv (Not doing code reviews)
2015/01/12 15:46:40
Could we just change ArrayToString to use DefaultO
caitp (gmail)
2015/01/12 15:53:16
hmm, that's a good point
|
+} |
+ |
function HarmonyToStringExtendSymbolPrototype() { |
%CheckIsBootstrapping(); |
@@ -70,3 +82,23 @@ function HarmonyToStringExtendObjectPrototype() { |
} |
HarmonyToStringExtendObjectPrototype(); |
+ |
+function HarmonyToStringExtendArrayPrototype() { |
+ %CheckIsBootstrapping(); |
+ |
+ // Can't use InstallFunctions() because will fail in Debug mode. |
+ // Emulate InstallFunctions here. |
+ %FunctionSetName(ArrayToStringHarmony, "toString"); |
+ %FunctionRemovePrototype(ArrayToStringHarmony); |
+ %SetNativeFlag(ArrayToStringHarmony); |
+ |
+ // Set up the non-enumerable functions on the Array prototype object. |
+ var desc = ToPropertyDescriptor({ |
+ value: ArrayToStringHarmony |
+ }); |
+ DefineOwnProperty($Array.prototype, "toString", desc, false); |
arv (Not doing code reviews)
2015/01/12 15:46:40
DefineOwnProperty takes a descriptor... can we use
caitp (gmail)
2015/01/12 15:53:16
Sort of --- Runtime_AddOwnProperty (used by Instal
|
+ |
+ %ToFastProperties($Array.prototype); |
+} |
+ |
+HarmonyToStringExtendArrayPrototype(); |