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

Unified Diff: src/weak-collection.js

Issue 1094563002: Wrap map and set implementation in functions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 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/templates.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/weak-collection.js
diff --git a/src/weak-collection.js b/src/weak-collection.js
index 233f9783841ffa9c39a46b6037f52a0d7e319cd7..44faa3ecd8826b770203d7eda2d6e1001f813570 100644
--- a/src/weak-collection.js
+++ b/src/weak-collection.js
@@ -2,15 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-"use strict";
+(function() {
-// This file relies on the fact that the following declaration has been made
-// in runtime.js:
-// var $Array = global.Array;
+"use strict";
-var $WeakMap = global.WeakMap;
-var $WeakSet = global.WeakSet;
+%CheckIsBootstrapping();
+var GlobalObject = global.Object;
+var GlobalWeakMap = global.WeakMap;
+var GlobalWeakSet = global.WeakSet;
// -------------------------------------------------------------------
// Harmony WeakMap
@@ -81,27 +81,21 @@ function WeakMapDelete(key) {
// -------------------------------------------------------------------
-function SetUpWeakMap() {
- %CheckIsBootstrapping();
-
- %SetCode($WeakMap, WeakMapConstructor);
- %FunctionSetLength($WeakMap, 0);
- %FunctionSetPrototype($WeakMap, new $Object());
- %AddNamedProperty($WeakMap.prototype, "constructor", $WeakMap, DONT_ENUM);
- %AddNamedProperty(
- $WeakMap.prototype, symbolToStringTag, "WeakMap", DONT_ENUM | READ_ONLY);
-
- // Set up the non-enumerable functions on the WeakMap prototype object.
- InstallFunctions($WeakMap.prototype, DONT_ENUM, [
- "get", WeakMapGet,
- "set", WeakMapSet,
- "has", WeakMapHas,
- "delete", WeakMapDelete
- ]);
-}
-
-SetUpWeakMap();
-
+%SetCode(GlobalWeakMap, WeakMapConstructor);
+%FunctionSetLength(GlobalWeakMap, 0);
+%FunctionSetPrototype(GlobalWeakMap, new GlobalObject());
+%AddNamedProperty(GlobalWeakMap.prototype, "constructor", GlobalWeakMap,
+ DONT_ENUM);
+%AddNamedProperty(GlobalWeakMap.prototype, symbolToStringTag, "WeakMap",
+ DONT_ENUM | READ_ONLY);
+
+// Set up the non-enumerable functions on the WeakMap prototype object.
+InstallFunctions(GlobalWeakMap.prototype, DONT_ENUM, [
+ "get", WeakMapGet,
+ "set", WeakMapSet,
+ "has", WeakMapHas,
+ "delete", WeakMapDelete
+]);
// -------------------------------------------------------------------
// Harmony WeakSet
@@ -159,22 +153,19 @@ function WeakSetDelete(value) {
// -------------------------------------------------------------------
-function SetUpWeakSet() {
- %CheckIsBootstrapping();
-
- %SetCode($WeakSet, WeakSetConstructor);
- %FunctionSetLength($WeakSet, 0);
- %FunctionSetPrototype($WeakSet, new $Object());
- %AddNamedProperty($WeakSet.prototype, "constructor", $WeakSet, DONT_ENUM);
- %AddNamedProperty(
- $WeakSet.prototype, symbolToStringTag, "WeakSet", DONT_ENUM | READ_ONLY);
-
- // Set up the non-enumerable functions on the WeakSet prototype object.
- InstallFunctions($WeakSet.prototype, DONT_ENUM, [
- "add", WeakSetAdd,
- "has", WeakSetHas,
- "delete", WeakSetDelete
- ]);
-}
-
-SetUpWeakSet();
+%SetCode(GlobalWeakSet, WeakSetConstructor);
+%FunctionSetLength(GlobalWeakSet, 0);
+%FunctionSetPrototype(GlobalWeakSet, new GlobalObject());
+%AddNamedProperty(GlobalWeakSet.prototype, "constructor", GlobalWeakSet,
+ DONT_ENUM);
+%AddNamedProperty(GlobalWeakSet.prototype, symbolToStringTag, "WeakSet",
+ DONT_ENUM | READ_ONLY);
+
+// Set up the non-enumerable functions on the WeakSet prototype object.
+InstallFunctions(GlobalWeakSet.prototype, DONT_ENUM, [
+ "add", WeakSetAdd,
+ "has", WeakSetHas,
+ "delete", WeakSetDelete
+]);
+
+})();
« no previous file with comments | « src/templates.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698