mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:38:11 +00:00
LibJS: Make Value::to_string_without_side_effects() infallible
Work towards #20449.
This commit is contained in:
parent
b8f78c0adc
commit
97ebfd9f0f
69 changed files with 182 additions and 182 deletions
|
@ -52,7 +52,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::apply)
|
|||
|
||||
// 1. If IsCallable(target) is false, throw a TypeError exception.
|
||||
if (!target.is_function())
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, TRY_OR_THROW_OOM(vm, target.to_string_without_side_effects()));
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, target.to_string_without_side_effects());
|
||||
|
||||
// 2. Let args be ? CreateListFromArrayLike(argumentsList).
|
||||
auto args = TRY(create_list_from_array_like(vm, arguments_list));
|
||||
|
@ -71,14 +71,14 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::construct)
|
|||
|
||||
// 1. If IsConstructor(target) is false, throw a TypeError exception.
|
||||
if (!target.is_constructor())
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAConstructor, TRY_OR_THROW_OOM(vm, target.to_string_without_side_effects()));
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAConstructor, target.to_string_without_side_effects());
|
||||
|
||||
// 2. If newTarget is not present, set newTarget to target.
|
||||
if (vm.argument_count() < 3)
|
||||
new_target = target;
|
||||
// 3. Else if IsConstructor(newTarget) is false, throw a TypeError exception.
|
||||
else if (!new_target.is_constructor())
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAConstructor, TRY_OR_THROW_OOM(vm, new_target.to_string_without_side_effects()));
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAConstructor, new_target.to_string_without_side_effects());
|
||||
|
||||
// 4. Let args be ? CreateListFromArrayLike(argumentsList).
|
||||
auto args = TRY(create_list_from_array_like(vm, arguments_list));
|
||||
|
@ -96,7 +96,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::define_property)
|
|||
|
||||
// 1. If Type(target) is not Object, throw a TypeError exception.
|
||||
if (!target.is_object())
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, target.to_string_without_side_effects()));
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, target.to_string_without_side_effects());
|
||||
|
||||
// 2. Let key be ? ToPropertyKey(propertyKey).
|
||||
auto key = TRY(property_key.to_property_key(vm));
|
||||
|
@ -116,7 +116,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::delete_property)
|
|||
|
||||
// 1. If Type(target) is not Object, throw a TypeError exception.
|
||||
if (!target.is_object())
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, target.to_string_without_side_effects()));
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, target.to_string_without_side_effects());
|
||||
|
||||
// 2. Let key be ? ToPropertyKey(propertyKey).
|
||||
auto key = TRY(property_key.to_property_key(vm));
|
||||
|
@ -134,7 +134,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::get)
|
|||
|
||||
// 1. If Type(target) is not Object, throw a TypeError exception.
|
||||
if (!target.is_object())
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, target.to_string_without_side_effects()));
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, target.to_string_without_side_effects());
|
||||
|
||||
// 2. Let key be ? ToPropertyKey(propertyKey).
|
||||
auto key = TRY(property_key.to_property_key(vm));
|
||||
|
@ -157,7 +157,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::get_own_property_descriptor)
|
|||
|
||||
// 1. If Type(target) is not Object, throw a TypeError exception.
|
||||
if (!target.is_object())
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, target.to_string_without_side_effects()));
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, target.to_string_without_side_effects());
|
||||
|
||||
// 2. Let key be ? ToPropertyKey(propertyKey).
|
||||
auto key = TRY(property_key.to_property_key(vm));
|
||||
|
@ -176,7 +176,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::get_prototype_of)
|
|||
|
||||
// 1. If Type(target) is not Object, throw a TypeError exception.
|
||||
if (!target.is_object())
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, target.to_string_without_side_effects()));
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, target.to_string_without_side_effects());
|
||||
|
||||
// 2. Return ? target.[[GetPrototypeOf]]().
|
||||
return TRY(target.as_object().internal_get_prototype_of());
|
||||
|
@ -190,7 +190,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::has)
|
|||
|
||||
// 1. If Type(target) is not Object, throw a TypeError exception.
|
||||
if (!target.is_object())
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, target.to_string_without_side_effects()));
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, target.to_string_without_side_effects());
|
||||
|
||||
// 2. Let key be ? ToPropertyKey(propertyKey).
|
||||
auto key = TRY(property_key.to_property_key(vm));
|
||||
|
@ -206,7 +206,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::is_extensible)
|
|||
|
||||
// 1. If Type(target) is not Object, throw a TypeError exception.
|
||||
if (!target.is_object())
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, target.to_string_without_side_effects()));
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, target.to_string_without_side_effects());
|
||||
|
||||
// 2. Return ? target.[[IsExtensible]]().
|
||||
return Value(TRY(target.as_object().internal_is_extensible()));
|
||||
|
@ -221,7 +221,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::own_keys)
|
|||
|
||||
// 1. If Type(target) is not Object, throw a TypeError exception.
|
||||
if (!target.is_object())
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, target.to_string_without_side_effects()));
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, target.to_string_without_side_effects());
|
||||
|
||||
// 2. Let keys be ? target.[[OwnPropertyKeys]]().
|
||||
auto keys = TRY(target.as_object().internal_own_property_keys());
|
||||
|
@ -237,7 +237,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::prevent_extensions)
|
|||
|
||||
// 1. If Type(target) is not Object, throw a TypeError exception.
|
||||
if (!target.is_object())
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, target.to_string_without_side_effects()));
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, target.to_string_without_side_effects());
|
||||
|
||||
// 2. Return ? target.[[PreventExtensions]]().
|
||||
return Value(TRY(target.as_object().internal_prevent_extensions()));
|
||||
|
@ -253,7 +253,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::set)
|
|||
|
||||
// 1. If Type(target) is not Object, throw a TypeError exception.
|
||||
if (!target.is_object())
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, target.to_string_without_side_effects()));
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, target.to_string_without_side_effects());
|
||||
|
||||
// 2. Let key be ? ToPropertyKey(propertyKey).
|
||||
auto key = TRY(property_key.to_property_key(vm));
|
||||
|
@ -276,7 +276,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::set_prototype_of)
|
|||
|
||||
// 1. If Type(target) is not Object, throw a TypeError exception.
|
||||
if (!target.is_object())
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, target.to_string_without_side_effects()));
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, target.to_string_without_side_effects());
|
||||
|
||||
// 2. If Type(proto) is not Object and proto is not null, throw a TypeError exception.
|
||||
if (!proto.is_object() && !proto.is_null())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue