mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 14:47:46 +00:00
LibJS: Use ThrowCompletionOr in get_function_realm()
This commit is contained in:
parent
3d43eb0774
commit
bc1b8f9cc8
3 changed files with 6 additions and 12 deletions
|
@ -132,7 +132,7 @@ ThrowCompletionOr<FunctionObject*> species_constructor(GlobalObject& global_obje
|
|||
}
|
||||
|
||||
// 7.3.24 GetFunctionRealm ( obj ), https://tc39.es/ecma262/#sec-getfunctionrealm
|
||||
Realm* get_function_realm(GlobalObject& global_object, FunctionObject const& function)
|
||||
ThrowCompletionOr<Realm*> get_function_realm(GlobalObject& global_object, FunctionObject const& function)
|
||||
{
|
||||
auto& vm = global_object.vm();
|
||||
|
||||
|
@ -160,10 +160,8 @@ Realm* get_function_realm(GlobalObject& global_object, FunctionObject const& fun
|
|||
auto& proxy = static_cast<ProxyObject const&>(function);
|
||||
|
||||
// a. If obj.[[ProxyHandler]] is null, throw a TypeError exception.
|
||||
if (proxy.is_revoked()) {
|
||||
vm.throw_exception<TypeError>(global_object, ErrorType::ProxyRevoked);
|
||||
return nullptr;
|
||||
}
|
||||
if (proxy.is_revoked())
|
||||
return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyRevoked);
|
||||
|
||||
// b. Let proxyTarget be obj.[[ProxyTarget]].
|
||||
auto& proxy_target = proxy.target();
|
||||
|
@ -340,9 +338,7 @@ Object* get_prototype_from_constructor(GlobalObject& global_object, FunctionObje
|
|||
if (vm.exception())
|
||||
return nullptr;
|
||||
if (!prototype.is_object()) {
|
||||
auto* realm = get_function_realm(global_object, constructor);
|
||||
if (vm.exception())
|
||||
return nullptr;
|
||||
auto* realm = TRY_OR_DISCARD(get_function_realm(global_object, constructor));
|
||||
prototype = (realm->global_object().*intrinsic_default_prototype)();
|
||||
}
|
||||
return &prototype.as_object();
|
||||
|
|
|
@ -23,7 +23,7 @@ ThrowCompletionOr<Value> require_object_coercible(GlobalObject&, Value);
|
|||
size_t length_of_array_like(GlobalObject&, Object const&);
|
||||
ThrowCompletionOr<MarkedValueList> create_list_from_array_like(GlobalObject&, Value, Function<ThrowCompletionOr<void>(Value)> = {});
|
||||
ThrowCompletionOr<FunctionObject*> species_constructor(GlobalObject&, Object const&, FunctionObject& default_constructor);
|
||||
Realm* get_function_realm(GlobalObject&, FunctionObject const&);
|
||||
ThrowCompletionOr<Realm*> get_function_realm(GlobalObject&, FunctionObject const&);
|
||||
bool is_compatible_property_descriptor(bool extensible, PropertyDescriptor const&, Optional<PropertyDescriptor> const& current);
|
||||
bool validate_and_apply_property_descriptor(Object*, PropertyName const&, bool extensible, PropertyDescriptor const&, Optional<PropertyDescriptor> const& current);
|
||||
Object* get_prototype_from_constructor(GlobalObject&, FunctionObject const& constructor, Object* (GlobalObject::*intrinsic_default_prototype)());
|
||||
|
|
|
@ -124,9 +124,7 @@ static Object* array_species_create(GlobalObject& global_object, Object& origina
|
|||
if (constructor.is_constructor()) {
|
||||
auto& constructor_function = constructor.as_function();
|
||||
auto* this_realm = vm.current_realm();
|
||||
auto* constructor_realm = get_function_realm(global_object, constructor_function);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
auto* constructor_realm = TRY_OR_DISCARD(get_function_realm(global_object, constructor_function));
|
||||
if (constructor_realm != this_realm) {
|
||||
if (&constructor_function == constructor_realm->global_object().array_constructor())
|
||||
constructor = js_undefined();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue