StringObject.cpp 764 B

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibJS/Runtime/GlobalObject.h>
  7. #include <LibJS/Runtime/PrimitiveString.h>
  8. #include <LibJS/Runtime/StringObject.h>
  9. namespace JS {
  10. StringObject* StringObject::create(GlobalObject& global_object, PrimitiveString& primitive_string)
  11. {
  12. return global_object.heap().allocate<StringObject>(global_object, primitive_string, *global_object.string_prototype());
  13. }
  14. StringObject::StringObject(PrimitiveString& string, Object& prototype)
  15. : Object(prototype)
  16. , m_string(string)
  17. {
  18. }
  19. StringObject::~StringObject()
  20. {
  21. }
  22. void StringObject::visit_edges(Cell::Visitor& visitor)
  23. {
  24. Object::visit_edges(visitor);
  25. visitor.visit(&m_string);
  26. }
  27. }