Chromium Code Reviews| Index: src/collection.js |
| diff --git a/src/collection.js b/src/collection.js |
| index d5a8fe21a456c3d99bd6572853a9dddc82a04fcd..b3c2db72d792732be2ae8f8caf9554df8c34ffaa 100644 |
| --- a/src/collection.js |
| +++ b/src/collection.js |
| @@ -97,6 +97,16 @@ function SetGetSize() { |
| } |
| +function SetClear() { |
| + if (!IS_SET(this)) { |
| + throw MakeTypeError('incompatible_method_receiver', |
| + ['Set.prototype.clear', this]); |
| + } |
| + // Replace the internal table with a new empty table. |
| + %SetInitialize(this); |
|
arv (Not doing code reviews)
2012/11/08 21:16:28
I first added a %SetClear before I realized that i
Michael Starzinger
2012/11/09 08:56:12
That's fine, I prefer it the way it is as well. Th
|
| +} |
| + |
| + |
| function MapConstructor() { |
| if (%_IsConstructCall()) { |
| %MapInitialize(this); |
| @@ -163,6 +173,16 @@ function MapGetSize() { |
| } |
| +function MapClear() { |
| + if (!IS_MAP(this)) { |
| + throw MakeTypeError('incompatible_method_receiver', |
| + ['Map.prototype.clear', this]); |
| + } |
| + // Replace the internal table with a new empty table. |
| + %MapInitialize(this); |
| +} |
| + |
| + |
| function WeakMapConstructor() { |
| if (%_IsConstructCall()) { |
| %WeakMapInitialize(this); |
| @@ -237,7 +257,8 @@ function WeakMapDelete(key) { |
| InstallFunctions($Set.prototype, DONT_ENUM, $Array( |
| "add", SetAdd, |
| "has", SetHas, |
| - "delete", SetDelete |
| + "delete", SetDelete, |
| + "clear", SetClear |
| )); |
| // Set up the non-enumerable functions on the Map prototype object. |
| @@ -246,7 +267,8 @@ function WeakMapDelete(key) { |
| "get", MapGet, |
| "set", MapSet, |
| "has", MapHas, |
| - "delete", MapDelete |
| + "delete", MapDelete, |
| + "clear", MapClear |
| )); |
| // Set up the WeakMap constructor function. |