mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:47:35 +00:00
LibJS: Initialize {Async,}{Generator,}Function constructors properly
We were previously manually initializing them instead of just calling GlobalObject::initialize_constructor, which aside from duplicating code also meant we didn't set the required name property.
This commit is contained in:
parent
de238ff351
commit
08d1ae58b1
2 changed files with 6 additions and 15 deletions
|
@ -74,7 +74,7 @@ protected:
|
|||
virtual void visit_edges(Visitor&) override;
|
||||
|
||||
template<typename ConstructorType>
|
||||
void initialize_constructor(PropertyKey const&, ConstructorType*&, Object* prototype);
|
||||
void initialize_constructor(PropertyKey const&, ConstructorType*&, Object* prototype, PropertyAttributes = Attribute::Writable | Attribute::Configurable);
|
||||
template<typename ConstructorType>
|
||||
void add_constructor(PropertyKey const&, ConstructorType*&, Object* prototype);
|
||||
|
||||
|
@ -143,13 +143,13 @@ private:
|
|||
};
|
||||
|
||||
template<typename ConstructorType>
|
||||
inline void GlobalObject::initialize_constructor(PropertyKey const& property_key, ConstructorType*& constructor, Object* prototype)
|
||||
inline void GlobalObject::initialize_constructor(PropertyKey const& property_key, ConstructorType*& constructor, Object* prototype, PropertyAttributes attributes)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
constructor = heap().allocate<ConstructorType>(*this, *this);
|
||||
constructor->define_direct_property(vm.names.name, js_string(heap(), property_key.as_string()), Attribute::Configurable);
|
||||
if (prototype)
|
||||
prototype->define_direct_property(vm.names.constructor, constructor, Attribute::Writable | Attribute::Configurable);
|
||||
prototype->define_direct_property(vm.names.constructor, constructor, attributes);
|
||||
}
|
||||
|
||||
template<typename ConstructorType>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue