Revision: 22111
Author:   [email protected]
Date:     Tue Jul  1 09:49:25 2014 UTC
Log:      Make Map.set() and Set.add() chainable

From the Harmony draft:

https://people.mozilla.org/~jorendorff/es6-draft.html#sec-map.prototype.set
https://people.mozilla.org/~jorendorff/es6-draft.html#sec-weakmap.prototype.set
https://people.mozilla.org/~jorendorff/es6-draft.html#sec-set.prototype.add
https://people.mozilla.org/~jorendorff/es6-draft.html#sec-weakset.prototype.add

BUG=v8:3410
[email protected], [email protected]

Review URL: https://codereview.chromium.org/359173002

Patch from caitp <[email protected]>.
http://code.google.com/p/v8/source/detail?r=22111

Modified:
 /branches/bleeding_edge/src/runtime.cc
 /branches/bleeding_edge/test/mjsunit/es6/weak_collections.js
 /branches/bleeding_edge/test/mjsunit/harmony/collections.js

=======================================
--- /branches/bleeding_edge/src/runtime.cc      Mon Jun 30 13:48:57 2014 UTC
+++ /branches/bleeding_edge/src/runtime.cc      Tue Jul  1 09:49:25 2014 UTC
@@ -1547,7 +1547,7 @@
   Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table()));
   table = OrderedHashSet::Add(table, key);
   holder->set_table(*table);
-  return isolate->heap()->undefined_value();
+  return *holder;
 }


@@ -1685,7 +1685,7 @@
   Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table()));
Handle<OrderedHashMap> new_table = OrderedHashMap::Put(table, key, value);
   holder->set_table(*new_table);
-  return isolate->heap()->undefined_value();
+  return *holder;
 }


@@ -1799,7 +1799,7 @@
   RUNTIME_ASSERT(table->IsKey(*key));
Handle<ObjectHashTable> new_table = ObjectHashTable::Put(table, key, value);
   weak_collection->set_table(*new_table);
-  return isolate->heap()->undefined_value();
+  return *weak_collection;
 }


=======================================
--- /branches/bleeding_edge/test/mjsunit/es6/weak_collections.js Tue May 6 14:48:34 2014 UTC +++ /branches/bleeding_edge/test/mjsunit/es6/weak_collections.js Tue Jul 1 09:49:25 2014 UTC
@@ -68,7 +68,7 @@
 // Test expected behavior for WeakSets
 function TestSet(set, key) {
   assertFalse(set.has(key));
-  assertSame(undefined, set.add(key));
+  assertSame(set, set.add(key));
   assertTrue(set.has(key));
   assertTrue(set.delete(key));
   assertFalse(set.has(key));
@@ -92,7 +92,7 @@

 // Test expected mapping behavior for WeakMaps
 function TestMapping(map, key, value) {
-  assertSame(undefined, map.set(key, value));
+  assertSame(map, map.set(key, value));
   assertSame(value, map.get(key));
 }
 function TestMapBehavior1(m) {
=======================================
--- /branches/bleeding_edge/test/mjsunit/harmony/collections.js Mon Jun 23 18:05:57 2014 UTC +++ /branches/bleeding_edge/test/mjsunit/harmony/collections.js Tue Jul 1 09:49:25 2014 UTC
@@ -67,7 +67,7 @@
 // Test expected behavior for Sets and WeakSets
 function TestSet(set, key) {
   assertFalse(set.has(key));
-  assertSame(undefined, set.add(key));
+  assertSame(set, set.add(key));
   assertTrue(set.has(key));
   assertTrue(set.delete(key));
   assertFalse(set.has(key));
@@ -92,7 +92,7 @@

 // Test expected mapping behavior for Maps and WeakMaps
 function TestMapping(map, key, value) {
-  assertSame(undefined, map.set(key, value));
+  assertSame(map, map.set(key, value));
   assertSame(value, map.get(key));
 }
 function TestMapBehavior1(m) {

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to