1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:57:35 +00:00

LibJS: Replace GlobalObject with VM in remaining AOs [Part 19/19]

This commit is contained in:
Linus Groh 2022-08-21 20:38:35 +01:00
parent 25849f8a6d
commit 56b2ae5ac0
46 changed files with 173 additions and 207 deletions

View file

@ -65,13 +65,13 @@ bool PropertyDescriptor::is_generic_descriptor() const
}
// 6.2.5.4 FromPropertyDescriptor ( Desc ), https://tc39.es/ecma262/#sec-frompropertydescriptor
Value from_property_descriptor(GlobalObject& global_object, Optional<PropertyDescriptor> const& property_descriptor)
Value from_property_descriptor(VM& vm, Optional<PropertyDescriptor> const& property_descriptor)
{
auto& realm = *global_object.associated_realm();
auto& realm = *vm.current_realm();
if (!property_descriptor.has_value())
return js_undefined();
auto& vm = global_object.vm();
auto* object = Object::create(realm, global_object.object_prototype());
auto* object = Object::create(realm, realm.global_object().object_prototype());
if (property_descriptor->value.has_value())
MUST(object->create_data_property_or_throw(vm.names.value, *property_descriptor->value));
if (property_descriptor->writable.has_value())
@ -88,10 +88,8 @@ Value from_property_descriptor(GlobalObject& global_object, Optional<PropertyDes
}
// 6.2.5.5 ToPropertyDescriptor ( Obj ), https://tc39.es/ecma262/#sec-topropertydescriptor
ThrowCompletionOr<PropertyDescriptor> to_property_descriptor(GlobalObject& global_object, Value argument)
ThrowCompletionOr<PropertyDescriptor> to_property_descriptor(VM& vm, Value argument)
{
auto& vm = global_object.vm();
// 1. If Type(Obj) is not Object, throw a TypeError exception.
if (!argument.is_object())
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, argument.to_string_without_side_effects());