Reviewers: adamk,

Message:
PTAL

Description:
Align GetIterator with ES6 spec

BUG=None
LOG=N
R=adamk

Please review this at https://codereview.chromium.org/936793003/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+9, -17 lines):
  M src/collection.js
  M src/v8natives.js
  M src/weak-collection.js
  M test/mjsunit/es6/collections.js


Index: src/collection.js
diff --git a/src/collection.js b/src/collection.js
index 94bda703578ea73829efda3a7db96705f614d54b..9b5716687bcc14ed06e628afd15de795b07c1a14 100644
--- a/src/collection.js
+++ b/src/collection.js
@@ -23,7 +23,7 @@ function SetConstructor(iterable) {
   var iter, adder;

   if (!IS_NULL_OR_UNDEFINED(iterable)) {
-    iter = GetIterator(ToObject(iterable));
+    iter = GetIterator(iterable);
     adder = this.add;
     if (!IS_SPEC_FUNCTION(adder)) {
       throw MakeTypeError('property_not_function', ['add', this]);
@@ -163,7 +163,7 @@ function MapConstructor(iterable) {
   var iter, adder;

   if (!IS_NULL_OR_UNDEFINED(iterable)) {
-    iter = GetIterator(ToObject(iterable));
+    iter = GetIterator(iterable);
     adder = this.set;
     if (!IS_SPEC_FUNCTION(adder)) {
       throw MakeTypeError('property_not_function', ['set', this]);
Index: src/v8natives.js
diff --git a/src/v8natives.js b/src/v8natives.js
index 23143345f666410c63a1d09c661cd2ecccb3d09d..3cba466494233df2bac910ffec5561b99fa6bf72 100644
--- a/src/v8natives.js
+++ b/src/v8natives.js
@@ -1879,21 +1879,11 @@ SetUpFunction();
// ----------------------------------------------------------------------------
 // Iterator related spec functions.

-// ES6 rev 26, 2014-07-18
-// 7.4.1 CheckIterable ( obj )
-function ToIterable(obj) {
-  if (!IS_SPEC_OBJECT(obj)) {
-    return UNDEFINED;
-  }
-  return obj[symbolIterator];
-}
-
-
-// ES6 rev 26, 2014-07-18
-// 7.4.2 GetIterator ( obj, method )
+// ES6 rev 33, 2015-02-12
+// 7.4.1 GetIterator ( obj, method )
 function GetIterator(obj, method) {
   if (IS_UNDEFINED(method)) {
-    method = ToIterable(obj);
+    method = ToObject(obj)[symbolIterator];
   }
   if (!IS_SPEC_FUNCTION(method)) {
     throw MakeTypeError('not_iterable', [obj]);
Index: src/weak-collection.js
diff --git a/src/weak-collection.js b/src/weak-collection.js
index a44c3d7cd7caeb2d7eb835b002332fc8df30a679..3cec9cc5071c6add9c3b9cd1830abaf82c859bbe 100644
--- a/src/weak-collection.js
+++ b/src/weak-collection.js
@@ -23,7 +23,7 @@ function WeakMapConstructor(iterable) {
   var iter, adder;

   if (!IS_NULL_OR_UNDEFINED(iterable)) {
-    iter = GetIterator(ToObject(iterable));
+    iter = GetIterator(iterable);
     adder = this.set;
     if (!IS_SPEC_FUNCTION(adder)) {
       throw MakeTypeError('property_not_function', ['set', this]);
@@ -130,7 +130,7 @@ function WeakSetConstructor(iterable) {
   var iter, adder;

   if (!IS_NULL_OR_UNDEFINED(iterable)) {
-    iter = GetIterator(ToObject(iterable));
+    iter = GetIterator(iterable);
     adder = this.add;
     if (!IS_SPEC_FUNCTION(adder)) {
       throw MakeTypeError('property_not_function', ['add', this]);
Index: test/mjsunit/es6/collections.js
diff --git a/test/mjsunit/es6/collections.js b/test/mjsunit/es6/collections.js index 92cd087839f13e8c5f9c3feac4abcdf29ff36a36..7f8b4a5feba1125fd22596486bdae07c2571e989 100644
--- a/test/mjsunit/es6/collections.js
+++ b/test/mjsunit/es6/collections.js
@@ -1192,6 +1192,7 @@ function TestSetConstructorIterableValue(ctor) {
     get: function() {
       assertEquals('object', typeof this);
       return function() {
+        assertEquals('number', typeof this);
         return oneAndTwo.keys();
       };
     },
@@ -1382,6 +1383,7 @@ function TestMapConstructorIterableValue(ctor) {
     get: function() {
       assertEquals('object', typeof this);
       return function() {
+        assertEquals('number', typeof this);
         return oneAndTwo.entries();
       };
     },


--
--
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