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

Unified Diff: src/weakmap.js

Issue 7572013: Additional functions to Harmony weak maps API. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix how undefined is used. Created 9 years, 4 months 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/weakmaps.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/weakmap.js
diff --git a/src/weakmap.js b/src/weakmap.js
index b209776829e37c49fd5e1ab5ed4f87bfa6ff78fa..15056c7f8226588fa99a0b827a047c8253f134ee 100644
--- a/src/weakmap.js
+++ b/src/weakmap.js
@@ -58,13 +58,36 @@ function WeakMapSet(key, value) {
return %WeakMapSet(this, key, value);
}
+
+function WeakMapHas(key) {
+ if (!IS_SPEC_OBJECT(key)) {
+ throw %MakeTypeError('invalid_weakmap_key', [this, key]);
+ }
+ return !IS_UNDEFINED(%WeakMapGet(this, key));
+}
+
+
+function WeakMapDelete(key) {
+ if (!IS_SPEC_OBJECT(key)) {
+ throw %MakeTypeError('invalid_weakmap_key', [this, key]);
+ }
+ if (!IS_UNDEFINED(%WeakMapGet(this, key))) {
+ %WeakMapSet(this, key, void 0);
+ return true;
+ } else {
+ return false;
+ }
+}
+
// -------------------------------------------------------------------
function SetupWeakMap() {
// Setup the non-enumerable functions on the WeakMap prototype object.
InstallFunctionsOnHiddenPrototype($WeakMap.prototype, DONT_ENUM, $Array(
"get", WeakMapGet,
- "set", WeakMapSet
+ "set", WeakMapSet,
+ "has", WeakMapHas,
+ "delete", WeakMapDelete
));
}
« no previous file with comments | « no previous file | test/mjsunit/harmony/weakmaps.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698