1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-02 22:42:08 +00:00

LibJS: Add define_direct_property and remove the define_property helper

This removes all usages of the non-standard define_property helper
method and replaces all it's usages with the specification required
alternative or with define_direct_property where appropriate.
This commit is contained in:
Idan Horowitz 2021-07-06 02:15:08 +03:00 committed by Linus Groh
parent e915155ca4
commit a6b8291a9b
81 changed files with 246 additions and 275 deletions

View file

@ -78,14 +78,14 @@ void OrdinaryFunctionObject::initialize(GlobalObject& global_object)
auto* prototype = vm.heap().allocate<Object>(global_object, *global_object.new_ordinary_function_prototype_object_shape());
switch (m_kind) {
case FunctionKind::Regular:
prototype->define_property(vm.names.constructor, this, Attribute::Writable | Attribute::Configurable);
prototype->define_property_or_throw(vm.names.constructor, { .value = this, .writable = true, .enumerable = false, .configurable = true });
break;
case FunctionKind::Generator:
// prototype is "g1.prototype" in figure-2 (https://tc39.es/ecma262/img/figure-2.png)
prototype->internal_set_prototype_of(global_object.generator_object_prototype());
break;
}
define_property(vm.names.prototype, prototype, Attribute::Writable);
define_direct_property(vm.names.prototype, prototype, Attribute::Writable);
}
define_property_or_throw(vm.names.length, { .value = Value(m_function_length), .writable = false, .enumerable = false, .configurable = true });
define_property_or_throw(vm.names.name, { .value = js_string(vm, m_name.is_null() ? "" : m_name), .writable = false, .enumerable = false, .configurable = true });