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

Side by Side Diff: src/string.js

Issue 564863002: ES6: String(symbol) should work like symbol.toString (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Code review feedback Created 6 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | test/mjsunit/es6/symbols.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 declaration has been made 5 // This file relies on the fact that the following declaration has been made
6 // in runtime.js: 6 // in runtime.js:
7 // var $String = global.String; 7 // var $String = global.String;
8 8
9 // ------------------------------------------------------------------- 9 // -------------------------------------------------------------------
10 10
11 function StringConstructor(x) { 11 function StringConstructor(x) {
12 var value = %_ArgumentsLength() == 0 ? '' : TO_STRING_INLINE(x); 12 if (%_ArgumentsLength() == 0) x = '';
13 if (%_IsConstructCall()) { 13 if (%_IsConstructCall()) {
14 %_SetValueOf(this, value); 14 %_SetValueOf(this, TO_STRING_INLINE(x));
15 } else { 15 } else {
16 return value; 16 return IS_SYMBOL(x) ?
17 %_CallFunction(x, SymbolToString) : TO_STRING_INLINE(x);
17 } 18 }
18 } 19 }
19 20
20 21
21 // ECMA-262 section 15.5.4.2 22 // ECMA-262 section 15.5.4.2
22 function StringToString() { 23 function StringToString() {
23 if (!IS_STRING(this) && !IS_STRING_WRAPPER(this)) { 24 if (!IS_STRING(this) && !IS_STRING_WRAPPER(this)) {
24 throw new $TypeError('String.prototype.toString is not generic'); 25 throw new $TypeError('String.prototype.toString is not generic');
25 } 26 }
26 return %_ValueOf(this); 27 return %_ValueOf(this);
(...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after
975 "fixed", StringFixed, 976 "fixed", StringFixed,
976 "italics", StringItalics, 977 "italics", StringItalics,
977 "small", StringSmall, 978 "small", StringSmall,
978 "strike", StringStrike, 979 "strike", StringStrike,
979 "sub", StringSub, 980 "sub", StringSub,
980 "sup", StringSup 981 "sup", StringSup
981 )); 982 ));
982 } 983 }
983 984
984 SetUpString(); 985 SetUpString();
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/es6/symbols.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698