Index: src/collection.js |
diff --git a/src/collection.js b/src/collection.js |
index c872efbb302c3d3d4a5417bb47534b2160ec1e50..b1257a31d5e6228fd9acf17d8a57b8dcd1ace342 100644 |
--- a/src/collection.js |
+++ b/src/collection.js |
@@ -27,16 +27,20 @@ |
"use strict"; |
+// This file relies on the fact that the following declaration has been made |
+// in runtime.js: |
+// var $Array = global.Array; |
+ |
var $Set = global.Set; |
var $Map = global.Map; |
var $WeakMap = global.WeakMap; |
-//------------------------------------------------------------------- |
- |
// Global sentinel to be used instead of undefined keys, which are not |
// supported internally but required for Harmony sets and maps. |
var undefined_sentinel = {}; |
+// ------------------------------------------------------------------- |
+// Harmony Set |
function SetConstructor() { |
if (%_IsConstructCall()) { |
@@ -107,6 +111,30 @@ function SetClear() { |
} |
+// ------------------------------------------------------------------- |
+ |
+function SetUpSet() { |
+ %CheckIsBootstrapping(); |
+ |
+ %SetCode($Set, SetConstructor); |
+ %SetProperty($Set.prototype, "constructor", $Set, DONT_ENUM); |
+ |
+ // Set up the non-enumerable functions on the Set prototype object. |
+ InstallGetter($Set.prototype, "size", SetGetSize); |
+ InstallFunctions($Set.prototype, DONT_ENUM, $Array( |
+ "add", SetAdd, |
+ "has", SetHas, |
+ "delete", SetDelete, |
+ "clear", SetClear |
+ )); |
+} |
+ |
+SetUpSet(); |
+ |
+ |
+// ------------------------------------------------------------------- |
+// Harmony Map |
+ |
function MapConstructor() { |
if (%_IsConstructCall()) { |
%MapInitialize(this); |
@@ -183,6 +211,31 @@ function MapClear() { |
} |
+// ------------------------------------------------------------------- |
+ |
+function SetUpMap() { |
+ %CheckIsBootstrapping(); |
+ |
+ %SetCode($Map, MapConstructor); |
+ %SetProperty($Map.prototype, "constructor", $Map, DONT_ENUM); |
+ |
+ // Set up the non-enumerable functions on the Map prototype object. |
+ InstallGetter($Map.prototype, "size", MapGetSize); |
+ InstallFunctions($Map.prototype, DONT_ENUM, $Array( |
+ "get", MapGet, |
+ "set", MapSet, |
+ "has", MapHas, |
+ "delete", MapDelete, |
+ "clear", MapClear |
+ )); |
+} |
+ |
+SetUpMap(); |
+ |
+ |
+// ------------------------------------------------------------------- |
+// Harmony WeakMap |
+ |
function WeakMapConstructor() { |
if (%_IsConstructCall()) { |
%WeakMapInitialize(this); |
@@ -239,42 +292,13 @@ function WeakMapDelete(key) { |
return %WeakMapDelete(this, key); |
} |
+ |
// ------------------------------------------------------------------- |
-(function () { |
+function SetUpWeakMap() { |
%CheckIsBootstrapping(); |
- // Set up the Set and Map constructor function. |
- %SetCode($Set, SetConstructor); |
- %SetCode($Map, MapConstructor); |
- |
- // Set up the constructor property on the Set and Map prototype object. |
- %SetProperty($Set.prototype, "constructor", $Set, DONT_ENUM); |
- %SetProperty($Map.prototype, "constructor", $Map, DONT_ENUM); |
- |
- // Set up the non-enumerable functions on the Set prototype object. |
- InstallGetter($Set.prototype, "size", SetGetSize); |
- InstallFunctions($Set.prototype, DONT_ENUM, $Array( |
- "add", SetAdd, |
- "has", SetHas, |
- "delete", SetDelete, |
- "clear", SetClear |
- )); |
- |
- // Set up the non-enumerable functions on the Map prototype object. |
- InstallGetter($Map.prototype, "size", MapGetSize); |
- InstallFunctions($Map.prototype, DONT_ENUM, $Array( |
- "get", MapGet, |
- "set", MapSet, |
- "has", MapHas, |
- "delete", MapDelete, |
- "clear", MapClear |
- )); |
- |
- // Set up the WeakMap constructor function. |
%SetCode($WeakMap, WeakMapConstructor); |
- |
- // Set up the constructor property on the WeakMap prototype object. |
%SetProperty($WeakMap.prototype, "constructor", $WeakMap, DONT_ENUM); |
// Set up the non-enumerable functions on the WeakMap prototype object. |
@@ -284,4 +308,6 @@ function WeakMapDelete(key) { |
"has", WeakMapHas, |
"delete", WeakMapDelete |
)); |
-})(); |
+} |
+ |
+SetUpWeakMap(); |