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

Unified Diff: src/symbol.js

Issue 12459026: ES6 symbols: implement name property (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add missing scavenge visitor Created 7 years, 9 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
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
« src/runtime.cc ('K') | « src/runtime.cc ('k') | test/mjsunit/harmony/symbols.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698