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 |
+]); |
+ |
+})(); |