mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 04:38:11 +00:00
LibJS+LibWeb: Pass prototype to Object constructor
Everyone who constructs an Object must now pass a prototype object when applicable. There's still a fair amount of code that passes something fetched from the Interpreter, but this brings us closer to being able to detach prototypes from Interpreter eventually.
This commit is contained in:
parent
f6d57c82f6
commit
bc1ece7f37
30 changed files with 60 additions and 28 deletions
|
@ -38,10 +38,15 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
Object::Object()
|
||||
Object* Object::create_empty(Interpreter& interpreter, GlobalObject&)
|
||||
{
|
||||
return interpreter.heap().allocate<Object>(interpreter.object_prototype());
|
||||
}
|
||||
|
||||
Object::Object(Object* prototype)
|
||||
{
|
||||
m_shape = interpreter().empty_object_shape();
|
||||
m_shape->set_prototype_without_transition(interpreter().object_prototype());
|
||||
set_prototype(prototype);
|
||||
}
|
||||
|
||||
Object::~Object()
|
||||
|
@ -60,6 +65,8 @@ const Object* Object::prototype() const
|
|||
|
||||
void Object::set_prototype(Object* new_prototype)
|
||||
{
|
||||
if (prototype() == new_prototype)
|
||||
return;
|
||||
m_shape = m_shape->create_prototype_transition(new_prototype);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue