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

Unified Diff: src/factory.cc

Issue 2407423002: [modules] Implement @@iterator on namespace objects. (Closed)
Patch Set: Rename kSize to kHeadersize again. 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
« no previous file with comments | « src/factory.h ('k') | src/heap/objects-visiting.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/factory.cc
diff --git a/src/factory.cc b/src/factory.cc
index 1449d0a98a9c0bd572c27ecee03428856a4377da..2e1c7d71c01324293cbd9069a90ad61245b530cf 100644
--- a/src/factory.cc
+++ b/src/factory.cc
@@ -2625,5 +2625,26 @@ void Factory::SetStrictFunctionInstanceDescriptor(Handle<Map> map,
}
}
+Handle<JSFixedArrayIterator> Factory::NewJSFixedArrayIterator(
+ Handle<FixedArray> array) {
+ // Create the "next" function (must be unique per iterator object).
+ Handle<Code> code(
+ isolate()->builtins()->builtin(Builtins::kFixedArrayIteratorNext));
+ // TODO(neis): Don't create a new SharedFunctionInfo each time.
+ 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_initial_next(*next);
+ iterator->set_array(*array);
+ iterator->set_index(0);
+ iterator->InObjectPropertyAtPut(JSFixedArrayIterator::kNextIndex, *next);
+ return iterator;
+}
+
} // namespace internal
} // namespace v8
« no previous file with comments | « src/factory.h ('k') | src/heap/objects-visiting.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698