ladybird/Userland/Libraries/LibJS/Runtime/StringIterator.cpp
Timothy Flynn b75b7f0c0d LibJS+Everywhere: Propagate Cell::initialize errors from Heap::allocate
Callers that are already in a fallible context will now TRY to allocate
cells. Callers in infallible contexts get a FIXME.
2023-01-29 00:02:45 +00:00

25 lines
706 B
C++

/*
* Copyright (c) 2020, Matthew Olsson <mattco@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/Utf8View.h>
#include <LibJS/Runtime/GlobalObject.h>
#include <LibJS/Runtime/StringIterator.h>
namespace JS {
NonnullGCPtr<StringIterator> StringIterator::create(Realm& realm, String string)
{
return realm.heap().allocate<StringIterator>(realm, move(string), *realm.intrinsics().string_iterator_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
}
StringIterator::StringIterator(String string, Object& prototype)
: Object(ConstructWithPrototypeTag::Tag, prototype)
, m_string(move(string))
, m_iterator(Utf8View(m_string).begin())
{
}
}