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

Unified Diff: src/collection.js

Issue 8439069: Fix Harmony sets and maps to allow undefined as keys. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Andreas Rossberg. Created 9 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 4e45885b96d524954110b6a76c0ffc7339036201..12ff893742982aba91776f18c6e7391315cd933e 100644
--- a/src/collection.js
+++ b/src/collection.js
@@ -32,6 +32,11 @@ const $WeakMap = global.WeakMap;
//-------------------------------------------------------------------
+// Global sentinel to be used instead of undefined keys, which are not
+// supported internally but required for Harmony sets and maps.
+var undefined_sentinel = {};
+
+
function SetConstructor() {
if (%_IsConstructCall()) {
%SetInitialize(this);
@@ -42,16 +47,25 @@ function SetConstructor() {
function SetAdd(key) {
+ if (IS_UNDEFINED(key)) {
+ key = undefined_sentinel;
+ }
return %SetAdd(this, key);
}
function SetHas(key) {
+ if (IS_UNDEFINED(key)) {
+ key = undefined_sentinel;
+ }
return %SetHas(this, key);
}
function SetDelete(key) {
+ if (IS_UNDEFINED(key)) {
+ key = undefined_sentinel;
+ }
return %SetDelete(this, key);
}
@@ -66,21 +80,33 @@ function MapConstructor() {
function MapGet(key) {
+ if (IS_UNDEFINED(key)) {
+ key = undefined_sentinel;
+ }
return %MapGet(this, key);
}
function MapSet(key, value) {
+ if (IS_UNDEFINED(key)) {
+ key = undefined_sentinel;
+ }
return %MapSet(this, key, value);
}
function MapHas(key) {
+ if (IS_UNDEFINED(key)) {
+ key = undefined_sentinel;
+ }
return !IS_UNDEFINED(%MapGet(this, key));
}
function MapDelete(key) {
+ if (IS_UNDEFINED(key)) {
+ key = undefined_sentinel;
+ }
if (!IS_UNDEFINED(%MapGet(this, key))) {
%MapSet(this, key, void 0);
return true;
« 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