RegExpStringIterator.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. * Copyright (c) 2021, Tim Flynn <trflynn89@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibJS/Runtime/GlobalObject.h>
  7. #include <LibJS/Runtime/RegExpStringIterator.h>
  8. namespace JS {
  9. JS_DEFINE_ALLOCATOR(RegExpStringIterator);
  10. // 22.2.9.1 CreateRegExpStringIterator ( R, S, global, fullUnicode ), https://tc39.es/ecma262/#sec-createregexpstringiterator
  11. NonnullGCPtr<RegExpStringIterator> RegExpStringIterator::create(Realm& realm, Object& regexp_object, Utf16String string, bool global, bool unicode)
  12. {
  13. return realm.heap().allocate<RegExpStringIterator>(realm, realm.intrinsics().regexp_string_iterator_prototype(), regexp_object, move(string), global, unicode);
  14. }
  15. RegExpStringIterator::RegExpStringIterator(Object& prototype, Object& regexp_object, Utf16String string, bool global, bool unicode)
  16. : Object(ConstructWithPrototypeTag::Tag, prototype)
  17. , m_regexp_object(regexp_object)
  18. , m_string(move(string))
  19. , m_global(global)
  20. , m_unicode(unicode)
  21. {
  22. }
  23. void RegExpStringIterator::visit_edges(Cell::Visitor& visitor)
  24. {
  25. Base::visit_edges(visitor);
  26. visitor.visit(m_regexp_object);
  27. }
  28. }