1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 03:47:34 +00:00

LibJS+LibWeb: Convert empty PrimitiveString invocators to String

This commit is contained in:
Timothy Flynn 2023-01-21 10:42:46 -05:00 committed by Linus Groh
parent 1bcde5d216
commit 34574c5ee8
9 changed files with 13 additions and 13 deletions

View file

@ -26,7 +26,7 @@ void CollatorCompareFunction::initialize(Realm&)
{
auto& vm = this->vm();
define_direct_property(vm.names.length, Value(2), Attribute::Configurable);
define_direct_property(vm.names.name, PrimitiveString::create(vm, DeprecatedString::empty()), Attribute::Configurable);
define_direct_property(vm.names.name, PrimitiveString::create(vm, String {}), Attribute::Configurable);
}
// 10.3.3.2 CompareStrings ( collator, x, y ), https://tc39.es/ecma402/#sec-collator-comparestrings

View file

@ -31,7 +31,7 @@ void DateTimeFormatFunction::initialize(Realm& realm)
Base::initialize(realm);
define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
define_direct_property(vm.names.name, PrimitiveString::create(vm, DeprecatedString::empty()), Attribute::Configurable);
define_direct_property(vm.names.name, PrimitiveString::create(vm, String {}), Attribute::Configurable);
}
ThrowCompletionOr<Value> DateTimeFormatFunction::call()

View file

@ -29,7 +29,7 @@ void NumberFormatFunction::initialize(Realm& realm)
Base::initialize(realm);
define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
define_direct_property(vm.names.name, PrimitiveString::create(vm, DeprecatedString::empty()), Attribute::Configurable);
define_direct_property(vm.names.name, PrimitiveString::create(vm, String {}), Attribute::Configurable);
}
ThrowCompletionOr<Value> NumberFormatFunction::call()

View file

@ -157,7 +157,7 @@ Promise::ResolvingFunctions Promise::create_resolving_functions()
// 16. Return undefined.
return js_undefined();
});
resolve_function->define_direct_property(vm.names.name, PrimitiveString::create(vm, DeprecatedString::empty()), Attribute::Configurable);
resolve_function->define_direct_property(vm.names.name, PrimitiveString::create(vm, String {}), Attribute::Configurable);
// 7. Let stepsReject be the algorithm steps defined in Promise Reject Functions.
// 8. Let lengthReject be the number of non-optional parameters of the function definition in Promise Reject Functions.
@ -189,7 +189,7 @@ Promise::ResolvingFunctions Promise::create_resolving_functions()
// 8. Return undefined.
return js_undefined();
});
reject_function->define_direct_property(vm.names.name, PrimitiveString::create(vm, DeprecatedString::empty()), Attribute::Configurable);
reject_function->define_direct_property(vm.names.name, PrimitiveString::create(vm, String {}), Attribute::Configurable);
// 12. Return the Record { [[Resolve]]: resolve, [[Reject]]: reject }.
return { *resolve_function, *reject_function };

View file

@ -139,7 +139,7 @@ static ThrowCompletionOr<Value> perform_promise_all(VM& vm, Iterator& iterator_r
// p. Set onFulfilled.[[Capability]] to resultCapability.
// q. Set onFulfilled.[[RemainingElements]] to remainingElementsCount.
auto on_fulfilled = PromiseAllResolveElementFunction::create(realm, index, values, result_capability, remaining_elements_count);
on_fulfilled->define_direct_property(vm.names.name, PrimitiveString::create(vm, DeprecatedString::empty()), Attribute::Configurable);
on_fulfilled->define_direct_property(vm.names.name, PrimitiveString::create(vm, String {}), Attribute::Configurable);
// s. Perform ? Invoke(nextPromise, "then", « onFulfilled, resultCapability.[[Reject]] »).
return next_promise.invoke(vm, vm.names.then, on_fulfilled, result_capability.reject());
@ -171,7 +171,7 @@ static ThrowCompletionOr<Value> perform_promise_all_settled(VM& vm, Iterator& it
// q. Set onFulfilled.[[Capability]] to resultCapability.
// r. Set onFulfilled.[[RemainingElements]] to remainingElementsCount.
auto on_fulfilled = PromiseAllSettledResolveElementFunction::create(realm, index, values, result_capability, remaining_elements_count);
on_fulfilled->define_direct_property(vm.names.name, PrimitiveString::create(vm, DeprecatedString::empty()), Attribute::Configurable);
on_fulfilled->define_direct_property(vm.names.name, PrimitiveString::create(vm, String {}), Attribute::Configurable);
// s. Let stepsRejected be the algorithm steps defined in Promise.allSettled Reject Element Functions.
// t. Let lengthRejected be the number of non-optional parameters of the function definition in Promise.allSettled Reject Element Functions.
@ -182,7 +182,7 @@ static ThrowCompletionOr<Value> perform_promise_all_settled(VM& vm, Iterator& it
// y. Set onRejected.[[Capability]] to resultCapability.
// z. Set onRejected.[[RemainingElements]] to remainingElementsCount.
auto on_rejected = PromiseAllSettledRejectElementFunction::create(realm, index, values, result_capability, remaining_elements_count);
on_rejected->define_direct_property(vm.names.name, PrimitiveString::create(vm, DeprecatedString::empty()), Attribute::Configurable);
on_rejected->define_direct_property(vm.names.name, PrimitiveString::create(vm, String {}), Attribute::Configurable);
// ab. Perform ? Invoke(nextPromise, "then", « onFulfilled, onRejected »).
return next_promise.invoke(vm, vm.names.then, on_fulfilled, on_rejected);
@ -217,7 +217,7 @@ static ThrowCompletionOr<Value> perform_promise_any(VM& vm, Iterator& iterator_r
// p. Set onRejected.[[Capability]] to resultCapability.
// q. Set onRejected.[[RemainingElements]] to remainingElementsCount.
auto on_rejected = PromiseAnyRejectElementFunction::create(realm, index, errors, result_capability, remaining_elements_count);
on_rejected->define_direct_property(vm.names.name, PrimitiveString::create(vm, DeprecatedString::empty()), Attribute::Configurable);
on_rejected->define_direct_property(vm.names.name, PrimitiveString::create(vm, String {}), Attribute::Configurable);
// s. Perform ? Invoke(nextPromise, "then", « resultCapability.[[Resolve]], onRejected »).
return next_promise.invoke(vm, vm.names.then, result_capability.resolve(), on_rejected);

View file

@ -83,7 +83,7 @@ ThrowCompletionOr<void> copy_name_and_length(VM& vm, FunctionObject& function, F
// 7. If Type(targetName) is not String, set targetName to the empty String.
if (!target_name.is_string())
target_name = PrimitiveString::create(vm, DeprecatedString::empty());
target_name = PrimitiveString::create(vm, String {});
// 8. Perform SetFunctionName(F, targetName, prefix).
function.set_function_name({ TRY(target_name.as_string().deprecated_string()) }, move(prefix));

View file

@ -41,7 +41,7 @@ VM::VM(OwnPtr<CustomData> custom_data)
: m_heap(*this)
, m_custom_data(move(custom_data))
{
m_empty_string = m_heap.allocate_without_realm<PrimitiveString>(DeprecatedString::empty());
m_empty_string = m_heap.allocate_without_realm<PrimitiveString>(String {});
for (size_t i = 0; i < 128; ++i) {
m_single_ascii_character_strings[i] = m_heap.allocate_without_realm<PrimitiveString>(DeprecatedString::formatted("{:c}", i));
}