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

Unified Diff: src/factory.cc

Issue 2407423002: [modules] Implement @@iterator on namespace objects. (Closed)
Patch Set: Created 4 years, 2 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
Index: src/factory.cc
diff --git a/src/factory.cc b/src/factory.cc
index 877818a29b7bd4884b5933dab196c194caaf4922..c6db2b8dcb13e36fa5e25ffdaee69ed3e9d0f6c2 100644
--- a/src/factory.cc
+++ b/src/factory.cc
@@ -2610,5 +2610,24 @@ void Factory::SetStrictFunctionInstanceDescriptor(Handle<Map> map,
}
}
+Handle<JSFixedArrayIterator> Factory::NewJSFixedArrayIterator(
+ Handle<FixedArray> array) {
+ // Create the "next" function.
+ Handle<Code> code(
+ isolate()->builtins()->builtin(Builtins::kFixedArrayIteratorNext));
Benedikt Meurer 2016/10/12 03:24:05 This is pretty inefficient, as you create a new Sh
neis 2016/10/13 07:37:21 Right, thanks!
+ Handle<JSFunction> next = isolate()->factory()->NewFunctionWithoutPrototype(
+ isolate()->factory()->next_string(), code, false);
+ next->shared()->set_native(true);
+
+ // Create the iterator.
+ Handle<Map> map(isolate()->native_context()->fixed_array_iterator_map());
+ Handle<JSFixedArrayIterator> iterator =
+ Handle<JSFixedArrayIterator>::cast(NewJSObjectFromMap(map));
+ iterator->set_next(*next);
+ iterator->set_array(*array);
+ iterator->set_index(0);
+ return iterator;
+}
+
} // namespace internal
} // namespace v8

Powered by Google App Engine
This is Rietveld 408576698