浏览代码

LibJS+LibWeb: Convert empty PrimitiveString invocators to String

Timothy Flynn 2 年之前
父节点
当前提交
34574c5ee8

+ 1 - 1
Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.cpp

@@ -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

+ 1 - 1
Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatFunction.cpp

@@ -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()

+ 1 - 1
Userland/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.cpp

@@ -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()

+ 2 - 2
Userland/Libraries/LibJS/Runtime/Promise.cpp

@@ -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 };

+ 4 - 4
Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp

@@ -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);

+ 1 - 1
Userland/Libraries/LibJS/Runtime/ShadowRealm.cpp

@@ -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));

+ 1 - 1
Userland/Libraries/LibJS/Runtime/VM.cpp

@@ -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));
     }

+ 1 - 1
Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp

@@ -341,7 +341,7 @@ JS::ThrowCompletionOr<JS::Value> CSSStyleDeclaration::internal_get(JS::PropertyK
         return Base::internal_get(name, receiver);
     if (auto maybe_property = property(property_id); maybe_property.has_value())
         return { JS::PrimitiveString::create(vm(), maybe_property->value->to_string().release_value_but_fixme_should_propagate_errors().to_deprecated_string()) };
-    return { JS::PrimitiveString::create(vm(), DeprecatedString::empty()) };
+    return { JS::PrimitiveString::create(vm(), String {}) };
 }
 
 JS::ThrowCompletionOr<bool> CSSStyleDeclaration::internal_set(JS::PropertyKey const& name, JS::Value value, JS::Value receiver)

+ 1 - 1
Userland/Libraries/LibWeb/Fetch/Body.cpp

@@ -153,7 +153,7 @@ JS::NonnullGCPtr<JS::Promise> consume_body(JS::Realm& realm, BodyMixin const& ob
     }
 
     // 2. Let promise be a promise resolved with an empty byte sequence.
-    auto promise = WebIDL::create_resolved_promise(realm, JS::PrimitiveString::create(vm, DeprecatedString::empty()));
+    auto promise = WebIDL::create_resolved_promise(realm, JS::PrimitiveString::create(vm, String {}));
 
     // 3. If object’s body is non-null, then set promise to the result of fully reading body as promise given object’s body.
     auto const& body = object.body_impl();