Revision: 21797
Author:   [email protected]
Date:     Thu Jun 12 08:53:07 2014 UTC
Log:      Add @@iterator for generator objects

[email protected], [email protected]
BUG=

Review URL: https://codereview.chromium.org/328093002
http://code.google.com/p/v8/source/detail?r=21797

Modified:
 /branches/bleeding_edge/src/collection-iterator.js
 /branches/bleeding_edge/src/flag-definitions.h
 /branches/bleeding_edge/src/generator.js
 /branches/bleeding_edge/test/mjsunit/harmony/generators-runtime.js
 /branches/bleeding_edge/tools/generate-runtime-tests.py

=======================================
--- /branches/bleeding_edge/src/collection-iterator.js Tue Jun 3 00:34:01 2014 UTC +++ /branches/bleeding_edge/src/collection-iterator.js Thu Jun 12 08:53:07 2014 UTC
@@ -59,7 +59,7 @@
   ));

   %FunctionSetName(SetIteratorSymbolIterator, '[Symbol.iterator]');
-  %SetProperty(SetIterator.prototype, InternalSymbol('Symbol.iterator'),
+  %SetProperty(SetIterator.prototype, symbolIterator,
       SetIteratorSymbolIterator, DONT_ENUM);
 }

@@ -74,7 +74,7 @@
     'values', SetValues
   ));

- %SetProperty($Set.prototype, InternalSymbol('Symbol.iterator'), SetValues,
+  %SetProperty($Set.prototype, symbolIterator, SetValues,
       DONT_ENUM);
 }

@@ -139,7 +139,7 @@
   ));

   %FunctionSetName(MapIteratorSymbolIterator, '[Symbol.iterator]');
-  %SetProperty(MapIterator.prototype, InternalSymbol('Symbol.iterator'),
+  %SetProperty(MapIterator.prototype, symbolIterator,
       MapIteratorSymbolIterator, DONT_ENUM);
 }

@@ -155,7 +155,7 @@
     'values', MapValues
   ));

- %SetProperty($Map.prototype, InternalSymbol('Symbol.iterator'), MapEntries,
+  %SetProperty($Map.prototype, symbolIterator, MapEntries,
       DONT_ENUM);
 }

=======================================
--- /branches/bleeding_edge/src/flag-definitions.h Thu Jun 12 07:38:49 2014 UTC +++ /branches/bleeding_edge/src/flag-definitions.h Thu Jun 12 08:53:07 2014 UTC
@@ -179,6 +179,7 @@
 DEFINE_implication(harmony, harmony_arrays)
 DEFINE_implication(harmony_modules, harmony_scoping)
 DEFINE_implication(harmony_collections, harmony_symbols)
+DEFINE_implication(harmony_generators, harmony_symbols)

 DEFINE_implication(harmony, es_staging)
 DEFINE_implication(es_staging, harmony_maths)
=======================================
--- /branches/bleeding_edge/src/generator.js    Thu Jun 12 08:28:19 2014 UTC
+++ /branches/bleeding_edge/src/generator.js    Thu Jun 12 08:53:07 2014 UTC
@@ -31,6 +31,10 @@

   return %_GeneratorThrow(this, exn);
 }
+
+function GeneratorObjectIterator() {
+  return this;
+}

 function GeneratorFunctionPrototypeConstructor(x) {
   if (%_IsConstructCall()) {
@@ -58,6 +62,8 @@
                    DONT_ENUM | DONT_DELETE | READ_ONLY,
                    ["next", GeneratorObjectNext,
                     "throw", GeneratorObjectThrow]);
+ %SetProperty(GeneratorObjectPrototype, symbolIterator, GeneratorObjectIterator,
+      DONT_ENUM | DONT_DELETE | READ_ONLY);
   %SetProperty(GeneratorObjectPrototype, "constructor",
GeneratorFunctionPrototype, DONT_ENUM | DONT_DELETE | READ_ONLY);
   %SetPrototype(GeneratorFunctionPrototype, $Function.prototype);
=======================================
--- /branches/bleeding_edge/test/mjsunit/harmony/generators-runtime.js Mon May 19 10:47:00 2014 UTC +++ /branches/bleeding_edge/test/mjsunit/harmony/generators-runtime.js Thu Jun 12 08:53:07 2014 UTC
@@ -29,9 +29,8 @@

 // Test aspects of the generator runtime.

-// FIXME(wingo): Replace this reference with a more official link.
 // See:
-// http://wiki.ecmascript.org/lib/exe/fetch.php?cache=cache&media=harmony:es6_generator_object_model_3-29-13.png +// http://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorfunction-objects

 function f() { }
 function* g() { yield 1; }
@@ -101,6 +100,16 @@
   found_property_names.sort();

   assertArrayEquals(expected_property_names, found_property_names);
+
+  iterator_desc = Object.getOwnPropertyDescriptor(GeneratorObjectPrototype,
+      Symbol.iterator);
+  assertTrue(iterator_desc !== undefined);
+  assertFalse(iterator_desc.writable);
+  assertFalse(iterator_desc.enumerable);
+  assertFalse(iterator_desc.configurable);
+
+  // The generator object's "iterator" function is just the identity.
+  assertSame(iterator_desc.value.call(42), 42);
 }
 TestGeneratorObjectPrototype();

=======================================
--- /branches/bleeding_edge/tools/generate-runtime-tests.py Tue Jun 10 09:42:41 2014 UTC +++ /branches/bleeding_edge/tools/generate-runtime-tests.py Thu Jun 12 08:53:07 2014 UTC
@@ -51,7 +51,7 @@
 EXPECTED_FUZZABLE_COUNT = 325
 EXPECTED_CCTEST_COUNT = 6
 EXPECTED_UNKNOWN_COUNT = 5
-EXPECTED_BUILTINS_COUNT = 796
+EXPECTED_BUILTINS_COUNT = 797


 # Don't call these at all.

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