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

Side by Side Diff: src/v8natives.js

Issue 461453002: Implement well-known symbol `Symbol.toStringTag` Base URL: git://github.com/v8/v8.git@master
Patch Set: Created 6 years, 4 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 | « src/symbol.js ('k') | test/mjsunit/es6/symbol-tostringtag.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 // This file relies on the fact that the following declarations have been made 5 // This file relies on the fact that the following declarations have been made
6 // in runtime.js: 6 // in runtime.js:
7 // var $Object = global.Object; 7 // var $Object = global.Object;
8 // var $Boolean = global.Boolean; 8 // var $Boolean = global.Boolean;
9 // var $Number = global.Number; 9 // var $Number = global.Number;
10 // var $Function = global.Function; 10 // var $Function = global.Function;
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 "eval", GlobalEval 208 "eval", GlobalEval
209 )); 209 ));
210 } 210 }
211 211
212 SetUpGlobal(); 212 SetUpGlobal();
213 213
214 214
215 // ---------------------------------------------------------------------------- 215 // ----------------------------------------------------------------------------
216 // Object 216 // Object
217 217
218 // ECMA-262 - 15.2.4.2 218 // ES6 draft Rev 26 - 19.1.3.6
219 var reservedTags = ["Arguments", "Array", "Boolean", "Date",
220 "Error", "Function", "Number", "RegExp", "String"];
219 function ObjectToString() { 221 function ObjectToString() {
220 if (IS_UNDEFINED(this) && !IS_UNDETECTABLE(this)) return "[object Undefined]"; 222 if (IS_UNDEFINED(this) && !IS_UNDETECTABLE(this)) return "[object Undefined]";
221 if (IS_NULL(this)) return "[object Null]"; 223 if (IS_NULL(this)) return "[object Null]";
222 return "[object " + %_ClassOf(ToObject(this)) + "]"; 224 var O = ToObject(this);
225 var builtinTag = %_ClassOf(O);
226 if(reservedTags.indexOf(builtinTag) === -1){
arv (Not doing code reviews) 2014/08/11 14:40:40 Can you change this to a switch? We do not want a
227 builtinTag = "Object";
228 }
229 var tag = builtinTag;
230 var hasTag = %HasProperty(O, symbolToStringTag);
231 if(hasTag){
232 tag = O[symbolToStringTag];
233 if(!IS_STRING(tag)){
234 tag = "???";
235 }
236 if(tag !== builtinTag && reservedTags.indexOf(tag) > -1){
237 tag = "~" + tag;
238 }
239 }
240 return "[object " + tag + "]";
223 } 241 }
224 242
225 243
226 // ECMA-262 - 15.2.4.3 244 // ECMA-262 - 15.2.4.3
227 function ObjectToLocaleString() { 245 function ObjectToLocaleString() {
228 CHECK_OBJECT_COERCIBLE(this, "Object.prototype.toLocaleString"); 246 CHECK_OBJECT_COERCIBLE(this, "Object.prototype.toLocaleString");
229 return this.toString(); 247 return this.toString();
230 } 248 }
231 249
232 250
(...skipping 1635 matching lines...) Expand 10 before | Expand all | Expand 10 after
1868 %SetCode($Function, FunctionConstructor); 1886 %SetCode($Function, FunctionConstructor);
1869 %AddNamedProperty($Function.prototype, "constructor", $Function, DONT_ENUM); 1887 %AddNamedProperty($Function.prototype, "constructor", $Function, DONT_ENUM);
1870 1888
1871 InstallFunctions($Function.prototype, DONT_ENUM, $Array( 1889 InstallFunctions($Function.prototype, DONT_ENUM, $Array(
1872 "bind", FunctionBind, 1890 "bind", FunctionBind,
1873 "toString", FunctionToString 1891 "toString", FunctionToString
1874 )); 1892 ));
1875 } 1893 }
1876 1894
1877 SetUpFunction(); 1895 SetUpFunction();
OLDNEW
« no previous file with comments | « src/symbol.js ('k') | test/mjsunit/es6/symbol-tostringtag.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698