aboutsummaryrefslogtreecommitdiff
path: root/deps/v8/src/weak-collection.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/weak-collection.js')
-rw-r--r--deps/v8/src/weak-collection.js119
1 files changed, 56 insertions, 63 deletions
diff --git a/deps/v8/src/weak-collection.js b/deps/v8/src/weak-collection.js
index 776043d9dc..f9863c1b20 100644
--- a/deps/v8/src/weak-collection.js
+++ b/deps/v8/src/weak-collection.js
@@ -2,22 +2,22 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-"use strict";
+(function(global, shared, exports) {
-// 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
function WeakMapConstructor(iterable) {
if (!%_IsConstructCall()) {
- throw MakeTypeError('constructor_not_function', ['WeakMap']);
+ throw MakeTypeError(kConstructorNotFunction, "WeakMap");
}
%WeakCollectionInitialize(this);
@@ -25,11 +25,11 @@ function WeakMapConstructor(iterable) {
if (!IS_NULL_OR_UNDEFINED(iterable)) {
var adder = this.set;
if (!IS_SPEC_FUNCTION(adder)) {
- throw MakeTypeError('property_not_function', ['set', this]);
+ throw MakeTypeError(kPropertyNotFunction, 'set', this);
}
for (var nextItem of iterable) {
if (!IS_SPEC_OBJECT(nextItem)) {
- throw MakeTypeError('iterator_value_not_an_object', [nextItem]);
+ throw MakeTypeError(kIteratorValueNotAnObject, nextItem);
}
%_CallFunction(this, nextItem[0], nextItem[1], adder);
}
@@ -39,8 +39,8 @@ function WeakMapConstructor(iterable) {
function WeakMapGet(key) {
if (!IS_WEAKMAP(this)) {
- throw MakeTypeError('incompatible_method_receiver',
- ['WeakMap.prototype.get', this]);
+ throw MakeTypeError(kIncompatibleMethodReceiver,
+ 'WeakMap.prototype.get', this);
}
if (!IS_SPEC_OBJECT(key)) return UNDEFINED;
return %WeakCollectionGet(this, key);
@@ -49,8 +49,8 @@ function WeakMapGet(key) {
function WeakMapSet(key, value) {
if (!IS_WEAKMAP(this)) {
- throw MakeTypeError('incompatible_method_receiver',
- ['WeakMap.prototype.set', this]);
+ throw MakeTypeError(kIncompatibleMethodReceiver,
+ 'WeakMap.prototype.set', this);
}
if (!IS_SPEC_OBJECT(key)) {
throw %MakeTypeError('invalid_weakmap_key', [this, key]);
@@ -61,8 +61,8 @@ function WeakMapSet(key, value) {
function WeakMapHas(key) {
if (!IS_WEAKMAP(this)) {
- throw MakeTypeError('incompatible_method_receiver',
- ['WeakMap.prototype.has', this]);
+ throw MakeTypeError(kIncompatibleMethodReceiver,
+ 'WeakMap.prototype.has', this);
}
if (!IS_SPEC_OBJECT(key)) return false;
return %WeakCollectionHas(this, key);
@@ -71,8 +71,8 @@ function WeakMapHas(key) {
function WeakMapDelete(key) {
if (!IS_WEAKMAP(this)) {
- throw MakeTypeError('incompatible_method_receiver',
- ['WeakMap.prototype.delete', this]);
+ throw MakeTypeError(kIncompatibleMethodReceiver,
+ 'WeakMap.prototype.delete', this);
}
if (!IS_SPEC_OBJECT(key)) return false;
return %WeakCollectionDelete(this, key);
@@ -81,33 +81,28 @@ function WeakMapDelete(key) {
// -------------------------------------------------------------------
-function SetUpWeakMap() {
- %CheckIsBootstrapping();
-
- %SetCode($WeakMap, WeakMapConstructor);
- %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, $Array(
- "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
function WeakSetConstructor(iterable) {
if (!%_IsConstructCall()) {
- throw MakeTypeError('constructor_not_function', ['WeakSet']);
+ throw MakeTypeError(kConstructorNotFunction, "WeakSet");
}
%WeakCollectionInitialize(this);
@@ -115,7 +110,7 @@ function WeakSetConstructor(iterable) {
if (!IS_NULL_OR_UNDEFINED(iterable)) {
var adder = this.add;
if (!IS_SPEC_FUNCTION(adder)) {
- throw MakeTypeError('property_not_function', ['add', this]);
+ throw MakeTypeError(kPropertyNotFunction, 'add', this);
}
for (var value of iterable) {
%_CallFunction(this, value, adder);
@@ -126,8 +121,8 @@ function WeakSetConstructor(iterable) {
function WeakSetAdd(value) {
if (!IS_WEAKSET(this)) {
- throw MakeTypeError('incompatible_method_receiver',
- ['WeakSet.prototype.add', this]);
+ throw MakeTypeError(kIncompatibleMethodReceiver,
+ 'WeakSet.prototype.add', this);
}
if (!IS_SPEC_OBJECT(value)) {
throw %MakeTypeError('invalid_weakset_value', [this, value]);
@@ -138,8 +133,8 @@ function WeakSetAdd(value) {
function WeakSetHas(value) {
if (!IS_WEAKSET(this)) {
- throw MakeTypeError('incompatible_method_receiver',
- ['WeakSet.prototype.has', this]);
+ throw MakeTypeError(kIncompatibleMethodReceiver,
+ 'WeakSet.prototype.has', this);
}
if (!IS_SPEC_OBJECT(value)) return false;
return %WeakCollectionHas(this, value);
@@ -148,8 +143,8 @@ function WeakSetHas(value) {
function WeakSetDelete(value) {
if (!IS_WEAKSET(this)) {
- throw MakeTypeError('incompatible_method_receiver',
- ['WeakSet.prototype.delete', this]);
+ throw MakeTypeError(kIncompatibleMethodReceiver,
+ 'WeakSet.prototype.delete', this);
}
if (!IS_SPEC_OBJECT(value)) return false;
return %WeakCollectionDelete(this, value);
@@ -158,21 +153,19 @@ function WeakSetDelete(value) {
// -------------------------------------------------------------------
-function SetUpWeakSet() {
- %CheckIsBootstrapping();
-
- %SetCode($WeakSet, WeakSetConstructor);
- %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, $Array(
- "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
+]);
+
+})