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

Unified Diff: src/symbol.js

Issue 1009443002: Hide Symbol implementation in a closure. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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
« no previous file with comments | « src/string.js ('k') | no next file » | 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 d9cf79265f33320a500a04cd5532440cb53bc929..7a80815229b8f83e27f639b8084b9540f9e96776 100644
--- a/src/symbol.js
+++ b/src/symbol.js
@@ -2,13 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-"use strict";
-
-// This file relies on the fact that the following declaration has been made
-// in runtime.js:
-// var $Array = global.Array;
-
-// And requires following symbols to be set in the bootstrapper during genesis:
+// Expects following symbols to be set in the bootstrapper during genesis:
// - symbolHasInstance
// - symbolIsConcatSpreadable
// - symbolIsRegExp
@@ -16,7 +10,17 @@
// - symbolToStringTag
// - symbolUnscopables
-var $Symbol = global.Symbol;
+var $symbolToString;
+
+(function() {
+
+"use strict";
+
+%CheckIsBootstrapping();
+
+var GlobalArray = global.Array;
+var GlobalObject = global.Object;
+var GlobalSymbol = global.Symbol;
// -------------------------------------------------------------------
@@ -77,46 +81,40 @@ function ObjectGetOwnPropertySymbols(obj) {
//-------------------------------------------------------------------
-function SetUpSymbol() {
- %CheckIsBootstrapping();
-
- %SetCode($Symbol, SymbolConstructor);
- %FunctionSetPrototype($Symbol, new $Object());
-
- InstallConstants($Symbol, $Array(
- // TODO(rossberg): expose when implemented.
- // "hasInstance", symbolHasInstance,
- // "isConcatSpreadable", symbolIsConcatSpreadable,
- // "isRegExp", symbolIsRegExp,
- "iterator", symbolIterator,
- // TODO(dslomov, caitp): Currently defined in harmony-tostring.js ---
- // Move here when shipping
- // "toStringTag", symbolToStringTag,
- "unscopables", symbolUnscopables
- ));
- InstallFunctions($Symbol, DONT_ENUM, $Array(
- "for", SymbolFor,
- "keyFor", SymbolKeyFor
- ));
-
- %AddNamedProperty($Symbol.prototype, "constructor", $Symbol, DONT_ENUM);
- %AddNamedProperty(
- $Symbol.prototype, symbolToStringTag, "Symbol", DONT_ENUM | READ_ONLY);
- InstallFunctions($Symbol.prototype, DONT_ENUM, $Array(
- "toString", SymbolToString,
- "valueOf", SymbolValueOf
- ));
-}
-
-SetUpSymbol();
-
-
-function ExtendObject() {
- %CheckIsBootstrapping();
-
- InstallFunctions($Object, DONT_ENUM, $Array(
- "getOwnPropertySymbols", ObjectGetOwnPropertySymbols
- ));
-}
-
-ExtendObject();
+%SetCode(GlobalSymbol, SymbolConstructor);
+%FunctionSetPrototype(GlobalSymbol, new GlobalObject());
+
+InstallConstants(GlobalSymbol, GlobalArray(
+ // TODO(rossberg): expose when implemented.
+ // "hasInstance", symbolHasInstance,
+ // "isConcatSpreadable", symbolIsConcatSpreadable,
+ // "isRegExp", symbolIsRegExp,
+ "iterator", symbolIterator,
+ // TODO(dslomov, caitp): Currently defined in harmony-tostring.js ---
+ // Move here when shipping
+ // "toStringTag", symbolToStringTag,
+ "unscopables", symbolUnscopables
+));
+
+InstallFunctions(GlobalSymbol, DONT_ENUM, GlobalArray(
+ "for", SymbolFor,
+ "keyFor", SymbolKeyFor
+));
+
+%AddNamedProperty(
+ GlobalSymbol.prototype, "constructor", GlobalSymbol, DONT_ENUM);
+%AddNamedProperty(
+ GlobalSymbol.prototype, symbolToStringTag, "Symbol", DONT_ENUM | READ_ONLY);
+
+InstallFunctions(GlobalSymbol.prototype, DONT_ENUM, GlobalArray(
+ "toString", SymbolToString,
+ "valueOf", SymbolValueOf
+));
+
+InstallFunctions(GlobalObject, DONT_ENUM, GlobalArray(
+ "getOwnPropertySymbols", ObjectGetOwnPropertySymbols
+));
+
+$symbolToString = SymbolToString;
+
+})();
« no previous file with comments | « src/string.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698