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

Unified Diff: src/js/symbol.js

Issue 2117273002: Revert of [intrinsic] Drop the %_ValueOf intrinsic. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 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 | « src/js/string.js ('k') | src/js/v8natives.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/js/symbol.js
diff --git a/src/js/symbol.js b/src/js/symbol.js
index 86af489601385b68d3f19490efedb06910f2b337..2e7cc53d008c0572b0a2dfec3ae092d1be6dbae5 100644
--- a/src/js/symbol.js
+++ b/src/js/symbol.js
@@ -31,6 +31,34 @@
});
// -------------------------------------------------------------------
+
+// 19.4.3.4 Symbol.prototype [ @@toPrimitive ] ( hint )
+function SymbolToPrimitive(hint) {
+ if (!(IS_SYMBOL(this) || IS_SYMBOL_WRAPPER(this))) {
+ throw MakeTypeError(kIncompatibleMethodReceiver,
+ "Symbol.prototype [ @@toPrimitive ]", this);
+ }
+ return %_ValueOf(this);
+}
+
+
+function SymbolToString() {
+ if (!(IS_SYMBOL(this) || IS_SYMBOL_WRAPPER(this))) {
+ throw MakeTypeError(kIncompatibleMethodReceiver,
+ "Symbol.prototype.toString", this);
+ }
+ return %SymbolDescriptiveString(%_ValueOf(this));
+}
+
+
+function SymbolValueOf() {
+ if (!(IS_SYMBOL(this) || IS_SYMBOL_WRAPPER(this))) {
+ throw MakeTypeError(kIncompatibleMethodReceiver,
+ "Symbol.prototype.valueOf", this);
+ }
+ return %_ValueOf(this);
+}
+
function SymbolFor(key) {
key = TO_STRING(key);
@@ -70,4 +98,23 @@
"keyFor", SymbolKeyFor
]);
+%AddNamedProperty(
+ GlobalSymbol.prototype, toStringTagSymbol, "Symbol", DONT_ENUM | READ_ONLY);
+
+utils.InstallFunctions(GlobalSymbol.prototype, DONT_ENUM | READ_ONLY, [
+ toPrimitiveSymbol, SymbolToPrimitive
+]);
+
+utils.InstallFunctions(GlobalSymbol.prototype, DONT_ENUM, [
+ "toString", SymbolToString,
+ "valueOf", SymbolValueOf
+]);
+
+// -------------------------------------------------------------------
+// Exports
+
+utils.Export(function(to) {
+ to.SymbolToString = SymbolToString;
})
+
+})
« no previous file with comments | « src/js/string.js ('k') | src/js/v8natives.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698