| 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;
|
| })
|
| +
|
| +})
|
|
|