Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(715)

Unified Diff: src/collection.js

Issue 11409002: ES6: Add support for Set and Map clear method (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/mjsunit/harmony/collections.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
« no previous file with comments | « no previous file | test/mjsunit/harmony/collections.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698