Chromium Code Reviews| Index: src/symbol.js |
| diff --git a/src/symbol.js b/src/symbol.js |
| index 1e65cb859da2543629f22028aa619a1b02e1a15e..47de265d9eb7f33fda9e9ec2001335f11a1f0e3f 100644 |
| --- a/src/symbol.js |
| +++ b/src/symbol.js |
| @@ -30,7 +30,8 @@ |
| var $Symbol = global.Symbol; |
| function SymbolConstructor(x) { |
| - var value = IS_SYMBOL(x) ? x : %CreateSymbol(); |
| + var value = |
| + IS_SYMBOL(x) ? x : %CreateSymbol(IS_UNDEFINED(x) ? x : ToString(x)); |
| if (%_IsConstructCall()) { |
| %_SetValueOf(this, value); |
| } else { |
| @@ -38,6 +39,14 @@ function SymbolConstructor(x) { |
| } |
| } |
| +function SymbolGetName() { |
| + var symbol = IS_SYMBOL_WRAPPER(this) ? %_ValueOf(this) : this; |
| + if (!IS_SYMBOL(symbol)) { |
| + throw new $TypeError("Symbol.prototype.name is not generic"); |
|
Michael Starzinger
2013/03/22 12:03:25
Use MakeTypeError here, see my comments in the pre
rossberg
2013/03/22 13:02:42
Done.
|
| + } |
| + return %SymbolName(symbol); |
| +} |
| + |
| function SymbolToString() { |
| throw new $TypeError("Symbol.prototype.toString is not allowed"); |
| } |
| @@ -60,6 +69,7 @@ function SetUpSymbol() { |
| %FunctionSetPrototype($Symbol, new $Symbol()); |
| %SetProperty($Symbol.prototype, "constructor", $Symbol, DONT_ENUM); |
| + InstallGetter($Symbol.prototype, "name", SymbolGetName); |
| InstallFunctions($Symbol.prototype, DONT_ENUM, $Array( |
| "toString", SymbolToString, |
| "valueOf", SymbolValueOf |