mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:57:35 +00:00
LbJS: Convert exception-related usages of Value::TDSWOSE to String
TDSWOSE being to_deprecated_string_without_side_effects.
This commit is contained in:
parent
3ffb6d9b5a
commit
a73b8292ed
47 changed files with 125 additions and 123 deletions
|
@ -436,9 +436,9 @@ Completion CallExpression::throw_type_error_for_callee(Interpreter& interpreter,
|
||||||
auto& vm = interpreter.vm();
|
auto& vm = interpreter.vm();
|
||||||
|
|
||||||
if (auto expression_string = this->expression_string(); expression_string.has_value())
|
if (auto expression_string = this->expression_string(); expression_string.has_value())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::IsNotAEvaluatedFrom, callee_value.to_deprecated_string_without_side_effects(), call_type, expression_string.release_value());
|
return vm.throw_completion<TypeError>(ErrorType::IsNotAEvaluatedFrom, TRY_OR_THROW_OOM(vm, callee_value.to_string_without_side_effects()), call_type, expression_string.release_value());
|
||||||
|
|
||||||
return vm.throw_completion<TypeError>(ErrorType::IsNotA, callee_value.to_deprecated_string_without_side_effects(), call_type);
|
return vm.throw_completion<TypeError>(ErrorType::IsNotA, TRY_OR_THROW_OOM(vm, callee_value.to_string_without_side_effects()), call_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 13.3.6.1 Runtime Semantics: Evaluation, https://tc39.es/ecma262/#sec-function-calls-runtime-semantics-evaluation
|
// 13.3.6.1 Runtime Semantics: Evaluation, https://tc39.es/ecma262/#sec-function-calls-runtime-semantics-evaluation
|
||||||
|
@ -1970,11 +1970,11 @@ ThrowCompletionOr<ECMAScriptFunctionObject*> ClassExpression::class_definition_e
|
||||||
if (super_class.is_null()) {
|
if (super_class.is_null()) {
|
||||||
proto_parent = nullptr;
|
proto_parent = nullptr;
|
||||||
} else if (!super_class.is_constructor()) {
|
} else if (!super_class.is_constructor()) {
|
||||||
return vm.throw_completion<TypeError>(ErrorType::ClassExtendsValueNotAConstructorOrNull, super_class.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::ClassExtendsValueNotAConstructorOrNull, TRY_OR_THROW_OOM(vm, super_class.to_string_without_side_effects()));
|
||||||
} else {
|
} else {
|
||||||
auto super_class_prototype = TRY(super_class.get(vm, vm.names.prototype));
|
auto super_class_prototype = TRY(super_class.get(vm, vm.names.prototype));
|
||||||
if (!super_class_prototype.is_null() && !super_class_prototype.is_object())
|
if (!super_class_prototype.is_null() && !super_class_prototype.is_object())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::ClassExtendsValueInvalidPrototype, super_class_prototype.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::ClassExtendsValueInvalidPrototype, TRY_OR_THROW_OOM(vm, super_class_prototype.to_string_without_side_effects()));
|
||||||
|
|
||||||
if (super_class_prototype.is_null())
|
if (super_class_prototype.is_null())
|
||||||
proto_parent = nullptr;
|
proto_parent = nullptr;
|
||||||
|
|
|
@ -74,7 +74,7 @@ static ThrowCompletionOr<void> put_by_property_key(Object* object, Value value,
|
||||||
case PropertyKind::KeyValue: {
|
case PropertyKind::KeyValue: {
|
||||||
bool succeeded = TRY(object->internal_set(name, interpreter.accumulator(), object));
|
bool succeeded = TRY(object->internal_set(name, interpreter.accumulator(), object));
|
||||||
if (!succeeded && vm.in_strict_mode())
|
if (!succeeded && vm.in_strict_mode())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::ReferenceNullishSetProperty, name, interpreter.accumulator().to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::ReferenceNullishSetProperty, name, TRY_OR_THROW_OOM(vm, interpreter.accumulator().to_string_without_side_effects()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PropertyKind::Spread:
|
case PropertyKind::Spread:
|
||||||
|
@ -614,11 +614,13 @@ static MarkedVector<Value> argument_list_evaluation(Bytecode::Interpreter& inter
|
||||||
|
|
||||||
Completion Call::throw_type_error_for_callee(Bytecode::Interpreter& interpreter, StringView callee_type) const
|
Completion Call::throw_type_error_for_callee(Bytecode::Interpreter& interpreter, StringView callee_type) const
|
||||||
{
|
{
|
||||||
|
auto& vm = interpreter.vm();
|
||||||
auto callee = interpreter.reg(m_callee);
|
auto callee = interpreter.reg(m_callee);
|
||||||
if (m_expression_string.has_value())
|
|
||||||
return interpreter.vm().throw_completion<TypeError>(ErrorType::IsNotAEvaluatedFrom, callee.to_deprecated_string_without_side_effects(), callee_type, interpreter.current_executable().get_string(m_expression_string->value()));
|
|
||||||
|
|
||||||
return interpreter.vm().throw_completion<TypeError>(ErrorType::IsNotA, callee.to_deprecated_string_without_side_effects(), callee_type);
|
if (m_expression_string.has_value())
|
||||||
|
return vm.throw_completion<TypeError>(ErrorType::IsNotAEvaluatedFrom, TRY_OR_THROW_OOM(vm, callee.to_string_without_side_effects()), callee_type, interpreter.current_executable().get_string(m_expression_string->value()));
|
||||||
|
|
||||||
|
return vm.throw_completion<TypeError>(ErrorType::IsNotA, TRY_OR_THROW_OOM(vm, callee.to_string_without_side_effects()), callee_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
ThrowCompletionOr<void> Call::execute_impl(Bytecode::Interpreter& interpreter) const
|
ThrowCompletionOr<void> Call::execute_impl(Bytecode::Interpreter& interpreter) const
|
||||||
|
@ -747,7 +749,7 @@ ThrowCompletionOr<void> ThrowIfNotObject::execute_impl(Bytecode::Interpreter& in
|
||||||
{
|
{
|
||||||
auto& vm = interpreter.vm();
|
auto& vm = interpreter.vm();
|
||||||
if (!interpreter.accumulator().is_object())
|
if (!interpreter.accumulator().is_object())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, interpreter.accumulator().to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, interpreter.accumulator().to_string_without_side_effects()));
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ namespace JS {
|
||||||
ThrowCompletionOr<Value> require_object_coercible(VM& vm, Value value)
|
ThrowCompletionOr<Value> require_object_coercible(VM& vm, Value value)
|
||||||
{
|
{
|
||||||
if (value.is_nullish())
|
if (value.is_nullish())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotObjectCoercible, value.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotObjectCoercible, TRY_OR_THROW_OOM(vm, value.to_string_without_side_effects()));
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ ThrowCompletionOr<Value> call_impl(VM& vm, Value function, Value this_value, Opt
|
||||||
|
|
||||||
// 2. If IsCallable(F) is false, throw a TypeError exception.
|
// 2. If IsCallable(F) is false, throw a TypeError exception.
|
||||||
if (!function.is_function())
|
if (!function.is_function())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, function.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, TRY_OR_THROW_OOM(vm, function.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 3. Return ? F.[[Call]](V, argumentsList).
|
// 3. Return ? F.[[Call]](V, argumentsList).
|
||||||
return function.as_function().internal_call(this_value, move(*arguments_list));
|
return function.as_function().internal_call(this_value, move(*arguments_list));
|
||||||
|
@ -100,7 +100,7 @@ ThrowCompletionOr<MarkedVector<Value>> create_list_from_array_like(VM& vm, Value
|
||||||
|
|
||||||
// 2. If Type(obj) is not Object, throw a TypeError exception.
|
// 2. If Type(obj) is not Object, throw a TypeError exception.
|
||||||
if (!value.is_object())
|
if (!value.is_object())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, value.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, value.to_string_without_side_effects()));
|
||||||
|
|
||||||
auto& array_like = value.as_object();
|
auto& array_like = value.as_object();
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ ThrowCompletionOr<FunctionObject*> species_constructor(VM& vm, Object const& obj
|
||||||
|
|
||||||
// 3. If Type(C) is not Object, throw a TypeError exception.
|
// 3. If Type(C) is not Object, throw a TypeError exception.
|
||||||
if (!constructor.is_object())
|
if (!constructor.is_object())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAConstructor, constructor.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAConstructor, TRY_OR_THROW_OOM(vm, constructor.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 4. Let S be ? Get(C, @@species).
|
// 4. Let S be ? Get(C, @@species).
|
||||||
auto species = TRY(constructor.as_object().get(*vm.well_known_symbol_species()));
|
auto species = TRY(constructor.as_object().get(*vm.well_known_symbol_species()));
|
||||||
|
@ -158,7 +158,7 @@ ThrowCompletionOr<FunctionObject*> species_constructor(VM& vm, Object const& obj
|
||||||
return &species.as_function();
|
return &species.as_function();
|
||||||
|
|
||||||
// 7. Throw a TypeError exception.
|
// 7. Throw a TypeError exception.
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAConstructor, species.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAConstructor, TRY_OR_THROW_OOM(vm, species.to_string_without_side_effects()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 7.3.25 GetFunctionRealm ( obj ), https://tc39.es/ecma262/#sec-getfunctionrealm
|
// 7.3.25 GetFunctionRealm ( obj ), https://tc39.es/ecma262/#sec-getfunctionrealm
|
||||||
|
@ -1333,7 +1333,7 @@ ThrowCompletionOr<void> add_disposable_resource(VM& vm, Vector<DisposableResourc
|
||||||
|
|
||||||
// b. If Type(V) is not Object, throw a TypeError exception.
|
// b. If Type(V) is not Object, throw a TypeError exception.
|
||||||
if (!value.is_object())
|
if (!value.is_object())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, value.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, value.to_string_without_side_effects()));
|
||||||
|
|
||||||
// c. Let resource be ? CreateDisposableResource(V, hint).
|
// c. Let resource be ? CreateDisposableResource(V, hint).
|
||||||
resource = TRY(create_disposable_resource(vm, value, hint));
|
resource = TRY(create_disposable_resource(vm, value, hint));
|
||||||
|
@ -1349,7 +1349,7 @@ ThrowCompletionOr<void> add_disposable_resource(VM& vm, Vector<DisposableResourc
|
||||||
else {
|
else {
|
||||||
// i. If Type(V) is not Object, throw a TypeError exception.
|
// i. If Type(V) is not Object, throw a TypeError exception.
|
||||||
if (!value.is_object())
|
if (!value.is_object())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, value.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, value.to_string_without_side_effects()));
|
||||||
|
|
||||||
// ii. Let resource be ? CreateDisposableResource(V, hint, method).
|
// ii. Let resource be ? CreateDisposableResource(V, hint, method).
|
||||||
resource = TRY(create_disposable_resource(vm, value, hint, method));
|
resource = TRY(create_disposable_resource(vm, value, hint, method));
|
||||||
|
@ -1378,7 +1378,7 @@ ThrowCompletionOr<DisposableResource> create_disposable_resource(VM& vm, Value v
|
||||||
|
|
||||||
// c. If method is undefined, throw a TypeError exception.
|
// c. If method is undefined, throw a TypeError exception.
|
||||||
if (!method)
|
if (!method)
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NoDisposeMethod, value.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NoDisposeMethod, TRY_OR_THROW_OOM(vm, value.to_string_without_side_effects()));
|
||||||
}
|
}
|
||||||
// 2. Else,
|
// 2. Else,
|
||||||
// a. If IsCallable(method) is false, throw a TypeError exception.
|
// a. If IsCallable(method) is false, throw a TypeError exception.
|
||||||
|
|
|
@ -148,7 +148,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayConstructor::from)
|
||||||
if (!mapfn_value.is_undefined()) {
|
if (!mapfn_value.is_undefined()) {
|
||||||
// a. If IsCallable(mapfn) is false, throw a TypeError exception.
|
// a. If IsCallable(mapfn) is false, throw a TypeError exception.
|
||||||
if (!mapfn_value.is_function())
|
if (!mapfn_value.is_function())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, mapfn_value.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, TRY_OR_THROW_OOM(vm, mapfn_value.to_string_without_side_effects()));
|
||||||
|
|
||||||
// b. Let mapping be true.
|
// b. Let mapping be true.
|
||||||
mapfn = &mapfn_value.as_function();
|
mapfn = &mapfn_value.as_function();
|
||||||
|
|
|
@ -145,7 +145,7 @@ static ThrowCompletionOr<Object*> array_species_create(VM& vm, Object& original_
|
||||||
return TRY(Array::create(realm, length)).ptr();
|
return TRY(Array::create(realm, length)).ptr();
|
||||||
|
|
||||||
if (!constructor.is_constructor())
|
if (!constructor.is_constructor())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAConstructor, constructor.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAConstructor, TRY_OR_THROW_OOM(vm, constructor.to_string_without_side_effects()));
|
||||||
|
|
||||||
return TRY(construct(vm, constructor.as_function(), Value(length))).ptr();
|
return TRY(construct(vm, constructor.as_function(), Value(length))).ptr();
|
||||||
}
|
}
|
||||||
|
@ -318,7 +318,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::every)
|
||||||
|
|
||||||
// 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
|
// 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
|
||||||
if (!callback_function.is_function())
|
if (!callback_function.is_function())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, callback_function.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, TRY_OR_THROW_OOM(vm, callback_function.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 4. Let k be 0.
|
// 4. Let k be 0.
|
||||||
// 5. Repeat, while k < len,
|
// 5. Repeat, while k < len,
|
||||||
|
@ -404,7 +404,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::filter)
|
||||||
|
|
||||||
// 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
|
// 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
|
||||||
if (!callback_function.is_function())
|
if (!callback_function.is_function())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, callback_function.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, TRY_OR_THROW_OOM(vm, callback_function.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 4. Let A be ? ArraySpeciesCreate(O, 0).
|
// 4. Let A be ? ArraySpeciesCreate(O, 0).
|
||||||
auto* array = TRY(array_species_create(vm, *object, 0));
|
auto* array = TRY(array_species_create(vm, *object, 0));
|
||||||
|
@ -462,7 +462,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::find)
|
||||||
|
|
||||||
// 3. If IsCallable(predicate) is false, throw a TypeError exception.
|
// 3. If IsCallable(predicate) is false, throw a TypeError exception.
|
||||||
if (!predicate.is_function())
|
if (!predicate.is_function())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, predicate.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, TRY_OR_THROW_OOM(vm, predicate.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 4. Let k be 0.
|
// 4. Let k be 0.
|
||||||
// 5. Repeat, while k < len,
|
// 5. Repeat, while k < len,
|
||||||
|
@ -501,7 +501,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::find_index)
|
||||||
|
|
||||||
// 3. If IsCallable(predicate) is false, throw a TypeError exception.
|
// 3. If IsCallable(predicate) is false, throw a TypeError exception.
|
||||||
if (!predicate.is_function())
|
if (!predicate.is_function())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, predicate.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, TRY_OR_THROW_OOM(vm, predicate.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 4. Let k be 0.
|
// 4. Let k be 0.
|
||||||
// 5. Repeat, while k < len,
|
// 5. Repeat, while k < len,
|
||||||
|
@ -540,7 +540,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::find_last)
|
||||||
|
|
||||||
// 3. If IsCallable(predicate) is false, throw a TypeError exception.
|
// 3. If IsCallable(predicate) is false, throw a TypeError exception.
|
||||||
if (!predicate.is_function())
|
if (!predicate.is_function())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, predicate.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, TRY_OR_THROW_OOM(vm, predicate.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 4. Let k be len - 1.
|
// 4. Let k be len - 1.
|
||||||
// 5. Repeat, while k ≥ 0,
|
// 5. Repeat, while k ≥ 0,
|
||||||
|
@ -579,7 +579,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::find_last_index)
|
||||||
|
|
||||||
// 3. If IsCallable(predicate) is false, throw a TypeError exception.
|
// 3. If IsCallable(predicate) is false, throw a TypeError exception.
|
||||||
if (!predicate.is_function())
|
if (!predicate.is_function())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, predicate.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, TRY_OR_THROW_OOM(vm, predicate.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 4. Let k be len - 1.
|
// 4. Let k be len - 1.
|
||||||
// 5. Repeat, while k ≥ 0,
|
// 5. Repeat, while k ≥ 0,
|
||||||
|
@ -671,7 +671,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::flat_map)
|
||||||
|
|
||||||
// 3. If IsCallable(mapperFunction) is false, throw a TypeError exception.
|
// 3. If IsCallable(mapperFunction) is false, throw a TypeError exception.
|
||||||
if (!mapper_function.is_function())
|
if (!mapper_function.is_function())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, mapper_function.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, TRY_OR_THROW_OOM(vm, mapper_function.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 4. Let A be ? ArraySpeciesCreate(O, 0).
|
// 4. Let A be ? ArraySpeciesCreate(O, 0).
|
||||||
auto* array = TRY(array_species_create(vm, *object, 0));
|
auto* array = TRY(array_species_create(vm, *object, 0));
|
||||||
|
@ -697,7 +697,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::for_each)
|
||||||
|
|
||||||
// 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
|
// 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
|
||||||
if (!callback_function.is_function())
|
if (!callback_function.is_function())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, callback_function.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, TRY_OR_THROW_OOM(vm, callback_function.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 4. Let k be 0.
|
// 4. Let k be 0.
|
||||||
// 5. Repeat, while k < len,
|
// 5. Repeat, while k < len,
|
||||||
|
@ -768,7 +768,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::group)
|
||||||
|
|
||||||
// 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
|
// 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
|
||||||
if (!callback_function.is_function())
|
if (!callback_function.is_function())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, callback_function.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, TRY_OR_THROW_OOM(vm, callback_function.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 5. Let groups be a new empty List.
|
// 5. Let groups be a new empty List.
|
||||||
OrderedHashMap<PropertyKey, MarkedVector<Value>> groups;
|
OrderedHashMap<PropertyKey, MarkedVector<Value>> groups;
|
||||||
|
@ -824,7 +824,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::group_to_map)
|
||||||
|
|
||||||
// 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
|
// 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
|
||||||
if (!callback_function.is_function())
|
if (!callback_function.is_function())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, callback_function.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, TRY_OR_THROW_OOM(vm, callback_function.to_string_without_side_effects()));
|
||||||
|
|
||||||
struct KeyedGroupTraits : public Traits<Handle<Value>> {
|
struct KeyedGroupTraits : public Traits<Handle<Value>> {
|
||||||
static unsigned hash(Handle<Value> const& value_handle)
|
static unsigned hash(Handle<Value> const& value_handle)
|
||||||
|
@ -1109,7 +1109,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::map)
|
||||||
|
|
||||||
// 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
|
// 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
|
||||||
if (!callback_function.is_function())
|
if (!callback_function.is_function())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, callback_function.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, TRY_OR_THROW_OOM(vm, callback_function.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 4. Let A be ? ArraySpeciesCreate(O, len).
|
// 4. Let A be ? ArraySpeciesCreate(O, len).
|
||||||
auto* array = TRY(array_species_create(vm, *object, length));
|
auto* array = TRY(array_species_create(vm, *object, length));
|
||||||
|
@ -1188,7 +1188,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::reduce)
|
||||||
|
|
||||||
// 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
|
// 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
|
||||||
if (!callback_function.is_function())
|
if (!callback_function.is_function())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, callback_function.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, TRY_OR_THROW_OOM(vm, callback_function.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 4. If len = 0 and initialValue is not present, throw a TypeError exception.
|
// 4. If len = 0 and initialValue is not present, throw a TypeError exception.
|
||||||
if (length == 0 && vm.argument_count() <= 1)
|
if (length == 0 && vm.argument_count() <= 1)
|
||||||
|
@ -1270,7 +1270,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::reduce_right)
|
||||||
|
|
||||||
// 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
|
// 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
|
||||||
if (!callback_function.is_function())
|
if (!callback_function.is_function())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, callback_function.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, TRY_OR_THROW_OOM(vm, callback_function.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 4. If len = 0 and initialValue is not present, throw a TypeError exception.
|
// 4. If len = 0 and initialValue is not present, throw a TypeError exception.
|
||||||
if (length == 0 && vm.argument_count() <= 1)
|
if (length == 0 && vm.argument_count() <= 1)
|
||||||
|
@ -1470,7 +1470,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::some)
|
||||||
|
|
||||||
// 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
|
// 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
|
||||||
if (!callback_function.is_function())
|
if (!callback_function.is_function())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, callback_function.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, TRY_OR_THROW_OOM(vm, callback_function.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 4. Let k be 0.
|
// 4. Let k be 0.
|
||||||
// 5. Repeat, while k < len,
|
// 5. Repeat, while k < len,
|
||||||
|
@ -1564,7 +1564,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::sort)
|
||||||
// 1. If comparefn is not undefined and IsCallable(comparefn) is false, throw a TypeError exception.
|
// 1. If comparefn is not undefined and IsCallable(comparefn) is false, throw a TypeError exception.
|
||||||
auto comparefn = vm.argument(0);
|
auto comparefn = vm.argument(0);
|
||||||
if (!comparefn.is_undefined() && !comparefn.is_function())
|
if (!comparefn.is_undefined() && !comparefn.is_function())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, comparefn.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, TRY_OR_THROW_OOM(vm, comparefn.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 2. Let obj be ? ToObject(this value).
|
// 2. Let obj be ? ToObject(this value).
|
||||||
auto* object = TRY(vm.this_value().to_object(vm));
|
auto* object = TRY(vm.this_value().to_object(vm));
|
||||||
|
|
|
@ -52,7 +52,7 @@ ThrowCompletionOr<NonnullGCPtr<Object>> DataViewConstructor::construct(FunctionO
|
||||||
|
|
||||||
// 2. Perform ? RequireInternalSlot(buffer, [[ArrayBufferData]]).
|
// 2. Perform ? RequireInternalSlot(buffer, [[ArrayBufferData]]).
|
||||||
if (!buffer.is_object() || !is<ArrayBuffer>(buffer.as_object()))
|
if (!buffer.is_object() || !is<ArrayBuffer>(buffer.as_object()))
|
||||||
return vm.throw_completion<TypeError>(ErrorType::IsNotAn, buffer.to_deprecated_string_without_side_effects(), vm.names.ArrayBuffer);
|
return vm.throw_completion<TypeError>(ErrorType::IsNotAn, TRY_OR_THROW_OOM(vm, buffer.to_string_without_side_effects()), vm.names.ArrayBuffer);
|
||||||
|
|
||||||
auto& array_buffer = static_cast<ArrayBuffer&>(buffer.as_object());
|
auto& array_buffer = static_cast<ArrayBuffer&>(buffer.as_object());
|
||||||
|
|
||||||
|
|
|
@ -1255,10 +1255,10 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::symbol_to_primitive)
|
||||||
{
|
{
|
||||||
auto this_value = vm.this_value();
|
auto this_value = vm.this_value();
|
||||||
if (!this_value.is_object())
|
if (!this_value.is_object())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, this_value.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, this_value.to_string_without_side_effects()));
|
||||||
auto hint_value = vm.argument(0);
|
auto hint_value = vm.argument(0);
|
||||||
if (!hint_value.is_string())
|
if (!hint_value.is_string())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::InvalidHint, hint_value.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::InvalidHint, TRY_OR_THROW_OOM(vm, hint_value.to_string_without_side_effects()));
|
||||||
auto hint = TRY(hint_value.as_string().deprecated_string());
|
auto hint = TRY(hint_value.as_string().deprecated_string());
|
||||||
Value::PreferredType try_first;
|
Value::PreferredType try_first;
|
||||||
if (hint == "string" || hint == "default")
|
if (hint == "string" || hint == "default")
|
||||||
|
|
|
@ -89,7 +89,7 @@ JS_DEFINE_NATIVE_FUNCTION(DisposableStackPrototype::use)
|
||||||
if (!value.is_nullish()) {
|
if (!value.is_nullish()) {
|
||||||
// a. If Type(value) is not Object, throw a TypeError exception.
|
// a. If Type(value) is not Object, throw a TypeError exception.
|
||||||
if (!value.is_object())
|
if (!value.is_object())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, value.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, value.to_string_without_side_effects()));
|
||||||
|
|
||||||
// FIXME: This should be TRY in the spec
|
// FIXME: This should be TRY in the spec
|
||||||
// b. Let method be GetDisposeMethod(value, sync-dispose).
|
// b. Let method be GetDisposeMethod(value, sync-dispose).
|
||||||
|
@ -98,7 +98,7 @@ JS_DEFINE_NATIVE_FUNCTION(DisposableStackPrototype::use)
|
||||||
// c. If method is undefined, then
|
// c. If method is undefined, then
|
||||||
if (!method.ptr()) {
|
if (!method.ptr()) {
|
||||||
// i. Throw a TypeError exception.
|
// i. Throw a TypeError exception.
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NoDisposeMethod, value.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NoDisposeMethod, TRY_OR_THROW_OOM(vm, value.to_string_without_side_effects()));
|
||||||
}
|
}
|
||||||
// d. Else,
|
// d. Else,
|
||||||
// i. Perform ? AddDisposableResource(disposableStack, value, sync-dispose, method).
|
// i. Perform ? AddDisposableResource(disposableStack, value, sync-dispose, method).
|
||||||
|
@ -128,7 +128,7 @@ JS_DEFINE_NATIVE_FUNCTION(DisposableStackPrototype::adopt)
|
||||||
|
|
||||||
// 4. If IsCallable(onDispose) is false, throw a TypeError exception.
|
// 4. If IsCallable(onDispose) is false, throw a TypeError exception.
|
||||||
if (!on_dispose.is_function())
|
if (!on_dispose.is_function())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, on_dispose.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, TRY_OR_THROW_OOM(vm, on_dispose.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 5. Let F be a new built-in function object as defined in 11.3.3.4.1.
|
// 5. Let F be a new built-in function object as defined in 11.3.3.4.1.
|
||||||
// 6. Set F.[[Argument]] to value.
|
// 6. Set F.[[Argument]] to value.
|
||||||
|
@ -169,7 +169,7 @@ JS_DEFINE_NATIVE_FUNCTION(DisposableStackPrototype::defer)
|
||||||
|
|
||||||
// 4. If IsCallable(onDispose) is false, throw a TypeError exception.
|
// 4. If IsCallable(onDispose) is false, throw a TypeError exception.
|
||||||
if (!on_dispose.is_function())
|
if (!on_dispose.is_function())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, on_dispose.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, TRY_OR_THROW_OOM(vm, on_dispose.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 5. Perform ? AddDisposableResource(disposableStack, undefined, sync-dispose, onDispose).
|
// 5. Perform ? AddDisposableResource(disposableStack, undefined, sync-dispose, onDispose).
|
||||||
TRY(add_disposable_resource(vm, disposable_stack->disposable_resource_stack(), js_undefined(), Environment::InitializeBindingHint::SyncDispose, &on_dispose.as_function()));
|
TRY(add_disposable_resource(vm, disposable_stack->disposable_resource_stack(), js_undefined(), Environment::InitializeBindingHint::SyncDispose, &on_dispose.as_function()));
|
||||||
|
|
|
@ -111,7 +111,7 @@ JS_DEFINE_NATIVE_FUNCTION(ErrorPrototype::stack_setter)
|
||||||
|
|
||||||
// 2. If ! Type(E) is not Object, throw a TypeError exception.
|
// 2. If ! Type(E) is not Object, throw a TypeError exception.
|
||||||
if (!this_value.is_object())
|
if (!this_value.is_object())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, this_value.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, this_value.to_string_without_side_effects()));
|
||||||
|
|
||||||
auto& this_object = this_value.as_object();
|
auto& this_object = this_value.as_object();
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ ThrowCompletionOr<NonnullGCPtr<Object>> FinalizationRegistryConstructor::constru
|
||||||
// 2. If IsCallable(cleanupCallback) is false, throw a TypeError exception.
|
// 2. If IsCallable(cleanupCallback) is false, throw a TypeError exception.
|
||||||
auto cleanup_callback = vm.argument(0);
|
auto cleanup_callback = vm.argument(0);
|
||||||
if (!cleanup_callback.is_function())
|
if (!cleanup_callback.is_function())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, cleanup_callback.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, TRY_OR_THROW_OOM(vm, cleanup_callback.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 3. Let finalizationRegistry be ? OrdinaryCreateFromConstructor(NewTarget, "%FinalizationRegistry.prototype%", « [[Realm]], [[CleanupCallback]], [[Cells]] »).
|
// 3. Let finalizationRegistry be ? OrdinaryCreateFromConstructor(NewTarget, "%FinalizationRegistry.prototype%", « [[Realm]], [[CleanupCallback]], [[Cells]] »).
|
||||||
// 4. Let fn be the active function object.
|
// 4. Let fn be the active function object.
|
||||||
|
|
|
@ -42,7 +42,7 @@ JS_DEFINE_NATIVE_FUNCTION(FinalizationRegistryPrototype::cleanup_some)
|
||||||
|
|
||||||
// 3. If callback is present and IsCallable(callback) is false, throw a TypeError exception.
|
// 3. If callback is present and IsCallable(callback) is false, throw a TypeError exception.
|
||||||
if (vm.argument_count() > 0 && !callback.is_function())
|
if (vm.argument_count() > 0 && !callback.is_function())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, callback.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, TRY_OR_THROW_OOM(vm, callback.to_string_without_side_effects()));
|
||||||
|
|
||||||
// IMPLEMENTATION DEFINED: The specification for this function hasn't been updated to accommodate for JobCallback records.
|
// IMPLEMENTATION DEFINED: The specification for this function hasn't been updated to accommodate for JobCallback records.
|
||||||
// This just follows how the constructor immediately converts the callback to a JobCallback using HostMakeJobCallback.
|
// This just follows how the constructor immediately converts the callback to a JobCallback using HostMakeJobCallback.
|
||||||
|
@ -66,7 +66,7 @@ JS_DEFINE_NATIVE_FUNCTION(FinalizationRegistryPrototype::register_)
|
||||||
|
|
||||||
// 3. If target is not an Object, throw a TypeError exception.
|
// 3. If target is not an Object, throw a TypeError exception.
|
||||||
if (!can_be_held_weakly(target))
|
if (!can_be_held_weakly(target))
|
||||||
return vm.throw_completion<TypeError>(ErrorType::CannotBeHeldWeakly, target.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::CannotBeHeldWeakly, TRY_OR_THROW_OOM(vm, target.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 4. If SameValue(target, heldValue) is true, throw a TypeError exception.
|
// 4. If SameValue(target, heldValue) is true, throw a TypeError exception.
|
||||||
if (same_value(target, held_value))
|
if (same_value(target, held_value))
|
||||||
|
@ -76,7 +76,7 @@ JS_DEFINE_NATIVE_FUNCTION(FinalizationRegistryPrototype::register_)
|
||||||
// a. If unregisterToken is not undefined, throw a TypeError exception.
|
// a. If unregisterToken is not undefined, throw a TypeError exception.
|
||||||
// b. Set unregisterToken to empty.
|
// b. Set unregisterToken to empty.
|
||||||
if (!can_be_held_weakly(unregister_token) && !unregister_token.is_undefined())
|
if (!can_be_held_weakly(unregister_token) && !unregister_token.is_undefined())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::CannotBeHeldWeakly, unregister_token.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::CannotBeHeldWeakly, TRY_OR_THROW_OOM(vm, unregister_token.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 6. Let cell be the Record { [[WeakRefTarget]]: target, [[HeldValue]]: heldValue, [[UnregisterToken]]: unregisterToken }.
|
// 6. Let cell be the Record { [[WeakRefTarget]]: target, [[HeldValue]]: heldValue, [[UnregisterToken]]: unregisterToken }.
|
||||||
// 7. Append cell to finalizationRegistry.[[Cells]].
|
// 7. Append cell to finalizationRegistry.[[Cells]].
|
||||||
|
@ -97,7 +97,7 @@ JS_DEFINE_NATIVE_FUNCTION(FinalizationRegistryPrototype::unregister)
|
||||||
|
|
||||||
// 3. If unregisterToken is not an Object, throw a TypeError exception.
|
// 3. If unregisterToken is not an Object, throw a TypeError exception.
|
||||||
if (!can_be_held_weakly(unregister_token))
|
if (!can_be_held_weakly(unregister_token))
|
||||||
return vm.throw_completion<TypeError>(ErrorType::CannotBeHeldWeakly, unregister_token.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::CannotBeHeldWeakly, TRY_OR_THROW_OOM(vm, unregister_token.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 4-6.
|
// 4-6.
|
||||||
return Value(finalization_registry->remove_by_token(unregister_token.as_cell()));
|
return Value(finalization_registry->remove_by_token(unregister_token.as_cell()));
|
||||||
|
|
|
@ -56,7 +56,7 @@ JS_DEFINE_NATIVE_FUNCTION(FunctionPrototype::apply)
|
||||||
|
|
||||||
// 2. If IsCallable(func) is false, throw a TypeError exception.
|
// 2. If IsCallable(func) is false, throw a TypeError exception.
|
||||||
if (!function_value.is_function())
|
if (!function_value.is_function())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, function_value.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, TRY_OR_THROW_OOM(vm, function_value.to_string_without_side_effects()));
|
||||||
|
|
||||||
auto& function = static_cast<FunctionObject&>(function_value.as_object());
|
auto& function = static_cast<FunctionObject&>(function_value.as_object());
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ JS_DEFINE_NATIVE_FUNCTION(FunctionPrototype::bind)
|
||||||
|
|
||||||
// 2. If IsCallable(Target) is false, throw a TypeError exception.
|
// 2. If IsCallable(Target) is false, throw a TypeError exception.
|
||||||
if (!target_value.is_function())
|
if (!target_value.is_function())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, target_value.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, TRY_OR_THROW_OOM(vm, target_value.to_string_without_side_effects()));
|
||||||
|
|
||||||
auto& target = static_cast<FunctionObject&>(target_value.as_object());
|
auto& target = static_cast<FunctionObject&>(target_value.as_object());
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ JS_DEFINE_NATIVE_FUNCTION(FunctionPrototype::call)
|
||||||
|
|
||||||
// 2. If IsCallable(func) is false, throw a TypeError exception.
|
// 2. If IsCallable(func) is false, throw a TypeError exception.
|
||||||
if (!function_value.is_function())
|
if (!function_value.is_function())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, function_value.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, TRY_OR_THROW_OOM(vm, function_value.to_string_without_side_effects()));
|
||||||
|
|
||||||
auto& function = static_cast<FunctionObject&>(function_value.as_object());
|
auto& function = static_cast<FunctionObject&>(function_value.as_object());
|
||||||
|
|
||||||
|
|
|
@ -48,14 +48,14 @@ ThrowCompletionOr<Iterator> get_iterator(VM& vm, Value value, IteratorHint hint,
|
||||||
|
|
||||||
// NOTE: Additional type check to produce a better error message than Call().
|
// NOTE: Additional type check to produce a better error message than Call().
|
||||||
if (!method->is_function())
|
if (!method->is_function())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotIterable, value.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotIterable, TRY_OR_THROW_OOM(vm, value.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 3. Let iterator be ? Call(method, obj).
|
// 3. Let iterator be ? Call(method, obj).
|
||||||
auto iterator = TRY(call(vm, *method, value));
|
auto iterator = TRY(call(vm, *method, value));
|
||||||
|
|
||||||
// 4. If Type(iterator) is not Object, throw a TypeError exception.
|
// 4. If Type(iterator) is not Object, throw a TypeError exception.
|
||||||
if (!iterator.is_object())
|
if (!iterator.is_object())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotIterable, value.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotIterable, TRY_OR_THROW_OOM(vm, value.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 5. Let nextMethod be ? GetV(iterator, "next").
|
// 5. Let nextMethod be ? GetV(iterator, "next").
|
||||||
auto next_method = TRY(iterator.get(vm, vm.names.next));
|
auto next_method = TRY(iterator.get(vm, vm.names.next));
|
||||||
|
|
|
@ -56,7 +56,7 @@ ThrowCompletionOr<NonnullGCPtr<Object>> MapConstructor::construct(FunctionObject
|
||||||
|
|
||||||
(void)TRY(get_iterator_values(vm, vm.argument(0), [&](Value iterator_value) -> Optional<Completion> {
|
(void)TRY(get_iterator_values(vm, vm.argument(0), [&](Value iterator_value) -> Optional<Completion> {
|
||||||
if (!iterator_value.is_object())
|
if (!iterator_value.is_object())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, DeprecatedString::formatted("Iterator value {}", iterator_value.to_deprecated_string_without_side_effects()));
|
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, DeprecatedString::formatted("Iterator value {}", TRY_OR_THROW_OOM(vm, iterator_value.to_string_without_side_effects())));
|
||||||
|
|
||||||
auto key = TRY(iterator_value.as_object().get(0));
|
auto key = TRY(iterator_value.as_object().get(0));
|
||||||
auto value = TRY(iterator_value.as_object().get(1));
|
auto value = TRY(iterator_value.as_object().get(1));
|
||||||
|
|
|
@ -71,7 +71,7 @@ JS_DEFINE_NATIVE_FUNCTION(MapPrototype::for_each)
|
||||||
{
|
{
|
||||||
auto* map = TRY(typed_this_object(vm));
|
auto* map = TRY(typed_this_object(vm));
|
||||||
if (!vm.argument(0).is_function())
|
if (!vm.argument(0).is_function())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, vm.argument(0).to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, TRY_OR_THROW_OOM(vm, vm.argument(0).to_string_without_side_effects()));
|
||||||
auto this_value = vm.this_value();
|
auto this_value = vm.this_value();
|
||||||
for (auto& entry : *map)
|
for (auto& entry : *map)
|
||||||
TRY(call(vm, vm.argument(0).as_function(), vm.argument(1), entry.value, entry.key, this_value));
|
TRY(call(vm, vm.argument(0).as_function(), vm.argument(1), entry.value, entry.key, this_value));
|
||||||
|
|
|
@ -229,7 +229,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::from_entries)
|
||||||
|
|
||||||
(void)TRY(get_iterator_values(vm, iterable, [&](Value iterator_value) -> Optional<Completion> {
|
(void)TRY(get_iterator_values(vm, iterable, [&](Value iterator_value) -> Optional<Completion> {
|
||||||
if (!iterator_value.is_object())
|
if (!iterator_value.is_object())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, DeprecatedString::formatted("Iterator value {}", iterator_value.to_deprecated_string_without_side_effects()));
|
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, DeprecatedString::formatted("Iterator value {}", TRY_OR_THROW_OOM(vm, iterator_value.to_string_without_side_effects())));
|
||||||
|
|
||||||
auto key = TRY(iterator_value.as_object().get(0));
|
auto key = TRY(iterator_value.as_object().get(0));
|
||||||
auto value = TRY(iterator_value.as_object().get(1));
|
auto value = TRY(iterator_value.as_object().get(1));
|
||||||
|
@ -301,7 +301,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::get_own_property_descriptors)
|
||||||
JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::define_property)
|
JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::define_property)
|
||||||
{
|
{
|
||||||
if (!vm.argument(0).is_object())
|
if (!vm.argument(0).is_object())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, vm.argument(0).to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, vm.argument(0).to_string_without_side_effects()));
|
||||||
auto key = TRY(vm.argument(1).to_property_key(vm));
|
auto key = TRY(vm.argument(1).to_property_key(vm));
|
||||||
auto descriptor = TRY(to_property_descriptor(vm, vm.argument(2)));
|
auto descriptor = TRY(to_property_descriptor(vm, vm.argument(2)));
|
||||||
TRY(vm.argument(0).as_object().define_property_or_throw(key, descriptor));
|
TRY(vm.argument(0).as_object().define_property_or_throw(key, descriptor));
|
||||||
|
|
|
@ -187,7 +187,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectPrototype::define_getter)
|
||||||
|
|
||||||
auto getter = vm.argument(1);
|
auto getter = vm.argument(1);
|
||||||
if (!getter.is_function())
|
if (!getter.is_function())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, getter.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, TRY_OR_THROW_OOM(vm, getter.to_string_without_side_effects()));
|
||||||
|
|
||||||
auto descriptor = PropertyDescriptor { .get = &getter.as_function(), .enumerable = true, .configurable = true };
|
auto descriptor = PropertyDescriptor { .get = &getter.as_function(), .enumerable = true, .configurable = true };
|
||||||
|
|
||||||
|
@ -205,7 +205,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectPrototype::define_setter)
|
||||||
|
|
||||||
auto setter = vm.argument(1);
|
auto setter = vm.argument(1);
|
||||||
if (!setter.is_function())
|
if (!setter.is_function())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, setter.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, TRY_OR_THROW_OOM(vm, setter.to_string_without_side_effects()));
|
||||||
|
|
||||||
auto descriptor = PropertyDescriptor { .set = &setter.as_function(), .enumerable = true, .configurable = true };
|
auto descriptor = PropertyDescriptor { .set = &setter.as_function(), .enumerable = true, .configurable = true };
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ ThrowCompletionOr<NonnullGCPtr<PromiseCapability>> new_promise_capability(VM& vm
|
||||||
|
|
||||||
// 1. If IsConstructor(C) is false, throw a TypeError exception.
|
// 1. If IsConstructor(C) is false, throw a TypeError exception.
|
||||||
if (!constructor.is_constructor())
|
if (!constructor.is_constructor())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAConstructor, constructor.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAConstructor, TRY_OR_THROW_OOM(vm, constructor.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 2. NOTE: C is assumed to be a constructor function that supports the parameter conventions of the Promise constructor (see 27.2.3.1).
|
// 2. NOTE: C is assumed to be a constructor function that supports the parameter conventions of the Promise constructor (see 27.2.3.1).
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ static ThrowCompletionOr<Value> get_promise_resolve(VM& vm, Value constructor)
|
||||||
|
|
||||||
// 2. If IsCallable(promiseResolve) is false, throw a TypeError exception.
|
// 2. If IsCallable(promiseResolve) is false, throw a TypeError exception.
|
||||||
if (!promise_resolve.is_function())
|
if (!promise_resolve.is_function())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, promise_resolve.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, TRY_OR_THROW_OOM(vm, promise_resolve.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 3. Return promiseResolve.
|
// 3. Return promiseResolve.
|
||||||
return promise_resolve;
|
return promise_resolve;
|
||||||
|
@ -474,7 +474,7 @@ JS_DEFINE_NATIVE_FUNCTION(PromiseConstructor::resolve)
|
||||||
|
|
||||||
// 2. If Type(C) is not Object, throw a TypeError exception.
|
// 2. If Type(C) is not Object, throw a TypeError exception.
|
||||||
if (!constructor.is_object())
|
if (!constructor.is_object())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, constructor.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, constructor.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 3. Return ? PromiseResolve(C, x).
|
// 3. Return ? PromiseResolve(C, x).
|
||||||
return TRY(promise_resolve(vm, constructor.as_object(), value));
|
return TRY(promise_resolve(vm, constructor.as_object(), value));
|
||||||
|
|
|
@ -83,7 +83,7 @@ JS_DEFINE_NATIVE_FUNCTION(PromisePrototype::finally)
|
||||||
|
|
||||||
// 2. If Type(promise) is not Object, throw a TypeError exception.
|
// 2. If Type(promise) is not Object, throw a TypeError exception.
|
||||||
if (!promise.is_object())
|
if (!promise.is_object())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, promise.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, promise.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 3. Let C be ? SpeciesConstructor(promise, %Promise%).
|
// 3. Let C be ? SpeciesConstructor(promise, %Promise%).
|
||||||
auto* constructor = TRY(species_constructor(vm, promise.as_object(), *realm.intrinsics().promise_constructor()));
|
auto* constructor = TRY(species_constructor(vm, promise.as_object(), *realm.intrinsics().promise_constructor()));
|
||||||
|
|
|
@ -92,7 +92,7 @@ ThrowCompletionOr<PropertyDescriptor> to_property_descriptor(VM& vm, Value argum
|
||||||
{
|
{
|
||||||
// 1. If Type(Obj) is not Object, throw a TypeError exception.
|
// 1. If Type(Obj) is not Object, throw a TypeError exception.
|
||||||
if (!argument.is_object())
|
if (!argument.is_object())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, argument.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, argument.to_string_without_side_effects()));
|
||||||
|
|
||||||
auto& object = argument.as_object();
|
auto& object = argument.as_object();
|
||||||
|
|
||||||
|
|
|
@ -18,9 +18,9 @@ static ThrowCompletionOr<ProxyObject*> proxy_create(VM& vm, Value target, Value
|
||||||
{
|
{
|
||||||
auto& realm = *vm.current_realm();
|
auto& realm = *vm.current_realm();
|
||||||
if (!target.is_object())
|
if (!target.is_object())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::ProxyConstructorBadType, "target", target.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::ProxyConstructorBadType, "target", TRY_OR_THROW_OOM(vm, target.to_string_without_side_effects()));
|
||||||
if (!handler.is_object())
|
if (!handler.is_object())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::ProxyConstructorBadType, "handler", handler.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::ProxyConstructorBadType, "handler", TRY_OR_THROW_OOM(vm, handler.to_string_without_side_effects()));
|
||||||
return ProxyObject::create(realm, target.as_object(), handler.as_object()).ptr();
|
return ProxyObject::create(realm, target.as_object(), handler.as_object()).ptr();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -707,7 +707,7 @@ ThrowCompletionOr<MarkedVector<Value>> ProxyObject::internal_own_property_keys()
|
||||||
for (auto& key : target_nonconfigurable_keys) {
|
for (auto& key : target_nonconfigurable_keys) {
|
||||||
// a. If key is not an element of uncheckedResultKeys, throw a TypeError exception.
|
// a. If key is not an element of uncheckedResultKeys, throw a TypeError exception.
|
||||||
if (!unchecked_result_keys.contains_slow(key))
|
if (!unchecked_result_keys.contains_slow(key))
|
||||||
return vm.throw_completion<TypeError>(ErrorType::ProxyOwnPropertyKeysSkippedNonconfigurableProperty, key.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::ProxyOwnPropertyKeysSkippedNonconfigurableProperty, TRY_OR_THROW_OOM(vm, key.to_string_without_side_effects()));
|
||||||
|
|
||||||
// b. Remove key from uncheckedResultKeys.
|
// b. Remove key from uncheckedResultKeys.
|
||||||
unchecked_result_keys.remove_first_matching([&](auto& value) {
|
unchecked_result_keys.remove_first_matching([&](auto& value) {
|
||||||
|
@ -723,7 +723,7 @@ ThrowCompletionOr<MarkedVector<Value>> ProxyObject::internal_own_property_keys()
|
||||||
for (auto& key : target_configurable_keys) {
|
for (auto& key : target_configurable_keys) {
|
||||||
// a. If key is not an element of uncheckedResultKeys, throw a TypeError exception.
|
// a. If key is not an element of uncheckedResultKeys, throw a TypeError exception.
|
||||||
if (!unchecked_result_keys.contains_slow(key))
|
if (!unchecked_result_keys.contains_slow(key))
|
||||||
return vm.throw_completion<TypeError>(ErrorType::ProxyOwnPropertyKeysNonExtensibleSkippedProperty, key.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::ProxyOwnPropertyKeysNonExtensibleSkippedProperty, TRY_OR_THROW_OOM(vm, key.to_string_without_side_effects()));
|
||||||
|
|
||||||
// b. Remove key from uncheckedResultKeys.
|
// b. Remove key from uncheckedResultKeys.
|
||||||
unchecked_result_keys.remove_first_matching([&](auto& value) {
|
unchecked_result_keys.remove_first_matching([&](auto& value) {
|
||||||
|
@ -733,7 +733,7 @@ ThrowCompletionOr<MarkedVector<Value>> ProxyObject::internal_own_property_keys()
|
||||||
|
|
||||||
// 22. If uncheckedResultKeys is not empty, throw a TypeError exception.
|
// 22. If uncheckedResultKeys is not empty, throw a TypeError exception.
|
||||||
if (!unchecked_result_keys.is_empty())
|
if (!unchecked_result_keys.is_empty())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::ProxyOwnPropertyKeysNonExtensibleNewProperty, unchecked_result_keys[0].to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::ProxyOwnPropertyKeysNonExtensibleNewProperty, TRY_OR_THROW_OOM(vm, unchecked_result_keys[0].to_string_without_side_effects()));
|
||||||
|
|
||||||
// 23. Return trapResult.
|
// 23. Return trapResult.
|
||||||
return { move(trap_result) };
|
return { move(trap_result) };
|
||||||
|
|
|
@ -53,7 +53,7 @@ ThrowCompletionOr<void> Reference::put_value(VM& vm, Value value)
|
||||||
|
|
||||||
// d. If succeeded is false and V.[[Strict]] is true, throw a TypeError exception.
|
// d. If succeeded is false and V.[[Strict]] is true, throw a TypeError exception.
|
||||||
if (!succeeded && m_strict)
|
if (!succeeded && m_strict)
|
||||||
return vm.throw_completion<TypeError>(ErrorType::ReferenceNullishSetProperty, m_name, m_base_value.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::ReferenceNullishSetProperty, m_name, TRY_OR_THROW_OOM(vm, m_base_value.to_string_without_side_effects()));
|
||||||
|
|
||||||
// e. Return unused.
|
// e. Return unused.
|
||||||
return {};
|
return {};
|
||||||
|
@ -178,7 +178,7 @@ ThrowCompletionOr<bool> Reference::delete_(VM& vm)
|
||||||
|
|
||||||
// e. If deleteStatus is false and ref.[[Strict]] is true, throw a TypeError exception.
|
// e. If deleteStatus is false and ref.[[Strict]] is true, throw a TypeError exception.
|
||||||
if (!delete_status && m_strict)
|
if (!delete_status && m_strict)
|
||||||
return vm.throw_completion<TypeError>(ErrorType::ReferenceNullishDeleteProperty, m_name, m_base_value.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::ReferenceNullishDeleteProperty, m_name, TRY_OR_THROW_OOM(vm, m_base_value.to_string_without_side_effects()));
|
||||||
|
|
||||||
// f. Return deleteStatus.
|
// f. Return deleteStatus.
|
||||||
return delete_status;
|
return delete_status;
|
||||||
|
|
|
@ -54,7 +54,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::apply)
|
||||||
|
|
||||||
// 1. If IsCallable(target) is false, throw a TypeError exception.
|
// 1. If IsCallable(target) is false, throw a TypeError exception.
|
||||||
if (!target.is_function())
|
if (!target.is_function())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, target.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, TRY_OR_THROW_OOM(vm, target.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 2. Let args be ? CreateListFromArrayLike(argumentsList).
|
// 2. Let args be ? CreateListFromArrayLike(argumentsList).
|
||||||
auto args = TRY(create_list_from_array_like(vm, arguments_list));
|
auto args = TRY(create_list_from_array_like(vm, arguments_list));
|
||||||
|
@ -73,14 +73,14 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::construct)
|
||||||
|
|
||||||
// 1. If IsConstructor(target) is false, throw a TypeError exception.
|
// 1. If IsConstructor(target) is false, throw a TypeError exception.
|
||||||
if (!target.is_constructor())
|
if (!target.is_constructor())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAConstructor, target.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAConstructor, TRY_OR_THROW_OOM(vm, target.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 2. If newTarget is not present, set newTarget to target.
|
// 2. If newTarget is not present, set newTarget to target.
|
||||||
if (vm.argument_count() < 3)
|
if (vm.argument_count() < 3)
|
||||||
new_target = target;
|
new_target = target;
|
||||||
// 3. Else if IsConstructor(newTarget) is false, throw a TypeError exception.
|
// 3. Else if IsConstructor(newTarget) is false, throw a TypeError exception.
|
||||||
else if (!new_target.is_constructor())
|
else if (!new_target.is_constructor())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAConstructor, new_target.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAConstructor, TRY_OR_THROW_OOM(vm, new_target.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 4. Let args be ? CreateListFromArrayLike(argumentsList).
|
// 4. Let args be ? CreateListFromArrayLike(argumentsList).
|
||||||
auto args = TRY(create_list_from_array_like(vm, arguments_list));
|
auto args = TRY(create_list_from_array_like(vm, arguments_list));
|
||||||
|
@ -98,7 +98,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::define_property)
|
||||||
|
|
||||||
// 1. If Type(target) is not Object, throw a TypeError exception.
|
// 1. If Type(target) is not Object, throw a TypeError exception.
|
||||||
if (!target.is_object())
|
if (!target.is_object())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, target.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, target.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 2. Let key be ? ToPropertyKey(propertyKey).
|
// 2. Let key be ? ToPropertyKey(propertyKey).
|
||||||
auto key = TRY(property_key.to_property_key(vm));
|
auto key = TRY(property_key.to_property_key(vm));
|
||||||
|
@ -118,7 +118,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::delete_property)
|
||||||
|
|
||||||
// 1. If Type(target) is not Object, throw a TypeError exception.
|
// 1. If Type(target) is not Object, throw a TypeError exception.
|
||||||
if (!target.is_object())
|
if (!target.is_object())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, target.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, target.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 2. Let key be ? ToPropertyKey(propertyKey).
|
// 2. Let key be ? ToPropertyKey(propertyKey).
|
||||||
auto key = TRY(property_key.to_property_key(vm));
|
auto key = TRY(property_key.to_property_key(vm));
|
||||||
|
@ -136,7 +136,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::get)
|
||||||
|
|
||||||
// 1. If Type(target) is not Object, throw a TypeError exception.
|
// 1. If Type(target) is not Object, throw a TypeError exception.
|
||||||
if (!target.is_object())
|
if (!target.is_object())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, target.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, target.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 2. Let key be ? ToPropertyKey(propertyKey).
|
// 2. Let key be ? ToPropertyKey(propertyKey).
|
||||||
auto key = TRY(property_key.to_property_key(vm));
|
auto key = TRY(property_key.to_property_key(vm));
|
||||||
|
@ -159,7 +159,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::get_own_property_descriptor)
|
||||||
|
|
||||||
// 1. If Type(target) is not Object, throw a TypeError exception.
|
// 1. If Type(target) is not Object, throw a TypeError exception.
|
||||||
if (!target.is_object())
|
if (!target.is_object())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, target.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, target.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 2. Let key be ? ToPropertyKey(propertyKey).
|
// 2. Let key be ? ToPropertyKey(propertyKey).
|
||||||
auto key = TRY(property_key.to_property_key(vm));
|
auto key = TRY(property_key.to_property_key(vm));
|
||||||
|
@ -178,7 +178,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::get_prototype_of)
|
||||||
|
|
||||||
// 1. If Type(target) is not Object, throw a TypeError exception.
|
// 1. If Type(target) is not Object, throw a TypeError exception.
|
||||||
if (!target.is_object())
|
if (!target.is_object())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, target.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, target.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 2. Return ? target.[[GetPrototypeOf]]().
|
// 2. Return ? target.[[GetPrototypeOf]]().
|
||||||
return TRY(target.as_object().internal_get_prototype_of());
|
return TRY(target.as_object().internal_get_prototype_of());
|
||||||
|
@ -192,7 +192,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::has)
|
||||||
|
|
||||||
// 1. If Type(target) is not Object, throw a TypeError exception.
|
// 1. If Type(target) is not Object, throw a TypeError exception.
|
||||||
if (!target.is_object())
|
if (!target.is_object())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, target.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, target.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 2. Let key be ? ToPropertyKey(propertyKey).
|
// 2. Let key be ? ToPropertyKey(propertyKey).
|
||||||
auto key = TRY(property_key.to_property_key(vm));
|
auto key = TRY(property_key.to_property_key(vm));
|
||||||
|
@ -208,7 +208,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::is_extensible)
|
||||||
|
|
||||||
// 1. If Type(target) is not Object, throw a TypeError exception.
|
// 1. If Type(target) is not Object, throw a TypeError exception.
|
||||||
if (!target.is_object())
|
if (!target.is_object())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, target.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, target.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 2. Return ? target.[[IsExtensible]]().
|
// 2. Return ? target.[[IsExtensible]]().
|
||||||
return Value(TRY(target.as_object().internal_is_extensible()));
|
return Value(TRY(target.as_object().internal_is_extensible()));
|
||||||
|
@ -223,7 +223,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::own_keys)
|
||||||
|
|
||||||
// 1. If Type(target) is not Object, throw a TypeError exception.
|
// 1. If Type(target) is not Object, throw a TypeError exception.
|
||||||
if (!target.is_object())
|
if (!target.is_object())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, target.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, target.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 2. Let keys be ? target.[[OwnPropertyKeys]]().
|
// 2. Let keys be ? target.[[OwnPropertyKeys]]().
|
||||||
auto keys = TRY(target.as_object().internal_own_property_keys());
|
auto keys = TRY(target.as_object().internal_own_property_keys());
|
||||||
|
@ -239,7 +239,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::prevent_extensions)
|
||||||
|
|
||||||
// 1. If Type(target) is not Object, throw a TypeError exception.
|
// 1. If Type(target) is not Object, throw a TypeError exception.
|
||||||
if (!target.is_object())
|
if (!target.is_object())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, target.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, target.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 2. Return ? target.[[PreventExtensions]]().
|
// 2. Return ? target.[[PreventExtensions]]().
|
||||||
return Value(TRY(target.as_object().internal_prevent_extensions()));
|
return Value(TRY(target.as_object().internal_prevent_extensions()));
|
||||||
|
@ -255,7 +255,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::set)
|
||||||
|
|
||||||
// 1. If Type(target) is not Object, throw a TypeError exception.
|
// 1. If Type(target) is not Object, throw a TypeError exception.
|
||||||
if (!target.is_object())
|
if (!target.is_object())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, target.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, target.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 2. Let key be ? ToPropertyKey(propertyKey).
|
// 2. Let key be ? ToPropertyKey(propertyKey).
|
||||||
auto key = TRY(property_key.to_property_key(vm));
|
auto key = TRY(property_key.to_property_key(vm));
|
||||||
|
@ -278,7 +278,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::set_prototype_of)
|
||||||
|
|
||||||
// 1. If Type(target) is not Object, throw a TypeError exception.
|
// 1. If Type(target) is not Object, throw a TypeError exception.
|
||||||
if (!target.is_object())
|
if (!target.is_object())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, target.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, target.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 2. If Type(proto) is not Object and proto is not null, throw a TypeError exception.
|
// 2. If Type(proto) is not Object and proto is not null, throw a TypeError exception.
|
||||||
if (!proto.is_object() && !proto.is_null())
|
if (!proto.is_object() && !proto.is_null())
|
||||||
|
|
|
@ -397,7 +397,7 @@ ThrowCompletionOr<Value> regexp_exec(VM& vm, Object& regexp_object, Utf16String
|
||||||
|
|
||||||
// b. If Type(result) is neither Object nor Null, throw a TypeError exception.
|
// b. If Type(result) is neither Object nor Null, throw a TypeError exception.
|
||||||
if (!result.is_object() && !result.is_null())
|
if (!result.is_object() && !result.is_null())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObjectOrNull, result.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAnObjectOrNull, TRY_OR_THROW_OOM(vm, result.to_string_without_side_effects()));
|
||||||
|
|
||||||
// c. Return result.
|
// c. Return result.
|
||||||
return result;
|
return result;
|
||||||
|
@ -1119,7 +1119,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::compile)
|
||||||
if (pattern.is_object() && is<RegExpObject>(pattern.as_object())) {
|
if (pattern.is_object() && is<RegExpObject>(pattern.as_object())) {
|
||||||
// a. If flags is not undefined, throw a TypeError exception.
|
// a. If flags is not undefined, throw a TypeError exception.
|
||||||
if (!flags.is_undefined())
|
if (!flags.is_undefined())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotUndefined, flags.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotUndefined, TRY_OR_THROW_OOM(vm, flags.to_string_without_side_effects()));
|
||||||
|
|
||||||
auto& regexp_pattern = static_cast<RegExpObject&>(pattern.as_object());
|
auto& regexp_pattern = static_cast<RegExpObject&>(pattern.as_object());
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,7 @@ JS_DEFINE_NATIVE_FUNCTION(SetPrototype::for_each)
|
||||||
{
|
{
|
||||||
auto* set = TRY(typed_this_object(vm));
|
auto* set = TRY(typed_this_object(vm));
|
||||||
if (!vm.argument(0).is_function())
|
if (!vm.argument(0).is_function())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, vm.argument(0).to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, TRY_OR_THROW_OOM(vm, vm.argument(0).to_string_without_side_effects()));
|
||||||
auto this_value = vm.this_value();
|
auto this_value = vm.this_value();
|
||||||
for (auto& entry : *set)
|
for (auto& entry : *set)
|
||||||
TRY(call(vm, vm.argument(0).as_function(), vm.argument(1), entry.key, entry.key, this_value));
|
TRY(call(vm, vm.argument(0).as_function(), vm.argument(1), entry.key, entry.key, this_value));
|
||||||
|
@ -137,7 +137,7 @@ static ThrowCompletionOr<SetRecord> get_set_record(VM& vm, Value value)
|
||||||
{
|
{
|
||||||
// 1. If obj is not an Object, throw a TypeError exception.
|
// 1. If obj is not an Object, throw a TypeError exception.
|
||||||
if (!value.is_object())
|
if (!value.is_object())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, value.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, value.to_string_without_side_effects()));
|
||||||
auto const& object = value.as_object();
|
auto const& object = value.as_object();
|
||||||
|
|
||||||
// 2. Let rawSize be ? Get(obj, "size").
|
// 2. Let rawSize be ? Get(obj, "size").
|
||||||
|
@ -159,14 +159,14 @@ static ThrowCompletionOr<SetRecord> get_set_record(VM& vm, Value value)
|
||||||
|
|
||||||
// 8. If IsCallable(has) is false, throw a TypeError exception.
|
// 8. If IsCallable(has) is false, throw a TypeError exception.
|
||||||
if (!has.is_function())
|
if (!has.is_function())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, has.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, TRY_OR_THROW_OOM(vm, has.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 9. Let keys be ? Get(obj, "keys").
|
// 9. Let keys be ? Get(obj, "keys").
|
||||||
auto keys = TRY(object.get(vm.names.keys));
|
auto keys = TRY(object.get(vm.names.keys));
|
||||||
|
|
||||||
// 10. If IsCallable(keys) is false, throw a TypeError exception.
|
// 10. If IsCallable(keys) is false, throw a TypeError exception.
|
||||||
if (!keys.is_function())
|
if (!keys.is_function())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, keys.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, TRY_OR_THROW_OOM(vm, keys.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 11. Return a new Set Record { [[Set]]: obj, [[Size]]: intSize, [[Has]]: has, [[Keys]]: keys }.
|
// 11. Return a new Set Record { [[Set]]: obj, [[Size]]: intSize, [[Has]]: has, [[Keys]]: keys }.
|
||||||
return SetRecord { .set = object, .size = integer_size, .has = has.as_function(), .keys = keys.as_function() };
|
return SetRecord { .set = object, .size = integer_size, .has = has.as_function(), .keys = keys.as_function() };
|
||||||
|
@ -180,14 +180,14 @@ static ThrowCompletionOr<Iterator> get_keys_iterator(VM& vm, SetRecord const& se
|
||||||
|
|
||||||
// 2. If keysIter is not an Object, throw a TypeError exception.
|
// 2. If keysIter is not an Object, throw a TypeError exception.
|
||||||
if (!keys_iterator.is_object())
|
if (!keys_iterator.is_object())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, keys_iterator.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, keys_iterator.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 3. Let nextMethod be ? Get(keysIter, "next").
|
// 3. Let nextMethod be ? Get(keysIter, "next").
|
||||||
auto next_method = TRY(keys_iterator.as_object().get(vm.names.next));
|
auto next_method = TRY(keys_iterator.as_object().get(vm.names.next));
|
||||||
|
|
||||||
// 4. If IsCallable(nextMethod) is false, throw a TypeError exception.
|
// 4. If IsCallable(nextMethod) is false, throw a TypeError exception.
|
||||||
if (!next_method.is_function())
|
if (!next_method.is_function())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, next_method.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, TRY_OR_THROW_OOM(vm, next_method.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 5. Return a new Iterator Record { [[Iterator]]: keysIter, [[NextMethod]]: nextMethod, [[Done]]: false }.
|
// 5. Return a new Iterator Record { [[Iterator]]: keysIter, [[NextMethod]]: nextMethod, [[Done]]: false }.
|
||||||
return Iterator { .iterator = &keys_iterator.as_object(), .next_method = next_method, .done = false };
|
return Iterator { .iterator = &keys_iterator.as_object(), .next_method = next_method, .done = false };
|
||||||
|
|
|
@ -69,7 +69,7 @@ JS_DEFINE_NATIVE_FUNCTION(ShadowRealmPrototype::import_value)
|
||||||
|
|
||||||
// 4. If Type(exportName) is not String, throw a TypeError exception.
|
// 4. If Type(exportName) is not String, throw a TypeError exception.
|
||||||
if (!export_name.is_string())
|
if (!export_name.is_string())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAString, export_name.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAString, TRY_OR_THROW_OOM(vm, export_name.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 5. Let callerRealm be the current Realm Record.
|
// 5. Let callerRealm be the current Realm Record.
|
||||||
auto* caller_realm = vm.current_realm();
|
auto* caller_realm = vm.current_realm();
|
||||||
|
|
|
@ -120,10 +120,10 @@ JS_DEFINE_NATIVE_FUNCTION(StringConstructor::from_code_point)
|
||||||
for (size_t i = 0; i < vm.argument_count(); ++i) {
|
for (size_t i = 0; i < vm.argument_count(); ++i) {
|
||||||
auto next_code_point = TRY(vm.argument(i).to_number(vm));
|
auto next_code_point = TRY(vm.argument(i).to_number(vm));
|
||||||
if (!next_code_point.is_integral_number())
|
if (!next_code_point.is_integral_number())
|
||||||
return vm.throw_completion<RangeError>(ErrorType::InvalidCodePoint, next_code_point.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<RangeError>(ErrorType::InvalidCodePoint, TRY_OR_THROW_OOM(vm, next_code_point.to_string_without_side_effects()));
|
||||||
auto code_point = TRY(next_code_point.to_i32(vm));
|
auto code_point = TRY(next_code_point.to_i32(vm));
|
||||||
if (code_point < 0 || code_point > 0x10FFFF)
|
if (code_point < 0 || code_point > 0x10FFFF)
|
||||||
return vm.throw_completion<RangeError>(ErrorType::InvalidCodePoint, next_code_point.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<RangeError>(ErrorType::InvalidCodePoint, TRY_OR_THROW_OOM(vm, next_code_point.to_string_without_side_effects()));
|
||||||
|
|
||||||
TRY_OR_THROW_OOM(vm, code_point_to_utf16(string, static_cast<u32>(code_point)));
|
TRY_OR_THROW_OOM(vm, code_point_to_utf16(string, static_cast<u32>(code_point)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,7 @@ JS_DEFINE_NATIVE_FUNCTION(SymbolConstructor::key_for)
|
||||||
{
|
{
|
||||||
auto argument = vm.argument(0);
|
auto argument = vm.argument(0);
|
||||||
if (!argument.is_symbol())
|
if (!argument.is_symbol())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotASymbol, argument.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotASymbol, TRY_OR_THROW_OOM(vm, argument.to_string_without_side_effects()));
|
||||||
|
|
||||||
auto& symbol = argument.as_symbol();
|
auto& symbol = argument.as_symbol();
|
||||||
if (symbol.is_global()) {
|
if (symbol.is_global()) {
|
||||||
|
|
|
@ -62,7 +62,7 @@ ThrowCompletionOr<MarkedVector<Value>> iterable_to_list_of_type(VM& vm, Value it
|
||||||
// ii. If Type(nextValue) is not an element of elementTypes, then
|
// ii. If Type(nextValue) is not an element of elementTypes, then
|
||||||
if (auto type = to_option_type(next_value); !type.has_value() || !element_types.contains_slow(*type)) {
|
if (auto type = to_option_type(next_value); !type.has_value() || !element_types.contains_slow(*type)) {
|
||||||
// 1. Let completion be ThrowCompletion(a newly created TypeError object).
|
// 1. Let completion be ThrowCompletion(a newly created TypeError object).
|
||||||
auto completion = vm.throw_completion<TypeError>(ErrorType::IterableToListOfTypeInvalidValue, next_value.to_deprecated_string_without_side_effects());
|
auto completion = vm.throw_completion<TypeError>(ErrorType::IterableToListOfTypeInvalidValue, TRY_OR_THROW_OOM(vm, next_value.to_string_without_side_effects()));
|
||||||
// 2. Return ? IteratorClose(iteratorRecord, completion).
|
// 2. Return ? IteratorClose(iteratorRecord, completion).
|
||||||
return iterator_close(vm, iterator_record, move(completion));
|
return iterator_close(vm, iterator_record, move(completion));
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,7 +152,7 @@ ThrowCompletionOr<Object*> calendar_merge_fields(VM& vm, Object& calendar, Objec
|
||||||
|
|
||||||
// 4. If Type(result) is not Object, throw a TypeError exception.
|
// 4. If Type(result) is not Object, throw a TypeError exception.
|
||||||
if (!result.is_object())
|
if (!result.is_object())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, result.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, result.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 5. Return result.
|
// 5. Return result.
|
||||||
return &result.as_object();
|
return &result.as_object();
|
||||||
|
|
|
@ -94,7 +94,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::date_from_fields)
|
||||||
// 4. If Type(fields) is not Object, throw a TypeError exception.
|
// 4. If Type(fields) is not Object, throw a TypeError exception.
|
||||||
auto fields = vm.argument(0);
|
auto fields = vm.argument(0);
|
||||||
if (!fields.is_object())
|
if (!fields.is_object())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, fields.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, fields.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 5. Set options to ? GetOptionsObject(options).
|
// 5. Set options to ? GetOptionsObject(options).
|
||||||
auto const* options = TRY(get_options_object(vm, vm.argument(1)));
|
auto const* options = TRY(get_options_object(vm, vm.argument(1)));
|
||||||
|
@ -120,7 +120,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::year_month_from_fields)
|
||||||
// 4. If Type(fields) is not Object, throw a TypeError exception.
|
// 4. If Type(fields) is not Object, throw a TypeError exception.
|
||||||
auto fields = vm.argument(0);
|
auto fields = vm.argument(0);
|
||||||
if (!fields.is_object())
|
if (!fields.is_object())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, fields.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, fields.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 5. Set options to ? GetOptionsObject(options).
|
// 5. Set options to ? GetOptionsObject(options).
|
||||||
auto const* options = TRY(get_options_object(vm, vm.argument(1)));
|
auto const* options = TRY(get_options_object(vm, vm.argument(1)));
|
||||||
|
@ -146,7 +146,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::month_day_from_fields)
|
||||||
// 4. If Type(fields) is not Object, throw a TypeError exception.
|
// 4. If Type(fields) is not Object, throw a TypeError exception.
|
||||||
auto fields = vm.argument(0);
|
auto fields = vm.argument(0);
|
||||||
if (!fields.is_object())
|
if (!fields.is_object())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, fields.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, fields.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 5. Set options to ? GetOptionsObject(options).
|
// 5. Set options to ? GetOptionsObject(options).
|
||||||
auto const* options = TRY(get_options_object(vm, vm.argument(1)));
|
auto const* options = TRY(get_options_object(vm, vm.argument(1)));
|
||||||
|
@ -555,7 +555,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::fields)
|
||||||
// ii. If Type(nextValue) is not String, then
|
// ii. If Type(nextValue) is not String, then
|
||||||
if (!next_value.is_string()) {
|
if (!next_value.is_string()) {
|
||||||
// 1. Let completion be ThrowCompletion(a newly created TypeError object).
|
// 1. Let completion be ThrowCompletion(a newly created TypeError object).
|
||||||
auto completion = vm.throw_completion<TypeError>(ErrorType::TemporalInvalidCalendarFieldValue, next_value.to_deprecated_string_without_side_effects());
|
auto completion = vm.throw_completion<TypeError>(ErrorType::TemporalInvalidCalendarFieldValue, TRY_OR_THROW_OOM(vm, next_value.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 2. Return ? IteratorClose(iteratorRecord, completion).
|
// 2. Return ? IteratorClose(iteratorRecord, completion).
|
||||||
return TRY(iterator_close(vm, iterator_record, move(completion)));
|
return TRY(iterator_close(vm, iterator_record, move(completion)));
|
||||||
|
|
|
@ -305,7 +305,7 @@ ThrowCompletionOr<PartialDurationRecord> to_temporal_partial_duration_record(VM&
|
||||||
// 1. If Type(temporalDurationLike) is not Object, then
|
// 1. If Type(temporalDurationLike) is not Object, then
|
||||||
if (!temporal_duration_like.is_object()) {
|
if (!temporal_duration_like.is_object()) {
|
||||||
// a. Throw a TypeError exception.
|
// a. Throw a TypeError exception.
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, temporal_duration_like.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, temporal_duration_like.to_string_without_side_effects()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Let result be a new partial Duration Record with each field set to undefined.
|
// 2. Let result be a new partial Duration Record with each field set to undefined.
|
||||||
|
|
|
@ -410,7 +410,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::with)
|
||||||
// 3. If Type(temporalDateLike) is not Object, then
|
// 3. If Type(temporalDateLike) is not Object, then
|
||||||
if (!temporal_date_like.is_object()) {
|
if (!temporal_date_like.is_object()) {
|
||||||
// a. Throw a TypeError exception.
|
// a. Throw a TypeError exception.
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, temporal_date_like.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, temporal_date_like.to_string_without_side_effects()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. Perform ? RejectObjectWithCalendarOrTimeZone(temporalDateLike).
|
// 4. Perform ? RejectObjectWithCalendarOrTimeZone(temporalDateLike).
|
||||||
|
|
|
@ -382,7 +382,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::with)
|
||||||
// 3. If Type(temporalDateTimeLike) is not Object, then
|
// 3. If Type(temporalDateTimeLike) is not Object, then
|
||||||
if (!temporal_date_time_like.is_object()) {
|
if (!temporal_date_time_like.is_object()) {
|
||||||
// a. Throw a TypeError exception.
|
// a. Throw a TypeError exception.
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, temporal_date_time_like.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, temporal_date_time_like.to_string_without_side_effects()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. Perform ? RejectObjectWithCalendarOrTimeZone(temporalDateTimeLike).
|
// 4. Perform ? RejectObjectWithCalendarOrTimeZone(temporalDateTimeLike).
|
||||||
|
|
|
@ -97,7 +97,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::with)
|
||||||
// 3. If Type(temporalMonthDayLike) is not Object, then
|
// 3. If Type(temporalMonthDayLike) is not Object, then
|
||||||
if (!temporal_month_day_like.is_object()) {
|
if (!temporal_month_day_like.is_object()) {
|
||||||
// a. Throw a TypeError exception.
|
// a. Throw a TypeError exception.
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, temporal_month_day_like.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, temporal_month_day_like.to_string_without_side_effects()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. Perform ? RejectObjectWithCalendarOrTimeZone(temporalMonthDayLike).
|
// 4. Perform ? RejectObjectWithCalendarOrTimeZone(temporalMonthDayLike).
|
||||||
|
|
|
@ -176,7 +176,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::with)
|
||||||
// 3. If Type(temporalTimeLike) is not Object, then
|
// 3. If Type(temporalTimeLike) is not Object, then
|
||||||
if (!temporal_time_like_argument.is_object()) {
|
if (!temporal_time_like_argument.is_object()) {
|
||||||
// a. Throw a TypeError exception.
|
// a. Throw a TypeError exception.
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, temporal_time_like_argument.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, temporal_time_like_argument.to_string_without_side_effects()));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto& temporal_time_like = temporal_time_like_argument.as_object();
|
auto& temporal_time_like = temporal_time_like_argument.as_object();
|
||||||
|
|
|
@ -208,7 +208,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::with)
|
||||||
// 3. If Type(temporalYearMonthLike) is not Object, then
|
// 3. If Type(temporalYearMonthLike) is not Object, then
|
||||||
if (!temporal_year_month_like.is_object()) {
|
if (!temporal_year_month_like.is_object()) {
|
||||||
// a. Throw a TypeError exception.
|
// a. Throw a TypeError exception.
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, temporal_year_month_like.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, temporal_year_month_like.to_string_without_side_effects()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. Perform ? RejectObjectWithCalendarOrTimeZone(temporalYearMonthLike).
|
// 4. Perform ? RejectObjectWithCalendarOrTimeZone(temporalYearMonthLike).
|
||||||
|
|
|
@ -756,7 +756,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::with)
|
||||||
// 3. If Type(temporalZonedDateTimeLike) is not Object, then
|
// 3. If Type(temporalZonedDateTimeLike) is not Object, then
|
||||||
if (!temporal_zoned_date_time_like.is_object()) {
|
if (!temporal_zoned_date_time_like.is_object()) {
|
||||||
// a. Throw a TypeError exception.
|
// a. Throw a TypeError exception.
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, temporal_zoned_date_time_like.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, temporal_zoned_date_time_like.to_string_without_side_effects()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. Perform ? RejectObjectWithCalendarOrTimeZone(temporalZonedDateTimeLike).
|
// 4. Perform ? RejectObjectWithCalendarOrTimeZone(temporalZonedDateTimeLike).
|
||||||
|
|
|
@ -57,13 +57,13 @@ JS_DEFINE_NATIVE_FUNCTION(TypedArrayConstructor::from)
|
||||||
{
|
{
|
||||||
auto constructor = vm.this_value();
|
auto constructor = vm.this_value();
|
||||||
if (!constructor.is_constructor())
|
if (!constructor.is_constructor())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAConstructor, constructor.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAConstructor, TRY_OR_THROW_OOM(vm, constructor.to_string_without_side_effects()));
|
||||||
|
|
||||||
FunctionObject* map_fn = nullptr;
|
FunctionObject* map_fn = nullptr;
|
||||||
if (!vm.argument(1).is_undefined()) {
|
if (!vm.argument(1).is_undefined()) {
|
||||||
auto callback = vm.argument(1);
|
auto callback = vm.argument(1);
|
||||||
if (!callback.is_function())
|
if (!callback.is_function())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, callback.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, TRY_OR_THROW_OOM(vm, callback.to_string_without_side_effects()));
|
||||||
map_fn = &callback.as_function();
|
map_fn = &callback.as_function();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ JS_DEFINE_NATIVE_FUNCTION(TypedArrayConstructor::of)
|
||||||
auto length = vm.argument_count();
|
auto length = vm.argument_count();
|
||||||
auto constructor = vm.this_value();
|
auto constructor = vm.this_value();
|
||||||
if (!constructor.is_constructor())
|
if (!constructor.is_constructor())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAConstructor, constructor.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAConstructor, TRY_OR_THROW_OOM(vm, constructor.to_string_without_side_effects()));
|
||||||
MarkedVector<Value> arguments(vm.heap());
|
MarkedVector<Value> arguments(vm.heap());
|
||||||
arguments.append(Value(length));
|
arguments.append(Value(length));
|
||||||
auto new_object = TRY(typed_array_create(vm, constructor.as_function(), move(arguments)));
|
auto new_object = TRY(typed_array_create(vm, constructor.as_function(), move(arguments)));
|
||||||
|
|
|
@ -95,7 +95,7 @@ static ThrowCompletionOr<FunctionObject*> callback_from_args(VM& vm, DeprecatedS
|
||||||
return vm.throw_completion<TypeError>(ErrorType::TypedArrayPrototypeOneArg, name);
|
return vm.throw_completion<TypeError>(ErrorType::TypedArrayPrototypeOneArg, name);
|
||||||
auto callback = vm.argument(0);
|
auto callback = vm.argument(0);
|
||||||
if (!callback.is_function())
|
if (!callback.is_function())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, callback.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, TRY_OR_THROW_OOM(vm, callback.to_string_without_side_effects()));
|
||||||
return &callback.as_function();
|
return &callback.as_function();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1410,7 +1410,7 @@ JS_DEFINE_NATIVE_FUNCTION(TypedArrayPrototype::sort)
|
||||||
// 1. If comparefn is not undefined and IsCallable(comparefn) is false, throw a TypeError exception.
|
// 1. If comparefn is not undefined and IsCallable(comparefn) is false, throw a TypeError exception.
|
||||||
auto compare_fn = vm.argument(0);
|
auto compare_fn = vm.argument(0);
|
||||||
if (!compare_fn.is_undefined() && !compare_fn.is_function())
|
if (!compare_fn.is_undefined() && !compare_fn.is_function())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, compare_fn.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, TRY_OR_THROW_OOM(vm, compare_fn.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 2. Let obj be the this value.
|
// 2. Let obj be the this value.
|
||||||
// 3. Perform ? ValidateTypedArray(obj).
|
// 3. Perform ? ValidateTypedArray(obj).
|
||||||
|
|
|
@ -541,7 +541,7 @@ ThrowCompletionOr<Value> Value::to_primitive(VM& vm, PreferredType preferred_typ
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
// vi. Throw a TypeError exception.
|
// vi. Throw a TypeError exception.
|
||||||
return vm.throw_completion<TypeError>(ErrorType::ToPrimitiveReturnedObject, to_deprecated_string_without_side_effects(), hint);
|
return vm.throw_completion<TypeError>(ErrorType::ToPrimitiveReturnedObject, TRY_OR_THROW_OOM(vm, to_string_without_side_effects()), hint);
|
||||||
}
|
}
|
||||||
|
|
||||||
// c. If preferredType is not present, let preferredType be number.
|
// c. If preferredType is not present, let preferredType be number.
|
||||||
|
@ -1241,7 +1241,7 @@ ThrowCompletionOr<FunctionObject*> Value::get_method(VM& vm, PropertyKey const&
|
||||||
|
|
||||||
// 4. If IsCallable(func) is false, throw a TypeError exception.
|
// 4. If IsCallable(func) is false, throw a TypeError exception.
|
||||||
if (!function.is_function())
|
if (!function.is_function())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, function.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, TRY_OR_THROW_OOM(vm, function.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 5. Return func.
|
// 5. Return func.
|
||||||
return &function.as_function();
|
return &function.as_function();
|
||||||
|
@ -2058,7 +2058,7 @@ ThrowCompletionOr<Value> instance_of(VM& vm, Value value, Value target)
|
||||||
{
|
{
|
||||||
// 1. If target is not an Object, throw a TypeError exception.
|
// 1. If target is not an Object, throw a TypeError exception.
|
||||||
if (!target.is_object())
|
if (!target.is_object())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, target.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, target.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 2. Let instOfHandler be ? GetMethod(target, @@hasInstance).
|
// 2. Let instOfHandler be ? GetMethod(target, @@hasInstance).
|
||||||
auto* instance_of_handler = TRY(target.get_method(vm, *vm.well_known_symbol_has_instance()));
|
auto* instance_of_handler = TRY(target.get_method(vm, *vm.well_known_symbol_has_instance()));
|
||||||
|
@ -2071,7 +2071,7 @@ ThrowCompletionOr<Value> instance_of(VM& vm, Value value, Value target)
|
||||||
|
|
||||||
// 4. If IsCallable(target) is false, throw a TypeError exception.
|
// 4. If IsCallable(target) is false, throw a TypeError exception.
|
||||||
if (!target.is_function())
|
if (!target.is_function())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, target.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, TRY_OR_THROW_OOM(vm, target.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 5. Return ? OrdinaryHasInstance(target, V).
|
// 5. Return ? OrdinaryHasInstance(target, V).
|
||||||
return ordinary_has_instance(vm, target, value);
|
return ordinary_has_instance(vm, target, value);
|
||||||
|
@ -2106,7 +2106,7 @@ ThrowCompletionOr<Value> ordinary_has_instance(VM& vm, Value lhs, Value rhs)
|
||||||
|
|
||||||
// 5. If P is not an Object, throw a TypeError exception.
|
// 5. If P is not an Object, throw a TypeError exception.
|
||||||
if (!rhs_prototype.is_object())
|
if (!rhs_prototype.is_object())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::InstanceOfOperatorBadPrototype, rhs.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::InstanceOfOperatorBadPrototype, TRY_OR_THROW_OOM(vm, rhs.to_string_without_side_effects()));
|
||||||
|
|
||||||
// 6. Repeat,
|
// 6. Repeat,
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
|
@ -54,7 +54,7 @@ ThrowCompletionOr<NonnullGCPtr<Object>> WeakMapConstructor::construct(FunctionOb
|
||||||
|
|
||||||
(void)TRY(get_iterator_values(vm, vm.argument(0), [&](Value iterator_value) -> Optional<Completion> {
|
(void)TRY(get_iterator_values(vm, vm.argument(0), [&](Value iterator_value) -> Optional<Completion> {
|
||||||
if (!iterator_value.is_object())
|
if (!iterator_value.is_object())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, DeprecatedString::formatted("Iterator value {}", iterator_value.to_deprecated_string_without_side_effects()));
|
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, DeprecatedString::formatted("Iterator value {}", TRY_OR_THROW_OOM(vm, iterator_value.to_string_without_side_effects())));
|
||||||
|
|
||||||
auto key = TRY(iterator_value.as_object().get(0));
|
auto key = TRY(iterator_value.as_object().get(0));
|
||||||
auto value = TRY(iterator_value.as_object().get(1));
|
auto value = TRY(iterator_value.as_object().get(1));
|
||||||
|
|
|
@ -74,7 +74,7 @@ JS_DEFINE_NATIVE_FUNCTION(WeakMapPrototype::set)
|
||||||
auto* weak_map = TRY(typed_this_object(vm));
|
auto* weak_map = TRY(typed_this_object(vm));
|
||||||
auto value = vm.argument(0);
|
auto value = vm.argument(0);
|
||||||
if (!can_be_held_weakly(value))
|
if (!can_be_held_weakly(value))
|
||||||
return vm.throw_completion<TypeError>(ErrorType::CannotBeHeldWeakly, value.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::CannotBeHeldWeakly, TRY_OR_THROW_OOM(vm, value.to_string_without_side_effects()));
|
||||||
weak_map->values().set(&value.as_cell(), vm.argument(1));
|
weak_map->values().set(&value.as_cell(), vm.argument(1));
|
||||||
return weak_map;
|
return weak_map;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ ThrowCompletionOr<NonnullGCPtr<Object>> WeakRefConstructor::construct(FunctionOb
|
||||||
|
|
||||||
auto target = vm.argument(0);
|
auto target = vm.argument(0);
|
||||||
if (!can_be_held_weakly(target))
|
if (!can_be_held_weakly(target))
|
||||||
return vm.throw_completion<TypeError>(ErrorType::CannotBeHeldWeakly, target.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::CannotBeHeldWeakly, TRY_OR_THROW_OOM(vm, target.to_string_without_side_effects()));
|
||||||
|
|
||||||
if (target.is_object())
|
if (target.is_object())
|
||||||
return TRY(ordinary_create_from_constructor<WeakRef>(vm, new_target, &Intrinsics::weak_ref_prototype, target.as_object()));
|
return TRY(ordinary_create_from_constructor<WeakRef>(vm, new_target, &Intrinsics::weak_ref_prototype, target.as_object()));
|
||||||
|
|
|
@ -38,7 +38,7 @@ JS_DEFINE_NATIVE_FUNCTION(WeakSetPrototype::add)
|
||||||
auto* weak_set = TRY(typed_this_object(vm));
|
auto* weak_set = TRY(typed_this_object(vm));
|
||||||
auto value = vm.argument(0);
|
auto value = vm.argument(0);
|
||||||
if (!can_be_held_weakly(value))
|
if (!can_be_held_weakly(value))
|
||||||
return vm.throw_completion<TypeError>(ErrorType::CannotBeHeldWeakly, value.to_deprecated_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::CannotBeHeldWeakly, TRY_OR_THROW_OOM(vm, value.to_string_without_side_effects()));
|
||||||
weak_set->values().set(&value.as_cell(), AK::HashSetExistingEntryBehavior::Keep);
|
weak_set->values().set(&value.as_cell(), AK::HashSetExistingEntryBehavior::Keep);
|
||||||
return weak_set;
|
return weak_set;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue