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

Side by Side Diff: src/harmony-tostring.js

Issue 895633004: Update harmony Object.prototype.toString to 2/2/2015 spec (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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 unified diff | Download patch
« no previous file with comments | « no previous file | test/mjsunit/es6/array-tostring.js » ('j') | test/mjsunit/es6/object-tostring.js » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 "use strict"; 5 "use strict";
6 6
7 // This file relies on the fact that the following declaration has been made 7 // This file relies on the fact that the following declaration has been made
8 // in runtime.js and symbol.js: 8 // in runtime.js and symbol.js:
9 // var $Object = global.Object; 9 // var $Object = global.Object;
10 // var $Symbol = global.Symbol; 10 // var $Symbol = global.Symbol;
11 11
12 var kBuiltinStringTags = {
13 "__proto__": null,
14 "Arguments": true,
15 "Array": true,
16 "Boolean": true,
17 "Date": true,
18 "Error": true,
19 "Function": true,
20 "Number": true,
21 "RegExp": true,
22 "String": true
23 };
24
25 DefaultObjectToString = ObjectToStringHarmony; 12 DefaultObjectToString = ObjectToStringHarmony;
26 // ES6 draft 08-24-14, section 19.1.3.6 13 // ES6 draft 08-24-14, section 19.1.3.6
27 function ObjectToStringHarmony() { 14 function ObjectToStringHarmony() {
28 if (IS_UNDEFINED(this) && !IS_UNDETECTABLE(this)) return "[object Undefined]"; 15 if (IS_UNDEFINED(this) && !IS_UNDETECTABLE(this)) return "[object Undefined]";
29 if (IS_NULL(this)) return "[object Null]"; 16 if (IS_NULL(this)) return "[object Null]";
30 var O = ToObject(this); 17 var O = ToObject(this);
31 var builtinTag = %_ClassOf(O); 18 var builtinTag = %_ClassOf(O);
32 var tag = O[symbolToStringTag]; 19 var tag = O[symbolToStringTag];
33 if (IS_UNDEFINED(tag)) { 20 if (!IS_STRING(tag)) {
34 tag = builtinTag; 21 tag = builtinTag;
35 } else if (!IS_STRING(tag)) {
36 return "[object ???]";
37 } else if (tag !== builtinTag && kBuiltinStringTags[tag]) {
38 return "[object ~" + tag + "]";
39 } 22 }
40 return "[object " + tag + "]"; 23 return "[object " + tag + "]";
41 } 24 }
42 25
43 function HarmonyToStringExtendSymbolPrototype() { 26 function HarmonyToStringExtendSymbolPrototype() {
44 %CheckIsBootstrapping(); 27 %CheckIsBootstrapping();
45 28
46 InstallConstants($Symbol, $Array( 29 InstallConstants($Symbol, $Array(
47 // TODO(dslomov, caitp): Move to symbol.js when shipping 30 // TODO(dslomov, caitp): Move to symbol.js when shipping
48 "toStringTag", symbolToStringTag 31 "toStringTag", symbolToStringTag
(...skipping 14 matching lines...) Expand all
63 // Set up the non-enumerable functions on the Array prototype object. 46 // Set up the non-enumerable functions on the Array prototype object.
64 var desc = ToPropertyDescriptor({ 47 var desc = ToPropertyDescriptor({
65 value: ObjectToStringHarmony 48 value: ObjectToStringHarmony
66 }); 49 });
67 DefineOwnProperty($Object.prototype, "toString", desc, false); 50 DefineOwnProperty($Object.prototype, "toString", desc, false);
68 51
69 %ToFastProperties($Object.prototype); 52 %ToFastProperties($Object.prototype);
70 } 53 }
71 54
72 HarmonyToStringExtendObjectPrototype(); 55 HarmonyToStringExtendObjectPrototype();
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/es6/array-tostring.js » ('j') | test/mjsunit/es6/object-tostring.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698