mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:47:35 +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
|
// 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();
|
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);
|
auto& proxy = static_cast<ProxyObject const&>(function);
|
||||||
|
|
||||||
// a. If obj.[[ProxyHandler]] is null, throw a TypeError exception.
|
// a. If obj.[[ProxyHandler]] is null, throw a TypeError exception.
|
||||||
if (proxy.is_revoked()) {
|
if (proxy.is_revoked())
|
||||||
vm.throw_exception<TypeError>(global_object, ErrorType::ProxyRevoked);
|
return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyRevoked);
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// b. Let proxyTarget be obj.[[ProxyTarget]].
|
// b. Let proxyTarget be obj.[[ProxyTarget]].
|
||||||
auto& proxy_target = proxy.target();
|
auto& proxy_target = proxy.target();
|
||||||
|
@ -340,9 +338,7 @@ Object* get_prototype_from_constructor(GlobalObject& global_object, FunctionObje
|
||||||
if (vm.exception())
|
if (vm.exception())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
if (!prototype.is_object()) {
|
if (!prototype.is_object()) {
|
||||||
auto* realm = get_function_realm(global_object, constructor);
|
auto* realm = TRY_OR_DISCARD(get_function_realm(global_object, constructor));
|
||||||
if (vm.exception())
|
|
||||||
return nullptr;
|
|
||||||
prototype = (realm->global_object().*intrinsic_default_prototype)();
|
prototype = (realm->global_object().*intrinsic_default_prototype)();
|
||||||
}
|
}
|
||||||
return &prototype.as_object();
|
return &prototype.as_object();
|
||||||
|
|
|
@ -23,7 +23,7 @@ ThrowCompletionOr<Value> require_object_coercible(GlobalObject&, Value);
|
||||||
size_t length_of_array_like(GlobalObject&, Object const&);
|
size_t length_of_array_like(GlobalObject&, Object const&);
|
||||||
ThrowCompletionOr<MarkedValueList> create_list_from_array_like(GlobalObject&, Value, Function<ThrowCompletionOr<void>(Value)> = {});
|
ThrowCompletionOr<MarkedValueList> create_list_from_array_like(GlobalObject&, Value, Function<ThrowCompletionOr<void>(Value)> = {});
|
||||||
ThrowCompletionOr<FunctionObject*> species_constructor(GlobalObject&, Object const&, FunctionObject& default_constructor);
|
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 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);
|
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)());
|
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()) {
|
if (constructor.is_constructor()) {
|
||||||
auto& constructor_function = constructor.as_function();
|
auto& constructor_function = constructor.as_function();
|
||||||
auto* this_realm = vm.current_realm();
|
auto* this_realm = vm.current_realm();
|
||||||
auto* constructor_realm = get_function_realm(global_object, constructor_function);
|
auto* constructor_realm = TRY_OR_DISCARD(get_function_realm(global_object, constructor_function));
|
||||||
if (vm.exception())
|
|
||||||
return {};
|
|
||||||
if (constructor_realm != this_realm) {
|
if (constructor_realm != this_realm) {
|
||||||
if (&constructor_function == constructor_realm->global_object().array_constructor())
|
if (&constructor_function == constructor_realm->global_object().array_constructor())
|
||||||
constructor = js_undefined();
|
constructor = js_undefined();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue