| Index: src/collection.js
|
| diff --git a/src/collection.js b/src/collection.js
|
| index c5604ab30f359b1287a664ed22d3656d8843b075..2ea7af1135a4d4eea633e185ec703111747d5a91 100644
|
| --- a/src/collection.js
|
| +++ b/src/collection.js
|
| @@ -325,3 +325,94 @@ function SetUpWeakMap() {
|
| }
|
|
|
| SetUpWeakMap();
|
| +
|
| +
|
| +// -------------------------------------------------------------------
|
| +// Harmony WeakSet
|
| +
|
| +var weaksetDataSymbol = %CreateSymbol(void 0);
|
| +
|
| +
|
| +function WeakSet() {
|
| + if (%_IsConstructCall()) {
|
| + this[weaksetDataSymbol] = new $WeakMap();
|
| + } else {
|
| + return new $WeakSet();
|
| + }
|
| +}
|
| +
|
| +
|
| +var $WeakSet = WeakSet;
|
| +
|
| +
|
| +function WeakSetAdd(value) {
|
| + var weaksetData = this[weaksetDataSymbol];
|
| + if (!weaksetData) {
|
| + throw %MakeTypeError('incompatible_method_receiver',
|
| + ['WeakSet.prototype.add', this]);
|
| + }
|
| + if (!(IS_SPEC_OBJECT(value) || IS_SYMBOL(value))) {
|
| + throw %MakeTypeError('invalid_weakset_value', [this, value]);
|
| + }
|
| + return %WeakMapSet(weaksetData, value, true);
|
| +}
|
| +
|
| +
|
| +function WeakSetHas(value) {
|
| + var weaksetData = this[weaksetDataSymbol];
|
| + if (!weaksetData) {
|
| + throw %MakeTypeError('incompatible_method_receiver',
|
| + ['WeakSet.prototype.has', this]);
|
| + }
|
| + if (!(IS_SPEC_OBJECT(value) || IS_SYMBOL(value))) {
|
| + throw %MakeTypeError('invalid_weakset_value', [this, value]);
|
| + }
|
| + return %WeakMapHas(weaksetData, value);
|
| +}
|
| +
|
| +
|
| +function WeakSetDelete(value) {
|
| + var weaksetData = this[weaksetDataSymbol];
|
| + if (!weaksetData) {
|
| + throw MakeTypeError('incompatible_method_receiver',
|
| + ['WeakSet.prototype.delete', this]);
|
| + }
|
| + if (!(IS_SPEC_OBJECT(value) || IS_SYMBOL(value))) {
|
| + throw %MakeTypeError('invalid_weakset_value', [this, value]);
|
| + }
|
| + return %WeakMapDelete(weaksetData, value);
|
| +}
|
| +
|
| +
|
| +function WeakSetClear() {
|
| + if (!this[weaksetDataSymbol]) {
|
| + throw %MakeTypeError('incompatible_method_receiver',
|
| + ['WeakSet.prototype.clear', this]);
|
| + }
|
| +
|
| + this[weaksetDataSymbol] = new $WeakMap();
|
| +}
|
| +
|
| +
|
| +// -------------------------------------------------------------------
|
| +
|
| +function SetUpWeakSet() {
|
| + %CheckIsBootstrapping();
|
| +
|
| + %SetProperty(global, 'WeakSet', $WeakSet, DONT_ENUM);
|
| +
|
| + %FunctionSetInstanceClassName($WeakSet, 'WeakSet');
|
| +
|
| + %FunctionSetPrototype($WeakSet, new $Object());
|
| + %SetProperty($WeakSet.prototype, 'constructor', $WeakSet, DONT_ENUM);
|
| +
|
| + // Set up the non-enumerable functions on the WeakSet prototype object.
|
| + InstallFunctions($WeakSet.prototype, DONT_ENUM, $Array(
|
| + 'add', WeakSetAdd,
|
| + 'has', WeakSetHas,
|
| + 'delete', WeakSetDelete,
|
| + 'clear', WeakSetClear
|
| + ));
|
| +}
|
| +
|
| +SetUpWeakSet();
|
|
|