Chromium Code Reviews| Index: src/v8natives.js |
| diff --git a/src/v8natives.js b/src/v8natives.js |
| index 1d2e03000763062f3777e1a565e1792227f3e634..7a1f25bdd9292641a96f4a614d1ff5fb5e2b5aa2 100644 |
| --- a/src/v8natives.js |
| +++ b/src/v8natives.js |
| @@ -214,12 +214,34 @@ SetUpGlobal(); |
| // ---------------------------------------------------------------------------- |
| // Object |
| +var kBuiltinStringTags = { |
|
caitp (gmail)
2014/10/10 14:56:28
ObjectCreate(null) would be better, I guess
rossberg
2014/10/17 11:19:30
Yes, the prototype has to be null, otherwise the c
|
| + "Arguments": "[object ~Arguments]", |
| + "Array": "[object ~Array]", |
| + "Boolean": "[object ~Boolean]", |
| + "Date": "[object ~Date]", |
| + "Error": "[object ~Error]", |
| + "Function": "[object ~Function]", |
| + "Number": "[object ~Number]", |
| + "RegExp": "[object ~RegExp]", |
| + "String": "[object ~String]" |
| +}; |
| // ECMA-262 - 15.2.4.2 |
| +// ES6 draft 08-24-14, section 19.1.3.6 |
| function ObjectToString() { |
| if (IS_UNDEFINED(this) && !IS_UNDETECTABLE(this)) return "[object Undefined]"; |
| if (IS_NULL(this)) return "[object Null]"; |
| - return "[object " + %_ClassOf(ToObject(this)) + "]"; |
| + var O = ToObject(this); |
| + var builtinTag = %_ClassOf(O); |
| + var tag = O[symbolToStringTag]; |
|
rossberg
2014/10/17 11:19:30
We need some way of putting this new behaviour beh
|
| + if (IS_UNDEFINED(tag)) tag = builtinTag; |
|
rossberg
2014/10/17 11:19:30
Style nit: new line if there is an 'else'.
|
| + else { |
| + if (!IS_STRING(tag)) return "[object ???]"; |
|
rossberg
2014/10/17 11:19:30
Same here. Can also merge into an 'else if' with t
|
| + else if (tag !== builtinTag && IS_STRING(kBuiltinStringTags[tag])) { |
| + return kBuiltinStringTags[tag]; |
|
arv (Not doing code reviews)
2014/10/17 14:40:51
Maybe make the kBuiltinStringTags a "set" and then
|
| + } |
| + } |
| + return "[object " + tag + "]"; |
| } |