LibJS: Convert Accessor::create() to NonnullGCPtr

This commit is contained in:
Linus Groh 2022-12-13 20:49:49 +00:00
parent 0ec433edce
commit 2b92c15b34
2 changed files with 4 additions and 4 deletions

View file

@ -249,7 +249,7 @@ bool validate_and_apply_property_descriptor(Object* object, PropertyKey const& p
// c. If IsAccessorDescriptor(Desc) is true, then
if (descriptor.is_accessor_descriptor()) {
// i. Create an own accessor property named P of object O whose [[Get]], [[Set]], [[Enumerable]], and [[Configurable]] attributes are set to the value of the corresponding field in Desc if Desc has that field, or to the attribute's default value otherwise.
auto* accessor = Accessor::create(object->vm(), descriptor.get.value_or(nullptr), descriptor.set.value_or(nullptr));
auto accessor = Accessor::create(object->vm(), descriptor.get.value_or(nullptr), descriptor.set.value_or(nullptr));
object->storage_set(property_key, { accessor, descriptor.attributes() });
}
// d. Else,
@ -316,7 +316,7 @@ bool validate_and_apply_property_descriptor(Object* object, PropertyKey const& p
auto enumerable = descriptor.enumerable.value_or(*current->enumerable);
// iii. Replace the property named P of object O with an accessor property having [[Configurable]] and [[Enumerable]] attributes set to configurable and enumerable, respectively, and each other attribute set to its corresponding value in Desc if present, otherwise to its default value.
auto* accessor = Accessor::create(object->vm(), descriptor.get.value_or(nullptr), descriptor.set.value_or(nullptr));
auto accessor = Accessor::create(object->vm(), descriptor.get.value_or(nullptr), descriptor.set.value_or(nullptr));
PropertyAttributes attributes;
attributes.set_enumerable(enumerable);
attributes.set_configurable(configurable);

View file

@ -17,9 +17,9 @@ class Accessor final : public Cell {
JS_CELL(Accessor, Cell);
public:
static Accessor* create(VM& vm, FunctionObject* getter, FunctionObject* setter)
static NonnullGCPtr<Accessor> create(VM& vm, FunctionObject* getter, FunctionObject* setter)
{
return vm.heap().allocate_without_realm<Accessor>(getter, setter);
return *vm.heap().allocate_without_realm<Accessor>(getter, setter);
}
FunctionObject* getter() const { return m_getter; }