summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2023-02-09 07:50:12 -0500
committerLinus Groh <mail@linusgroh.de>2023-02-09 17:13:33 +0000
commit49e8dcf0b22bf190e9a38f7b6356bfbd22e9caf2 (patch)
treea8622f207b62985ffabc1047747a767d16d4029f /Userland/Libraries/LibJS
parente99a4ba7c88c7b9742e7333263eae52052d9772e (diff)
downloadserenity-49e8dcf0b22bf190e9a38f7b6356bfbd22e9caf2.zip
LibJS+LibWeb: Convert empty PrimitiveString instances to String
Diffstat (limited to 'Userland/Libraries/LibJS')
-rw-r--r--Userland/Libraries/LibJS/Console.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/AggregateErrorPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/ErrorPrototype.cpp32
-rw-r--r--Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intrinsics.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/StringConstructor.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/SuppressedErrorPrototype.cpp2
8 files changed, 25 insertions, 25 deletions
diff --git a/Userland/Libraries/LibJS/Console.cpp b/Userland/Libraries/LibJS/Console.cpp
index 16e6b03ca0..f5d2a46802 100644
--- a/Userland/Libraries/LibJS/Console.cpp
+++ b/Userland/Libraries/LibJS/Console.cpp
@@ -622,7 +622,7 @@ ThrowCompletionOr<MarkedVector<Value>> ConsoleClient::formatter(MarkedVector<Val
else if (specifier == "%c"sv) {
// NOTE: This has no spec yet. `%c` specifiers treat the argument as CSS styling for the log message.
add_css_style_to_current_message(TRY(current.to_deprecated_string(vm)));
- converted = PrimitiveString::create(vm, "");
+ converted = PrimitiveString::create(vm, String {});
}
// 7. If any of the previous steps set converted, replace specifier in target with converted.
diff --git a/Userland/Libraries/LibJS/Runtime/AggregateErrorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/AggregateErrorPrototype.cpp
index ba659a139d..cbea946f9e 100644
--- a/Userland/Libraries/LibJS/Runtime/AggregateErrorPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/AggregateErrorPrototype.cpp
@@ -21,7 +21,7 @@ ThrowCompletionOr<void> AggregateErrorPrototype::initialize(Realm& realm)
MUST_OR_THROW_OOM(Base::initialize(realm));
u8 attr = Attribute::Writable | Attribute::Configurable;
define_direct_property(vm.names.name, PrimitiveString::create(vm, "AggregateError"), attr);
- define_direct_property(vm.names.message, PrimitiveString::create(vm, ""), attr);
+ define_direct_property(vm.names.message, PrimitiveString::create(vm, String {}), attr);
return {};
}
diff --git a/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp
index 5fddd36339..f3ae154081 100644
--- a/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp
@@ -993,7 +993,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::join)
// FWIW: engine262, a "100% spec compliant" ECMA-262 impl, aborts with "too much recursion".
// Same applies to Array.prototype.toLocaleString().
if (s_array_join_seen_objects.contains(this_object))
- return PrimitiveString::create(vm, "");
+ return PrimitiveString::create(vm, String {});
s_array_join_seen_objects.set(this_object);
ArmedScopeGuard unsee_object_guard = [&] {
s_array_join_seen_objects.remove(this_object);
@@ -1704,7 +1704,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::to_locale_string)
auto* this_object = TRY(vm.this_value().to_object(vm));
if (s_array_join_seen_objects.contains(this_object))
- return PrimitiveString::create(vm, "");
+ return PrimitiveString::create(vm, String {});
s_array_join_seen_objects.set(this_object);
ArmedScopeGuard unsee_object_guard = [&] {
s_array_join_seen_objects.remove(this_object);
diff --git a/Userland/Libraries/LibJS/Runtime/ErrorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ErrorPrototype.cpp
index 203da27ccf..13d8690016 100644
--- a/Userland/Libraries/LibJS/Runtime/ErrorPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ErrorPrototype.cpp
@@ -25,7 +25,7 @@ ThrowCompletionOr<void> ErrorPrototype::initialize(Realm& realm)
MUST_OR_THROW_OOM(Base::initialize(realm));
u8 attr = Attribute::Writable | Attribute::Configurable;
define_direct_property(vm.names.name, PrimitiveString::create(vm, "Error"), attr);
- define_direct_property(vm.names.message, PrimitiveString::create(vm, ""), attr);
+ define_direct_property(vm.names.message, PrimitiveString::create(vm, String {}), attr);
define_native_function(realm, vm.names.toString, to_string, 0, attr);
// Non standard property "stack"
// Every other engine seems to have this in some way or another, and the spec
@@ -124,21 +124,21 @@ JS_DEFINE_NATIVE_FUNCTION(ErrorPrototype::stack_setter)
return TRY(this_object.create_data_property_or_throw(vm.names.stack, vm.argument(0)));
}
-#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
- PrototypeName::PrototypeName(Realm& realm) \
- : PrototypeObject(*realm.intrinsics().error_prototype()) \
- { \
- } \
- \
- ThrowCompletionOr<void> PrototypeName::initialize(Realm& realm) \
- { \
- auto& vm = this->vm(); \
- MUST_OR_THROW_OOM(Base::initialize(realm)); \
- u8 attr = Attribute::Writable | Attribute::Configurable; \
- define_direct_property(vm.names.name, PrimitiveString::create(vm, #ClassName), attr); \
- define_direct_property(vm.names.message, PrimitiveString::create(vm, ""), attr); \
- \
- return {}; \
+#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
+ PrototypeName::PrototypeName(Realm& realm) \
+ : PrototypeObject(*realm.intrinsics().error_prototype()) \
+ { \
+ } \
+ \
+ ThrowCompletionOr<void> PrototypeName::initialize(Realm& realm) \
+ { \
+ auto& vm = this->vm(); \
+ MUST_OR_THROW_OOM(Base::initialize(realm)); \
+ u8 attr = Attribute::Writable | Attribute::Configurable; \
+ define_direct_property(vm.names.name, PrimitiveString::create(vm, #ClassName), attr); \
+ define_direct_property(vm.names.message, PrimitiveString::create(vm, String {}), attr); \
+ \
+ return {}; \
}
JS_ENUMERATE_NATIVE_ERRORS
diff --git a/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp b/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp
index 79b68489a2..c9fcdd6f4a 100644
--- a/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp
@@ -36,7 +36,7 @@ ThrowCompletionOr<void> FunctionPrototype::initialize(Realm& realm)
define_native_function(realm, vm.names.toString, to_string, 0, attr);
define_native_function(realm, *vm.well_known_symbol_has_instance(), symbol_has_instance, 1, 0);
define_direct_property(vm.names.length, Value(0), Attribute::Configurable);
- define_direct_property(vm.names.name, PrimitiveString::create(vm, ""), Attribute::Configurable);
+ define_direct_property(vm.names.name, PrimitiveString::create(vm, String {}), Attribute::Configurable);
return {};
}
diff --git a/Userland/Libraries/LibJS/Runtime/Intrinsics.cpp b/Userland/Libraries/LibJS/Runtime/Intrinsics.cpp
index 8e3c456749..aa88e07431 100644
--- a/Userland/Libraries/LibJS/Runtime/Intrinsics.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intrinsics.cpp
@@ -232,7 +232,7 @@ void Intrinsics::initialize_intrinsics(Realm& realm)
},
0, "", &realm);
m_throw_type_error_function->define_direct_property(vm.names.length, Value(0), 0);
- m_throw_type_error_function->define_direct_property(vm.names.name, PrimitiveString::create(vm, ""), 0);
+ m_throw_type_error_function->define_direct_property(vm.names.name, PrimitiveString::create(vm, String {}), 0);
MUST(m_throw_type_error_function->internal_prevent_extensions());
initialize_constructor(vm, vm.names.Error, *m_error_constructor, m_error_prototype);
diff --git a/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp b/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp
index 5391e1c552..87bc647a9a 100644
--- a/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp
@@ -59,7 +59,7 @@ ThrowCompletionOr<NonnullGCPtr<Object>> StringConstructor::construct(FunctionObj
PrimitiveString* primitive_string;
if (!vm.argument_count())
- primitive_string = PrimitiveString::create(vm, "");
+ primitive_string = PrimitiveString::create(vm, String {});
else
primitive_string = TRY(vm.argument(0).to_primitive_string(vm));
auto* prototype = TRY(get_prototype_from_constructor(vm, new_target, &Intrinsics::string_prototype));
@@ -75,7 +75,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringConstructor::raw)
auto literal_segments = TRY(length_of_array_like(vm, *raw));
if (literal_segments == 0)
- return PrimitiveString::create(vm, "");
+ return PrimitiveString::create(vm, String {});
auto const number_of_substituions = vm.argument_count() - 1;
diff --git a/Userland/Libraries/LibJS/Runtime/SuppressedErrorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/SuppressedErrorPrototype.cpp
index c0b3cc6234..1d660d29f2 100644
--- a/Userland/Libraries/LibJS/Runtime/SuppressedErrorPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/SuppressedErrorPrototype.cpp
@@ -21,7 +21,7 @@ ThrowCompletionOr<void> SuppressedErrorPrototype::initialize(Realm& realm)
MUST_OR_THROW_OOM(Base::initialize(realm));
u8 attr = Attribute::Writable | Attribute::Configurable;
define_direct_property(vm.names.name, PrimitiveString::create(vm, "SuppressedError"), attr);
- define_direct_property(vm.names.message, PrimitiveString::create(vm, ""), attr);
+ define_direct_property(vm.names.message, PrimitiveString::create(vm, String {}), attr);
return {};
}