diff options
author | Idan Horowitz <idan.horowitz@gmail.com> | 2022-01-30 21:34:41 +0200 |
---|---|---|
committer | Idan Horowitz <idan.horowitz@gmail.com> | 2022-01-31 21:05:04 +0200 |
commit | 2cd3d4a287cced09225fa6807942287ea2088307 (patch) | |
tree | 76174de7910cc20b8717db14d3d68e6e9ce843dc /Userland/Libraries/LibJS/Runtime/Intl/SegmentIterator.cpp | |
parent | 366468f1def4adef06f1f945d7fdf31bd612ddd1 (diff) | |
download | serenity-2cd3d4a287cced09225fa6807942287ea2088307.zip |
LibJS: Implement Intl %SegmentIteratorPrototype%.next ( )
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime/Intl/SegmentIterator.cpp')
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/Intl/SegmentIterator.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/SegmentIterator.cpp b/Userland/Libraries/LibJS/Runtime/Intl/SegmentIterator.cpp index 2d848e8adb..ff67e68dba 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/SegmentIterator.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/SegmentIterator.cpp @@ -6,11 +6,12 @@ #include <LibJS/Runtime/GlobalObject.h> #include <LibJS/Runtime/Intl/SegmentIterator.h> +#include <LibJS/Runtime/Intl/Segments.h> namespace JS::Intl { // 18.6.1 CreateSegmentIterator ( segmenter, string ), https://tc39.es/ecma402/#sec-createsegmentsobject -SegmentIterator* SegmentIterator::create(GlobalObject& global_object, Segmenter& segmenter, Utf16View const& string) +SegmentIterator* SegmentIterator::create(GlobalObject& global_object, Segmenter& segmenter, Utf16View const& string, Segments const& segments) { // 1. Let internalSlotsList be ยซ [[IteratingSegmenter]], [[IteratedString]], [[IteratedStringNextSegmentCodeUnitIndex]] ยป. // 2. Let iterator be ! OrdinaryObjectCreate(%SegmentIteratorPrototype%, internalSlotsList). @@ -18,14 +19,15 @@ SegmentIterator* SegmentIterator::create(GlobalObject& global_object, Segmenter& // 4. Set iterator.[[IteratedString]] to string. // 5. Set iterator.[[IteratedStringNextSegmentCodeUnitIndex]] to 0. // 6. Return iterator. - return global_object.heap().allocate<SegmentIterator>(global_object, global_object, segmenter, move(string)); + return global_object.heap().allocate<SegmentIterator>(global_object, global_object, segmenter, move(string), segments); } // 18.6 Segment Iterator Objects, https://tc39.es/ecma402/#sec-segment-iterator-objects -SegmentIterator::SegmentIterator(GlobalObject& global_object, Segmenter& segmenter, Utf16View const& string) +SegmentIterator::SegmentIterator(GlobalObject& global_object, Segmenter& segmenter, Utf16View const& string, Segments const& segments) : Object(*global_object.intl_segment_iterator_prototype()) , m_iterating_segmenter(segmenter) , m_iterated_string(string) + , m_segments(segments) { } @@ -33,6 +35,7 @@ void SegmentIterator::visit_edges(Cell::Visitor& visitor) { Base::visit_edges(visitor); visitor.visit(&m_iterating_segmenter); + visitor.visit(&m_segments); } } |