mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-27 18:17:22 +02:00
LibJS: Pass prototype to StringObject constructor
This commit is contained in:
Notes:
sideshowbarker
2024-07-19 07:31:41 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/298c6062000
@@ -26,6 +26,7 @@
|
||||
|
||||
#include <LibJS/Heap/Heap.h>
|
||||
#include <LibJS/Interpreter.h>
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
#include <LibJS/Runtime/PrimitiveString.h>
|
||||
#include <LibJS/Runtime/StringObject.h>
|
||||
#include <LibJS/Runtime/StringPrototype.h>
|
||||
@@ -33,10 +34,16 @@
|
||||
|
||||
namespace JS {
|
||||
|
||||
StringObject::StringObject(PrimitiveString* string)
|
||||
StringObject* StringObject::create(GlobalObject& global_object, PrimitiveString& primitive_string)
|
||||
{
|
||||
auto& interpreter = global_object.interpreter();
|
||||
return interpreter.heap().allocate<StringObject>(primitive_string, *interpreter.string_prototype());
|
||||
}
|
||||
|
||||
StringObject::StringObject(PrimitiveString& string, Object& prototype)
|
||||
: m_string(string)
|
||||
{
|
||||
set_prototype(interpreter().string_prototype());
|
||||
set_prototype(&prototype);
|
||||
}
|
||||
|
||||
StringObject::~StringObject()
|
||||
@@ -46,7 +53,7 @@ StringObject::~StringObject()
|
||||
void StringObject::visit_children(Cell::Visitor& visitor)
|
||||
{
|
||||
Object::visit_children(visitor);
|
||||
visitor.visit(m_string);
|
||||
visitor.visit(&m_string);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user