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

Unified Diff: src/symbol.js

Issue 181453002: Reset trunk to 3.24.35.4 (Closed) Base URL: https://v8.googlecode.com/svn/trunk
Patch Set: Created 6 years, 10 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/sweeper-thread.cc ('k') | src/type-info.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/symbol.js
diff --git a/src/symbol.js b/src/symbol.js
index 8cb19271835f609b269af987a6cbeae8723b4048..be308d947cb0353dd9eb10aa4077a473536884f7 100644
--- a/src/symbol.js
+++ b/src/symbol.js
@@ -36,28 +36,34 @@ var $Symbol = global.Symbol;
// -------------------------------------------------------------------
function SymbolConstructor(x) {
+ var value =
+ IS_SYMBOL(x) ? x : %CreateSymbol(IS_UNDEFINED(x) ? x : ToString(x));
if (%_IsConstructCall()) {
- throw MakeTypeError('not_constructor', ["Symbol"]);
+ %_SetValueOf(this, value);
+ } else {
+ return value;
}
- // NOTE: Passing in a Symbol value will throw on ToString().
- return %CreateSymbol(IS_UNDEFINED(x) ? x : ToString(x));
}
-
-function SymbolToString() {
- if (!(IS_SYMBOL(this) || IS_SYMBOL_WRAPPER(this))) {
+function SymbolGetName() {
+ var symbol = IS_SYMBOL_WRAPPER(this) ? %_ValueOf(this) : this;
+ if (!IS_SYMBOL(symbol)) {
throw MakeTypeError(
- 'incompatible_method_receiver', ["Symbol.prototype.toString", this]);
+ 'incompatible_method_receiver', ["Symbol.prototype.name", this]);
}
- var description = %SymbolDescription(%_ValueOf(this));
- return "Symbol(" + (IS_UNDEFINED(description) ? "" : description) + ")";
+ return %SymbolName(symbol);
}
+function SymbolToString() {
+ throw MakeTypeError('symbol_to_string');
+}
function SymbolValueOf() {
- if (!(IS_SYMBOL(this) || IS_SYMBOL_WRAPPER(this))) {
+ // NOTE: Both Symbol objects and values can enter here as
+ // 'this'. This is not as dictated by ECMA-262.
+ if (!IS_SYMBOL(this) && !IS_SYMBOL_WRAPPER(this)) {
throw MakeTypeError(
- 'incompatible_method_receiver', ["Symbol.prototype.valueOf", this]);
+ 'incompatible_method_receiver', ["Symbol.prototype.valueOf", this]);
}
return %_ValueOf(this);
}
@@ -82,9 +88,10 @@ function SetUpSymbol() {
%CheckIsBootstrapping();
%SetCode($Symbol, SymbolConstructor);
- %FunctionSetPrototype($Symbol, new $Object());
-
+ %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
« no previous file with comments | « src/sweeper-thread.cc ('k') | src/type-info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698