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

Unified 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: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/mjsunit/es6/symbols.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/string.js
diff --git a/src/string.js b/src/string.js
index ae65264d4a3ae2c29cc39add829dd45e51ccf0c3..1f14ec3dc69c09f1ca85bb0db3c73c364e0c175a 100644
--- a/src/string.js
+++ b/src/string.js
@@ -9,11 +9,12 @@
// -------------------------------------------------------------------
function StringConstructor(x) {
- var value = %_ArgumentsLength() == 0 ? '' : TO_STRING_INLINE(x);
if (%_IsConstructCall()) {
- %_SetValueOf(this, value);
+ %_SetValueOf(this, %_ArgumentsLength() == 0 ? '' : TO_STRING_INLINE(x));
} else {
- return value;
+ if (%_ArgumentsLength() == 0) return '';
rossberg 2014/09/12 12:56:38 We could avoid duplicating this case by pulling ou
+ if (IS_SYMBOL(x)) return %_CallFunction(x, SymbolToString);
+ return TO_STRING_INLINE(x);
rossberg 2014/09/12 12:56:38 Nit: merge the returns into a ?:
}
}
« 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