mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:48:11 +00:00
LibJS: Pass prototype to StringObject constructor
This commit is contained in:
parent
cf702a13b9
commit
298c606200
5 changed files with 23 additions and 12 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue