From 525f22d018cb5f9c4c6ea0e2b5544fdcab8da483 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Tue, 6 Dec 2022 22:17:27 +0000 Subject: [PATCH] LibJS: Replace standalone js_string() with PrimitiveString::create() Note that js_rope_string() has been folded into this, the old name was misleading - it would not always create a rope string, only if both sides are not empty strings. Use a three-argument create() overload instead. --- .../BindingsGenerator/IDLGenerators.cpp | 10 +- .../GenerateWindowOrWorkerInterfaces.cpp | 2 +- Userland/Applications/Spreadsheet/Cell.cpp | 3 +- .../Spreadsheet/CellType/String.cpp | 3 +- .../Spreadsheet/JSIntegration.cpp | 12 +- .../Applications/Spreadsheet/Spreadsheet.cpp | 2 +- Userland/Libraries/LibJS/AST.cpp | 7 +- Userland/Libraries/LibJS/Bytecode/Op.cpp | 12 +- Userland/Libraries/LibJS/Console.cpp | 22 +-- Userland/Libraries/LibJS/Print.cpp | 158 +++++++++--------- .../Runtime/AggregateErrorConstructor.cpp | 2 +- .../LibJS/Runtime/AggregateErrorPrototype.cpp | 4 +- Userland/Libraries/LibJS/Runtime/Array.cpp | 6 +- .../LibJS/Runtime/ArrayBufferPrototype.cpp | 2 +- .../LibJS/Runtime/ArrayIteratorPrototype.cpp | 2 +- .../LibJS/Runtime/ArrayPrototype.cpp | 8 +- .../LibJS/Runtime/AsyncFunctionPrototype.cpp | 2 +- .../AsyncGeneratorFunctionPrototype.cpp | 2 +- .../LibJS/Runtime/AsyncGeneratorPrototype.cpp | 2 +- .../Libraries/LibJS/Runtime/AtomicsObject.cpp | 2 +- .../LibJS/Runtime/BigIntPrototype.cpp | 6 +- .../LibJS/Runtime/BooleanPrototype.cpp | 4 +- .../LibJS/Runtime/DataViewPrototype.cpp | 2 +- .../LibJS/Runtime/DateConstructor.cpp | 2 +- .../Libraries/LibJS/Runtime/DatePrototype.cpp | 28 ++-- .../Runtime/ECMAScriptFunctionObject.cpp | 4 +- Userland/Libraries/LibJS/Runtime/Error.cpp | 4 +- .../LibJS/Runtime/ErrorConstructor.cpp | 4 +- .../LibJS/Runtime/ErrorPrototype.cpp | 38 ++--- .../Runtime/FinalizationRegistryPrototype.cpp | 2 +- .../LibJS/Runtime/FunctionConstructor.cpp | 2 +- .../LibJS/Runtime/FunctionObject.cpp | 2 +- .../LibJS/Runtime/FunctionPrototype.cpp | 8 +- .../Runtime/GeneratorFunctionPrototype.cpp | 2 +- .../LibJS/Runtime/GeneratorPrototype.cpp | 2 +- .../Libraries/LibJS/Runtime/GlobalObject.cpp | 16 +- .../LibJS/Runtime/Intl/AbstractOperations.cpp | 2 +- .../Runtime/Intl/CollatorCompareFunction.cpp | 2 +- .../Runtime/Intl/CollatorConstructor.cpp | 6 +- .../LibJS/Runtime/Intl/CollatorPrototype.cpp | 12 +- .../LibJS/Runtime/Intl/DateTimeFormat.cpp | 16 +- .../Runtime/Intl/DateTimeFormatFunction.cpp | 4 +- .../Runtime/Intl/DateTimeFormatPrototype.cpp | 20 +-- .../LibJS/Runtime/Intl/DisplayNames.cpp | 12 +- .../Runtime/Intl/DisplayNamesPrototype.cpp | 18 +- .../LibJS/Runtime/Intl/DurationFormat.cpp | 16 +- .../Runtime/Intl/DurationFormatPrototype.cpp | 54 +++--- .../Libraries/LibJS/Runtime/Intl/Intl.cpp | 6 +- .../LibJS/Runtime/Intl/ListFormat.cpp | 4 +- .../Runtime/Intl/ListFormatPrototype.cpp | 10 +- .../Libraries/LibJS/Runtime/Intl/Locale.cpp | 4 +- .../LibJS/Runtime/Intl/LocaleConstructor.cpp | 2 +- .../LibJS/Runtime/Intl/LocalePrototype.cpp | 28 ++-- .../LibJS/Runtime/Intl/NumberFormat.cpp | 16 +- .../Runtime/Intl/NumberFormatFunction.cpp | 4 +- .../Runtime/Intl/NumberFormatPrototype.cpp | 36 ++-- .../Runtime/Intl/PluralRulesPrototype.cpp | 18 +- .../LibJS/Runtime/Intl/RelativeTimeFormat.cpp | 6 +- .../Intl/RelativeTimeFormatConstructor.cpp | 4 +- .../Intl/RelativeTimeFormatPrototype.cpp | 12 +- .../Runtime/Intl/SegmentIteratorPrototype.cpp | 2 +- .../LibJS/Runtime/Intl/Segmenter.cpp | 4 +- .../LibJS/Runtime/Intl/SegmenterPrototype.cpp | 6 +- .../Libraries/LibJS/Runtime/Intrinsics.cpp | 4 +- .../Libraries/LibJS/Runtime/JSONObject.cpp | 12 +- .../LibJS/Runtime/MapIteratorPrototype.cpp | 2 +- .../Libraries/LibJS/Runtime/MapPrototype.cpp | 2 +- .../Libraries/LibJS/Runtime/MathObject.cpp | 2 +- .../LibJS/Runtime/ModuleNamespaceObject.cpp | 4 +- .../LibJS/Runtime/NumberPrototype.cpp | 34 ++-- Userland/Libraries/LibJS/Runtime/Object.cpp | 2 +- .../LibJS/Runtime/ObjectPrototype.cpp | 6 +- .../LibJS/Runtime/PrimitiveString.cpp | 54 +++--- .../Libraries/LibJS/Runtime/PrimitiveString.h | 17 +- Userland/Libraries/LibJS/Runtime/Promise.cpp | 4 +- .../LibJS/Runtime/PromiseConstructor.cpp | 8 +- .../LibJS/Runtime/PromisePrototype.cpp | 2 +- .../PromiseResolvingElementFunctions.cpp | 4 +- .../Libraries/LibJS/Runtime/ProxyObject.cpp | 4 +- .../Libraries/LibJS/Runtime/ReflectObject.cpp | 2 +- .../LibJS/Runtime/RegExpConstructor.cpp | 4 +- .../Runtime/RegExpLegacyStaticProperties.cpp | 2 +- .../LibJS/Runtime/RegExpPrototype.cpp | 46 ++--- .../Runtime/RegExpStringIteratorPrototype.cpp | 2 +- .../LibJS/Runtime/SetIteratorPrototype.cpp | 2 +- .../Libraries/LibJS/Runtime/SetPrototype.cpp | 2 +- .../Libraries/LibJS/Runtime/ShadowRealm.cpp | 2 +- .../LibJS/Runtime/ShadowRealmPrototype.cpp | 2 +- .../LibJS/Runtime/StringConstructor.cpp | 14 +- .../LibJS/Runtime/StringIteratorPrototype.cpp | 4 +- .../Libraries/LibJS/Runtime/StringObject.cpp | 6 +- .../Libraries/LibJS/Runtime/StringOrSymbol.h | 2 +- .../LibJS/Runtime/StringPrototype.cpp | 82 ++++----- .../LibJS/Runtime/SymbolConstructor.cpp | 2 +- .../LibJS/Runtime/SymbolPrototype.cpp | 6 +- .../Runtime/Temporal/AbstractOperations.cpp | 10 +- .../LibJS/Runtime/Temporal/Calendar.cpp | 6 +- .../Runtime/Temporal/CalendarPrototype.cpp | 10 +- .../LibJS/Runtime/Temporal/Duration.cpp | 10 +- .../Runtime/Temporal/DurationPrototype.cpp | 8 +- .../Runtime/Temporal/InstantPrototype.cpp | 8 +- .../Libraries/LibJS/Runtime/Temporal/Now.cpp | 2 +- .../LibJS/Runtime/Temporal/PlainDate.cpp | 2 +- .../Runtime/Temporal/PlainDatePrototype.cpp | 10 +- .../LibJS/Runtime/Temporal/PlainDateTime.cpp | 2 +- .../Temporal/PlainDateTimePrototype.cpp | 10 +- .../LibJS/Runtime/Temporal/PlainMonthDay.cpp | 2 +- .../Temporal/PlainMonthDayPrototype.cpp | 12 +- .../Runtime/Temporal/PlainTimePrototype.cpp | 8 +- .../LibJS/Runtime/Temporal/PlainYearMonth.cpp | 2 +- .../Temporal/PlainYearMonthPrototype.cpp | 12 +- .../LibJS/Runtime/Temporal/Temporal.cpp | 2 +- .../Runtime/Temporal/TimeZonePrototype.cpp | 10 +- .../LibJS/Runtime/Temporal/ZonedDateTime.cpp | 2 +- .../Temporal/ZonedDateTimePrototype.cpp | 14 +- Userland/Libraries/LibJS/Runtime/TypedArray.h | 2 +- .../LibJS/Runtime/TypedArrayPrototype.cpp | 6 +- Userland/Libraries/LibJS/Runtime/Value.cpp | 6 +- .../LibJS/Runtime/WeakMapPrototype.cpp | 2 +- .../LibJS/Runtime/WeakRefPrototype.cpp | 2 +- .../LibJS/Runtime/WeakSetPrototype.cpp | 2 +- Userland/Libraries/LibJS/SyntheticModule.cpp | 2 +- .../LibWeb/Bindings/CSSNamespace.cpp | 2 +- .../LibWeb/Bindings/LegacyPlatformObject.cpp | 4 +- .../LibWeb/Bindings/LocationObject.cpp | 32 ++-- .../LibWeb/CSS/CSSStyleDeclaration.cpp | 4 +- Userland/Libraries/LibWeb/CSS/MediaList.cpp | 2 +- .../Libraries/LibWeb/DOM/DOMTokenList.cpp | 2 +- Userland/Libraries/LibWeb/DOM/EventTarget.cpp | 4 +- Userland/Libraries/LibWeb/Fetch/Body.cpp | 4 +- .../LibWeb/Fetch/HeadersIterator.cpp | 6 +- .../Fetch/Infrastructure/HTTP/Bodies.cpp | 2 +- Userland/Libraries/LibWeb/FileAPI/Blob.cpp | 2 +- .../HTML/CrossOrigin/AbstractOperations.cpp | 4 +- .../Libraries/LibWeb/HTML/DOMStringMap.cpp | 2 +- Userland/Libraries/LibWeb/HTML/Window.cpp | 12 +- .../Libraries/LibWeb/HTML/WindowProxy.cpp | 2 +- Userland/Libraries/LibWeb/Infra/JSON.cpp | 2 +- .../LibWeb/URL/URLSearchParamsIterator.cpp | 6 +- .../WebAssemblyMemoryPrototype.cpp | 2 +- .../LibWeb/WebAssembly/WebAssemblyObject.cpp | 8 +- .../Libraries/LibWeb/WebSockets/WebSocket.cpp | 2 +- .../Libraries/LibWeb/XHR/XMLHttpRequest.cpp | 4 +- Userland/Utilities/js.cpp | 2 +- 144 files changed, 656 insertions(+), 672 deletions(-) diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp index 3c0c35836e0..c511892e848 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp @@ -1412,7 +1412,7 @@ static void generate_wrap_statement(SourceGenerator& generator, DeprecatedString if (type.is_string()) { scoped_generator.append(R"~~~( - @result_expression@ JS::js_string(vm, @value@); + @result_expression@ JS::PrimitiveString::create(vm, @value@); )~~~"); } else if (type.name() == "sequence") { // https://webidl.spec.whatwg.org/#es-sequence @@ -1527,7 +1527,7 @@ static void generate_wrap_statement(SourceGenerator& generator, DeprecatedString )~~~"); } else if (interface.enumerations.contains(type.name())) { scoped_generator.append(R"~~~( - @result_expression@ JS::js_string(vm, Bindings::idl_enum_to_deprecated_string(@value@)); + @result_expression@ JS::PrimitiveString::create(vm, Bindings::idl_enum_to_deprecated_string(@value@)); )~~~"); } else if (interface.callback_functions.contains(type.name())) { // https://webidl.spec.whatwg.org/#es-callback-function @@ -2574,7 +2574,7 @@ void @prototype_class@::initialize(JS::Realm& realm) } generator.append(R"~~~( - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "@name@"), JS::Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), JS::PrimitiveString::create(vm, "@name@"), JS::Attribute::Configurable); Object::initialize(realm); } @@ -2735,7 +2735,7 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::to_string) } stringifier_generator.append(R"~~~( - return JS::js_string(vm, move(retval)); + return JS::PrimitiveString::create(vm, move(retval)); } )~~~"); } @@ -2893,7 +2893,7 @@ void @prototype_class@::initialize(JS::Realm& realm) Object::initialize(realm); define_native_function(realm, vm.names.next, next, 0, JS::Attribute::Writable | JS::Attribute::Enumerable | JS::Attribute::Configurable); - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Iterator"), JS::Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), JS::PrimitiveString::create(vm, "Iterator"), JS::Attribute::Configurable); } static JS::ThrowCompletionOr<@fully_qualified_name@*> impl_from(JS::VM& vm) diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWindowOrWorkerInterfaces.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWindowOrWorkerInterfaces.cpp index 7d23b67f1b4..18a893ca9db 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWindowOrWorkerInterfaces.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWindowOrWorkerInterfaces.cpp @@ -103,7 +103,7 @@ void add_@global_object_snake_name@_exposed_interfaces(JS::Object& global, JS::R auto& constructor = Bindings::ensure_web_constructor(realm, "@interface_name@"); global.define_direct_property("@interface_name@", &constructor, JS::Attribute::Writable | JS::Attribute::Configurable); prototype.define_direct_property(vm.names.constructor, &constructor, JS::Attribute::Writable | JS::Attribute::Configurable); - constructor.define_direct_property(vm.names.name, js_string(vm, "@interface_name@"), JS::Attribute::Configurable); + constructor.define_direct_property(vm.names.name, JS::PrimitiveString::create(vm, "@interface_name@"), JS::Attribute::Configurable); } )~~~"); }; diff --git a/Userland/Applications/Spreadsheet/Cell.cpp b/Userland/Applications/Spreadsheet/Cell.cpp index dea260bb97b..9b534328ba4 100644 --- a/Userland/Applications/Spreadsheet/Cell.cpp +++ b/Userland/Applications/Spreadsheet/Cell.cpp @@ -153,7 +153,8 @@ JS::Value Cell::js_data() if (m_kind == Formula) return m_evaluated_data; - return JS::js_string(m_sheet->interpreter().heap(), m_data); + auto& vm = m_sheet->interpreter().vm(); + return JS::PrimitiveString::create(vm, m_data); } DeprecatedString Cell::source() const diff --git a/Userland/Applications/Spreadsheet/CellType/String.cpp b/Userland/Applications/Spreadsheet/CellType/String.cpp index 79ebe52cd65..d011ca0a152 100644 --- a/Userland/Applications/Spreadsheet/CellType/String.cpp +++ b/Userland/Applications/Spreadsheet/CellType/String.cpp @@ -27,8 +27,9 @@ JS::ThrowCompletionOr StringCell::display(Cell& cell, CellType JS::ThrowCompletionOr StringCell::js_value(Cell& cell, CellTypeMetadata const& metadata) const { + auto& vm = cell.sheet().interpreter().vm(); auto string = TRY(display(cell, metadata)); - return JS::js_string(cell.sheet().interpreter().heap(), string); + return JS::PrimitiveString::create(vm, string); } DeprecatedString StringCell::metadata_hint(MetadataName metadata) const diff --git a/Userland/Applications/Spreadsheet/JSIntegration.cpp b/Userland/Applications/Spreadsheet/JSIntegration.cpp index 68f9a087f3b..87bbd64cc10 100644 --- a/Userland/Applications/Spreadsheet/JSIntegration.cpp +++ b/Userland/Applications/Spreadsheet/JSIntegration.cpp @@ -178,7 +178,7 @@ JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::get_name) return vm.throw_completion(JS::ErrorType::NotAnObjectOfType, "SheetGlobalObject"); auto sheet_object = static_cast(this_object); - return JS::js_string(vm, sheet_object->m_sheet.name()); + return JS::PrimitiveString::create(vm, sheet_object->m_sheet.name()); } JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::get_real_cell_contents) @@ -205,9 +205,9 @@ JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::get_real_cell_contents) return JS::js_undefined(); if (cell->kind() == Spreadsheet::Cell::Kind::Formula) - return JS::js_string(vm, DeprecatedString::formatted("={}", cell->data())); + return JS::PrimitiveString::create(vm, DeprecatedString::formatted("={}", cell->data())); - return JS::js_string(vm, cell->data()); + return JS::PrimitiveString::create(vm, cell->data()); } JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::set_real_cell_contents) @@ -260,7 +260,7 @@ JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::parse_cell_name) return JS::js_undefined(); auto object = JS::Object::create(realm, realm.intrinsics().object_prototype()); - object->define_direct_property("column", JS::js_string(vm, sheet_object->m_sheet.column(position.value().column)), JS::default_attributes); + object->define_direct_property("column", JS::PrimitiveString::create(vm, sheet_object->m_sheet.column(position.value().column)), JS::default_attributes); object->define_direct_property("row", JS::Value((unsigned)position.value().row), JS::default_attributes); return object; @@ -286,7 +286,7 @@ JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::current_cell_position) auto position = current_cell->position(); auto object = JS::Object::create(realm, realm.intrinsics().object_prototype()); - object->define_direct_property("column", JS::js_string(vm, sheet_object->m_sheet.column(position.column)), JS::default_attributes); + object->define_direct_property("column", JS::PrimitiveString::create(vm, sheet_object->m_sheet.column(position.column)), JS::default_attributes); object->define_direct_property("row", JS::Value((unsigned)position.row), JS::default_attributes); return object; @@ -342,7 +342,7 @@ JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::column_arithmetic) if (!new_column.has_value()) return vm.throw_completion(DeprecatedString::formatted("'{}' is not a valid column", column_name_str)); - return JS::js_string(vm, new_column.release_value()); + return JS::PrimitiveString::create(vm, new_column.release_value()); } JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::get_column_bound) diff --git a/Userland/Applications/Spreadsheet/Spreadsheet.cpp b/Userland/Applications/Spreadsheet/Spreadsheet.cpp index 8dd11ea9fcf..1c3d0ae067e 100644 --- a/Userland/Applications/Spreadsheet/Spreadsheet.cpp +++ b/Userland/Applications/Spreadsheet/Spreadsheet.cpp @@ -426,7 +426,7 @@ RefPtr Sheet::from_json(JsonObject const& object, Workbook& workbook) break; case Cell::Formula: { auto& vm = sheet->interpreter().vm(); - auto value_or_error = JS::call(vm, parse_function, json, JS::js_string(vm, obj.get("value"sv).as_string())); + auto value_or_error = JS::call(vm, parse_function, json, JS::PrimitiveString::create(vm, obj.get("value"sv).as_string())); if (value_or_error.is_error()) { warnln("Failed to load previous value for cell {}, leaving as undefined", position.to_cell_identifier(sheet)); value_or_error = JS::js_undefined(); diff --git a/Userland/Libraries/LibJS/AST.cpp b/Userland/Libraries/LibJS/AST.cpp index c0f8364304a..caf127db71e 100644 --- a/Userland/Libraries/LibJS/AST.cpp +++ b/Userland/Libraries/LibJS/AST.cpp @@ -1538,7 +1538,7 @@ Completion UnaryExpression::execute(Interpreter& interpreter) const case UnaryOp::Minus: return TRY(unary_minus(vm, lhs_result)); case UnaryOp::Typeof: - return Value { js_string(vm, lhs_result.typeof()) }; + return Value { PrimitiveString::create(vm, lhs_result.typeof()) }; case UnaryOp::Void: return js_undefined(); case UnaryOp::Delete: @@ -3465,9 +3465,10 @@ Completion ImportCall::execute(Interpreter& interpreter) const Completion StringLiteral::execute(Interpreter& interpreter) const { InterpreterNodeScope node_scope { interpreter, *this }; + auto& vm = interpreter.vm(); // 1. Return the SV of StringLiteral as defined in 12.8.4.2. - return Value { js_string(interpreter.heap(), m_value) }; + return Value { PrimitiveString::create(vm, m_value) }; } // 13.2.3.1 Runtime Semantics: Evaluation, https://tc39.es/ecma262/#sec-literals-runtime-semantics-evaluation @@ -3627,7 +3628,7 @@ Completion TemplateLiteral::execute(Interpreter& interpreter) const } // 7. Return the string-concatenation of head, middle, and tail. - return Value { js_string(interpreter.heap(), string_builder.build()) }; + return Value { PrimitiveString::create(vm, string_builder.build()) }; } void TaggedTemplateLiteral::dump(int indent) const diff --git a/Userland/Libraries/LibJS/Bytecode/Op.cpp b/Userland/Libraries/LibJS/Bytecode/Op.cpp index a500b297eb3..920152cde17 100644 --- a/Userland/Libraries/LibJS/Bytecode/Op.cpp +++ b/Userland/Libraries/LibJS/Bytecode/Op.cpp @@ -150,7 +150,7 @@ static ThrowCompletionOr not_(VM&, Value value) static ThrowCompletionOr typeof_(VM& vm, Value value) { - return Value(js_string(vm, value.typeof())); + return Value(PrimitiveString::create(vm, value.typeof())); } #define JS_DEFINE_COMMON_UNARY_OP(OpTitleCase, op_snake_case) \ @@ -296,7 +296,7 @@ ThrowCompletionOr IteratorToArray::execute_impl(Bytecode::Interpreter& int ThrowCompletionOr NewString::execute_impl(Bytecode::Interpreter& interpreter) const { - interpreter.accumulator() = js_string(interpreter.vm(), interpreter.current_executable().get_string(m_string)); + interpreter.accumulator() = PrimitiveString::create(interpreter.vm(), interpreter.current_executable().get_string(m_string)); return {}; } @@ -316,7 +316,7 @@ ThrowCompletionOr NewRegExp::execute_impl(Bytecode::Interpreter& interpret auto source = interpreter.current_executable().get_string(m_source_index); auto flags = interpreter.current_executable().get_string(m_flags_index); - interpreter.accumulator() = TRY(regexp_create(vm, js_string(vm, source), js_string(vm, flags))); + interpreter.accumulator() = TRY(regexp_create(vm, PrimitiveString::create(vm, source), PrimitiveString::create(vm, flags))); return {}; } @@ -923,7 +923,7 @@ ThrowCompletionOr GetObjectPropertyIterator::execute_impl(Bytecode::Interp if (key.is_number()) result_object->define_direct_property(vm.names.value, JS::Value(key.as_number()), default_attributes); else if (key.is_string()) - result_object->define_direct_property(vm.names.value, js_string(vm, key.as_string()), default_attributes); + result_object->define_direct_property(vm.names.value, PrimitiveString::create(vm, key.as_string()), default_attributes); else VERIFY_NOT_REACHED(); // We should not have non-string/number keys. @@ -992,7 +992,7 @@ ThrowCompletionOr TypeofVariable::execute_impl(Bytecode::Interpreter& inte // 2. If val is a Reference Record, then // a. If IsUnresolvableReference(val) is true, return "undefined". if (reference.is_unresolvable()) { - interpreter.accumulator() = js_string(vm, "undefined"sv); + interpreter.accumulator() = PrimitiveString::create(vm, "undefined"sv); return {}; } @@ -1001,7 +1001,7 @@ ThrowCompletionOr TypeofVariable::execute_impl(Bytecode::Interpreter& inte // 4. NOTE: This step is replaced in section B.3.6.3. // 5. Return a String according to Table 41. - interpreter.accumulator() = js_string(vm, value.typeof()); + interpreter.accumulator() = PrimitiveString::create(vm, value.typeof()); return {}; } diff --git a/Userland/Libraries/LibJS/Console.cpp b/Userland/Libraries/LibJS/Console.cpp index 5a2fd1ce85f..14bb58acc82 100644 --- a/Userland/Libraries/LibJS/Console.cpp +++ b/Userland/Libraries/LibJS/Console.cpp @@ -139,7 +139,7 @@ ThrowCompletionOr Console::count() // 5. Perform Logger("count", « concat »). MarkedVector concat_as_vector { vm.heap() }; - concat_as_vector.append(js_string(vm, concat)); + concat_as_vector.append(PrimitiveString::create(vm, concat)); if (m_client) TRY(m_client->logger(LogLevel::Count, concat_as_vector)); return js_undefined(); @@ -167,7 +167,7 @@ ThrowCompletionOr Console::count_reset() auto message = DeprecatedString::formatted("\"{}\" doesn't have a count", label); // 2. Perform Logger("countReset", « message »); MarkedVector message_as_vector { vm.heap() }; - message_as_vector.append(js_string(vm, message)); + message_as_vector.append(PrimitiveString::create(vm, message)); if (m_client) TRY(m_client->logger(LogLevel::CountReset, message_as_vector)); } @@ -186,7 +186,7 @@ ThrowCompletionOr Console::assert_() return js_undefined(); // 2. Let message be a string without any formatting specifiers indicating generically an assertion failure (such as "Assertion failed"). - auto message = js_string(vm, "Assertion failed"); + auto message = PrimitiveString::create(vm, "Assertion failed"); // NOTE: Assemble `data` from the function arguments. MarkedVector data { vm.heap() }; @@ -212,7 +212,7 @@ ThrowCompletionOr Console::assert_() // 3. Otherwise: else { // 1. Let concat be the concatenation of message, U+003A (:), U+0020 SPACE, and first. - auto concat = js_string(vm, DeprecatedString::formatted("{}: {}", message->deprecated_string(), first.to_string(vm).value())); + auto concat = PrimitiveString::create(vm, DeprecatedString::formatted("{}: {}", message->deprecated_string(), first.to_string(vm).value())); // 2. Set data[0] to concat. data[0] = concat; } @@ -319,7 +319,7 @@ ThrowCompletionOr Console::time() if (m_timer_table.contains(label)) { if (m_client) { MarkedVector timer_already_exists_warning_message_as_vector { vm.heap() }; - timer_already_exists_warning_message_as_vector.append(js_string(vm, DeprecatedString::formatted("Timer '{}' already exists.", label))); + timer_already_exists_warning_message_as_vector.append(PrimitiveString::create(vm, DeprecatedString::formatted("Timer '{}' already exists.", label))); TRY(m_client->printer(LogLevel::Warn, move(timer_already_exists_warning_message_as_vector))); } return js_undefined(); @@ -347,7 +347,7 @@ ThrowCompletionOr Console::time_log() if (maybe_start_time == m_timer_table.end()) { if (m_client) { MarkedVector timer_does_not_exist_warning_message_as_vector { vm.heap() }; - timer_does_not_exist_warning_message_as_vector.append(js_string(vm, DeprecatedString::formatted("Timer '{}' does not exist.", label))); + timer_does_not_exist_warning_message_as_vector.append(PrimitiveString::create(vm, DeprecatedString::formatted("Timer '{}' does not exist.", label))); TRY(m_client->printer(LogLevel::Warn, move(timer_does_not_exist_warning_message_as_vector))); } return js_undefined(); @@ -363,7 +363,7 @@ ThrowCompletionOr Console::time_log() // 5. Prepend concat to data. MarkedVector data { vm.heap() }; data.ensure_capacity(vm.argument_count()); - data.append(js_string(vm, concat)); + data.append(PrimitiveString::create(vm, concat)); for (size_t i = 1; i < vm.argument_count(); ++i) data.append(vm.argument(i)); @@ -390,7 +390,7 @@ ThrowCompletionOr Console::time_end() if (maybe_start_time == m_timer_table.end()) { if (m_client) { MarkedVector timer_does_not_exist_warning_message_as_vector { vm.heap() }; - timer_does_not_exist_warning_message_as_vector.append(js_string(vm, DeprecatedString::formatted("Timer '{}' does not exist.", label))); + timer_does_not_exist_warning_message_as_vector.append(PrimitiveString::create(vm, DeprecatedString::formatted("Timer '{}' does not exist.", label))); TRY(m_client->printer(LogLevel::Warn, move(timer_does_not_exist_warning_message_as_vector))); } return js_undefined(); @@ -409,7 +409,7 @@ ThrowCompletionOr Console::time_end() // 6. Perform Printer("timeEnd", « concat »). if (m_client) { MarkedVector concat_as_vector { vm.heap() }; - concat_as_vector.append(js_string(vm, concat)); + concat_as_vector.append(PrimitiveString::create(vm, concat)); TRY(m_client->printer(LogLevel::TimeEnd, move(concat_as_vector))); } return js_undefined(); @@ -622,7 +622,7 @@ ThrowCompletionOr> ConsoleClient::formatter(MarkedVector> ConsoleClient::formatter(MarkedVector result { vm.heap() }; result.ensure_capacity(args.size() - 1); - result.empend(js_string(vm, target)); + result.empend(PrimitiveString::create(vm, target)); for (size_t i = 2; i < args.size(); ++i) result.unchecked_append(args[i]); diff --git a/Userland/Libraries/LibJS/Print.cpp b/Userland/Libraries/LibJS/Print.cpp index d9bd91fc562..027e695130d 100644 --- a/Userland/Libraries/LibJS/Print.cpp +++ b/Userland/Libraries/LibJS/Print.cpp @@ -425,7 +425,7 @@ ErrorOr print_temporal_calendar(JS::PrintContext& print_context, JS::Tempo { TRY(print_type(print_context, "Temporal.Calendar")); TRY(js_out(print_context, " ")); - TRY(print_value(print_context, JS::js_string(calendar.vm(), calendar.identifier()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(calendar.vm(), calendar.identifier()), seen_objects)); return {}; } @@ -496,7 +496,7 @@ ErrorOr print_temporal_time_zone(JS::PrintContext& print_context, JS::Temp { TRY(print_type(print_context, "Temporal.TimeZone")); TRY(js_out(print_context, " ")); - TRY(print_value(print_context, JS::js_string(time_zone.vm(), time_zone.identifier()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(time_zone.vm(), time_zone.identifier()), seen_objects)); if (time_zone.offset_nanoseconds().has_value()) { TRY(js_out(print_context, "\n offset (ns): ")); TRY(print_value(print_context, JS::Value(*time_zone.offset_nanoseconds()), seen_objects)); @@ -520,16 +520,16 @@ ErrorOr print_intl_display_names(JS::PrintContext& print_context, JS::Intl { TRY(print_type(print_context, "Intl.DisplayNames")); TRY(js_out(print_context, "\n locale: ")); - TRY(print_value(print_context, js_string(display_names.vm(), display_names.locale()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(display_names.vm(), display_names.locale()), seen_objects)); TRY(js_out(print_context, "\n type: ")); - TRY(print_value(print_context, js_string(display_names.vm(), display_names.type_string()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(display_names.vm(), display_names.type_string()), seen_objects)); TRY(js_out(print_context, "\n style: ")); - TRY(print_value(print_context, js_string(display_names.vm(), display_names.style_string()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(display_names.vm(), display_names.style_string()), seen_objects)); TRY(js_out(print_context, "\n fallback: ")); - TRY(print_value(print_context, js_string(display_names.vm(), display_names.fallback_string()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(display_names.vm(), display_names.fallback_string()), seen_objects)); if (display_names.has_language_display()) { TRY(js_out(print_context, "\n languageDisplay: ")); - TRY(print_value(print_context, js_string(display_names.vm(), display_names.language_display_string()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(display_names.vm(), display_names.language_display_string()), seen_objects)); } return {}; } @@ -538,26 +538,26 @@ ErrorOr print_intl_locale(JS::PrintContext& print_context, JS::Intl::Local { TRY(print_type(print_context, "Intl.Locale")); TRY(js_out(print_context, "\n locale: ")); - TRY(print_value(print_context, js_string(locale.vm(), locale.locale()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(locale.vm(), locale.locale()), seen_objects)); if (locale.has_calendar()) { TRY(js_out(print_context, "\n calendar: ")); - TRY(print_value(print_context, js_string(locale.vm(), locale.calendar()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(locale.vm(), locale.calendar()), seen_objects)); } if (locale.has_case_first()) { TRY(js_out(print_context, "\n caseFirst: ")); - TRY(print_value(print_context, js_string(locale.vm(), locale.case_first()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(locale.vm(), locale.case_first()), seen_objects)); } if (locale.has_collation()) { TRY(js_out(print_context, "\n collation: ")); - TRY(print_value(print_context, js_string(locale.vm(), locale.collation()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(locale.vm(), locale.collation()), seen_objects)); } if (locale.has_hour_cycle()) { TRY(js_out(print_context, "\n hourCycle: ")); - TRY(print_value(print_context, js_string(locale.vm(), locale.hour_cycle()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(locale.vm(), locale.hour_cycle()), seen_objects)); } if (locale.has_numbering_system()) { TRY(js_out(print_context, "\n numberingSystem: ")); - TRY(print_value(print_context, js_string(locale.vm(), locale.numbering_system()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(locale.vm(), locale.numbering_system()), seen_objects)); } TRY(js_out(print_context, "\n numeric: ")); TRY(print_value(print_context, JS::Value(locale.numeric()), seen_objects)); @@ -568,11 +568,11 @@ ErrorOr print_intl_list_format(JS::PrintContext& print_context, JS::Intl:: { TRY(print_type(print_context, "Intl.ListFormat")); TRY(js_out(print_context, "\n locale: ")); - TRY(print_value(print_context, js_string(list_format.vm(), list_format.locale()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(list_format.vm(), list_format.locale()), seen_objects)); TRY(js_out(print_context, "\n type: ")); - TRY(print_value(print_context, js_string(list_format.vm(), list_format.type_string()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(list_format.vm(), list_format.type_string()), seen_objects)); TRY(js_out(print_context, "\n style: ")); - TRY(print_value(print_context, js_string(list_format.vm(), list_format.style_string()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(list_format.vm(), list_format.style_string()), seen_objects)); return {}; } @@ -580,32 +580,32 @@ ErrorOr print_intl_number_format(JS::PrintContext& print_context, JS::Intl { TRY(print_type(print_context, "Intl.NumberFormat")); TRY(js_out(print_context, "\n locale: ")); - TRY(print_value(print_context, js_string(number_format.vm(), number_format.locale()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(number_format.vm(), number_format.locale()), seen_objects)); TRY(js_out(print_context, "\n dataLocale: ")); - TRY(print_value(print_context, js_string(number_format.vm(), number_format.data_locale()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(number_format.vm(), number_format.data_locale()), seen_objects)); TRY(js_out(print_context, "\n numberingSystem: ")); - TRY(print_value(print_context, js_string(number_format.vm(), number_format.numbering_system()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(number_format.vm(), number_format.numbering_system()), seen_objects)); TRY(js_out(print_context, "\n style: ")); - TRY(print_value(print_context, js_string(number_format.vm(), number_format.style_string()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(number_format.vm(), number_format.style_string()), seen_objects)); if (number_format.has_currency()) { TRY(js_out(print_context, "\n currency: ")); - TRY(print_value(print_context, js_string(number_format.vm(), number_format.currency()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(number_format.vm(), number_format.currency()), seen_objects)); } if (number_format.has_currency_display()) { TRY(js_out(print_context, "\n currencyDisplay: ")); - TRY(print_value(print_context, js_string(number_format.vm(), number_format.currency_display_string()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(number_format.vm(), number_format.currency_display_string()), seen_objects)); } if (number_format.has_currency_sign()) { TRY(js_out(print_context, "\n currencySign: ")); - TRY(print_value(print_context, js_string(number_format.vm(), number_format.currency_sign_string()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(number_format.vm(), number_format.currency_sign_string()), seen_objects)); } if (number_format.has_unit()) { TRY(js_out(print_context, "\n unit: ")); - TRY(print_value(print_context, js_string(number_format.vm(), number_format.unit()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(number_format.vm(), number_format.unit()), seen_objects)); } if (number_format.has_unit_display()) { TRY(js_out(print_context, "\n unitDisplay: ")); - TRY(print_value(print_context, js_string(number_format.vm(), number_format.unit_display_string()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(number_format.vm(), number_format.unit_display_string()), seen_objects)); } TRY(js_out(print_context, "\n minimumIntegerDigits: ")); TRY(print_value(print_context, JS::Value(number_format.min_integer_digits()), seen_objects)); @@ -628,21 +628,21 @@ ErrorOr print_intl_number_format(JS::PrintContext& print_context, JS::Intl TRY(js_out(print_context, "\n useGrouping: ")); TRY(print_value(print_context, number_format.use_grouping_to_value(number_format.vm()), seen_objects)); TRY(js_out(print_context, "\n roundingType: ")); - TRY(print_value(print_context, js_string(number_format.vm(), number_format.rounding_type_string()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(number_format.vm(), number_format.rounding_type_string()), seen_objects)); TRY(js_out(print_context, "\n roundingMode: ")); - TRY(print_value(print_context, js_string(number_format.vm(), number_format.rounding_mode_string()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(number_format.vm(), number_format.rounding_mode_string()), seen_objects)); TRY(js_out(print_context, "\n roundingIncrement: ")); TRY(print_value(print_context, JS::Value(number_format.rounding_increment()), seen_objects)); TRY(js_out(print_context, "\n notation: ")); - TRY(print_value(print_context, js_string(number_format.vm(), number_format.notation_string()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(number_format.vm(), number_format.notation_string()), seen_objects)); if (number_format.has_compact_display()) { TRY(js_out(print_context, "\n compactDisplay: ")); - TRY(print_value(print_context, js_string(number_format.vm(), number_format.compact_display_string()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(number_format.vm(), number_format.compact_display_string()), seen_objects)); } TRY(js_out(print_context, "\n signDisplay: ")); - TRY(print_value(print_context, js_string(number_format.vm(), number_format.sign_display_string()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(number_format.vm(), number_format.sign_display_string()), seen_objects)); TRY(js_out(print_context, "\n trailingZeroDisplay: ")); - TRY(print_value(print_context, js_string(number_format.vm(), number_format.trailing_zero_display_string()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(number_format.vm(), number_format.trailing_zero_display_string()), seen_objects)); return {}; } @@ -650,26 +650,26 @@ ErrorOr print_intl_date_time_format(JS::PrintContext& print_context, JS::I { TRY(print_type(print_context, "Intl.DateTimeFormat")); TRY(js_out(print_context, "\n locale: ")); - TRY(print_value(print_context, js_string(date_time_format.vm(), date_time_format.locale()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(date_time_format.vm(), date_time_format.locale()), seen_objects)); TRY(js_out(print_context, "\n pattern: ")); - TRY(print_value(print_context, js_string(date_time_format.vm(), date_time_format.pattern()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(date_time_format.vm(), date_time_format.pattern()), seen_objects)); TRY(js_out(print_context, "\n calendar: ")); - TRY(print_value(print_context, js_string(date_time_format.vm(), date_time_format.calendar()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(date_time_format.vm(), date_time_format.calendar()), seen_objects)); TRY(js_out(print_context, "\n numberingSystem: ")); - TRY(print_value(print_context, js_string(date_time_format.vm(), date_time_format.numbering_system()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(date_time_format.vm(), date_time_format.numbering_system()), seen_objects)); if (date_time_format.has_hour_cycle()) { TRY(js_out(print_context, "\n hourCycle: ")); - TRY(print_value(print_context, js_string(date_time_format.vm(), date_time_format.hour_cycle_string()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(date_time_format.vm(), date_time_format.hour_cycle_string()), seen_objects)); } TRY(js_out(print_context, "\n timeZone: ")); - TRY(print_value(print_context, js_string(date_time_format.vm(), date_time_format.time_zone()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(date_time_format.vm(), date_time_format.time_zone()), seen_objects)); if (date_time_format.has_date_style()) { TRY(js_out(print_context, "\n dateStyle: ")); - TRY(print_value(print_context, js_string(date_time_format.vm(), date_time_format.date_style_string()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(date_time_format.vm(), date_time_format.date_style_string()), seen_objects)); } if (date_time_format.has_time_style()) { TRY(js_out(print_context, "\n timeStyle: ")); - TRY(print_value(print_context, js_string(date_time_format.vm(), date_time_format.time_style_string()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(date_time_format.vm(), date_time_format.time_style_string()), seen_objects)); } auto result = JS::Intl::for_each_calendar_field(date_time_format.vm(), date_time_format, [&](auto& option, auto const& property, auto const&) -> JS::ThrowCompletionOr { @@ -688,7 +688,7 @@ ErrorOr print_intl_date_time_format(JS::PrintContext& print_context, JS::I return JS::throw_completion(JS::js_null()); } else { auto name = Locale::calendar_pattern_style_to_string(*option); - if (print_value(print_context, js_string(date_time_format.vm(), name), seen_objects).is_error()) + if (print_value(print_context, JS::PrimitiveString::create(date_time_format.vm(), name), seen_objects).is_error()) return JS::throw_completion(JS::js_null()); } @@ -705,13 +705,13 @@ ErrorOr print_intl_relative_time_format(JS::PrintContext& print_context, J { TRY(print_type(print_context, "Intl.RelativeTimeFormat")); TRY(js_out(print_context, "\n locale: ")); - TRY(print_value(print_context, js_string(date_time_format.vm(), date_time_format.locale()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(date_time_format.vm(), date_time_format.locale()), seen_objects)); TRY(js_out(print_context, "\n numberingSystem: ")); - TRY(print_value(print_context, js_string(date_time_format.vm(), date_time_format.numbering_system()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(date_time_format.vm(), date_time_format.numbering_system()), seen_objects)); TRY(js_out(print_context, "\n style: ")); - TRY(print_value(print_context, js_string(date_time_format.vm(), date_time_format.style_string()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(date_time_format.vm(), date_time_format.style_string()), seen_objects)); TRY(js_out(print_context, "\n numeric: ")); - TRY(print_value(print_context, js_string(date_time_format.vm(), date_time_format.numeric_string()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(date_time_format.vm(), date_time_format.numeric_string()), seen_objects)); return {}; } @@ -719,9 +719,9 @@ ErrorOr print_intl_plural_rules(JS::PrintContext& print_context, JS::Intl: { TRY(print_type(print_context, "Intl.PluralRules")); TRY(js_out(print_context, "\n locale: ")); - TRY(print_value(print_context, js_string(plural_rules.vm(), plural_rules.locale()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(plural_rules.vm(), plural_rules.locale()), seen_objects)); TRY(js_out(print_context, "\n type: ")); - TRY(print_value(print_context, js_string(plural_rules.vm(), plural_rules.type_string()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(plural_rules.vm(), plural_rules.type_string()), seen_objects)); TRY(js_out(print_context, "\n minimumIntegerDigits: ")); TRY(print_value(print_context, JS::Value(plural_rules.min_integer_digits()), seen_objects)); if (plural_rules.has_min_fraction_digits()) { @@ -741,7 +741,7 @@ ErrorOr print_intl_plural_rules(JS::PrintContext& print_context, JS::Intl: TRY(print_value(print_context, JS::Value(plural_rules.max_significant_digits()), seen_objects)); } TRY(js_out(print_context, "\n roundingType: ")); - TRY(print_value(print_context, js_string(plural_rules.vm(), plural_rules.rounding_type_string()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(plural_rules.vm(), plural_rules.rounding_type_string()), seen_objects)); return {}; } @@ -749,15 +749,15 @@ ErrorOr print_intl_collator(JS::PrintContext& print_context, JS::Intl::Col { TRY(print_type(print_context, "Intl.Collator")); out("\n locale: "); - TRY(print_value(print_context, js_string(collator.vm(), collator.locale()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(collator.vm(), collator.locale()), seen_objects)); out("\n usage: "); - TRY(print_value(print_context, js_string(collator.vm(), collator.usage_string()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(collator.vm(), collator.usage_string()), seen_objects)); out("\n sensitivity: "); - TRY(print_value(print_context, js_string(collator.vm(), collator.sensitivity_string()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(collator.vm(), collator.sensitivity_string()), seen_objects)); out("\n caseFirst: "); - TRY(print_value(print_context, js_string(collator.vm(), collator.case_first_string()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(collator.vm(), collator.case_first_string()), seen_objects)); out("\n collation: "); - TRY(print_value(print_context, js_string(collator.vm(), collator.collation()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(collator.vm(), collator.collation()), seen_objects)); out("\n ignorePunctuation: "); TRY(print_value(print_context, JS::Value(collator.ignore_punctuation()), seen_objects)); out("\n numeric: "); @@ -769,9 +769,9 @@ ErrorOr print_intl_segmenter(JS::PrintContext& print_context, JS::Intl::Se { TRY(print_type(print_context, "Intl.Segmenter")); out("\n locale: "); - TRY(print_value(print_context, js_string(segmenter.vm(), segmenter.locale()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(segmenter.vm(), segmenter.locale()), seen_objects)); out("\n granularity: "); - TRY(print_value(print_context, js_string(segmenter.vm(), segmenter.segmenter_granularity_string()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(segmenter.vm(), segmenter.segmenter_granularity_string()), seen_objects)); return {}; } @@ -779,7 +779,7 @@ ErrorOr print_intl_segments(JS::PrintContext& print_context, JS::Intl::Seg { TRY(print_type(print_context, "Segments")); out("\n string: "); - TRY(print_value(print_context, js_string(segments.vm(), segments.segments_string()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(segments.vm(), segments.segments_string()), seen_objects)); out("\n segmenter: "); TRY(print_value(print_context, &segments.segments_segmenter(), seen_objects)); return {}; @@ -789,53 +789,53 @@ ErrorOr print_intl_duration_format(JS::PrintContext& print_context, JS::In { TRY(print_type(print_context, "Intl.DurationFormat")); out("\n locale: "); - TRY(print_value(print_context, js_string(duration_format.vm(), duration_format.locale()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(duration_format.vm(), duration_format.locale()), seen_objects)); out("\n dataLocale: "); - TRY(print_value(print_context, js_string(duration_format.vm(), duration_format.data_locale()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(duration_format.vm(), duration_format.data_locale()), seen_objects)); out("\n numberingSystem: "); - TRY(print_value(print_context, js_string(duration_format.vm(), duration_format.numbering_system()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(duration_format.vm(), duration_format.numbering_system()), seen_objects)); out("\n style: "); - TRY(print_value(print_context, js_string(duration_format.vm(), duration_format.style_string()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(duration_format.vm(), duration_format.style_string()), seen_objects)); out("\n years: "); - TRY(print_value(print_context, js_string(duration_format.vm(), duration_format.years_style_string()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(duration_format.vm(), duration_format.years_style_string()), seen_objects)); out("\n yearsDisplay: "); - TRY(print_value(print_context, js_string(duration_format.vm(), duration_format.years_display_string()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(duration_format.vm(), duration_format.years_display_string()), seen_objects)); out("\n months: "); - TRY(print_value(print_context, js_string(duration_format.vm(), duration_format.months_style_string()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(duration_format.vm(), duration_format.months_style_string()), seen_objects)); out("\n monthsDisplay: "); - TRY(print_value(print_context, js_string(duration_format.vm(), duration_format.months_display_string()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(duration_format.vm(), duration_format.months_display_string()), seen_objects)); out("\n weeks: "); - TRY(print_value(print_context, js_string(duration_format.vm(), duration_format.weeks_style_string()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(duration_format.vm(), duration_format.weeks_style_string()), seen_objects)); out("\n weeksDisplay: "); - TRY(print_value(print_context, js_string(duration_format.vm(), duration_format.weeks_display_string()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(duration_format.vm(), duration_format.weeks_display_string()), seen_objects)); out("\n days: "); - TRY(print_value(print_context, js_string(duration_format.vm(), duration_format.days_style_string()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(duration_format.vm(), duration_format.days_style_string()), seen_objects)); out("\n daysDisplay: "); - TRY(print_value(print_context, js_string(duration_format.vm(), duration_format.days_display_string()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(duration_format.vm(), duration_format.days_display_string()), seen_objects)); out("\n hours: "); - TRY(print_value(print_context, js_string(duration_format.vm(), duration_format.hours_style_string()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(duration_format.vm(), duration_format.hours_style_string()), seen_objects)); out("\n hoursDisplay: "); - TRY(print_value(print_context, js_string(duration_format.vm(), duration_format.hours_display_string()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(duration_format.vm(), duration_format.hours_display_string()), seen_objects)); out("\n minutes: "); - TRY(print_value(print_context, js_string(duration_format.vm(), duration_format.minutes_style_string()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(duration_format.vm(), duration_format.minutes_style_string()), seen_objects)); out("\n minutesDisplay: "); - TRY(print_value(print_context, js_string(duration_format.vm(), duration_format.minutes_display_string()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(duration_format.vm(), duration_format.minutes_display_string()), seen_objects)); out("\n seconds: "); - TRY(print_value(print_context, js_string(duration_format.vm(), duration_format.seconds_style_string()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(duration_format.vm(), duration_format.seconds_style_string()), seen_objects)); out("\n secondsDisplay: "); - TRY(print_value(print_context, js_string(duration_format.vm(), duration_format.seconds_display_string()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(duration_format.vm(), duration_format.seconds_display_string()), seen_objects)); out("\n milliseconds: "); - TRY(print_value(print_context, js_string(duration_format.vm(), duration_format.milliseconds_style_string()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(duration_format.vm(), duration_format.milliseconds_style_string()), seen_objects)); out("\n millisecondsDisplay: "); - TRY(print_value(print_context, js_string(duration_format.vm(), duration_format.milliseconds_display_string()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(duration_format.vm(), duration_format.milliseconds_display_string()), seen_objects)); out("\n microseconds: "); - TRY(print_value(print_context, js_string(duration_format.vm(), duration_format.microseconds_style_string()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(duration_format.vm(), duration_format.microseconds_style_string()), seen_objects)); out("\n microsecondsDisplay: "); - TRY(print_value(print_context, js_string(duration_format.vm(), duration_format.microseconds_display_string()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(duration_format.vm(), duration_format.microseconds_display_string()), seen_objects)); out("\n nanoseconds: "); - TRY(print_value(print_context, js_string(duration_format.vm(), duration_format.nanoseconds_style_string()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(duration_format.vm(), duration_format.nanoseconds_style_string()), seen_objects)); out("\n nanosecondsDisplay: "); - TRY(print_value(print_context, js_string(duration_format.vm(), duration_format.nanoseconds_display_string()), seen_objects)); + TRY(print_value(print_context, JS::PrimitiveString::create(duration_format.vm(), duration_format.nanoseconds_display_string()), seen_objects)); if (duration_format.has_fractional_digits()) { out("\n fractionalDigits: "); TRY(print_value(print_context, JS::Value(duration_format.fractional_digits()), seen_objects)); diff --git a/Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.cpp b/Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.cpp index 9230e26c73a..1b631e5172f 100644 --- a/Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.cpp @@ -46,7 +46,7 @@ ThrowCompletionOr AggregateErrorConstructor::construct(FunctionObject& if (!vm.argument(1).is_undefined()) { auto message = TRY(vm.argument(1).to_string(vm)); - aggregate_error->create_non_enumerable_data_property_or_throw(vm.names.message, js_string(vm, message)); + aggregate_error->create_non_enumerable_data_property_or_throw(vm.names.message, PrimitiveString::create(vm, message)); } TRY(aggregate_error->install_error_cause(vm.argument(2))); diff --git a/Userland/Libraries/LibJS/Runtime/AggregateErrorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/AggregateErrorPrototype.cpp index 34302bc3f92..370c9d65698 100644 --- a/Userland/Libraries/LibJS/Runtime/AggregateErrorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/AggregateErrorPrototype.cpp @@ -20,8 +20,8 @@ void AggregateErrorPrototype::initialize(Realm& realm) auto& vm = this->vm(); Object::initialize(realm); u8 attr = Attribute::Writable | Attribute::Configurable; - define_direct_property(vm.names.name, js_string(vm, "AggregateError"), attr); - define_direct_property(vm.names.message, js_string(vm, ""), attr); + define_direct_property(vm.names.name, PrimitiveString::create(vm, "AggregateError"), attr); + define_direct_property(vm.names.message, PrimitiveString::create(vm, ""), attr); } } diff --git a/Userland/Libraries/LibJS/Runtime/Array.cpp b/Userland/Libraries/LibJS/Runtime/Array.cpp index 8d732203987..5b7b7011b25 100644 --- a/Userland/Libraries/LibJS/Runtime/Array.cpp +++ b/Userland/Libraries/LibJS/Runtime/Array.cpp @@ -186,10 +186,10 @@ ThrowCompletionOr compare_array_elements(VM& vm, Value x, Value y, Funct } // 5. Let xString be ? ToString(x). - auto* x_string = js_string(vm, TRY(x.to_string(vm))); + auto x_string = PrimitiveString::create(vm, TRY(x.to_string(vm))); // 6. Let yString be ? ToString(y). - auto* y_string = js_string(vm, TRY(y.to_string(vm))); + auto y_string = PrimitiveString::create(vm, TRY(y.to_string(vm))); // 7. Let xSmaller be ! IsLessThan(xString, yString, true). auto x_smaller = MUST(is_less_than(vm, x_string, y_string, true)); @@ -330,7 +330,7 @@ ThrowCompletionOr> Array::internal_own_property_keys() const auto& vm = this->vm(); auto keys = TRY(Object::internal_own_property_keys()); // FIXME: This is pretty expensive, find a better way to do this - keys.insert(indexed_properties().real_size(), js_string(vm, vm.names.length.as_string())); + keys.insert(indexed_properties().real_size(), PrimitiveString::create(vm, vm.names.length.as_string())); return { move(keys) }; } diff --git a/Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.cpp index 5c53ec60cdf..047bf1afa80 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.cpp @@ -28,7 +28,7 @@ void ArrayBufferPrototype::initialize(Realm& realm) define_native_accessor(realm, vm.names.byteLength, byte_length_getter, {}, Attribute::Configurable); // 25.1.5.4 ArrayBuffer.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-arraybuffer.prototype-@@tostringtag - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, vm.names.ArrayBuffer.as_string()), Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.ArrayBuffer.as_string()), Attribute::Configurable); } // 25.1.5.3 ArrayBuffer.prototype.slice ( start, end ), https://tc39.es/ecma262/#sec-arraybuffer.prototype.slice diff --git a/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.cpp index 259587414c9..0ef20298883 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.cpp @@ -27,7 +27,7 @@ void ArrayIteratorPrototype::initialize(Realm& realm) define_native_function(realm, vm.names.next, next, 0, Attribute::Configurable | Attribute::Writable); // 23.1.5.2.2 %ArrayIteratorPrototype% [ @@toStringTag ], https://tc39.es/ecma262/#sec-%arrayiteratorprototype%-@@tostringtag - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Array Iterator"), Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Array Iterator"), Attribute::Configurable); } // 23.1.5.2.1 %ArrayIteratorPrototype%.next ( ), https://tc39.es/ecma262/#sec-%arrayiteratorprototype%.next diff --git a/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp index cfb05f7fa3b..7f8325ec215 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp @@ -991,7 +991,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 js_string(vm, ""); + return PrimitiveString::create(vm, ""); s_array_join_seen_objects.set(this_object); ArmedScopeGuard unsee_object_guard = [&] { s_array_join_seen_objects.remove(this_object); @@ -1012,7 +1012,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::join) builder.append(string); } - return js_string(vm, builder.to_deprecated_string()); + return PrimitiveString::create(vm, builder.to_deprecated_string()); } // 23.1.3.19 Array.prototype.keys ( ), https://tc39.es/ecma262/#sec-array.prototype.keys @@ -1702,7 +1702,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 js_string(vm, ""); + return PrimitiveString::create(vm, ""); s_array_join_seen_objects.set(this_object); ArmedScopeGuard unsee_object_guard = [&] { s_array_join_seen_objects.remove(this_object); @@ -1743,7 +1743,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::to_locale_string) } // 7. Return R. - return js_string(vm, builder.to_deprecated_string()); + return PrimitiveString::create(vm, builder.to_deprecated_string()); } // 1.1.1.4 Array.prototype.toReversed ( ), https://tc39.es/proposal-change-array-by-copy/#sec-array.prototype.toReversed diff --git a/Userland/Libraries/LibJS/Runtime/AsyncFunctionPrototype.cpp b/Userland/Libraries/LibJS/Runtime/AsyncFunctionPrototype.cpp index a2149557bf2..55f42d0dd10 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncFunctionPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/AsyncFunctionPrototype.cpp @@ -20,7 +20,7 @@ void AsyncFunctionPrototype::initialize(Realm& realm) Object::initialize(realm); // 27.7.3.2 AsyncFunction.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-async-function-prototype-properties-toStringTag - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, vm.names.AsyncFunction.as_string()), Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.AsyncFunction.as_string()), Attribute::Configurable); } } diff --git a/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionPrototype.cpp b/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionPrototype.cpp index 24cd8741065..39459950a2f 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionPrototype.cpp @@ -27,7 +27,7 @@ void AsyncGeneratorFunctionPrototype::initialize(Realm& realm) define_direct_property(vm.names.prototype, realm.intrinsics().async_generator_prototype(), Attribute::Configurable); // 27.4.3.3 AsyncGeneratorFunction.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-asyncgeneratorfunction-prototype-tostringtag - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, vm.names.AsyncGeneratorFunction.as_string()), Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.AsyncGeneratorFunction.as_string()), Attribute::Configurable); } } diff --git a/Userland/Libraries/LibJS/Runtime/AsyncGeneratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/AsyncGeneratorPrototype.cpp index db9f611d715..cdb9bf73102 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncGeneratorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/AsyncGeneratorPrototype.cpp @@ -20,7 +20,7 @@ void AsyncGeneratorPrototype::initialize(Realm& realm) Object::initialize(realm); // 27.6.1.5 AsyncGenerator.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-asyncgenerator-prototype-tostringtag - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "AsyncGenerator"), Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "AsyncGenerator"), Attribute::Configurable); } } diff --git a/Userland/Libraries/LibJS/Runtime/AtomicsObject.cpp b/Userland/Libraries/LibJS/Runtime/AtomicsObject.cpp index f41a2304f02..19753f3313b 100644 --- a/Userland/Libraries/LibJS/Runtime/AtomicsObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/AtomicsObject.cpp @@ -147,7 +147,7 @@ void AtomicsObject::initialize(Realm& realm) define_native_function(realm, vm.names.xor_, xor_, 3, attr); // 25.4.15 Atomics [ @@toStringTag ], https://tc39.es/ecma262/#sec-atomics-@@tostringtag - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Atomics"), Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Atomics"), Attribute::Configurable); } // 25.4.3 Atomics.add ( typedArray, index, value ), https://tc39.es/ecma262/#sec-atomics.add diff --git a/Userland/Libraries/LibJS/Runtime/BigIntPrototype.cpp b/Userland/Libraries/LibJS/Runtime/BigIntPrototype.cpp index d98ea5cba26..23654ac87cf 100644 --- a/Userland/Libraries/LibJS/Runtime/BigIntPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/BigIntPrototype.cpp @@ -32,7 +32,7 @@ void BigIntPrototype::initialize(Realm& realm) define_native_function(realm, vm.names.valueOf, value_of, 0, attr); // 21.2.3.5 BigInt.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-bigint.prototype-@@tostringtag - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, vm.names.BigInt.as_string()), Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.BigInt.as_string()), Attribute::Configurable); } // thisBigIntValue ( value ), https://tc39.es/ecma262/#thisbigintvalue @@ -55,7 +55,7 @@ JS_DEFINE_NATIVE_FUNCTION(BigIntPrototype::to_string) if (radix < 2 || radix > 36) return vm.throw_completion(ErrorType::InvalidRadix); } - return js_string(vm, bigint->big_integer().to_base(radix)); + return PrimitiveString::create(vm, bigint->big_integer().to_base(radix)); } // 21.2.3.2 BigInt.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ), https://tc39.es/ecma262/#sec-bigint.prototype.tolocalestring @@ -75,7 +75,7 @@ JS_DEFINE_NATIVE_FUNCTION(BigIntPrototype::to_locale_string) // 3. Return ? FormatNumeric(numberFormat, x). auto formatted = Intl::format_numeric(vm, *number_format, Value(bigint)); - return js_string(vm, move(formatted)); + return PrimitiveString::create(vm, move(formatted)); } // 21.2.3.4 BigInt.prototype.valueOf ( ), https://tc39.es/ecma262/#sec-bigint.prototype.valueof diff --git a/Userland/Libraries/LibJS/Runtime/BooleanPrototype.cpp b/Userland/Libraries/LibJS/Runtime/BooleanPrototype.cpp index d3dc7036cc0..0a8f85c3a0c 100644 --- a/Userland/Libraries/LibJS/Runtime/BooleanPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/BooleanPrototype.cpp @@ -31,12 +31,12 @@ JS_DEFINE_NATIVE_FUNCTION(BooleanPrototype::to_string) { auto this_value = vm.this_value(); if (this_value.is_boolean()) - return js_string(vm, this_value.as_bool() ? "true" : "false"); + return PrimitiveString::create(vm, this_value.as_bool() ? "true" : "false"); if (!this_value.is_object() || !is(this_value.as_object())) return vm.throw_completion(ErrorType::NotAnObjectOfType, "Boolean"); bool bool_value = static_cast(this_value.as_object()).boolean(); - return js_string(vm, bool_value ? "true" : "false"); + return PrimitiveString::create(vm, bool_value ? "true" : "false"); } // 20.3.3.3 Boolean.prototype.valueOf ( ), https://tc39.es/ecma262/#sec-boolean.prototype.valueof diff --git a/Userland/Libraries/LibJS/Runtime/DataViewPrototype.cpp b/Userland/Libraries/LibJS/Runtime/DataViewPrototype.cpp index a9363d40c36..5fb6cc62f66 100644 --- a/Userland/Libraries/LibJS/Runtime/DataViewPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/DataViewPrototype.cpp @@ -47,7 +47,7 @@ void DataViewPrototype::initialize(Realm& realm) define_native_accessor(realm, vm.names.byteOffset, byte_offset_getter, {}, Attribute::Configurable); // 25.3.4.25 DataView.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-dataview.prototype-@@tostringtag - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, vm.names.DataView.as_string()), Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.DataView.as_string()), Attribute::Configurable); } // 25.3.1.1 GetViewValue ( view, requestIndex, isLittleEndian, type ), https://tc39.es/ecma262/#sec-getviewvalue diff --git a/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp b/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp index 5e5a00a9919..317161df5ba 100644 --- a/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp @@ -202,7 +202,7 @@ ThrowCompletionOr DateConstructor::call() auto now = AK::Time::now_realtime().to_milliseconds(); // b. Return ToDateString(now). - return js_string(vm(), to_date_string(now)); + return PrimitiveString::create(vm(), to_date_string(now)); } // 21.4.2.1 Date ( ...values ), https://tc39.es/ecma262/#sec-date diff --git a/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp b/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp index 5d5decc61dc..1f88678d8bb 100644 --- a/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp @@ -951,11 +951,11 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_date_string) // 3. If tv is NaN, return "Invalid Date". if (isnan(time)) - return js_string(vm, "Invalid Date"sv); + return PrimitiveString::create(vm, "Invalid Date"sv); // 4. Let t be LocalTime(tv). // 5. Return DateString(t). - return js_string(vm, date_string(local_time(time))); + return PrimitiveString::create(vm, date_string(local_time(time))); } // 21.4.4.36 Date.prototype.toISOString ( ), https://tc39.es/ecma262/#sec-date.prototype.toisostring @@ -967,7 +967,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_iso_string) return vm.throw_completion(ErrorType::InvalidTimeValue); auto string = this_object->iso_date_string(); - return js_string(vm, move(string)); + return PrimitiveString::create(vm, move(string)); } // 21.4.4.37 Date.prototype.toJSON ( key ), https://tc39.es/ecma262/#sec-date.prototype.tojson @@ -1002,7 +1002,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_locale_date_string) // 2. If x is NaN, return "Invalid Date". if (isnan(time)) - return js_string(vm, "Invalid Date"sv); + return PrimitiveString::create(vm, "Invalid Date"sv); // 3. Let options be ? ToDateTimeOptions(options, "date", "date"). options = Value(TRY(Intl::to_date_time_options(vm, options, Intl::OptionRequired::Date, Intl::OptionDefaults::Date))); @@ -1012,7 +1012,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_locale_date_string) // 5. Return ? FormatDateTime(dateFormat, x). auto formatted = TRY(Intl::format_date_time(vm, *date_format, time)); - return js_string(vm, move(formatted)); + return PrimitiveString::create(vm, move(formatted)); } // 21.4.4.39 Date.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ), https://tc39.es/ecma262/#sec-date.prototype.tolocalestring @@ -1027,7 +1027,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_locale_string) // 2. If x is NaN, return "Invalid Date". if (isnan(time)) - return js_string(vm, "Invalid Date"sv); + return PrimitiveString::create(vm, "Invalid Date"sv); // 3. Let options be ? ToDateTimeOptions(options, "any", "all"). options = Value(TRY(Intl::to_date_time_options(vm, options, Intl::OptionRequired::Any, Intl::OptionDefaults::All))); @@ -1037,7 +1037,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_locale_string) // 5. Return ? FormatDateTime(dateFormat, x). auto formatted = TRY(Intl::format_date_time(vm, *date_format, time)); - return js_string(vm, move(formatted)); + return PrimitiveString::create(vm, move(formatted)); } // 21.4.4.40 Date.prototype.toLocaleTimeString ( [ reserved1 [ , reserved2 ] ] ), https://tc39.es/ecma262/#sec-date.prototype.tolocaletimestring @@ -1052,7 +1052,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_locale_time_string) // 2. If x is NaN, return "Invalid Date". if (isnan(time)) - return js_string(vm, "Invalid Date"sv); + return PrimitiveString::create(vm, "Invalid Date"sv); // 3. Let options be ? ToDateTimeOptions(options, "time", "time"). options = Value(TRY(Intl::to_date_time_options(vm, options, Intl::OptionRequired::Time, Intl::OptionDefaults::Time))); @@ -1062,7 +1062,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_locale_time_string) // 5. Return ? FormatDateTime(dateFormat, x). auto formatted = TRY(Intl::format_date_time(vm, *time_format, time)); - return js_string(vm, move(formatted)); + return PrimitiveString::create(vm, move(formatted)); } // 21.4.4.41 Date.prototype.toString ( ), https://tc39.es/ecma262/#sec-date.prototype.tostring @@ -1072,7 +1072,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_string) auto time = TRY(this_time_value(vm, vm.this_value())); // 2. Return ToDateString(tv). - return js_string(vm, JS::to_date_string(time)); + return PrimitiveString::create(vm, JS::to_date_string(time)); } // 21.4.4.41.1 TimeString ( tv ), https://tc39.es/ecma262/#sec-timestring @@ -1209,12 +1209,12 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_time_string) // 3. If tv is NaN, return "Invalid Date". if (isnan(time)) - return js_string(vm, "Invalid Date"sv); + return PrimitiveString::create(vm, "Invalid Date"sv); // 4. Let t be LocalTime(tv). // 5. Return the string-concatenation of TimeString(t) and TimeZoneString(tv). auto string = DeprecatedString::formatted("{}{}", time_string(local_time(time)), time_zone_string(time)); - return js_string(vm, move(string)); + return PrimitiveString::create(vm, move(string)); } // 21.4.4.43 Date.prototype.toUTCString ( ), https://tc39.es/ecma262/#sec-date.prototype.toutcstring @@ -1226,7 +1226,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_utc_string) // 3. If tv is NaN, return "Invalid Date". if (isnan(time)) - return js_string(vm, "Invalid Date"sv); + return PrimitiveString::create(vm, "Invalid Date"sv); // 4. Let weekday be the Name of the entry in Table 62 with the Number WeekDay(tv). auto weekday = short_day_names[week_day(time)]; @@ -1246,7 +1246,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_utc_string) // 9. Let paddedYear be ToZeroPaddedDecimalString(abs(ℝ(yv)), 4). // 10. Return the string-concatenation of weekday, ",", the code unit 0x0020 (SPACE), day, the code unit 0x0020 (SPACE), month, the code unit 0x0020 (SPACE), yearSign, paddedYear, the code unit 0x0020 (SPACE), and TimeString(tv). auto string = DeprecatedString::formatted("{}, {:02} {} {}{:04} {}", weekday, day, month, year_sign, abs(year), time_string(time)); - return js_string(vm, move(string)); + return PrimitiveString::create(vm, move(string)); } // 21.4.4.45 Date.prototype [ @@toPrimitive ] ( hint ), https://tc39.es/ecma262/#sec-date.prototype-@@toprimitive diff --git a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp index cee4d0a1a93..f0ba8470ca0 100644 --- a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp @@ -108,7 +108,7 @@ void ECMAScriptFunctionObject::initialize(Realm& realm) // are defined in the spec. MUST(define_property_or_throw(vm.names.length, { .value = Value(m_function_length), .writable = false, .enumerable = false, .configurable = true })); - MUST(define_property_or_throw(vm.names.name, { .value = js_string(vm, m_name.is_null() ? "" : m_name), .writable = false, .enumerable = false, .configurable = true })); + MUST(define_property_or_throw(vm.names.name, { .value = PrimitiveString::create(vm, m_name.is_null() ? "" : m_name), .writable = false, .enumerable = false, .configurable = true })); if (!m_is_arrow_function) { Object* prototype = nullptr; @@ -911,7 +911,7 @@ void ECMAScriptFunctionObject::set_name(FlyString const& name) VERIFY(!name.is_null()); auto& vm = this->vm(); m_name = name; - MUST(define_property_or_throw(vm.names.name, { .value = js_string(vm, m_name), .writable = false, .enumerable = false, .configurable = true })); + MUST(define_property_or_throw(vm.names.name, { .value = PrimitiveString::create(vm, m_name), .writable = false, .enumerable = false, .configurable = true })); } } diff --git a/Userland/Libraries/LibJS/Runtime/Error.cpp b/Userland/Libraries/LibJS/Runtime/Error.cpp index c8babe021c5..2579c357401 100644 --- a/Userland/Libraries/LibJS/Runtime/Error.cpp +++ b/Userland/Libraries/LibJS/Runtime/Error.cpp @@ -24,7 +24,7 @@ Error* Error::create(Realm& realm, DeprecatedString const& message) auto& vm = realm.vm(); auto* error = Error::create(realm); u8 attr = Attribute::Writable | Attribute::Configurable; - error->define_direct_property(vm.names.message, js_string(vm, message), attr); + error->define_direct_property(vm.names.message, PrimitiveString::create(vm, message), attr); return error; } @@ -109,7 +109,7 @@ DeprecatedString Error::stack_string() const auto& vm = realm.vm(); \ auto* error = ClassName::create(realm); \ u8 attr = Attribute::Writable | Attribute::Configurable; \ - error->define_direct_property(vm.names.message, js_string(vm, message), attr); \ + error->define_direct_property(vm.names.message, PrimitiveString::create(vm, message), attr); \ return error; \ } \ \ diff --git a/Userland/Libraries/LibJS/Runtime/ErrorConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ErrorConstructor.cpp index bdbf0f86b51..a3a085b137a 100644 --- a/Userland/Libraries/LibJS/Runtime/ErrorConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/ErrorConstructor.cpp @@ -51,7 +51,7 @@ ThrowCompletionOr ErrorConstructor::construct(FunctionObject& new_targe auto msg = TRY(message.to_string(vm)); // b. Perform CreateNonEnumerableDataPropertyOrThrow(O, "message", msg). - error->create_non_enumerable_data_property_or_throw(vm.names.message, js_string(vm, move(msg))); + error->create_non_enumerable_data_property_or_throw(vm.names.message, PrimitiveString::create(vm, move(msg))); } // 4. Perform ? InstallErrorCause(O, options). @@ -104,7 +104,7 @@ ThrowCompletionOr ErrorConstructor::construct(FunctionObject& new_targe auto msg = TRY(message.to_string(vm)); \ \ /* b. Perform CreateNonEnumerableDataPropertyOrThrow(O, "message", msg). */ \ - error->create_non_enumerable_data_property_or_throw(vm.names.message, js_string(vm, move(msg))); \ + error->create_non_enumerable_data_property_or_throw(vm.names.message, PrimitiveString::create(vm, move(msg))); \ } \ \ /* 4. Perform ? InstallErrorCause(O, options). */ \ diff --git a/Userland/Libraries/LibJS/Runtime/ErrorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ErrorPrototype.cpp index 72976c058a7..206e721b266 100644 --- a/Userland/Libraries/LibJS/Runtime/ErrorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/ErrorPrototype.cpp @@ -24,8 +24,8 @@ void ErrorPrototype::initialize(Realm& realm) auto& vm = this->vm(); Object::initialize(realm); u8 attr = Attribute::Writable | Attribute::Configurable; - define_direct_property(vm.names.name, js_string(vm, "Error"), attr); - define_direct_property(vm.names.message, js_string(vm, ""), attr); + define_direct_property(vm.names.name, PrimitiveString::create(vm, "Error"), attr); + define_direct_property(vm.names.message, PrimitiveString::create(vm, ""), 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 @@ -58,14 +58,14 @@ JS_DEFINE_NATIVE_FUNCTION(ErrorPrototype::to_string) // 7. If name is the empty String, return msg. if (name.is_empty()) - return js_string(vm, message); + return PrimitiveString::create(vm, message); // 8. If msg is the empty String, return name. if (message.is_empty()) - return js_string(vm, name); + return PrimitiveString::create(vm, name); // 9. Return the string-concatenation of name, the code unit 0x003A (COLON), the code unit 0x0020 (SPACE), and msg. - return js_string(vm, DeprecatedString::formatted("{}: {}", name, message)); + return PrimitiveString::create(vm, DeprecatedString::formatted("{}: {}", name, message)); } // B.1.1 get Error.prototype.stack ( ), https://tc39.es/proposal-error-stacks/#sec-get-error.prototype-stack @@ -98,7 +98,7 @@ JS_DEFINE_NATIVE_FUNCTION(ErrorPrototype::stack_getter) if (!message.is_empty()) header = DeprecatedString::formatted("{}: {}", name, message); - return js_string(vm, DeprecatedString::formatted("{}\n{}", header, error.stack_string())); + return PrimitiveString::create(vm, DeprecatedString::formatted("{}\n{}", header, error.stack_string())); } // B.1.2 set Error.prototype.stack ( value ), https://tc39.es/proposal-error-stacks/#sec-set-error.prototype-stack @@ -122,19 +122,19 @@ 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()) \ - { \ - } \ - \ - void PrototypeName::initialize(Realm& realm) \ - { \ - auto& vm = this->vm(); \ - Object::initialize(realm); \ - u8 attr = Attribute::Writable | Attribute::Configurable; \ - define_direct_property(vm.names.name, js_string(vm, #ClassName), attr); \ - define_direct_property(vm.names.message, js_string(vm, ""), attr); \ +#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \ + PrototypeName::PrototypeName(Realm& realm) \ + : PrototypeObject(*realm.intrinsics().error_prototype()) \ + { \ + } \ + \ + void PrototypeName::initialize(Realm& realm) \ + { \ + auto& vm = this->vm(); \ + Object::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); \ } JS_ENUMERATE_NATIVE_ERRORS diff --git a/Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.cpp b/Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.cpp index ee1b76ceb66..03ad9f4bbdf 100644 --- a/Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.cpp @@ -26,7 +26,7 @@ void FinalizationRegistryPrototype::initialize(Realm& realm) define_native_function(realm, vm.names.unregister, unregister, 1, attr); // 26.2.3.4 FinalizationRegistry.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-finalization-registry.prototype-@@tostringtag - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, vm.names.FinalizationRegistry.as_string()), Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.FinalizationRegistry.as_string()), Attribute::Configurable); } // @STAGE 2@ FinalizationRegistry.prototype.cleanupSome ( [ callback ] ), https://github.com/tc39/proposal-cleanup-some/blob/master/spec/finalization-registry.html diff --git a/Userland/Libraries/LibJS/Runtime/FunctionConstructor.cpp b/Userland/Libraries/LibJS/Runtime/FunctionConstructor.cpp index c3afc3947d3..147b46833fe 100644 --- a/Userland/Libraries/LibJS/Runtime/FunctionConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/FunctionConstructor.cpp @@ -119,7 +119,7 @@ ThrowCompletionOr FunctionConstructor::create_dynamic // 10. If argCount = 0, let bodyArg be the empty String. if (arg_count == 0) { - // Optimization: Instead of creating a js_string() here, we just check if body_arg is empty in step 16. + // Optimization: Instead of creating a PrimitiveString here, we just check if body_arg is empty in step 16. } // 11. Else if argCount = 1, let bodyArg be args[0]. else if (arg_count == 1) { diff --git a/Userland/Libraries/LibJS/Runtime/FunctionObject.cpp b/Userland/Libraries/LibJS/Runtime/FunctionObject.cpp index 38eea536c2a..1552634b766 100644 --- a/Userland/Libraries/LibJS/Runtime/FunctionObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/FunctionObject.cpp @@ -75,7 +75,7 @@ void FunctionObject::set_function_name(Variant const& } // 6. Perform ! DefinePropertyOrThrow(F, "name", PropertyDescriptor { [[Value]]: name, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }). - MUST(define_property_or_throw(vm.names.name, PropertyDescriptor { .value = js_string(vm, move(name)), .writable = false, .enumerable = false, .configurable = true })); + MUST(define_property_or_throw(vm.names.name, PropertyDescriptor { .value = PrimitiveString::create(vm, move(name)), .writable = false, .enumerable = false, .configurable = true })); // 7. Return unused. } diff --git a/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp b/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp index 693c264f50a..bb2f1f50131 100644 --- a/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp @@ -36,7 +36,7 @@ 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, js_string(heap(), ""), Attribute::Configurable); + define_direct_property(vm.names.name, PrimitiveString::create(vm, ""), Attribute::Configurable); } ThrowCompletionOr FunctionPrototype::internal_call(Value, MarkedVector) @@ -156,7 +156,7 @@ JS_DEFINE_NATIVE_FUNCTION(FunctionPrototype::to_string) // 2. If Type(func) is Object and func has a [[SourceText]] internal slot and func.[[SourceText]] is a sequence of Unicode code points and HostHasSourceTextAvailable(func) is true, then if (is(function)) { // a. Return CodePointsToString(func.[[SourceText]]). - return js_string(vm, static_cast(function).source_text()); + return PrimitiveString::create(vm, static_cast(function).source_text()); } // 3. If func is a built-in function object, return an implementation-defined String source code representation of func. The representation must have the syntax of a NativeFunction. Additionally, if func has an [[InitialName]] internal slot and func.[[InitialName]] is a String, the portion of the returned String that would be matched by NativeFunctionAccessor[opt] PropertyName must be the value of func.[[InitialName]]. @@ -164,12 +164,12 @@ JS_DEFINE_NATIVE_FUNCTION(FunctionPrototype::to_string) // NOTE: once we remove name(), the fallback here can simply be an empty string. auto const& native_function = static_cast(function); auto const name = native_function.initial_name().value_or(native_function.name()); - return js_string(vm, DeprecatedString::formatted("function {}() {{ [native code] }}", name)); + return PrimitiveString::create(vm, DeprecatedString::formatted("function {}() {{ [native code] }}", name)); } // 4. If Type(func) is Object and IsCallable(func) is true, return an implementation-defined String source code representation of func. The representation must have the syntax of a NativeFunction. // NOTE: ProxyObject, BoundFunction, WrappedFunction - return js_string(vm, "function () { [native code] }"); + return PrimitiveString::create(vm, "function () { [native code] }"); } // 20.2.3.6 Function.prototype [ @@hasInstance ] ( V ), https://tc39.es/ecma262/#sec-function.prototype-@@hasinstance diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorFunctionPrototype.cpp b/Userland/Libraries/LibJS/Runtime/GeneratorFunctionPrototype.cpp index 62e39cbf08a..3343ca3ad2e 100644 --- a/Userland/Libraries/LibJS/Runtime/GeneratorFunctionPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/GeneratorFunctionPrototype.cpp @@ -23,7 +23,7 @@ void GeneratorFunctionPrototype::initialize(Realm& realm) // 27.3.3.2 GeneratorFunction.prototype.prototype, https://tc39.es/ecma262/#sec-generatorfunction.prototype.prototype define_direct_property(vm.names.prototype, realm.intrinsics().generator_prototype(), Attribute::Configurable); // 27.3.3.3 GeneratorFunction.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-generatorfunction.prototype-@@tostringtag - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "GeneratorFunction"), Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "GeneratorFunction"), Attribute::Configurable); } } diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/GeneratorPrototype.cpp index 52ed3452008..ebfc3d21c1b 100644 --- a/Userland/Libraries/LibJS/Runtime/GeneratorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/GeneratorPrototype.cpp @@ -24,7 +24,7 @@ void GeneratorPrototype::initialize(Realm& realm) define_native_function(realm, vm.names.throw_, throw_, 1, attr); // 27.5.1.5 Generator.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-generator.prototype-@@tostringtag - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Generator"), Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Generator"), Attribute::Configurable); } // 27.5.1.2 Generator.prototype.next ( value ), https://tc39.es/ecma262/#sec-generator.prototype.next diff --git a/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp b/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp index b482b34dbf6..952a450de45 100644 --- a/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp @@ -226,7 +226,7 @@ JS_DEFINE_NATIVE_FUNCTION(GlobalObject::parse_float) if (vm.argument(0).is_number()) return vm.argument(0); auto input_string = TRY(vm.argument(0).to_string(vm)); - auto trimmed_string = MUST(trim_string(vm, js_string(vm, input_string), TrimMode::Left)); + auto trimmed_string = MUST(trim_string(vm, PrimitiveString::create(vm, input_string), TrimMode::Left)); if (trimmed_string.is_empty()) return js_nan(); @@ -253,7 +253,7 @@ JS_DEFINE_NATIVE_FUNCTION(GlobalObject::parse_int) auto input_string = TRY(vm.argument(0).to_string(vm)); // 2. Let S be ! TrimString(inputString, start). - auto string = MUST(trim_string(vm, js_string(vm, input_string), TrimMode::Left)); + auto string = MUST(trim_string(vm, PrimitiveString::create(vm, input_string), TrimMode::Left)); // 3. Let sign be 1. auto sign = 1; @@ -458,7 +458,7 @@ JS_DEFINE_NATIVE_FUNCTION(GlobalObject::encode_uri) { auto uri_string = TRY(vm.argument(0).to_string(vm)); auto encoded = TRY(encode(vm, uri_string, ";/?:@&=+$,abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.!~*'()#"sv)); - return js_string(vm, move(encoded)); + return PrimitiveString::create(vm, move(encoded)); } // 19.2.6.2 decodeURI ( encodedURI ), https://tc39.es/ecma262/#sec-decodeuri-encodeduri @@ -466,7 +466,7 @@ JS_DEFINE_NATIVE_FUNCTION(GlobalObject::decode_uri) { auto uri_string = TRY(vm.argument(0).to_string(vm)); auto decoded = TRY(decode(vm, uri_string, ";/?:@&=+$,#"sv)); - return js_string(vm, move(decoded)); + return PrimitiveString::create(vm, move(decoded)); } // 19.2.6.5 encodeURIComponent ( uriComponent ), https://tc39.es/ecma262/#sec-encodeuricomponent-uricomponent @@ -474,7 +474,7 @@ JS_DEFINE_NATIVE_FUNCTION(GlobalObject::encode_uri_component) { auto uri_string = TRY(vm.argument(0).to_string(vm)); auto encoded = TRY(encode(vm, uri_string, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.!~*'()"sv)); - return js_string(vm, move(encoded)); + return PrimitiveString::create(vm, move(encoded)); } // 19.2.6.3 decodeURIComponent ( encodedURIComponent ), https://tc39.es/ecma262/#sec-decodeuricomponent-encodeduricomponent @@ -482,7 +482,7 @@ JS_DEFINE_NATIVE_FUNCTION(GlobalObject::decode_uri_component) { auto uri_string = TRY(vm.argument(0).to_string(vm)); auto decoded = TRY(decode(vm, uri_string, ""sv)); - return js_string(vm, move(decoded)); + return PrimitiveString::create(vm, move(decoded)); } // B.2.1.1 escape ( string ), https://tc39.es/ecma262/#sec-escape-string @@ -500,7 +500,7 @@ JS_DEFINE_NATIVE_FUNCTION(GlobalObject::escape) } escaped.appendff("%u{:04X}", code_point); } - return js_string(vm, escaped.build()); + return PrimitiveString::create(vm, escaped.build()); } // B.2.1.2 unescape ( string ), https://tc39.es/ecma262/#sec-unescape-string @@ -522,7 +522,7 @@ JS_DEFINE_NATIVE_FUNCTION(GlobalObject::unescape) } unescaped.append_code_point(code_point); } - return js_string(vm, unescaped.build()); + return PrimitiveString::create(vm, unescaped.build()); } } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.cpp b/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.cpp index c418d1215c2..0d635f20c66 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.cpp @@ -589,7 +589,7 @@ ThrowCompletionOr supported_locales(VM& vm, Vector con } // 5. Return CreateArrayFromList(supportedLocales). - return Array::create_from(realm, supported_locales, [&vm](auto& locale) { return js_string(vm, locale); }); + return Array::create_from(realm, supported_locales, [&vm](auto& locale) { return PrimitiveString::create(vm, locale); }); } // 9.2.12 CoerceOptionsToObject ( options ), https://tc39.es/ecma402/#sec-coerceoptionstoobject diff --git a/Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.cpp b/Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.cpp index 771f2104f66..ce9d77b282e 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.cpp +++ b/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, js_string(vm, DeprecatedString::empty()), Attribute::Configurable); + define_direct_property(vm.names.name, PrimitiveString::create(vm, DeprecatedString::empty()), Attribute::Configurable); } // 10.3.3.2 CompareStrings ( collator, x, y ), https://tc39.es/ecma402/#sec-collator-comparestrings diff --git a/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.cpp index 9240f0e8fa5..022c8bceb12 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.cpp @@ -88,7 +88,7 @@ static ThrowCompletionOr initialize_collator(VM& vm, Collator& collat // 24. If relevantExtensionKeys contains "kn", then if (relevant_extension_keys.span().contains_slow("kn"sv) && result.kn.has_value()) { // a. Set collator.[[Numeric]] to SameValue(r.[[kn]], "true"). - collator.set_numeric(same_value(js_string(vm, result.kn.release_value()), js_string(vm, "true"sv))); + collator.set_numeric(same_value(PrimitiveString::create(vm, result.kn.release_value()), PrimitiveString::create(vm, "true"sv))); } // 25. If relevantExtensionKeys contains "kf", then @@ -105,14 +105,14 @@ static ThrowCompletionOr initialize_collator(VM& vm, Collator& collat // a. If usage is "sort", then if (collator.usage() == Collator::Usage::Sort) { // i. Let sensitivity be "variant". - sensitivity = js_string(vm, "variant"sv); + sensitivity = PrimitiveString::create(vm, "variant"sv); } // b. Else, else { // i. Let dataLocale be r.[[dataLocale]]. // ii. Let dataLocaleData be localeData.[[]]. // iii. Let sensitivity be dataLocaleData.[[sensitivity]]. - sensitivity = js_string(vm, "base"sv); + sensitivity = PrimitiveString::create(vm, "base"sv); } } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/CollatorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/CollatorPrototype.cpp index 78c65fd1f9a..b098839f2a0 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/CollatorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/CollatorPrototype.cpp @@ -24,7 +24,7 @@ void CollatorPrototype::initialize(Realm& realm) auto& vm = this->vm(); // 10.3.2 Intl.Collator.prototype [ @@toStringTag ], https://tc39.es/ecma402/#sec-intl.collator.prototype-@@tostringtag - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Intl.Collator"), Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Intl.Collator"), Attribute::Configurable); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_accessor(realm, vm.names.compare, compare_getter, {}, attr); @@ -75,13 +75,13 @@ JS_DEFINE_NATIVE_FUNCTION(CollatorPrototype::resolved_options) // 1. Let v be undefined. // d. If v is not undefined, then // i. Perform ! CreateDataPropertyOrThrow(options, p, v). - MUST(options->create_data_property_or_throw(vm.names.locale, js_string(vm, collator->locale()))); - MUST(options->create_data_property_or_throw(vm.names.usage, js_string(vm, collator->usage_string()))); - MUST(options->create_data_property_or_throw(vm.names.sensitivity, js_string(vm, collator->sensitivity_string()))); + MUST(options->create_data_property_or_throw(vm.names.locale, PrimitiveString::create(vm, collator->locale()))); + MUST(options->create_data_property_or_throw(vm.names.usage, PrimitiveString::create(vm, collator->usage_string()))); + MUST(options->create_data_property_or_throw(vm.names.sensitivity, PrimitiveString::create(vm, collator->sensitivity_string()))); MUST(options->create_data_property_or_throw(vm.names.ignorePunctuation, Value(collator->ignore_punctuation()))); - MUST(options->create_data_property_or_throw(vm.names.collation, js_string(vm, collator->collation()))); + MUST(options->create_data_property_or_throw(vm.names.collation, PrimitiveString::create(vm, collator->collation()))); MUST(options->create_data_property_or_throw(vm.names.numeric, Value(collator->numeric()))); - MUST(options->create_data_property_or_throw(vm.names.caseFirst, js_string(vm, collator->case_first_string()))); + MUST(options->create_data_property_or_throw(vm.names.caseFirst, PrimitiveString::create(vm, collator->case_first_string()))); // 5. Return options. return options; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.cpp index 99c457e8cfd..82bdc14222f 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.cpp @@ -135,7 +135,7 @@ ThrowCompletionOr to_date_time_options(VM& vm, Value options_value, Opt // a. For each property name prop of « "year", "month", "day" », do for (auto const& property : AK::Array { vm.names.year, vm.names.month, vm.names.day }) { // i. Perform ? CreateDataPropertyOrThrow(options, prop, "numeric"). - TRY(options->create_data_property_or_throw(property, js_string(vm, "numeric"sv))); + TRY(options->create_data_property_or_throw(property, PrimitiveString::create(vm, "numeric"sv))); } } @@ -144,7 +144,7 @@ ThrowCompletionOr to_date_time_options(VM& vm, Value options_value, Opt // a. For each property name prop of « "hour", "minute", "second" », do for (auto const& property : AK::Array { vm.names.hour, vm.names.minute, vm.names.second }) { // i. Perform ? CreateDataPropertyOrThrow(options, prop, "numeric"). - TRY(options->create_data_property_or_throw(property, js_string(vm, "numeric"sv))); + TRY(options->create_data_property_or_throw(property, PrimitiveString::create(vm, "numeric"sv))); } } @@ -548,7 +548,7 @@ ThrowCompletionOr> format_date_time_pattern(VM& vm, Dat auto const& data_locale = date_time_format.data_locale(); auto construct_number_format = [&](auto* options) -> ThrowCompletionOr { - auto* number_format = TRY(construct(vm, *realm.intrinsics().intl_number_format_constructor(), js_string(vm, locale), options)); + auto* number_format = TRY(construct(vm, *realm.intrinsics().intl_number_format_constructor(), PrimitiveString::create(vm, locale), options)); return static_cast(number_format); }; @@ -868,10 +868,10 @@ ThrowCompletionOr format_date_time_to_parts(VM& vm, DateTimeFormat& date auto* object = Object::create(realm, realm.intrinsics().object_prototype()); // b. Perform ! CreateDataPropertyOrThrow(O, "type", part.[[Type]]). - MUST(object->create_data_property_or_throw(vm.names.type, js_string(vm, part.type))); + MUST(object->create_data_property_or_throw(vm.names.type, PrimitiveString::create(vm, part.type))); // c. Perform ! CreateDataPropertyOrThrow(O, "value", part.[[Value]]). - MUST(object->create_data_property_or_throw(vm.names.value, js_string(vm, move(part.value)))); + MUST(object->create_data_property_or_throw(vm.names.value, PrimitiveString::create(vm, move(part.value)))); // d. Perform ! CreateDataProperty(result, ! ToString(n), O). MUST(result->create_data_property_or_throw(n, object)); @@ -1184,13 +1184,13 @@ ThrowCompletionOr format_date_time_range_to_parts(VM& vm, DateTimeFormat auto* object = Object::create(realm, realm.intrinsics().object_prototype()); // b. Perform ! CreateDataPropertyOrThrow(O, "type", part.[[Type]]). - MUST(object->create_data_property_or_throw(vm.names.type, js_string(vm, part.type))); + MUST(object->create_data_property_or_throw(vm.names.type, PrimitiveString::create(vm, part.type))); // c. Perform ! CreateDataPropertyOrThrow(O, "value", part.[[Value]]). - MUST(object->create_data_property_or_throw(vm.names.value, js_string(vm, move(part.value)))); + MUST(object->create_data_property_or_throw(vm.names.value, PrimitiveString::create(vm, move(part.value)))); // d. Perform ! CreateDataPropertyOrThrow(O, "source", part.[[Source]]). - MUST(object->create_data_property_or_throw(vm.names.source, js_string(vm, part.source))); + MUST(object->create_data_property_or_throw(vm.names.source, PrimitiveString::create(vm, part.source))); // e. Perform ! CreateDataProperty(result, ! ToString(n), O). MUST(result->create_data_property_or_throw(n, object)); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatFunction.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatFunction.cpp index 09587a72c11..9408a7904d7 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatFunction.cpp +++ b/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, js_string(vm, DeprecatedString::empty()), Attribute::Configurable); + define_direct_property(vm.names.name, PrimitiveString::create(vm, DeprecatedString::empty()), Attribute::Configurable); } ThrowCompletionOr DateTimeFormatFunction::call() @@ -59,7 +59,7 @@ ThrowCompletionOr DateTimeFormatFunction::call() // 5. Return ? FormatDateTime(dtf, x). auto formatted = TRY(format_date_time(vm, m_date_time_format, date_value)); - return js_string(vm, move(formatted)); + return PrimitiveString::create(vm, move(formatted)); } void DateTimeFormatFunction::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatPrototype.cpp index 4afb1192f60..2e6b99c5da4 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatPrototype.cpp @@ -26,7 +26,7 @@ void DateTimeFormatPrototype::initialize(Realm& realm) auto& vm = this->vm(); // 11.3.2 Intl.DateTimeFormat.prototype [ @@toStringTag ], https://tc39.es/ecma402/#sec-intl.datetimeformat.prototype-@@tostringtag - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Intl.DateTimeFormat"), Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Intl.DateTimeFormat"), Attribute::Configurable); define_native_accessor(realm, vm.names.format, format, nullptr, Attribute::Configurable); @@ -114,7 +114,7 @@ JS_DEFINE_NATIVE_FUNCTION(DateTimeFormatPrototype::format_range) // 6. Return ? FormatDateTimeRange(dtf, x, y). auto formatted = TRY(format_date_time_range(vm, *date_time_format, start_date_number, end_date_number)); - return js_string(vm, move(formatted)); + return PrimitiveString::create(vm, move(formatted)); } // 11.3.6 Intl.DateTimeFormat.prototype.formatRangeToParts ( startDate, endDate ), https://tc39.es/ecma402/#sec-Intl.DateTimeFormat.prototype.formatRangeToParts @@ -171,13 +171,13 @@ JS_DEFINE_NATIVE_FUNCTION(DateTimeFormatPrototype::resolved_options) // 1. Let v be undefined. // e. If v is not undefined, then // i. Perform ! CreateDataPropertyOrThrow(options, p, v). - MUST(options->create_data_property_or_throw(vm.names.locale, js_string(vm, date_time_format->locale()))); - MUST(options->create_data_property_or_throw(vm.names.calendar, js_string(vm, date_time_format->calendar()))); - MUST(options->create_data_property_or_throw(vm.names.numberingSystem, js_string(vm, date_time_format->numbering_system()))); - MUST(options->create_data_property_or_throw(vm.names.timeZone, js_string(vm, date_time_format->time_zone()))); + MUST(options->create_data_property_or_throw(vm.names.locale, PrimitiveString::create(vm, date_time_format->locale()))); + MUST(options->create_data_property_or_throw(vm.names.calendar, PrimitiveString::create(vm, date_time_format->calendar()))); + MUST(options->create_data_property_or_throw(vm.names.numberingSystem, PrimitiveString::create(vm, date_time_format->numbering_system()))); + MUST(options->create_data_property_or_throw(vm.names.timeZone, PrimitiveString::create(vm, date_time_format->time_zone()))); if (date_time_format->has_hour_cycle()) { - MUST(options->create_data_property_or_throw(vm.names.hourCycle, js_string(vm, date_time_format->hour_cycle_string()))); + MUST(options->create_data_property_or_throw(vm.names.hourCycle, PrimitiveString::create(vm, date_time_format->hour_cycle_string()))); switch (date_time_format->hour_cycle()) { case ::Locale::HourCycle::H11: @@ -202,7 +202,7 @@ JS_DEFINE_NATIVE_FUNCTION(DateTimeFormatPrototype::resolved_options) TRY(options->create_data_property_or_throw(property, Value(*option))); } else { auto name = ::Locale::calendar_pattern_style_to_string(*option); - TRY(options->create_data_property_or_throw(property, js_string(vm, name))); + TRY(options->create_data_property_or_throw(property, PrimitiveString::create(vm, name))); } return {}; @@ -210,9 +210,9 @@ JS_DEFINE_NATIVE_FUNCTION(DateTimeFormatPrototype::resolved_options) } if (date_time_format->has_date_style()) - MUST(options->create_data_property_or_throw(vm.names.dateStyle, js_string(vm, date_time_format->date_style_string()))); + MUST(options->create_data_property_or_throw(vm.names.dateStyle, PrimitiveString::create(vm, date_time_format->date_style_string()))); if (date_time_format->has_time_style()) - MUST(options->create_data_property_or_throw(vm.names.timeStyle, js_string(vm, date_time_format->time_style_string()))); + MUST(options->create_data_property_or_throw(vm.names.timeStyle, PrimitiveString::create(vm, date_time_format->time_style_string()))); // 6. Return options. return options; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNames.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNames.cpp index e2a2b875f82..3d5358d1aee 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNames.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNames.cpp @@ -116,7 +116,7 @@ ThrowCompletionOr canonical_code_for_display_names(VM& vm, DisplayNames:: // c. Return ! CanonicalizeUnicodeLocaleId(code). auto canonicalized_tag = JS::Intl::canonicalize_unicode_locale_id(*locale_id); - return js_string(vm, move(canonicalized_tag)); + return PrimitiveString::create(vm, move(canonicalized_tag)); } // 2. If type is "region", then @@ -126,7 +126,7 @@ ThrowCompletionOr canonical_code_for_display_names(VM& vm, DisplayNames:: return vm.throw_completion(ErrorType::OptionIsNotValidValue, code, "region"sv); // b. Return the ASCII-uppercase of code. - return js_string(vm, code.to_uppercase_string()); + return PrimitiveString::create(vm, code.to_uppercase_string()); } // 3. If type is "script", then @@ -142,7 +142,7 @@ ThrowCompletionOr canonical_code_for_display_names(VM& vm, DisplayNames:: // c. Let first be the ASCII-uppercase of the substring of code from 0 to 1. // d. Let rest be the ASCII-lowercase of the substring of code from 1. // e. Return the string-concatenation of first and rest. - return js_string(vm, code.to_titlecase_string()); + return PrimitiveString::create(vm, code.to_titlecase_string()); } // 4. If type is "calendar", then @@ -156,7 +156,7 @@ ThrowCompletionOr canonical_code_for_display_names(VM& vm, DisplayNames:: return vm.throw_completion(ErrorType::OptionIsNotValidValue, code, "calendar"sv); // c. Return the ASCII-lowercase of code. - return js_string(vm, code.to_lowercase_string()); + return PrimitiveString::create(vm, code.to_lowercase_string()); } // 5. If type is "dateTimeField", then @@ -166,7 +166,7 @@ ThrowCompletionOr canonical_code_for_display_names(VM& vm, DisplayNames:: return vm.throw_completion(ErrorType::OptionIsNotValidValue, code, "dateTimeField"sv); // b. Return code. - return js_string(vm, code); + return PrimitiveString::create(vm, code); } // 6. Assert: type is "currency". @@ -177,7 +177,7 @@ ThrowCompletionOr canonical_code_for_display_names(VM& vm, DisplayNames:: return vm.throw_completion(ErrorType::OptionIsNotValidValue, code, "currency"sv); // 8. Return the ASCII-uppercase of code. - return js_string(vm, code.to_uppercase_string()); + return PrimitiveString::create(vm, code.to_uppercase_string()); } // 12.5.2 IsValidDateTimeFieldCode ( field ), https://tc39.es/ecma402/#sec-isvaliddatetimefieldcode diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp index a0fd0bf7afe..8b440813964 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp @@ -26,7 +26,7 @@ void DisplayNamesPrototype::initialize(Realm& realm) auto& vm = this->vm(); // 12.3.2 Intl.DisplayNames.prototype[ @@toStringTag ], https://tc39.es/ecma402/#sec-Intl.DisplayNames.prototype-@@tostringtag - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Intl.DisplayNames"), Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Intl.DisplayNames"), Attribute::Configurable); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.names.of, of, 1, attr); @@ -44,7 +44,7 @@ JS_DEFINE_NATIVE_FUNCTION(DisplayNamesPrototype::of) // 3. Let code be ? ToString(code). auto code_string = TRY(code.to_string(vm)); - code = js_string(vm, move(code_string)); + code = PrimitiveString::create(vm, move(code_string)); // 4. Let code be ? CanonicalCodeForDisplayNames(displayNames.[[Type]], code). code = TRY(canonical_code_for_display_names(vm, display_names->type(), code.as_string().deprecated_string())); @@ -109,9 +109,9 @@ JS_DEFINE_NATIVE_FUNCTION(DisplayNamesPrototype::of) } if (result.has_value()) - return js_string(vm, result.release_value()); + return PrimitiveString::create(vm, result.release_value()); if (formatted_result.has_value()) - return js_string(vm, formatted_result.release_value()); + return PrimitiveString::create(vm, formatted_result.release_value()); // 7. If displayNames.[[Fallback]] is "code", return code. if (display_names->fallback() == DisplayNames::Fallback::Code) @@ -138,14 +138,14 @@ JS_DEFINE_NATIVE_FUNCTION(DisplayNamesPrototype::resolved_options) // b. Let v be the value of displayNames's internal slot whose name is the Internal Slot value of the current row. // c. Assert: v is not undefined. // d. Perform ! CreateDataPropertyOrThrow(options, p, v). - MUST(options->create_data_property_or_throw(vm.names.locale, js_string(vm, display_names->locale()))); - MUST(options->create_data_property_or_throw(vm.names.style, js_string(vm, display_names->style_string()))); - MUST(options->create_data_property_or_throw(vm.names.type, js_string(vm, display_names->type_string()))); - MUST(options->create_data_property_or_throw(vm.names.fallback, js_string(vm, display_names->fallback_string()))); + MUST(options->create_data_property_or_throw(vm.names.locale, PrimitiveString::create(vm, display_names->locale()))); + MUST(options->create_data_property_or_throw(vm.names.style, PrimitiveString::create(vm, display_names->style_string()))); + MUST(options->create_data_property_or_throw(vm.names.type, PrimitiveString::create(vm, display_names->type_string()))); + MUST(options->create_data_property_or_throw(vm.names.fallback, PrimitiveString::create(vm, display_names->fallback_string()))); // NOTE: Step 4c indicates languageDisplay must not be undefined, but it is only set when the type option is language. if (display_names->has_language_display()) - MUST(options->create_data_property_or_throw(vm.names.languageDisplay, js_string(vm, display_names->language_display_string()))); + MUST(options->create_data_property_or_throw(vm.names.languageDisplay, PrimitiveString::create(vm, display_names->language_display_string()))); // 5. Return options. return options; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp index ce8b24b665c..11a9c61281a 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp @@ -401,7 +401,7 @@ Vector partition_duration_format_pattern(VM& vm, DurationForma // i. If style is "2-digit" or "numeric", then if (style == DurationFormat::ValueStyle::TwoDigit || style == DurationFormat::ValueStyle::Numeric) { // 1. Let nf be ! Construct(%NumberFormat%, « durationFormat.[[Locale]], nfOpts »). - auto* number_format = static_cast(MUST(construct(vm, *realm.intrinsics().intl_number_format_constructor(), js_string(vm, duration_format.locale()), number_format_options))); + auto* number_format = static_cast(MUST(construct(vm, *realm.intrinsics().intl_number_format_constructor(), PrimitiveString::create(vm, duration_format.locale()), number_format_options))); // 2. Let dataLocale be durationFormat.[[DataLocale]]. auto const& data_locale = duration_format.data_locale(); @@ -455,17 +455,17 @@ Vector partition_duration_format_pattern(VM& vm, DurationForma // ii. Else, else { // 1. Perform ! CreateDataPropertyOrThrow(nfOpts, "style", "unit"). - MUST(number_format_options->create_data_property_or_throw(vm.names.style, js_string(vm, "unit"sv))); + MUST(number_format_options->create_data_property_or_throw(vm.names.style, PrimitiveString::create(vm, "unit"sv))); // 2. Perform ! CreateDataPropertyOrThrow(nfOpts, "unit", numberFormatUnit). - MUST(number_format_options->create_data_property_or_throw(vm.names.unit, js_string(vm, number_format_unit))); + MUST(number_format_options->create_data_property_or_throw(vm.names.unit, PrimitiveString::create(vm, number_format_unit))); // 3. Perform ! CreateDataPropertyOrThrow(nfOpts, "unitDisplay", style). auto unicode_style = ::Locale::style_to_string(static_cast<::Locale::Style>(style)); - MUST(number_format_options->create_data_property_or_throw(vm.names.unitDisplay, js_string(vm, unicode_style))); + MUST(number_format_options->create_data_property_or_throw(vm.names.unitDisplay, PrimitiveString::create(vm, unicode_style))); // 4. Let nf be ! Construct(%NumberFormat%, « durationFormat.[[Locale]], nfOpts »). - auto* number_format = static_cast(MUST(construct(vm, *realm.intrinsics().intl_number_format_constructor(), js_string(vm, duration_format.locale()), number_format_options))); + auto* number_format = static_cast(MUST(construct(vm, *realm.intrinsics().intl_number_format_constructor(), PrimitiveString::create(vm, duration_format.locale()), number_format_options))); // 5. Let parts be ! PartitionNumberPattern(nf, 𝔽(value)). auto parts = partition_number_pattern(vm, *number_format, MathematicalValue(value)); @@ -489,7 +489,7 @@ Vector partition_duration_format_pattern(VM& vm, DurationForma auto* list_format_options = Object::create(realm, nullptr); // 5. Perform ! CreateDataPropertyOrThrow(lfOpts, "type", "unit"). - MUST(list_format_options->create_data_property_or_throw(vm.names.type, js_string(vm, "unit"sv))); + MUST(list_format_options->create_data_property_or_throw(vm.names.type, PrimitiveString::create(vm, "unit"sv))); // 6. Let listStyle be durationFormat.[[Style]]. auto list_style = duration_format.style(); @@ -503,10 +503,10 @@ Vector partition_duration_format_pattern(VM& vm, DurationForma auto unicode_list_style = ::Locale::style_to_string(static_cast<::Locale::Style>(list_style)); // 8. Perform ! CreateDataPropertyOrThrow(lfOpts, "style", listStyle). - MUST(list_format_options->create_data_property_or_throw(vm.names.style, js_string(vm, unicode_list_style))); + MUST(list_format_options->create_data_property_or_throw(vm.names.style, PrimitiveString::create(vm, unicode_list_style))); // 9. Let lf be ! Construct(%ListFormat%, « durationFormat.[[Locale]], lfOpts »). - auto* list_format = static_cast(MUST(construct(vm, *realm.intrinsics().intl_list_format_constructor(), js_string(vm, duration_format.locale()), list_format_options))); + auto* list_format = static_cast(MUST(construct(vm, *realm.intrinsics().intl_list_format_constructor(), PrimitiveString::create(vm, duration_format.locale()), list_format_options))); // FIXME: CreatePartsFromList expects a list of strings and creates a list of Pattern Partition records, but we already created a list of Pattern Partition records // so we try to hack something together from it that looks mostly right diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatPrototype.cpp index 32eab7fc652..166f97d3a59 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatPrototype.cpp @@ -24,7 +24,7 @@ void DurationFormatPrototype::initialize(Realm& realm) auto& vm = this->vm(); // 1.4.2 Intl.DurationFormat.prototype [ @@toStringTag ], https://tc39.es/proposal-intl-duration-format/#sec-Intl.DurationFormat.prototype-@@tostringtag - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Intl.DurationFormat"), Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Intl.DurationFormat"), Attribute::Configurable); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.names.format, format, 1, attr); @@ -59,7 +59,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationFormatPrototype::format) } // 8. Return result. - return js_string(vm, result.build()); + return PrimitiveString::create(vm, result.build()); } // 1.4.4 Intl.DurationFormat.prototype.formatToParts ( duration ), https://tc39.es/proposal-intl-duration-format/#sec-Intl.DurationFormat.prototype.formatToParts @@ -93,10 +93,10 @@ JS_DEFINE_NATIVE_FUNCTION(DurationFormatPrototype::format_to_parts) auto* object = Object::create(realm, realm.intrinsics().object_prototype()); // b. Perform ! CreateDataPropertyOrThrow(obj, "type", part.[[Type]]). - MUST(object->create_data_property_or_throw(vm.names.type, js_string(vm, part.type))); + MUST(object->create_data_property_or_throw(vm.names.type, PrimitiveString::create(vm, part.type))); // c. Perform ! CreateDataPropertyOrThrow(obj, "value", part.[[Value]]). - MUST(object->create_data_property_or_throw(vm.names.value, js_string(vm, part.value))); + MUST(object->create_data_property_or_throw(vm.names.value, PrimitiveString::create(vm, part.value))); // d. Perform ! CreateDataPropertyOrThrow(result, ! ToString(n), obj). MUST(result->create_data_property_or_throw(n, object)); @@ -125,30 +125,30 @@ JS_DEFINE_NATIVE_FUNCTION(DurationFormatPrototype::resolved_options) // b. Let v be the value of df's internal slot whose name is the Internal Slot value of the current row. // c. Assert: v is not undefined. // d. Perform ! CreateDataPropertyOrThrow(options, p, v). - MUST(options->create_data_property_or_throw(vm.names.locale, js_string(vm, duration_format->locale()))); - MUST(options->create_data_property_or_throw(vm.names.style, js_string(vm, duration_format->style_string()))); - MUST(options->create_data_property_or_throw(vm.names.years, js_string(vm, duration_format->years_style_string()))); - MUST(options->create_data_property_or_throw(vm.names.yearsDisplay, js_string(vm, duration_format->years_display_string()))); - MUST(options->create_data_property_or_throw(vm.names.months, js_string(vm, duration_format->months_style_string()))); - MUST(options->create_data_property_or_throw(vm.names.monthsDisplay, js_string(vm, duration_format->months_display_string()))); - MUST(options->create_data_property_or_throw(vm.names.weeks, js_string(vm, duration_format->weeks_style_string()))); - MUST(options->create_data_property_or_throw(vm.names.weeksDisplay, js_string(vm, duration_format->weeks_display_string()))); - MUST(options->create_data_property_or_throw(vm.names.days, js_string(vm, duration_format->days_style_string()))); - MUST(options->create_data_property_or_throw(vm.names.daysDisplay, js_string(vm, duration_format->days_display_string()))); - MUST(options->create_data_property_or_throw(vm.names.hours, js_string(vm, duration_format->hours_style_string()))); - MUST(options->create_data_property_or_throw(vm.names.hoursDisplay, js_string(vm, duration_format->hours_display_string()))); - MUST(options->create_data_property_or_throw(vm.names.minutes, js_string(vm, duration_format->minutes_style_string()))); - MUST(options->create_data_property_or_throw(vm.names.minutesDisplay, js_string(vm, duration_format->minutes_display_string()))); - MUST(options->create_data_property_or_throw(vm.names.seconds, js_string(vm, duration_format->seconds_style_string()))); - MUST(options->create_data_property_or_throw(vm.names.secondsDisplay, js_string(vm, duration_format->seconds_display_string()))); - MUST(options->create_data_property_or_throw(vm.names.milliseconds, js_string(vm, duration_format->milliseconds_style_string()))); - MUST(options->create_data_property_or_throw(vm.names.millisecondsDisplay, js_string(vm, duration_format->milliseconds_display_string()))); - MUST(options->create_data_property_or_throw(vm.names.microseconds, js_string(vm, duration_format->microseconds_style_string()))); - MUST(options->create_data_property_or_throw(vm.names.microsecondsDisplay, js_string(vm, duration_format->microseconds_display_string()))); - MUST(options->create_data_property_or_throw(vm.names.nanoseconds, js_string(vm, duration_format->nanoseconds_style_string()))); - MUST(options->create_data_property_or_throw(vm.names.nanosecondsDisplay, js_string(vm, duration_format->nanoseconds_display_string()))); + MUST(options->create_data_property_or_throw(vm.names.locale, PrimitiveString::create(vm, duration_format->locale()))); + MUST(options->create_data_property_or_throw(vm.names.style, PrimitiveString::create(vm, duration_format->style_string()))); + MUST(options->create_data_property_or_throw(vm.names.years, PrimitiveString::create(vm, duration_format->years_style_string()))); + MUST(options->create_data_property_or_throw(vm.names.yearsDisplay, PrimitiveString::create(vm, duration_format->years_display_string()))); + MUST(options->create_data_property_or_throw(vm.names.months, PrimitiveString::create(vm, duration_format->months_style_string()))); + MUST(options->create_data_property_or_throw(vm.names.monthsDisplay, PrimitiveString::create(vm, duration_format->months_display_string()))); + MUST(options->create_data_property_or_throw(vm.names.weeks, PrimitiveString::create(vm, duration_format->weeks_style_string()))); + MUST(options->create_data_property_or_throw(vm.names.weeksDisplay, PrimitiveString::create(vm, duration_format->weeks_display_string()))); + MUST(options->create_data_property_or_throw(vm.names.days, PrimitiveString::create(vm, duration_format->days_style_string()))); + MUST(options->create_data_property_or_throw(vm.names.daysDisplay, PrimitiveString::create(vm, duration_format->days_display_string()))); + MUST(options->create_data_property_or_throw(vm.names.hours, PrimitiveString::create(vm, duration_format->hours_style_string()))); + MUST(options->create_data_property_or_throw(vm.names.hoursDisplay, PrimitiveString::create(vm, duration_format->hours_display_string()))); + MUST(options->create_data_property_or_throw(vm.names.minutes, PrimitiveString::create(vm, duration_format->minutes_style_string()))); + MUST(options->create_data_property_or_throw(vm.names.minutesDisplay, PrimitiveString::create(vm, duration_format->minutes_display_string()))); + MUST(options->create_data_property_or_throw(vm.names.seconds, PrimitiveString::create(vm, duration_format->seconds_style_string()))); + MUST(options->create_data_property_or_throw(vm.names.secondsDisplay, PrimitiveString::create(vm, duration_format->seconds_display_string()))); + MUST(options->create_data_property_or_throw(vm.names.milliseconds, PrimitiveString::create(vm, duration_format->milliseconds_style_string()))); + MUST(options->create_data_property_or_throw(vm.names.millisecondsDisplay, PrimitiveString::create(vm, duration_format->milliseconds_display_string()))); + MUST(options->create_data_property_or_throw(vm.names.microseconds, PrimitiveString::create(vm, duration_format->microseconds_style_string()))); + MUST(options->create_data_property_or_throw(vm.names.microsecondsDisplay, PrimitiveString::create(vm, duration_format->microseconds_display_string()))); + MUST(options->create_data_property_or_throw(vm.names.nanoseconds, PrimitiveString::create(vm, duration_format->nanoseconds_style_string()))); + MUST(options->create_data_property_or_throw(vm.names.nanosecondsDisplay, PrimitiveString::create(vm, duration_format->nanoseconds_display_string()))); MUST(options->create_data_property_or_throw(vm.names.fractionalDigits, duration_format->has_fractional_digits() ? Value(duration_format->fractional_digits()) : js_undefined())); - MUST(options->create_data_property_or_throw(vm.names.numberingSystem, js_string(vm, duration_format->numbering_system()))); + MUST(options->create_data_property_or_throw(vm.names.numberingSystem, PrimitiveString::create(vm, duration_format->numbering_system()))); // 5. Return options. return options; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/Intl.cpp b/Userland/Libraries/LibJS/Runtime/Intl/Intl.cpp index ff3e0aabfea..a9ba5d35265 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/Intl.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/Intl.cpp @@ -39,7 +39,7 @@ void Intl::initialize(Realm& realm) auto& vm = this->vm(); // 8.1.1 Intl[ @@toStringTag ], https://tc39.es/ecma402/#sec-Intl-toStringTag - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Intl"), Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Intl"), Attribute::Configurable); u8 attr = Attribute::Writable | Attribute::Configurable; define_intrinsic_accessor(vm.names.Collator, attr, [](auto& realm) -> Value { return realm.intrinsics().intl_collator_constructor(); }); @@ -70,7 +70,7 @@ JS_DEFINE_NATIVE_FUNCTION(Intl::get_canonical_locales) MarkedVector marked_locale_list { vm.heap() }; marked_locale_list.ensure_capacity(locale_list.size()); for (auto& locale : locale_list) - marked_locale_list.append(js_string(vm, move(locale))); + marked_locale_list.append(PrimitiveString::create(vm, move(locale))); // 2. Return CreateArrayFromList(ll). return Array::create_from(realm, marked_locale_list); @@ -154,7 +154,7 @@ JS_DEFINE_NATIVE_FUNCTION(Intl::supported_values_of) } // 9. Return CreateArrayFromList( list ). - return Array::create_from(realm, list, [&](auto value) { return js_string(vm, value); }); + return Array::create_from(realm, list, [&](auto value) { return PrimitiveString::create(vm, value); }); } } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/ListFormat.cpp b/Userland/Libraries/LibJS/Runtime/Intl/ListFormat.cpp index fed856a4949..7f1bd1a5942 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/ListFormat.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/ListFormat.cpp @@ -220,10 +220,10 @@ Array* format_list_to_parts(VM& vm, ListFormat const& list_format, Vectorcreate_data_property_or_throw(vm.names.type, js_string(vm, part.type))); + MUST(object->create_data_property_or_throw(vm.names.type, PrimitiveString::create(vm, part.type))); // c. Perform ! CreateDataPropertyOrThrow(O, "value", part.[[Value]]). - MUST(object->create_data_property_or_throw(vm.names.value, js_string(vm, move(part.value)))); + MUST(object->create_data_property_or_throw(vm.names.value, PrimitiveString::create(vm, move(part.value)))); // d. Perform ! CreateDataPropertyOrThrow(result, ! ToString(n), O). MUST(result->create_data_property_or_throw(n, object)); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.cpp index 0e9a563c22a..2976dadfe27 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.cpp @@ -25,7 +25,7 @@ void ListFormatPrototype::initialize(Realm& realm) auto& vm = this->vm(); // 13.3.2 Intl.ListFormat.prototype [ @@toStringTag ], https://tc39.es/ecma402/#sec-Intl.ListFormat.prototype-toStringTag - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Intl.ListFormat"), Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Intl.ListFormat"), Attribute::Configurable); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.names.format, format, 1, attr); @@ -47,7 +47,7 @@ JS_DEFINE_NATIVE_FUNCTION(ListFormatPrototype::format) // 4. Return ! FormatList(lf, stringList). auto formatted = format_list(*list_format, string_list); - return js_string(vm, move(formatted)); + return PrimitiveString::create(vm, move(formatted)); } // 13.3.4 Intl.ListFormat.prototype.formatToParts ( list ), https://tc39.es/ecma402/#sec-Intl.ListFormat.prototype.formatToParts @@ -83,9 +83,9 @@ JS_DEFINE_NATIVE_FUNCTION(ListFormatPrototype::resolved_options) // b. Let v be the value of lf's internal slot whose name is the Internal Slot value of the current row. // c. Assert: v is not undefined. // d. Perform ! CreateDataPropertyOrThrow(options, p, v). - MUST(options->create_data_property_or_throw(vm.names.locale, js_string(vm, list_format->locale()))); - MUST(options->create_data_property_or_throw(vm.names.type, js_string(vm, list_format->type_string()))); - MUST(options->create_data_property_or_throw(vm.names.style, js_string(vm, list_format->style_string()))); + MUST(options->create_data_property_or_throw(vm.names.locale, PrimitiveString::create(vm, list_format->locale()))); + MUST(options->create_data_property_or_throw(vm.names.type, PrimitiveString::create(vm, list_format->type_string()))); + MUST(options->create_data_property_or_throw(vm.names.style, PrimitiveString::create(vm, list_format->style_string()))); // 5. Return options. return options; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/Locale.cpp b/Userland/Libraries/LibJS/Runtime/Intl/Locale.cpp index a63486c79b1..4ac2d7be5e1 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/Locale.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/Locale.cpp @@ -67,7 +67,7 @@ static Array* create_array_from_list_or_restricted(VM& vm, Vector li // 2. Return ! CreateArrayFromList( list ). return Array::create_from(realm, list, [&vm](auto value) { - return js_string(vm, value); + return PrimitiveString::create(vm, value); }); } @@ -163,7 +163,7 @@ Array* time_zones_of_locale(VM& vm, StringView region) // 5. Return ! CreateArrayFromList( list ). return Array::create_from(realm, list, [&vm](auto value) { - return js_string(vm, value); + return PrimitiveString::create(vm, value); }); } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp index d86b9e4d23d..724f70c67e8 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp @@ -346,7 +346,7 @@ ThrowCompletionOr LocaleConstructor::construct(FunctionObject& new_targ // 35. If relevantExtensionKeys contains "kn", then if (relevant_extension_keys.span().contains_slow("kn"sv)) { // a. If SameValue(r.[[kn]], "true") is true or r.[[kn]] is the empty String, then - if (result.kn.has_value() && (same_value(js_string(vm, *result.kn), js_string(vm, "true")) || result.kn->is_empty())) { + if (result.kn.has_value() && (same_value(PrimitiveString::create(vm, *result.kn), PrimitiveString::create(vm, "true")) || result.kn->is_empty())) { // i. Set locale.[[Numeric]] to true. locale->set_numeric(true); } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.cpp index b9d217e6b97..e9059a007e5 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.cpp @@ -31,7 +31,7 @@ void LocalePrototype::initialize(Realm& realm) define_native_function(realm, vm.names.toString, to_string, 0, attr); // 14.3.2 Intl.Locale.prototype[ @@toStringTag ], https://tc39.es/ecma402/#sec-Intl.Locale.prototype-@@tostringtag - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Intl.Locale"), Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Intl.Locale"), Attribute::Configurable); define_native_accessor(realm, vm.names.baseName, base_name, {}, Attribute::Configurable); define_native_accessor(realm, vm.names.calendar, calendar, {}, Attribute::Configurable); @@ -100,7 +100,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::to_string) auto* locale_object = TRY(typed_this_object(vm)); // 3. Return loc.[[Locale]]. - return js_string(vm, locale_object->locale()); + return PrimitiveString::create(vm, locale_object->locale()); } // 14.3.6 get Intl.Locale.prototype.baseName, https://tc39.es/ecma402/#sec-Intl.Locale.prototype.baseName @@ -115,7 +115,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::base_name) VERIFY(locale.has_value()); // 4. Return the substring of locale corresponding to the unicode_language_id production. - return js_string(vm, locale->language_id.to_deprecated_string()); + return PrimitiveString::create(vm, locale->language_id.to_deprecated_string()); } #define JS_ENUMERATE_LOCALE_KEYWORD_PROPERTIES \ @@ -130,13 +130,13 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::base_name) // 14.3.9 get Intl.Locale.prototype.collation, https://tc39.es/ecma402/#sec-Intl.Locale.prototype.collation // 14.3.10 get Intl.Locale.prototype.hourCycle, https://tc39.es/ecma402/#sec-Intl.Locale.prototype.hourCycle // 14.3.12 get Intl.Locale.prototype.numberingSystem, https://tc39.es/ecma402/#sec-Intl.Locale.prototype.numberingSystem -#define __JS_ENUMERATE(keyword) \ - JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::keyword) \ - { \ - auto* locale_object = TRY(typed_this_object(vm)); \ - if (!locale_object->has_##keyword()) \ - return js_undefined(); \ - return js_string(vm, locale_object->keyword()); \ +#define __JS_ENUMERATE(keyword) \ + JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::keyword) \ + { \ + auto* locale_object = TRY(typed_this_object(vm)); \ + if (!locale_object->has_##keyword()) \ + return js_undefined(); \ + return PrimitiveString::create(vm, locale_object->keyword()); \ } JS_ENUMERATE_LOCALE_KEYWORD_PROPERTIES #undef __JS_ENUMERATE @@ -166,7 +166,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::language) VERIFY(locale.has_value()); // 5. Return the substring of locale corresponding to the unicode_language_subtag production of the unicode_language_id. - return js_string(vm, *locale->language_id.language); + return PrimitiveString::create(vm, *locale->language_id.language); } // 14.3.14 get Intl.Locale.prototype.script, https://tc39.es/ecma402/#sec-Intl.Locale.prototype.script @@ -187,7 +187,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::script) return js_undefined(); // 6. Return the substring of locale corresponding to the unicode_script_subtag production of the unicode_language_id. - return js_string(vm, *locale->language_id.script); + return PrimitiveString::create(vm, *locale->language_id.script); } // 14.3.15 get Intl.Locale.prototype.region, https://tc39.es/ecma402/#sec-Intl.Locale.prototype.region @@ -208,7 +208,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::region) return js_undefined(); // 6. Return the substring of locale corresponding to the unicode_region_subtag production of the unicode_language_id. - return js_string(vm, *locale->language_id.region); + return PrimitiveString::create(vm, *locale->language_id.region); } #define JS_ENUMERATE_LOCALE_INFO_PROPERTIES \ @@ -264,7 +264,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::text_info) auto direction = character_direction_of_locale(*locale_object); // 5. Perform ! CreateDataPropertyOrThrow(info, "direction", dir). - MUST(info->create_data_property_or_throw(vm.names.direction, js_string(vm, direction))); + MUST(info->create_data_property_or_throw(vm.names.direction, PrimitiveString::create(vm, direction))); // 6. Return info. return info; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormat.cpp b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormat.cpp index 786cfe85089..3f9b643d337 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormat.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormat.cpp @@ -246,11 +246,11 @@ Value NumberFormat::use_grouping_to_value(VM& vm) const { switch (m_use_grouping) { case UseGrouping::Always: - return js_string(vm, "always"sv); + return PrimitiveString::create(vm, "always"sv); case UseGrouping::Auto: - return js_string(vm, "auto"sv); + return PrimitiveString::create(vm, "auto"sv); case UseGrouping::Min2: - return js_string(vm, "min2"sv); + return PrimitiveString::create(vm, "min2"sv); case UseGrouping::False: return Value(false); default: @@ -925,10 +925,10 @@ Array* format_numeric_to_parts(VM& vm, NumberFormat& number_format, Mathematical auto* object = Object::create(realm, realm.intrinsics().object_prototype()); // b. Perform ! CreateDataPropertyOrThrow(O, "type", part.[[Type]]). - MUST(object->create_data_property_or_throw(vm.names.type, js_string(vm, part.type))); + MUST(object->create_data_property_or_throw(vm.names.type, PrimitiveString::create(vm, part.type))); // c. Perform ! CreateDataPropertyOrThrow(O, "value", part.[[Value]]). - MUST(object->create_data_property_or_throw(vm.names.value, js_string(vm, move(part.value)))); + MUST(object->create_data_property_or_throw(vm.names.value, PrimitiveString::create(vm, move(part.value)))); // d. Perform ! CreateDataPropertyOrThrow(result, ! ToString(n), O). MUST(result->create_data_property_or_throw(n, object)); @@ -1835,13 +1835,13 @@ ThrowCompletionOr format_numeric_range_to_parts(VM& vm, NumberFormat& nu auto* object = Object::create(realm, realm.intrinsics().object_prototype()); // b. Perform ! CreateDataPropertyOrThrow(O, "type", part.[[Type]]). - MUST(object->create_data_property_or_throw(vm.names.type, js_string(vm, part.type))); + MUST(object->create_data_property_or_throw(vm.names.type, PrimitiveString::create(vm, part.type))); // c. Perform ! CreateDataPropertyOrThrow(O, "value", part.[[Value]]). - MUST(object->create_data_property_or_throw(vm.names.value, js_string(vm, move(part.value)))); + MUST(object->create_data_property_or_throw(vm.names.value, PrimitiveString::create(vm, move(part.value)))); // d. Perform ! CreateDataPropertyOrThrow(O, "source", part.[[Source]]). - MUST(object->create_data_property_or_throw(vm.names.source, js_string(vm, part.source))); + MUST(object->create_data_property_or_throw(vm.names.source, PrimitiveString::create(vm, part.source))); // e. Perform ! CreateDataPropertyOrThrow(result, ! ToString(n), O). MUST(result->create_data_property_or_throw(n, object)); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.cpp b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.cpp index dbc29898ffd..f8c2e3419b9 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.cpp +++ b/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, js_string(vm, DeprecatedString::empty()), Attribute::Configurable); + define_direct_property(vm.names.name, PrimitiveString::create(vm, DeprecatedString::empty()), Attribute::Configurable); } ThrowCompletionOr NumberFormatFunction::call() @@ -47,7 +47,7 @@ ThrowCompletionOr NumberFormatFunction::call() // 5. Return ? FormatNumeric(nf, x). // Note: Our implementation of FormatNumeric does not throw. auto formatted = format_numeric(vm, m_number_format, move(mathematical_value)); - return js_string(vm, move(formatted)); + return PrimitiveString::create(vm, move(formatted)); } void NumberFormatFunction::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.cpp index 403d8b5f530..b6e4187491d 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.cpp @@ -26,7 +26,7 @@ void NumberFormatPrototype::initialize(Realm& realm) auto& vm = this->vm(); // 15.3.2 Intl.NumberFormat.prototype [ @@toStringTag ], https://tc39.es/ecma402/#sec-intl.numberformat.prototype-@@tostringtag - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Intl.NumberFormat"), Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Intl.NumberFormat"), Attribute::Configurable); define_native_accessor(realm, vm.names.format, format, nullptr, Attribute::Configurable); @@ -104,7 +104,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberFormatPrototype::format_range) // 6. Return ? FormatNumericRange(nf, x, y). auto formatted = TRY(format_numeric_range(vm, *number_format, move(x), move(y))); - return js_string(vm, move(formatted)); + return PrimitiveString::create(vm, move(formatted)); } // 1.4.6 Intl.NumberFormat.prototype.formatRangeToParts ( start, end ), https://tc39.es/proposal-intl-numberformat-v3/out/numberformat/proposed.html#sec-intl.numberformat.prototype.formatrangetoparts @@ -152,19 +152,19 @@ JS_DEFINE_NATIVE_FUNCTION(NumberFormatPrototype::resolved_options) // b. Let v be the value of nf's internal slot whose name is the Internal Slot value of the current row. // c. If v is not undefined, then // i. Perform ! CreateDataPropertyOrThrow(options, p, v). - MUST(options->create_data_property_or_throw(vm.names.locale, js_string(vm, number_format->locale()))); - MUST(options->create_data_property_or_throw(vm.names.numberingSystem, js_string(vm, number_format->numbering_system()))); - MUST(options->create_data_property_or_throw(vm.names.style, js_string(vm, number_format->style_string()))); + MUST(options->create_data_property_or_throw(vm.names.locale, PrimitiveString::create(vm, number_format->locale()))); + MUST(options->create_data_property_or_throw(vm.names.numberingSystem, PrimitiveString::create(vm, number_format->numbering_system()))); + MUST(options->create_data_property_or_throw(vm.names.style, PrimitiveString::create(vm, number_format->style_string()))); if (number_format->has_currency()) - MUST(options->create_data_property_or_throw(vm.names.currency, js_string(vm, number_format->currency()))); + MUST(options->create_data_property_or_throw(vm.names.currency, PrimitiveString::create(vm, number_format->currency()))); if (number_format->has_currency_display()) - MUST(options->create_data_property_or_throw(vm.names.currencyDisplay, js_string(vm, number_format->currency_display_string()))); + MUST(options->create_data_property_or_throw(vm.names.currencyDisplay, PrimitiveString::create(vm, number_format->currency_display_string()))); if (number_format->has_currency_sign()) - MUST(options->create_data_property_or_throw(vm.names.currencySign, js_string(vm, number_format->currency_sign_string()))); + MUST(options->create_data_property_or_throw(vm.names.currencySign, PrimitiveString::create(vm, number_format->currency_sign_string()))); if (number_format->has_unit()) - MUST(options->create_data_property_or_throw(vm.names.unit, js_string(vm, number_format->unit()))); + MUST(options->create_data_property_or_throw(vm.names.unit, PrimitiveString::create(vm, number_format->unit()))); if (number_format->has_unit_display()) - MUST(options->create_data_property_or_throw(vm.names.unitDisplay, js_string(vm, number_format->unit_display_string()))); + MUST(options->create_data_property_or_throw(vm.names.unitDisplay, PrimitiveString::create(vm, number_format->unit_display_string()))); MUST(options->create_data_property_or_throw(vm.names.minimumIntegerDigits, Value(number_format->min_integer_digits()))); if (number_format->has_min_fraction_digits()) MUST(options->create_data_property_or_throw(vm.names.minimumFractionDigits, Value(number_format->min_fraction_digits()))); @@ -175,29 +175,29 @@ JS_DEFINE_NATIVE_FUNCTION(NumberFormatPrototype::resolved_options) if (number_format->has_max_significant_digits()) MUST(options->create_data_property_or_throw(vm.names.maximumSignificantDigits, Value(number_format->max_significant_digits()))); MUST(options->create_data_property_or_throw(vm.names.useGrouping, number_format->use_grouping_to_value(vm))); - MUST(options->create_data_property_or_throw(vm.names.notation, js_string(vm, number_format->notation_string()))); + MUST(options->create_data_property_or_throw(vm.names.notation, PrimitiveString::create(vm, number_format->notation_string()))); if (number_format->has_compact_display()) - MUST(options->create_data_property_or_throw(vm.names.compactDisplay, js_string(vm, number_format->compact_display_string()))); - MUST(options->create_data_property_or_throw(vm.names.signDisplay, js_string(vm, number_format->sign_display_string()))); - MUST(options->create_data_property_or_throw(vm.names.roundingMode, js_string(vm, number_format->rounding_mode_string()))); + MUST(options->create_data_property_or_throw(vm.names.compactDisplay, PrimitiveString::create(vm, number_format->compact_display_string()))); + MUST(options->create_data_property_or_throw(vm.names.signDisplay, PrimitiveString::create(vm, number_format->sign_display_string()))); + MUST(options->create_data_property_or_throw(vm.names.roundingMode, PrimitiveString::create(vm, number_format->rounding_mode_string()))); MUST(options->create_data_property_or_throw(vm.names.roundingIncrement, Value(number_format->rounding_increment()))); - MUST(options->create_data_property_or_throw(vm.names.trailingZeroDisplay, js_string(vm, number_format->trailing_zero_display_string()))); + MUST(options->create_data_property_or_throw(vm.names.trailingZeroDisplay, PrimitiveString::create(vm, number_format->trailing_zero_display_string()))); switch (number_format->rounding_type()) { // 6. If nf.[[RoundingType]] is morePrecision, then case NumberFormatBase::RoundingType::MorePrecision: // a. Perform ! CreateDataPropertyOrThrow(options, "roundingPriority", "morePrecision"). - MUST(options->create_data_property_or_throw(vm.names.roundingPriority, js_string(vm, "morePrecision"sv))); + MUST(options->create_data_property_or_throw(vm.names.roundingPriority, PrimitiveString::create(vm, "morePrecision"sv))); break; // 7. Else if nf.[[RoundingType]] is lessPrecision, then case NumberFormatBase::RoundingType::LessPrecision: // a. Perform ! CreateDataPropertyOrThrow(options, "roundingPriority", "lessPrecision"). - MUST(options->create_data_property_or_throw(vm.names.roundingPriority, js_string(vm, "lessPrecision"sv))); + MUST(options->create_data_property_or_throw(vm.names.roundingPriority, PrimitiveString::create(vm, "lessPrecision"sv))); break; // 8. Else, default: // a. Perform ! CreateDataPropertyOrThrow(options, "roundingPriority", "auto"). - MUST(options->create_data_property_or_throw(vm.names.roundingPriority, js_string(vm, "auto"sv))); + MUST(options->create_data_property_or_throw(vm.names.roundingPriority, PrimitiveString::create(vm, "auto"sv))); break; } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesPrototype.cpp index f6c948cf8cd..7fe8279c047 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesPrototype.cpp @@ -25,7 +25,7 @@ void PluralRulesPrototype::initialize(Realm& realm) auto& vm = this->vm(); // 16.3.2 Intl.PluralRules.prototype [ @@toStringTag ], https://tc39.es/ecma402/#sec-intl.pluralrules.prototype-tostringtag - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Intl.PluralRules"sv), Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Intl.PluralRules"sv), Attribute::Configurable); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.names.select, select, 1, attr); @@ -45,7 +45,7 @@ JS_DEFINE_NATIVE_FUNCTION(PluralRulesPrototype::select) // 4. Return ! ResolvePlural(pr, n). auto plurality = resolve_plural(*plural_rules, number); - return js_string(vm, ::Locale::plural_category_to_string(plurality)); + return PrimitiveString::create(vm, ::Locale::plural_category_to_string(plurality)); } // 1.4.4 Intl.PluralRules.prototype.selectRange ( start, end ), https://tc39.es/proposal-intl-numberformat-v3/out/pluralrules/proposed.html#sec-intl.pluralrules.prototype.selectrange @@ -72,7 +72,7 @@ JS_DEFINE_NATIVE_FUNCTION(PluralRulesPrototype::select_range) // 6. Return ? ResolvePluralRange(pr, x, y). auto plurality = TRY(resolve_plural_range(vm, *plural_rules, x, y)); - return js_string(vm, ::Locale::plural_category_to_string(plurality)); + return PrimitiveString::create(vm, ::Locale::plural_category_to_string(plurality)); } // 16.3.4 Intl.PluralRules.prototype.resolvedOptions ( ), https://tc39.es/ecma402/#sec-intl.pluralrules.prototype.resolvedoptions @@ -93,8 +93,8 @@ JS_DEFINE_NATIVE_FUNCTION(PluralRulesPrototype::resolved_options) // b. Let v be the value of pr's internal slot whose name is the Internal Slot value of the current row. // c. If v is not undefined, then // i. Perform ! CreateDataPropertyOrThrow(options, p, v). - MUST(options->create_data_property_or_throw(vm.names.locale, js_string(vm, plural_rules->locale()))); - MUST(options->create_data_property_or_throw(vm.names.type, js_string(vm, plural_rules->type_string()))); + MUST(options->create_data_property_or_throw(vm.names.locale, PrimitiveString::create(vm, plural_rules->locale()))); + MUST(options->create_data_property_or_throw(vm.names.type, PrimitiveString::create(vm, plural_rules->type_string()))); MUST(options->create_data_property_or_throw(vm.names.minimumIntegerDigits, Value(plural_rules->min_integer_digits()))); if (plural_rules->has_min_fraction_digits()) MUST(options->create_data_property_or_throw(vm.names.minimumFractionDigits, Value(plural_rules->min_fraction_digits()))); @@ -109,7 +109,7 @@ JS_DEFINE_NATIVE_FUNCTION(PluralRulesPrototype::resolved_options) auto available_categories = ::Locale::available_plural_categories(plural_rules->locale(), plural_rules->type()); auto* plural_categories = Array::create_from<::Locale::PluralCategory>(realm, available_categories, [&](auto category) { - return js_string(vm, ::Locale::plural_category_to_string(category)); + return PrimitiveString::create(vm, ::Locale::plural_category_to_string(category)); }); // 6. Perform ! CreateDataProperty(options, "pluralCategories", CreateArrayFromList(pluralCategories)). @@ -119,17 +119,17 @@ JS_DEFINE_NATIVE_FUNCTION(PluralRulesPrototype::resolved_options) // 7. If pr.[[RoundingType]] is morePrecision, then case NumberFormatBase::RoundingType::MorePrecision: // a. Perform ! CreateDataPropertyOrThrow(options, "roundingPriority", "morePrecision"). - MUST(options->create_data_property_or_throw(vm.names.roundingPriority, js_string(vm, "morePrecision"sv))); + MUST(options->create_data_property_or_throw(vm.names.roundingPriority, PrimitiveString::create(vm, "morePrecision"sv))); break; // 8. Else if pr.[[RoundingType]] is lessPrecision, then case NumberFormatBase::RoundingType::LessPrecision: // a. Perform ! CreateDataPropertyOrThrow(options, "roundingPriority", "lessPrecision"). - MUST(options->create_data_property_or_throw(vm.names.roundingPriority, js_string(vm, "lessPrecision"sv))); + MUST(options->create_data_property_or_throw(vm.names.roundingPriority, PrimitiveString::create(vm, "lessPrecision"sv))); break; // 9. Else, default: // a. Perform ! CreateDataPropertyOrThrow(options, "roundingPriority", "auto"). - MUST(options->create_data_property_or_throw(vm.names.roundingPriority, js_string(vm, "auto"sv))); + MUST(options->create_data_property_or_throw(vm.names.roundingPriority, PrimitiveString::create(vm, "auto"sv))); break; } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormat.cpp b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormat.cpp index 248782ebdee..3b34526877d 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormat.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormat.cpp @@ -260,15 +260,15 @@ ThrowCompletionOr format_relative_time_to_parts(VM& vm, RelativeTimeForm auto* object = Object::create(realm, realm.intrinsics().object_prototype()); // b. Perform ! CreateDataPropertyOrThrow(O, "type", part.[[Type]]). - MUST(object->create_data_property_or_throw(vm.names.type, js_string(vm, part.type))); + MUST(object->create_data_property_or_throw(vm.names.type, PrimitiveString::create(vm, part.type))); // c. Perform ! CreateDataPropertyOrThrow(O, "value", part.[[Value]]). - MUST(object->create_data_property_or_throw(vm.names.value, js_string(vm, move(part.value)))); + MUST(object->create_data_property_or_throw(vm.names.value, PrimitiveString::create(vm, move(part.value)))); // d. If part.[[Unit]] is not empty, then if (!part.unit.is_empty()) { // i. Perform ! CreateDataPropertyOrThrow(O, "unit", part.[[Unit]]). - MUST(object->create_data_property_or_throw(vm.names.unit, js_string(vm, part.unit))); + MUST(object->create_data_property_or_throw(vm.names.unit, PrimitiveString::create(vm, part.unit))); } // e. Perform ! CreateDataPropertyOrThrow(result, ! ToString(n), O). diff --git a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.cpp index 8a2731b6881..c368af4b148 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.cpp @@ -138,11 +138,11 @@ ThrowCompletionOr initialize_relative_time_format(VM& vm, R relative_time_format.set_numeric(numeric.as_string().deprecated_string()); // 19. Let relativeTimeFormat.[[NumberFormat]] be ! Construct(%NumberFormat%, « locale »). - auto* number_format = MUST(construct(vm, *realm.intrinsics().intl_number_format_constructor(), js_string(vm, locale))); + auto* number_format = MUST(construct(vm, *realm.intrinsics().intl_number_format_constructor(), PrimitiveString::create(vm, locale))); relative_time_format.set_number_format(static_cast(number_format)); // 20. Let relativeTimeFormat.[[PluralRules]] be ! Construct(%PluralRules%, « locale »). - auto* plural_rules = MUST(construct(vm, *realm.intrinsics().intl_plural_rules_constructor(), js_string(vm, locale))); + auto* plural_rules = MUST(construct(vm, *realm.intrinsics().intl_plural_rules_constructor(), PrimitiveString::create(vm, locale))); relative_time_format.set_plural_rules(static_cast(plural_rules)); // 21. Return relativeTimeFormat. diff --git a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatPrototype.cpp index 21ab4500e8e..103ba2b3eb2 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatPrototype.cpp @@ -23,7 +23,7 @@ void RelativeTimeFormatPrototype::initialize(Realm& realm) auto& vm = this->vm(); // 17.3.2 Intl.RelativeTimeFormat.prototype[ @@toStringTag ], https://tc39.es/ecma402/#sec-Intl.RelativeTimeFormat.prototype-toStringTag - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Intl.RelativeTimeFormat"sv), Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Intl.RelativeTimeFormat"sv), Attribute::Configurable); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.names.format, format, 2, attr); @@ -46,7 +46,7 @@ JS_DEFINE_NATIVE_FUNCTION(RelativeTimeFormatPrototype::format) // 5. Return ? FormatRelativeTime(relativeTimeFormat, value, unit). auto formatted = TRY(format_relative_time(vm, *relative_time_format, value.as_double(), unit)); - return js_string(vm, move(formatted)); + return PrimitiveString::create(vm, move(formatted)); } // 17.3.4 Intl.RelativeTimeFormat.prototype.formatToParts ( value, unit ), https://tc39.es/ecma402/#sec-Intl.RelativeTimeFormat.prototype.formatToParts @@ -83,10 +83,10 @@ JS_DEFINE_NATIVE_FUNCTION(RelativeTimeFormatPrototype::resolved_options) // b. Let v be the value of relativeTimeFormat's internal slot whose name is the Internal Slot value of the current row. // c. Assert: v is not undefined. // d. Perform ! CreateDataPropertyOrThrow(options, p, v). - MUST(options->create_data_property_or_throw(vm.names.locale, js_string(vm, relative_time_format->locale()))); - MUST(options->create_data_property_or_throw(vm.names.style, js_string(vm, relative_time_format->style_string()))); - MUST(options->create_data_property_or_throw(vm.names.numeric, js_string(vm, relative_time_format->numeric_string()))); - MUST(options->create_data_property_or_throw(vm.names.numberingSystem, js_string(vm, relative_time_format->numbering_system()))); + MUST(options->create_data_property_or_throw(vm.names.locale, PrimitiveString::create(vm, relative_time_format->locale()))); + MUST(options->create_data_property_or_throw(vm.names.style, PrimitiveString::create(vm, relative_time_format->style_string()))); + MUST(options->create_data_property_or_throw(vm.names.numeric, PrimitiveString::create(vm, relative_time_format->numeric_string()))); + MUST(options->create_data_property_or_throw(vm.names.numberingSystem, PrimitiveString::create(vm, relative_time_format->numbering_system()))); // 5. Return options. return options; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/SegmentIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/SegmentIteratorPrototype.cpp index 9854ee73144..09c0a1586f6 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/SegmentIteratorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/SegmentIteratorPrototype.cpp @@ -25,7 +25,7 @@ void SegmentIteratorPrototype::initialize(Realm& realm) auto& vm = this->vm(); // 18.6.2.2 %SegmentIteratorPrototype% [ @@toStringTag ], https://tc39.es/ecma402/#sec-%segmentiteratorprototype%.@@tostringtag - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Segmenter String Iterator"), Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Segmenter String Iterator"), Attribute::Configurable); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.names.next, next, 0, attr); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/Segmenter.cpp b/Userland/Libraries/LibJS/Runtime/Intl/Segmenter.cpp index 0323aceb6c9..72e1bf865d5 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/Segmenter.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/Segmenter.cpp @@ -68,13 +68,13 @@ Object* create_segment_data_object(VM& vm, Segmenter const& segmenter, Utf16View auto segment = string.substring_view(start_index, end_index - start_index); // 7. Perform ! CreateDataPropertyOrThrow(result, "segment", segment). - MUST(result->create_data_property_or_throw(vm.names.segment, js_string(vm, segment))); + MUST(result->create_data_property_or_throw(vm.names.segment, PrimitiveString::create(vm, segment))); // 8. Perform ! CreateDataPropertyOrThrow(result, "index", 𝔽(startIndex)). MUST(result->create_data_property_or_throw(vm.names.index, Value(start_index))); // 9. Perform ! CreateDataPropertyOrThrow(result, "input", string). - MUST(result->create_data_property_or_throw(vm.names.input, js_string(vm, string))); + MUST(result->create_data_property_or_throw(vm.names.input, PrimitiveString::create(vm, string))); // 10. Let granularity be segmenter.[[SegmenterGranularity]]. auto granularity = segmenter.segmenter_granularity(); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/SegmenterPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/SegmenterPrototype.cpp index a0fd1e7bce8..036f334ae08 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/SegmenterPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/SegmenterPrototype.cpp @@ -24,7 +24,7 @@ void SegmenterPrototype::initialize(Realm& realm) auto& vm = this->vm(); // 18.3.2 Intl.Segmenter.prototype [ @@toStringTag ], https://tc39.es/ecma402/#sec-intl.segmenter.prototype-@@tostringtag - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Intl.Segmenter"), Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Intl.Segmenter"), Attribute::Configurable); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.names.resolvedOptions, resolved_options, 0, attr); @@ -48,8 +48,8 @@ JS_DEFINE_NATIVE_FUNCTION(SegmenterPrototype::resolved_options) // b. Let v be the value of segmenter's internal slot whose name is the Internal Slot value of the current row. // c. Assert: v is not undefined. // d. Perform ! CreateDataPropertyOrThrow(options, p, v). - MUST(options->create_data_property_or_throw(vm.names.locale, js_string(vm, segmenter->locale()))); - MUST(options->create_data_property_or_throw(vm.names.granularity, js_string(vm, segmenter->segmenter_granularity_string()))); + MUST(options->create_data_property_or_throw(vm.names.locale, PrimitiveString::create(vm, segmenter->locale()))); + MUST(options->create_data_property_or_throw(vm.names.granularity, PrimitiveString::create(vm, segmenter->segmenter_granularity_string()))); // 5. Return options. return options; diff --git a/Userland/Libraries/LibJS/Runtime/Intrinsics.cpp b/Userland/Libraries/LibJS/Runtime/Intrinsics.cpp index ff4ee891a3a..b22331070df 100644 --- a/Userland/Libraries/LibJS/Runtime/Intrinsics.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intrinsics.cpp @@ -126,7 +126,7 @@ namespace JS { static void initialize_constructor(VM& vm, PropertyKey const& property_key, Object& constructor, Object* prototype, PropertyAttributes constructor_property_attributes = Attribute::Writable | Attribute::Configurable) { - constructor.define_direct_property(vm.names.name, js_string(vm, property_key.as_string()), Attribute::Configurable); + constructor.define_direct_property(vm.names.name, PrimitiveString::create(vm, property_key.as_string()), Attribute::Configurable); if (prototype) prototype->define_direct_property(vm.names.constructor, &constructor, constructor_property_attributes); } @@ -228,7 +228,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, js_string(vm, ""), 0); + m_throw_type_error_function->define_direct_property(vm.names.name, PrimitiveString::create(vm, ""), 0); MUST(m_throw_type_error_function->internal_prevent_extensions()); #define __JS_ENUMERATE(ClassName, snake_name) \ diff --git a/Userland/Libraries/LibJS/Runtime/JSONObject.cpp b/Userland/Libraries/LibJS/Runtime/JSONObject.cpp index 3f59ebf9428..489d6f04e39 100644 --- a/Userland/Libraries/LibJS/Runtime/JSONObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/JSONObject.cpp @@ -40,7 +40,7 @@ void JSONObject::initialize(Realm& realm) define_native_function(realm, vm.names.parse, parse, 2, attr); // 25.5.3 JSON [ @@toStringTag ], https://tc39.es/ecma262/#sec-json-@@tostringtag - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "JSON"), Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "JSON"), Attribute::Configurable); } // 25.5.2 JSON.stringify ( value [ , replacer [ , space ] ] ), https://tc39.es/ecma262/#sec-json.stringify @@ -121,7 +121,7 @@ JS_DEFINE_NATIVE_FUNCTION(JSONObject::stringify) if (string.is_null()) return js_undefined(); - return js_string(vm, string); + return PrimitiveString::create(vm, string); } // 25.5.2.1 SerializeJSONProperty ( state, key, holder ), https://tc39.es/ecma262/#sec-serializejsonproperty @@ -138,14 +138,14 @@ ThrowCompletionOr JSONObject::serialize_json_property(VM& vm, // b. If IsCallable(toJSON) is true, then if (to_json.is_function()) { // i. Set value to ? Call(toJSON, value, « key »). - value = TRY(call(vm, to_json.as_function(), value, js_string(vm, key.to_string()))); + value = TRY(call(vm, to_json.as_function(), value, PrimitiveString::create(vm, key.to_string()))); } } // 3. If state.[[ReplacerFunction]] is not undefined, then if (state.replacer_function) { // a. Set value to ? Call(state.[[ReplacerFunction]], holder, « key, value »). - value = TRY(call(vm, *state.replacer_function, holder, js_string(vm, key.to_string()), value)); + value = TRY(call(vm, *state.replacer_function, holder, PrimitiveString::create(vm, key.to_string()), value)); } // 4. If Type(value) is Object, then @@ -422,7 +422,7 @@ Value JSONObject::parse_json_value(VM& vm, JsonValue const& value) if (value.is_number()) return Value(value.to_double(0)); if (value.is_string()) - return js_string(vm, value.to_deprecated_string()); + return PrimitiveString::create(vm, value.to_deprecated_string()); if (value.is_bool()) return Value(static_cast(value.as_bool())); VERIFY_NOT_REACHED(); @@ -477,7 +477,7 @@ ThrowCompletionOr JSONObject::internalize_json_property(VM& vm, Object* h } } - return TRY(call(vm, reviver, holder, js_string(vm, name.to_string()), value)); + return TRY(call(vm, reviver, holder, PrimitiveString::create(vm, name.to_string()), value)); } } diff --git a/Userland/Libraries/LibJS/Runtime/MapIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/MapIteratorPrototype.cpp index 88800c8d036..3ad6888a05b 100644 --- a/Userland/Libraries/LibJS/Runtime/MapIteratorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/MapIteratorPrototype.cpp @@ -24,7 +24,7 @@ void MapIteratorPrototype::initialize(Realm& realm) Object::initialize(realm); define_native_function(realm, vm.names.next, next, 0, Attribute::Configurable | Attribute::Writable); - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Map Iterator"), Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Map Iterator"), Attribute::Configurable); } // 24.1.5.2.1 %MapIteratorPrototype%.next ( ), https://tc39.es/ecma262/#sec-%mapiteratorprototype%.next diff --git a/Userland/Libraries/LibJS/Runtime/MapPrototype.cpp b/Userland/Libraries/LibJS/Runtime/MapPrototype.cpp index 0321086adcb..c0336b52cdb 100644 --- a/Userland/Libraries/LibJS/Runtime/MapPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/MapPrototype.cpp @@ -36,7 +36,7 @@ void MapPrototype::initialize(Realm& realm) define_native_accessor(realm, vm.names.size, size_getter, {}, Attribute::Configurable); define_direct_property(*vm.well_known_symbol_iterator(), get_without_side_effects(vm.names.entries), attr); - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, vm.names.Map.as_string()), Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.Map.as_string()), Attribute::Configurable); } // 24.1.3.1 Map.prototype.clear ( ), https://tc39.es/ecma262/#sec-map.prototype.clear diff --git a/Userland/Libraries/LibJS/Runtime/MathObject.cpp b/Userland/Libraries/LibJS/Runtime/MathObject.cpp index 29bd30f3262..33aa0670d24 100644 --- a/Userland/Libraries/LibJS/Runtime/MathObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/MathObject.cpp @@ -72,7 +72,7 @@ void MathObject::initialize(Realm& realm) define_direct_property(vm.names.SQRT2, Value(M_SQRT2), 0); // 21.3.1.9 Math [ @@toStringTag ], https://tc39.es/ecma262/#sec-math-@@tostringtag - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, vm.names.Math.as_string()), Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.Math.as_string()), Attribute::Configurable); } // 21.3.2.1 Math.abs ( x ), https://tc39.es/ecma262/#sec-math.abs diff --git a/Userland/Libraries/LibJS/Runtime/ModuleNamespaceObject.cpp b/Userland/Libraries/LibJS/Runtime/ModuleNamespaceObject.cpp index 2645a620c66..c41a2ee49e2 100644 --- a/Userland/Libraries/LibJS/Runtime/ModuleNamespaceObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ModuleNamespaceObject.cpp @@ -27,7 +27,7 @@ void ModuleNamespaceObject::initialize(Realm& realm) Object::initialize(realm); // 28.3.1 @@toStringTag, https://tc39.es/ecma262/#sec-@@tostringtag - define_direct_property(*vm().well_known_symbol_to_string_tag(), js_string(vm(), "Module"sv), 0); + define_direct_property(*vm().well_known_symbol_to_string_tag(), PrimitiveString::create(vm(), "Module"sv), 0); } // 10.4.6.1 [[GetPrototypeOf]] ( ), https://tc39.es/ecma262/#sec-module-namespace-exotic-objects-getprototypeof @@ -219,7 +219,7 @@ ThrowCompletionOr> ModuleNamespaceObject::internal_own_prope // 3. Return the list-concatenation of exports and symbolKeys. exports.ensure_capacity(m_exports.size() + symbol_keys.size()); for (auto const& export_name : m_exports) - exports.unchecked_append(js_string(vm(), export_name)); + exports.unchecked_append(PrimitiveString::create(vm(), export_name)); exports.extend(symbol_keys); return exports; diff --git a/Userland/Libraries/LibJS/Runtime/NumberPrototype.cpp b/Userland/Libraries/LibJS/Runtime/NumberPrototype.cpp index 89a6a467f55..5ea29a0d2dd 100644 --- a/Userland/Libraries/LibJS/Runtime/NumberPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/NumberPrototype.cpp @@ -90,7 +90,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_exponential) // 4. If x is not finite, return Number::toString(x). if (!number_value.is_finite_number()) - return js_string(vm, MUST(number_value.to_string(vm))); + return PrimitiveString::create(vm, MUST(number_value.to_string(vm))); // 5. If f < 0 or f > 100, throw a RangeError exception. if (fraction_digits < 0 || fraction_digits > 100) @@ -195,7 +195,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_exponential) // 14. Set m to the string-concatenation of m, "e", c, and d. // 15. Return the string-concatenation of s and m. - return js_string(vm, DeprecatedString::formatted("{}{}e{}{}", sign, number_string, exponent_sign, exponent_string)); + return PrimitiveString::create(vm, DeprecatedString::formatted("{}{}e{}{}", sign, number_string, exponent_sign, exponent_string)); } // 21.1.3.3 Number.prototype.toFixed ( fractionDigits ), https://tc39.es/ecma262/#sec-number.prototype.tofixed @@ -218,7 +218,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_fixed) // 6. If x is not finite, return Number::toString(x). if (!number_value.is_finite_number()) - return js_string(vm, TRY(number_value.to_string(vm))); + return PrimitiveString::create(vm, TRY(number_value.to_string(vm))); // 7. Set x to ℝ(x). auto number = number_value.as_double(); @@ -233,7 +233,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_fixed) // 10. If x ≥ 10^21, then if (fabs(number) >= 1e+21) - return js_string(vm, MUST(number_value.to_string(vm))); + return PrimitiveString::create(vm, MUST(number_value.to_string(vm))); // 11. Else, // a. Let n be an integer for which n / (10^f) - x is as close to zero as possible. If there are two such n, pick the larger n. @@ -269,7 +269,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_fixed) } // 12. Return the string-concatenation of s and m. - return js_string(vm, DeprecatedString::formatted("{}{}", s, m)); + return PrimitiveString::create(vm, DeprecatedString::formatted("{}{}", s, m)); } // 19.2.1 Number.prototype.toLocaleString ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sup-number.prototype.tolocalestring @@ -289,7 +289,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_locale_string) // 3. Return ? FormatNumeric(numberFormat, x). // Note: Our implementation of FormatNumeric does not throw. auto formatted = Intl::format_numeric(vm, *number_format, number_value); - return js_string(vm, move(formatted)); + return PrimitiveString::create(vm, move(formatted)); } // 21.1.3.5 Number.prototype.toPrecision ( precision ), https://tc39.es/ecma262/#sec-number.prototype.toprecision @@ -302,14 +302,14 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_precision) // 2. If precision is undefined, return ! ToString(x). if (precision_value.is_undefined()) - return js_string(vm, MUST(number_value.to_string(vm))); + return PrimitiveString::create(vm, MUST(number_value.to_string(vm))); // 3. Let p be ? ToIntegerOrInfinity(precision). auto precision = TRY(precision_value.to_integer_or_infinity(vm)); // 4. If x is not finite, return Number::toString(x). if (!number_value.is_finite_number()) - return js_string(vm, MUST(number_value.to_string(vm))); + return PrimitiveString::create(vm, MUST(number_value.to_string(vm))); // 5. If p < 1 or p > 100, throw a RangeError exception. if ((precision < 1) || (precision > 100)) @@ -391,13 +391,13 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_precision) auto exponent_string = DeprecatedString::number(exponent); // vi. Return the string-concatenation of s, m, the code unit 0x0065 (LATIN SMALL LETTER E), c, and d. - return js_string(vm, DeprecatedString::formatted("{}{}e{}{}", sign, number_string, exponent_sign, exponent_string)); + return PrimitiveString::create(vm, DeprecatedString::formatted("{}{}e{}{}", sign, number_string, exponent_sign, exponent_string)); } } // 11. If e = p - 1, return the string-concatenation of s and m. if (exponent == precision - 1) - return js_string(vm, DeprecatedString::formatted("{}{}", sign, number_string)); + return PrimitiveString::create(vm, DeprecatedString::formatted("{}{}", sign, number_string)); // 12. If e ≥ 0, then if (exponent >= 0) { @@ -417,7 +417,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_precision) } // 14. Return the string-concatenation of s and m. - return js_string(vm, DeprecatedString::formatted("{}{}", sign, number_string)); + return PrimitiveString::create(vm, DeprecatedString::formatted("{}{}", sign, number_string)); } // 21.1.3.6 Number.prototype.toString ( [ radix ] ), https://tc39.es/ecma262/#sec-number.prototype.tostring @@ -441,17 +441,17 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_string) // 5. If radixMV = 10, return ! ToString(x). if (radix_mv == 10) - return js_string(vm, MUST(number_value.to_string(vm))); + return PrimitiveString::create(vm, MUST(number_value.to_string(vm))); // 6. Return the String representation of this Number value using the radix specified by radixMV. Letters a-z are used for digits with values 10 through 35. The precise algorithm is implementation-defined, however the algorithm should be a generalization of that specified in 6.1.6.1.20. if (number_value.is_positive_infinity()) - return js_string(vm, "Infinity"); + return PrimitiveString::create(vm, "Infinity"); if (number_value.is_negative_infinity()) - return js_string(vm, "-Infinity"); + return PrimitiveString::create(vm, "-Infinity"); if (number_value.is_nan()) - return js_string(vm, "NaN"); + return PrimitiveString::create(vm, "NaN"); if (number_value.is_positive_zero() || number_value.is_negative_zero()) - return js_string(vm, "0"); + return PrimitiveString::create(vm, "0"); double number = number_value.as_double(); bool negative = number < 0; @@ -499,7 +499,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_string) characters.take_last(); } - return js_string(vm, DeprecatedString(characters.data(), characters.size())); + return PrimitiveString::create(vm, DeprecatedString(characters.data(), characters.size())); } // 21.1.3.7 Number.prototype.valueOf ( ), https://tc39.es/ecma262/#sec-number.prototype.valueof diff --git a/Userland/Libraries/LibJS/Runtime/Object.cpp b/Userland/Libraries/LibJS/Runtime/Object.cpp index cc872f3e5b2..d9e626c9767 100644 --- a/Userland/Libraries/LibJS/Runtime/Object.cpp +++ b/Userland/Libraries/LibJS/Runtime/Object.cpp @@ -961,7 +961,7 @@ ThrowCompletionOr> Object::internal_own_property_keys() cons // 2. For each own property key P of O such that P is an array index, in ascending numeric index order, do for (auto& entry : m_indexed_properties) { // a. Add P as the last element of keys. - keys.append(js_string(vm, DeprecatedString::number(entry.index()))); + keys.append(PrimitiveString::create(vm, DeprecatedString::number(entry.index()))); } // 3. For each own property key P of O such that Type(P) is String and P is not an array index, in ascending chronological order of property creation, do diff --git a/Userland/Libraries/LibJS/Runtime/ObjectPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ObjectPrototype.cpp index ba4a0eb7c64..5a53ffcdadc 100644 --- a/Userland/Libraries/LibJS/Runtime/ObjectPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/ObjectPrototype.cpp @@ -70,11 +70,11 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectPrototype::to_string) // 1. If the this value is undefined, return "[object Undefined]". if (this_value.is_undefined()) - return js_string(vm, "[object Undefined]"); + return PrimitiveString::create(vm, "[object Undefined]"); // 2. If the this value is null, return "[object Null]". if (this_value.is_null()) - return js_string(vm, "[object Null]"); + return PrimitiveString::create(vm, "[object Null]"); // 3. Let O be ! ToObject(this value). auto* object = MUST(this_value.to_object(vm)); @@ -128,7 +128,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectPrototype::to_string) tag = to_string_tag.as_string().deprecated_string(); // 17. Return the string-concatenation of "[object ", tag, and "]". - return js_string(vm, DeprecatedString::formatted("[object {}]", tag)); + return PrimitiveString::create(vm, DeprecatedString::formatted("[object {}]", tag)); } // 20.1.3.5 Object.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ), https://tc39.es/ecma262/#sec-object.prototype.tolocalestring diff --git a/Userland/Libraries/LibJS/Runtime/PrimitiveString.cpp b/Userland/Libraries/LibJS/Runtime/PrimitiveString.cpp index 51f4a1f7567..2b0a3ed4d6b 100644 --- a/Userland/Libraries/LibJS/Runtime/PrimitiveString.cpp +++ b/Userland/Libraries/LibJS/Runtime/PrimitiveString.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2020, Andreas Kling + * Copyright (c) 2022, Linus Groh * * SPDX-License-Identifier: BSD-2-Clause */ @@ -105,65 +106,50 @@ Optional PrimitiveString::get(VM& vm, PropertyKey const& property_key) co auto length = str.length_in_code_units(); if (length <= index.as_index()) return {}; - return js_string(vm, str.substring_view(index.as_index(), 1)); + return create(vm, str.substring_view(index.as_index(), 1)); } -PrimitiveString* js_string(Heap& heap, Utf16View const& view) +NonnullGCPtr PrimitiveString::create(VM& vm, Utf16View const& view) { - return js_string(heap, Utf16String(view)); + return create(vm, Utf16String(view)); } -PrimitiveString* js_string(VM& vm, Utf16View const& view) -{ - return js_string(vm.heap(), view); -} - -PrimitiveString* js_string(Heap& heap, Utf16String string) +NonnullGCPtr PrimitiveString::create(VM& vm, Utf16String string) { if (string.is_empty()) - return &heap.vm().empty_string(); + return vm.empty_string(); if (string.length_in_code_units() == 1) { u16 code_unit = string.code_unit_at(0); if (is_ascii(code_unit)) - return &heap.vm().single_ascii_character_string(static_cast(code_unit)); + return vm.single_ascii_character_string(static_cast(code_unit)); } - return heap.allocate_without_realm(move(string)); + return *vm.heap().allocate_without_realm(move(string)); } -PrimitiveString* js_string(VM& vm, Utf16String string) -{ - return js_string(vm.heap(), move(string)); -} - -PrimitiveString* js_string(Heap& heap, DeprecatedString string) +NonnullGCPtr PrimitiveString::create(VM& vm, DeprecatedString string) { if (string.is_empty()) - return &heap.vm().empty_string(); + return vm.empty_string(); if (string.length() == 1) { auto ch = static_cast(string.characters()[0]); if (is_ascii(ch)) - return &heap.vm().single_ascii_character_string(ch); + return vm.single_ascii_character_string(ch); } - auto& string_cache = heap.vm().string_cache(); + auto& string_cache = vm.string_cache(); auto it = string_cache.find(string); if (it == string_cache.end()) { - auto* new_string = heap.allocate_without_realm(string); + auto* new_string = vm.heap().allocate_without_realm(string); string_cache.set(move(string), new_string); - return new_string; + return *new_string; } - return it->value; + return *it->value; } -PrimitiveString* js_string(VM& vm, DeprecatedString string) -{ - return js_string(vm.heap(), move(string)); -} - -PrimitiveString* js_rope_string(VM& vm, PrimitiveString& lhs, PrimitiveString& rhs) +NonnullGCPtr PrimitiveString::create(VM& vm, PrimitiveString& lhs, PrimitiveString& rhs) { // We're here to concatenate two strings into a new rope string. // However, if any of them are empty, no rope is required. @@ -172,15 +158,15 @@ PrimitiveString* js_rope_string(VM& vm, PrimitiveString& lhs, PrimitiveString& r bool rhs_empty = rhs.is_empty(); if (lhs_empty && rhs_empty) - return &vm.empty_string(); + return vm.empty_string(); if (lhs_empty) - return &rhs; + return rhs; if (rhs_empty) - return &lhs; + return lhs; - return vm.heap().allocate_without_realm(lhs, rhs); + return *vm.heap().allocate_without_realm(lhs, rhs); } void PrimitiveString::resolve_rope_if_needed() const diff --git a/Userland/Libraries/LibJS/Runtime/PrimitiveString.h b/Userland/Libraries/LibJS/Runtime/PrimitiveString.h index 0cd9ad8a620..210e066cd60 100644 --- a/Userland/Libraries/LibJS/Runtime/PrimitiveString.h +++ b/Userland/Libraries/LibJS/Runtime/PrimitiveString.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2020, Andreas Kling + * Copyright (c) 2022, Linus Groh * * SPDX-License-Identifier: BSD-2-Clause */ @@ -19,6 +20,11 @@ class PrimitiveString final : public Cell { JS_CELL(PrimitiveString, Cell); public: + [[nodiscard]] static NonnullGCPtr create(VM&, Utf16View const&); + [[nodiscard]] static NonnullGCPtr create(VM&, Utf16String); + [[nodiscard]] static NonnullGCPtr create(VM&, DeprecatedString); + [[nodiscard]] static NonnullGCPtr create(VM&, PrimitiveString&, PrimitiveString&); + virtual ~PrimitiveString(); PrimitiveString(PrimitiveString const&) = delete; @@ -56,15 +62,4 @@ private: mutable Utf16String m_utf16_string; }; -PrimitiveString* js_string(Heap&, Utf16View const&); -PrimitiveString* js_string(VM&, Utf16View const&); - -PrimitiveString* js_string(Heap&, Utf16String); -PrimitiveString* js_string(VM&, Utf16String); - -PrimitiveString* js_string(Heap&, DeprecatedString); -PrimitiveString* js_string(VM&, DeprecatedString); - -PrimitiveString* js_rope_string(VM&, PrimitiveString&, PrimitiveString&); - } diff --git a/Userland/Libraries/LibJS/Runtime/Promise.cpp b/Userland/Libraries/LibJS/Runtime/Promise.cpp index 46defb8580f..daee59051db 100644 --- a/Userland/Libraries/LibJS/Runtime/Promise.cpp +++ b/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, js_string(vm, DeprecatedString::empty()), Attribute::Configurable); + resolve_function->define_direct_property(vm.names.name, PrimitiveString::create(vm, DeprecatedString::empty()), 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, js_string(vm, DeprecatedString::empty()), Attribute::Configurable); + reject_function->define_direct_property(vm.names.name, PrimitiveString::create(vm, DeprecatedString::empty()), Attribute::Configurable); // 12. Return the Record { [[Resolve]]: resolve, [[Reject]]: reject }. return { *resolve_function, *reject_function }; diff --git a/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp b/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp index 9cb1fa540e4..4a3b735c822 100644 --- a/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp @@ -139,7 +139,7 @@ static ThrowCompletionOr 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, js_string(vm, DeprecatedString::empty()), Attribute::Configurable); + on_fulfilled->define_direct_property(vm.names.name, PrimitiveString::create(vm, DeprecatedString::empty()), 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 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, js_string(vm, DeprecatedString::empty()), Attribute::Configurable); + on_fulfilled->define_direct_property(vm.names.name, PrimitiveString::create(vm, DeprecatedString::empty()), 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 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, js_string(vm, DeprecatedString::empty()), Attribute::Configurable); + on_rejected->define_direct_property(vm.names.name, PrimitiveString::create(vm, DeprecatedString::empty()), 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 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, js_string(vm, DeprecatedString::empty()), Attribute::Configurable); + on_rejected->define_direct_property(vm.names.name, PrimitiveString::create(vm, DeprecatedString::empty()), Attribute::Configurable); // s. Perform ? Invoke(nextPromise, "then", « resultCapability.[[Resolve]], onRejected »). return next_promise.invoke(vm, vm.names.then, result_capability.resolve(), on_rejected); diff --git a/Userland/Libraries/LibJS/Runtime/PromisePrototype.cpp b/Userland/Libraries/LibJS/Runtime/PromisePrototype.cpp index e14fe7e5d5b..ff349e8e007 100644 --- a/Userland/Libraries/LibJS/Runtime/PromisePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/PromisePrototype.cpp @@ -32,7 +32,7 @@ void PromisePrototype::initialize(Realm& realm) define_native_function(realm, vm.names.finally, finally, 1, attr); // 27.2.5.5 Promise.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-promise.prototype-@@tostringtag - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, vm.names.Promise.as_string()), Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.Promise.as_string()), Attribute::Configurable); } // 27.2.5.4 Promise.prototype.then ( onFulfilled, onRejected ), https://tc39.es/ecma262/#sec-promise.prototype.then diff --git a/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.cpp b/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.cpp index 35824d5d377..ce8de8dcbbb 100644 --- a/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.cpp +++ b/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.cpp @@ -104,7 +104,7 @@ ThrowCompletionOr PromiseAllSettledResolveElementFunction::resolve_elemen auto* object = Object::create(realm, realm.intrinsics().object_prototype()); // 10. Perform ! CreateDataPropertyOrThrow(obj, "status", "fulfilled"). - MUST(object->create_data_property_or_throw(vm.names.status, js_string(vm, "fulfilled"sv))); + MUST(object->create_data_property_or_throw(vm.names.status, PrimitiveString::create(vm, "fulfilled"sv))); // 11. Perform ! CreateDataPropertyOrThrow(obj, "value", x). MUST(object->create_data_property_or_throw(vm.names.value, vm.argument(0))); @@ -145,7 +145,7 @@ ThrowCompletionOr PromiseAllSettledRejectElementFunction::resolve_element auto* object = Object::create(realm, realm.intrinsics().object_prototype()); // 10. Perform ! CreateDataPropertyOrThrow(obj, "status", "rejected"). - MUST(object->create_data_property_or_throw(vm.names.status, js_string(vm, "rejected"sv))); + MUST(object->create_data_property_or_throw(vm.names.status, PrimitiveString::create(vm, "rejected"sv))); // 11. Perform ! CreateDataPropertyOrThrow(obj, "reason", x). MUST(object->create_data_property_or_throw(vm.names.reason, vm.argument(0))); diff --git a/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp b/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp index 89c09dc0f9e..e09167a824f 100644 --- a/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp @@ -34,10 +34,10 @@ static Value property_key_to_value(VM& vm, PropertyKey const& property_key) return property_key.as_symbol(); if (property_key.is_string()) - return js_string(vm, property_key.as_string()); + return PrimitiveString::create(vm, property_key.as_string()); VERIFY(property_key.is_number()); - return js_string(vm, DeprecatedString::number(property_key.as_number())); + return PrimitiveString::create(vm, DeprecatedString::number(property_key.as_number())); } // 10.5.1 [[GetPrototypeOf]] ( ), https://tc39.es/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-getprototypeof diff --git a/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp b/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp index 7ac1d6ecc99..2c679de90d6 100644 --- a/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp @@ -40,7 +40,7 @@ void ReflectObject::initialize(Realm& realm) define_native_function(realm, vm.names.setPrototypeOf, set_prototype_of, 2, attr); // 28.1.14 Reflect [ @@toStringTag ], https://tc39.es/ecma262/#sec-reflect-@@tostringtag - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, vm.names.Reflect.as_string()), Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.Reflect.as_string()), Attribute::Configurable); } // 28.1.1 Reflect.apply ( target, thisArgument, argumentsList ), https://tc39.es/ecma262/#sec-reflect.apply diff --git a/Userland/Libraries/LibJS/Runtime/RegExpConstructor.cpp b/Userland/Libraries/LibJS/Runtime/RegExpConstructor.cpp index a6f27d3de6b..492305da8e4 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/RegExpConstructor.cpp @@ -100,11 +100,11 @@ ThrowCompletionOr RegExpConstructor::construct(FunctionObject& new_targ if (pattern.is_object() && is(pattern.as_object())) { // a. Let P be pattern.[[OriginalSource]]. auto& regexp_pattern = static_cast(pattern.as_object()); - pattern_value = js_string(vm, regexp_pattern.pattern()); + pattern_value = PrimitiveString::create(vm, regexp_pattern.pattern()); // b. If flags is undefined, let F be pattern.[[OriginalFlags]]. if (flags.is_undefined()) - flags_value = js_string(vm, regexp_pattern.flags()); + flags_value = PrimitiveString::create(vm, regexp_pattern.flags()); // c. Else, let F be flags. else flags_value = flags; diff --git a/Userland/Libraries/LibJS/Runtime/RegExpLegacyStaticProperties.cpp b/Userland/Libraries/LibJS/Runtime/RegExpLegacyStaticProperties.cpp index 39d10dc6deb..50445480379 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpLegacyStaticProperties.cpp +++ b/Userland/Libraries/LibJS/Runtime/RegExpLegacyStaticProperties.cpp @@ -46,7 +46,7 @@ ThrowCompletionOr get_legacy_regexp_static_property(VM& vm, RegExpConstru return vm.throw_completion(ErrorType::GetLegacyRegExpStaticPropertyValueEmpty); // 5. Return val. - return js_string(vm, val.release_value()); + return PrimitiveString::create(vm, val.release_value()); } // SetLegacyRegExpStaticProperty( C, thisValue, internalSlotName, val ), https://github.com/tc39/proposal-regexp-legacy-features#setlegacyregexpstaticproperty-c-thisvalue-internalslotname-val- diff --git a/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp b/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp index 677fb0a7e5d..dcbd064cc33 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp @@ -275,7 +275,7 @@ static ThrowCompletionOr regexp_builtin_exec(VM& vm, RegExpObject& regexp // 27. Let matchedValue be ! GetMatchString(S, match). // 28. Perform ! CreateDataPropertyOrThrow(A, "0", matchedValue). - MUST(array->create_data_property_or_throw(0, js_string(vm, match.view.u16_view()))); + MUST(array->create_data_property_or_throw(0, PrimitiveString::create(vm, match.view.u16_view()))); // 29. If R contains any GroupName, then // a. Let groups be OrdinaryObjectCreate(null). @@ -312,7 +312,7 @@ static ThrowCompletionOr regexp_builtin_exec(VM& vm, RegExpObject& regexp // iv. Let capture be the Match { [[StartIndex]]: captureStart, [[EndIndex]: captureEnd }. // v. Let capturedValue be ! GetMatchString(S, capture). auto capture_as_utf16_string = Utf16String(capture.view.u16_view()); - captured_value = js_string(vm, capture_as_utf16_string); + captured_value = PrimitiveString::create(vm, capture_as_utf16_string); // vi. Append capture to indices. indices.append(Match::create(capture)); // vii. Append capturedValue to the end of capturedValues. @@ -375,8 +375,8 @@ static ThrowCompletionOr regexp_builtin_exec(VM& vm, RegExpObject& regexp } // 22. Perform ! CreateDataPropertyOrThrow(A, "input", S). - // NOTE: This step is performed last to allow the string to be moved into the js_string invocation. - MUST(array->create_data_property_or_throw(vm.names.input, js_string(vm, move(string)))); + // NOTE: This step is performed last to allow the string to be moved into the PrimitiveString::create() invocation. + MUST(array->create_data_property_or_throw(vm.names.input, PrimitiveString::create(vm, move(string)))); // 34. Return A. return array; @@ -391,7 +391,7 @@ ThrowCompletionOr regexp_exec(VM& vm, Object& regexp_object, Utf16String // 2. If IsCallable(exec) is true, then if (exec.is_function()) { // a. Let result be ? Call(exec, R, « S »). - auto result = TRY(call(vm, exec.as_function(), ®exp_object, js_string(vm, move(string)))); + auto result = TRY(call(vm, exec.as_function(), ®exp_object, PrimitiveString::create(vm, move(string)))); // b. If Type(result) is neither Object nor Null, throw a TypeError exception. if (!result.is_object() && !result.is_null()) @@ -510,7 +510,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::flags) #undef __JS_ENUMERATE // 18. Return result. - return js_string(vm, builder.to_deprecated_string()); + return PrimitiveString::create(vm, builder.to_deprecated_string()); } // 22.2.5.8 RegExp.prototype [ @@match ] ( string ), https://tc39.es/ecma262/#sec-regexp.prototype-@@match @@ -576,7 +576,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_match) auto match_str = TRY(match_value.to_string(vm)); // 2. Perform ! CreateDataPropertyOrThrow(A, ! ToString(𝔽(n)), matchStr). - MUST(array->create_data_property_or_throw(n, js_string(vm, match_str))); + MUST(array->create_data_property_or_throw(n, PrimitiveString::create(vm, match_str))); // 3. If matchStr is the empty String, then if (match_str.is_empty()) { @@ -620,7 +620,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_match_all) bool full_unicode = flags.contains('u') || flags.contains('v'); // 6. Let matcher be ? Construct(C, « R, flags »). - auto* matcher = TRY(construct(vm, *constructor, regexp_object, js_string(vm, move(flags)))); + auto* matcher = TRY(construct(vm, *constructor, regexp_object, PrimitiveString::create(vm, move(flags)))); // 7. Let lastIndex be ? ToLength(? Get(R, "lastIndex")). auto last_index_value = TRY(regexp_object->get(vm.names.lastIndex)); @@ -654,7 +654,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_replace) if (!replace_value.is_function()) { // a. Set replaceValue to ? ToString(replaceValue). auto replace_string = TRY(replace_value.to_string(vm)); - replace_value = js_string(vm, move(replace_string)); + replace_value = PrimitiveString::create(vm, move(replace_string)); } // 7. Let flags be ? ToString(? Get(rx, "flags")). @@ -752,7 +752,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_replace) // ii. If capN is not undefined, then if (!capture.is_undefined()) { // 1. Set capN to ? ToString(capN). - capture = js_string(vm, TRY(capture.to_string(vm))); + capture = PrimitiveString::create(vm, TRY(capture.to_string(vm))); } // iii. Append capN as the last element of captures. @@ -771,14 +771,14 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_replace) if (replace_value.is_function()) { // i. Let replacerArgs be « matched ». MarkedVector replacer_args(vm.heap()); - replacer_args.append(js_string(vm, move(matched))); + replacer_args.append(PrimitiveString::create(vm, move(matched))); // ii. Append in List order the elements of captures to the end of the List replacerArgs. replacer_args.extend(move(captures)); // iii. Append 𝔽(position) and S to replacerArgs. replacer_args.append(Value(position)); - replacer_args.append(js_string(vm, string)); + replacer_args.append(PrimitiveString::create(vm, string)); // iv. If namedCaptures is not undefined, then if (!named_captures.is_undefined()) { @@ -820,13 +820,13 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_replace) // 15. If nextSourcePosition ≥ lengthS, return accumulatedResult. if (next_source_position >= string.length_in_code_units()) - return js_string(vm, accumulated_result.build()); + return PrimitiveString::create(vm, accumulated_result.build()); // 16. Return the string-concatenation of accumulatedResult and the substring of S from nextSourcePosition. auto substring = string.substring_view(next_source_position); accumulated_result.append(substring); - return js_string(vm, accumulated_result.build()); + return PrimitiveString::create(vm, accumulated_result.build()); } // 22.2.5.12 RegExp.prototype [ @@search ] ( string ), https://tc39.es/ecma262/#sec-regexp.prototype-@@search @@ -881,7 +881,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::source) if (!is(regexp_object)) { // a. If SameValue(R, %RegExp.prototype%) is true, return "(?:)". if (same_value(regexp_object, realm.intrinsics().regexp_prototype())) - return js_string(vm, "(?:)"); + return PrimitiveString::create(vm, "(?:)"); // b. Otherwise, throw a TypeError exception. return vm.throw_completion(ErrorType::NotAnObjectOfType, "RegExp"); @@ -891,7 +891,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::source) // 5. Let src be R.[[OriginalSource]]. // 6. Let flags be R.[[OriginalFlags]]. // 7. Return EscapeRegExpPattern(src, flags). - return js_string(vm, static_cast(*regexp_object).escape_regexp_pattern()); + return PrimitiveString::create(vm, static_cast(*regexp_object).escape_regexp_pattern()); } // 22.2.5.14 RegExp.prototype [ @@split ] ( string, limit ), https://tc39.es/ecma262/#sec-regexp.prototype-@@split @@ -923,7 +923,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_split) auto new_flags = flags.find('y').has_value() ? move(flags) : DeprecatedString::formatted("{}y", flags); // 10. Let splitter be ? Construct(C, « rx, newFlags »). - auto* splitter = TRY(construct(vm, *constructor, regexp_object, js_string(vm, move(new_flags)))); + auto* splitter = TRY(construct(vm, *constructor, regexp_object, PrimitiveString::create(vm, move(new_flags)))); // 11. Let A be ! ArrayCreate(0). auto* array = MUST(Array::create(realm, 0)); @@ -951,7 +951,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_split) return array; // c. Perform ! CreateDataPropertyOrThrow(A, "0", S). - MUST(array->create_data_property_or_throw(0, js_string(vm, move(string)))); + MUST(array->create_data_property_or_throw(0, PrimitiveString::create(vm, move(string)))); // d. Return A. return array; @@ -998,7 +998,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_split) auto substring = string.substring_view(last_match_end, next_search_from - last_match_end); // 2. Perform ! CreateDataPropertyOrThrow(A, ! ToString(𝔽(lengthA)), T). - MUST(array->create_data_property_or_throw(array_length, js_string(vm, substring))); + MUST(array->create_data_property_or_throw(array_length, PrimitiveString::create(vm, substring))); // 3. Set lengthA to lengthA + 1. ++array_length; @@ -1045,7 +1045,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_split) auto substring = string.substring_view(last_match_end); // 21. Perform ! CreateDataPropertyOrThrow(A, ! ToString(𝔽(lengthA)), T). - MUST(array->create_data_property_or_throw(array_length, js_string(vm, substring))); + MUST(array->create_data_property_or_throw(array_length, PrimitiveString::create(vm, substring))); // 22. Return A. return array; @@ -1085,7 +1085,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::to_string) // 5. Let result be the string-concatenation of "/", pattern, "/", and flags. // 6. Return result. - return js_string(vm, DeprecatedString::formatted("/{}/{}", pattern, flags)); + return PrimitiveString::create(vm, DeprecatedString::formatted("/{}/{}", pattern, flags)); } // B.2.4.1 RegExp.prototype.compile ( pattern, flags ), https://tc39.es/ecma262/#sec-regexp.prototype.compile @@ -1122,10 +1122,10 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::compile) auto& regexp_pattern = static_cast(pattern.as_object()); // b. Let P be pattern.[[OriginalSource]]. - pattern = js_string(vm, regexp_pattern.pattern()); + pattern = PrimitiveString::create(vm, regexp_pattern.pattern()); // c. Let F be pattern.[[OriginalFlags]]. - flags = js_string(vm, regexp_pattern.flags()); + flags = PrimitiveString::create(vm, regexp_pattern.flags()); } // 8. Else, // a. Let P be pattern. diff --git a/Userland/Libraries/LibJS/Runtime/RegExpStringIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/RegExpStringIteratorPrototype.cpp index f202b759e9f..db5976216f7 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpStringIteratorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/RegExpStringIteratorPrototype.cpp @@ -26,7 +26,7 @@ void RegExpStringIteratorPrototype::initialize(Realm& realm) define_native_function(realm, vm.names.next, next, 0, attr); // 22.2.7.2.2 %RegExpStringIteratorPrototype% [ @@toStringTag ], https://tc39.es/ecma262/#sec-%regexpstringiteratorprototype%-@@tostringtag - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "RegExp String Iterator"), Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "RegExp String Iterator"), Attribute::Configurable); } // 22.2.7.2.1 %RegExpStringIteratorPrototype%.next ( ), https://tc39.es/ecma262/#sec-%regexpstringiteratorprototype%.next diff --git a/Userland/Libraries/LibJS/Runtime/SetIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/SetIteratorPrototype.cpp index d93db45b96a..aa7cce8380b 100644 --- a/Userland/Libraries/LibJS/Runtime/SetIteratorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/SetIteratorPrototype.cpp @@ -26,7 +26,7 @@ void SetIteratorPrototype::initialize(Realm& realm) define_native_function(realm, vm.names.next, next, 0, Attribute::Configurable | Attribute::Writable); // 24.2.5.2.2 %SetIteratorPrototype% [ @@toStringTag ], https://tc39.es/ecma262/#sec-%setiteratorprototype%-@@tostringtag - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Set Iterator"), Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Set Iterator"), Attribute::Configurable); } // 24.2.5.2.1 %SetIteratorPrototype%.next ( ), https://tc39.es/ecma262/#sec-%setiteratorprototype%.next diff --git a/Userland/Libraries/LibJS/Runtime/SetPrototype.cpp b/Userland/Libraries/LibJS/Runtime/SetPrototype.cpp index 724e9ccc38b..fcef496d103 100644 --- a/Userland/Libraries/LibJS/Runtime/SetPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/SetPrototype.cpp @@ -47,7 +47,7 @@ void SetPrototype::initialize(Realm& realm) define_direct_property(*vm.well_known_symbol_iterator(), get_without_side_effects(vm.names.values), attr); // 24.2.3.12 Set.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-set.prototype-@@tostringtag - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, vm.names.Set.as_string()), Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.Set.as_string()), Attribute::Configurable); } // 24.2.3.1 Set.prototype.add ( value ), https://tc39.es/ecma262/#sec-set.prototype.add diff --git a/Userland/Libraries/LibJS/Runtime/ShadowRealm.cpp b/Userland/Libraries/LibJS/Runtime/ShadowRealm.cpp index b7cafea214b..cc5d5524106 100644 --- a/Userland/Libraries/LibJS/Runtime/ShadowRealm.cpp +++ b/Userland/Libraries/LibJS/Runtime/ShadowRealm.cpp @@ -83,7 +83,7 @@ ThrowCompletionOr 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 = js_string(vm, DeprecatedString::empty()); + target_name = PrimitiveString::create(vm, DeprecatedString::empty()); // 8. Perform SetFunctionName(F, targetName, prefix). function.set_function_name({ target_name.as_string().deprecated_string() }, move(prefix)); diff --git a/Userland/Libraries/LibJS/Runtime/ShadowRealmPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ShadowRealmPrototype.cpp index 9025b7197f5..a1b17512e91 100644 --- a/Userland/Libraries/LibJS/Runtime/ShadowRealmPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/ShadowRealmPrototype.cpp @@ -26,7 +26,7 @@ void ShadowRealmPrototype::initialize(Realm& realm) define_native_function(realm, vm.names.importValue, import_value, 2, attr); // 3.4.3 ShadowRealm.prototype [ @@toStringTag ], https://tc39.es/proposal-shadowrealm/#sec-shadowrealm.prototype-@@tostringtag - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, vm.names.ShadowRealm.as_string()), Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.ShadowRealm.as_string()), Attribute::Configurable); } // 3.4.1 ShadowRealm.prototype.evaluate ( sourceText ), https://tc39.es/proposal-shadowrealm/#sec-shadowrealm.prototype.evaluate diff --git a/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp b/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp index 9526a764bc6..ee38bd04a26 100644 --- a/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp @@ -43,9 +43,9 @@ ThrowCompletionOr StringConstructor::call() { auto& vm = this->vm(); if (!vm.argument_count()) - return js_string(heap(), ""); + return PrimitiveString::create(vm, ""); if (vm.argument(0).is_symbol()) - return js_string(vm, vm.argument(0).as_symbol().to_deprecated_string()); + return PrimitiveString::create(vm, vm.argument(0).as_symbol().to_deprecated_string()); return TRY(vm.argument(0).to_primitive_string(vm)); } @@ -57,7 +57,7 @@ ThrowCompletionOr StringConstructor::construct(FunctionObject& new_targ PrimitiveString* primitive_string; if (!vm.argument_count()) - primitive_string = js_string(vm, ""); + primitive_string = PrimitiveString::create(vm, ""); else primitive_string = TRY(vm.argument(0).to_primitive_string(vm)); auto* prototype = TRY(get_prototype_from_constructor(vm, new_target, &Intrinsics::string_prototype)); @@ -73,7 +73,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringConstructor::raw) auto literal_segments = TRY(length_of_array_like(vm, *raw)); if (literal_segments == 0) - return js_string(vm, ""); + return PrimitiveString::create(vm, ""); auto const number_of_substituions = vm.argument_count() - 1; @@ -94,7 +94,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringConstructor::raw) builder.append(next_sub); } } - return js_string(vm, builder.build()); + return PrimitiveString::create(vm, builder.build()); } // 22.1.2.1 String.fromCharCode ( ...codeUnits ), https://tc39.es/ecma262/#sec-string.fromcharcode @@ -106,7 +106,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringConstructor::from_char_code) for (size_t i = 0; i < vm.argument_count(); ++i) string.append(TRY(vm.argument(i).to_u16(vm))); - return js_string(vm, Utf16String(move(string))); + return PrimitiveString::create(vm, Utf16String(move(string))); } // 22.1.2.2 String.fromCodePoint ( ...codePoints ), https://tc39.es/ecma262/#sec-string.fromcodepoint @@ -126,7 +126,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringConstructor::from_code_point) AK::code_point_to_utf16(string, static_cast(code_point)); } - return js_string(vm, Utf16String(move(string))); + return PrimitiveString::create(vm, Utf16String(move(string))); } } diff --git a/Userland/Libraries/LibJS/Runtime/StringIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/StringIteratorPrototype.cpp index 3f250daed4e..b9932f09559 100644 --- a/Userland/Libraries/LibJS/Runtime/StringIteratorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/StringIteratorPrototype.cpp @@ -25,7 +25,7 @@ void StringIteratorPrototype::initialize(Realm& realm) define_native_function(realm, vm.names.next, next, 0, Attribute::Configurable | Attribute::Writable); // 22.1.5.1.2 %StringIteratorPrototype% [ @@toStringTag ], https://tc39.es/ecma262/#sec-%stringiteratorprototype%-@@tostringtag - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "String Iterator"), Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "String Iterator"), Attribute::Configurable); } // 22.1.5.1.1 %StringIteratorPrototype%.next ( ), https://tc39.es/ecma262/#sec-%stringiteratorprototype%.next @@ -46,7 +46,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringIteratorPrototype::next) builder.append_code_point(*utf8_iterator); ++utf8_iterator; - return create_iterator_result_object(vm, js_string(vm, builder.to_deprecated_string()), false); + return create_iterator_result_object(vm, PrimitiveString::create(vm, builder.to_deprecated_string()), false); } } diff --git a/Userland/Libraries/LibJS/Runtime/StringObject.cpp b/Userland/Libraries/LibJS/Runtime/StringObject.cpp index eb186653e6e..2ebd852bd8a 100644 --- a/Userland/Libraries/LibJS/Runtime/StringObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/StringObject.cpp @@ -71,7 +71,7 @@ static Optional string_get_own_property(StringObject const& return {}; // 10. Let resultStr be the String value of length 1, containing one code unit from str, specifically the code unit at index ℝ(index). - auto result_str = js_string(string.vm(), str.substring_view(index.as_index(), 1)); + auto result_str = PrimitiveString::create(string.vm(), str.substring_view(index.as_index(), 1)); // 11. Return the PropertyDescriptor { [[Value]]: resultStr, [[Writable]]: false, [[Enumerable]]: true, [[Configurable]]: false }. return PropertyDescriptor { @@ -138,14 +138,14 @@ ThrowCompletionOr> StringObject::internal_own_property_keys( // 5. For each integer i starting with 0 such that i < len, in ascending order, do for (size_t i = 0; i < length; ++i) { // a. Add ! ToString(𝔽(i)) as the last element of keys. - keys.append(js_string(vm, DeprecatedString::number(i))); + keys.append(PrimitiveString::create(vm, DeprecatedString::number(i))); } // 6. For each own property key P of O such that P is an array index and ! ToIntegerOrInfinity(P) ≥ len, in ascending numeric index order, do for (auto& entry : indexed_properties()) { if (entry.index() >= length) { // a. Add P as the last element of keys. - keys.append(js_string(vm, DeprecatedString::number(entry.index()))); + keys.append(PrimitiveString::create(vm, DeprecatedString::number(entry.index()))); } } diff --git a/Userland/Libraries/LibJS/Runtime/StringOrSymbol.h b/Userland/Libraries/LibJS/Runtime/StringOrSymbol.h index 7e96e84fb43..1da6be44df4 100644 --- a/Userland/Libraries/LibJS/Runtime/StringOrSymbol.h +++ b/Userland/Libraries/LibJS/Runtime/StringOrSymbol.h @@ -86,7 +86,7 @@ public: Value to_value(VM& vm) const { if (is_string()) - return js_string(vm, as_string()); + return PrimitiveString::create(vm, as_string()); if (is_symbol()) return const_cast(as_symbol()); return {}; diff --git a/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp b/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp index 423b3b711d0..45adc0ec27b 100644 --- a/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp @@ -131,7 +131,7 @@ CodePoint code_point_at(Utf16View const& string, size_t position) } StringPrototype::StringPrototype(Realm& realm) - : StringObject(*js_string(realm.vm(), DeprecatedString::empty()), *realm.intrinsics().object_prototype()) + : StringObject(*PrimitiveString::create(realm.vm(), DeprecatedString::empty()), *realm.intrinsics().object_prototype()) { } @@ -237,7 +237,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::at) return js_undefined(); // 7. Return ? Get(O, ! ToString(𝔽(k))). - return js_string(vm, string.substring_view(index.value(), 1)); + return PrimitiveString::create(vm, string.substring_view(index.value(), 1)); } // 22.1.3.2 String.prototype.charAt ( pos ), https://tc39.es/ecma262/#sec-string.prototype.charat @@ -246,9 +246,9 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::char_at) auto string = TRY(utf16_string_from(vm)); auto position = TRY(vm.argument(0).to_integer_or_infinity(vm)); if (position < 0 || position >= string.length_in_code_units()) - return js_string(vm, DeprecatedString::empty()); + return PrimitiveString::create(vm, DeprecatedString::empty()); - return js_string(vm, string.substring_view(position, 1)); + return PrimitiveString::create(vm, string.substring_view(position, 1)); } // 22.1.3.3 String.prototype.charCodeAt ( pos ), https://tc39.es/ecma262/#sec-string.prototype.charcodeat @@ -292,7 +292,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::concat) auto* next_string = TRY(vm.argument(i).to_primitive_string(vm)); // b. Set R to the string-concatenation of R and nextString. - result = js_rope_string(vm, *result, *next_string); + result = PrimitiveString::create(vm, *result, *next_string); } // 5. Return R. @@ -451,7 +451,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::match) auto string = TRY(this_object.to_utf16_string(vm)); auto rx = TRY(regexp_create(vm, regexp, js_undefined())); - return TRY(Value(rx).invoke(vm, *vm.well_known_symbol_match(), js_string(vm, move(string)))); + return TRY(Value(rx).invoke(vm, *vm.well_known_symbol_match(), PrimitiveString::create(vm, move(string)))); } // 22.1.3.13 String.prototype.matchAll ( regexp ), https://tc39.es/ecma262/#sec-string.prototype.matchall @@ -474,8 +474,8 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::match_all) auto string = TRY(this_object.to_utf16_string(vm)); - auto rx = TRY(regexp_create(vm, regexp, js_string(vm, "g"))); - return TRY(Value(rx).invoke(vm, *vm.well_known_symbol_match_all(), js_string(vm, move(string)))); + auto rx = TRY(regexp_create(vm, regexp, PrimitiveString::create(vm, "g"))); + return TRY(Value(rx).invoke(vm, *vm.well_known_symbol_match_all(), PrimitiveString::create(vm, move(string)))); } // 22.1.3.14 String.prototype.normalize ( [ form ] ), https://tc39.es/ecma262/#sec-string.prototype.normalize @@ -501,7 +501,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::normalize) auto ns = Unicode::normalize(string, unicode_form); // 7. return ns. - return js_string(vm, move(ns)); + return PrimitiveString::create(vm, move(ns)); } enum class PadPlacement { @@ -516,13 +516,13 @@ static ThrowCompletionOr pad_string(VM& vm, Utf16String string, PadPlacem auto max_length = TRY(vm.argument(0).to_length(vm)); if (max_length <= string_length) - return js_string(vm, move(string)); + return PrimitiveString::create(vm, move(string)); Utf16String fill_string(Vector { 0x20 }); if (!vm.argument(1).is_undefined()) { fill_string = TRY(vm.argument(1).to_utf16_string(vm)); if (fill_string.is_empty()) - return js_string(vm, move(string)); + return PrimitiveString::create(vm, move(string)); } auto fill_code_units = fill_string.length_in_code_units(); @@ -538,7 +538,7 @@ static ThrowCompletionOr pad_string(VM& vm, Utf16String string, PadPlacem auto formatted = placement == PadPlacement::Start ? DeprecatedString::formatted("{}{}", filler, string.view()) : DeprecatedString::formatted("{}{}", string.view(), filler); - return js_string(vm, move(formatted)); + return PrimitiveString::create(vm, move(formatted)); } // 22.1.3.15 String.prototype.padEnd ( maxLength [ , fillString ] ), https://tc39.es/ecma262/#sec-string.prototype.padend @@ -569,16 +569,16 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::repeat) return vm.throw_completion(ErrorType::StringRepeatCountMustBe, "finite"); if (n == 0) - return js_string(vm, DeprecatedString::empty()); + return PrimitiveString::create(vm, DeprecatedString::empty()); // NOTE: This is an optimization, it is not required by the specification but it produces equivalent behavior if (string.is_empty()) - return js_string(vm, DeprecatedString::empty()); + return PrimitiveString::create(vm, DeprecatedString::empty()); StringBuilder builder; for (size_t i = 0; i < n; ++i) builder.append(string); - return js_string(vm, builder.to_deprecated_string()); + return PrimitiveString::create(vm, builder.to_deprecated_string()); } // 22.1.3.18 String.prototype.replace ( searchValue, replaceValue ), https://tc39.es/ecma262/#sec-string.prototype.replace @@ -598,18 +598,18 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::replace) if (!replace_value.is_function()) { auto replace_string = TRY(replace_value.to_utf16_string(vm)); - replace_value = js_string(vm, move(replace_string)); + replace_value = PrimitiveString::create(vm, move(replace_string)); } Optional position = string_index_of(string.view(), search_string.view(), 0); if (!position.has_value()) - return js_string(vm, move(string)); + return PrimitiveString::create(vm, move(string)); auto preserved = string.substring_view(0, position.value()); DeprecatedString replacement; if (replace_value.is_function()) { - auto result = TRY(call(vm, replace_value.as_function(), js_undefined(), js_string(vm, search_string), Value(position.value()), js_string(vm, string))); + auto result = TRY(call(vm, replace_value.as_function(), js_undefined(), PrimitiveString::create(vm, search_string), Value(position.value()), PrimitiveString::create(vm, string))); replacement = TRY(result.to_string(vm)); } else { replacement = TRY(get_substitution(vm, search_string.view(), string.view(), *position, {}, js_undefined(), replace_value)); @@ -620,7 +620,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::replace) builder.append(replacement); builder.append(string.substring_view(*position + search_string.length_in_code_units())); - return js_string(vm, builder.build()); + return PrimitiveString::create(vm, builder.build()); } // 22.1.3.19 String.prototype.replaceAll ( searchValue, replaceValue ), https://tc39.es/ecma262/#sec-string.prototype.replaceall @@ -651,7 +651,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::replace_all) if (!replace_value.is_function()) { auto replace_string = TRY(replace_value.to_utf16_string(vm)); - replace_value = js_string(vm, move(replace_string)); + replace_value = PrimitiveString::create(vm, move(replace_string)); } auto string_length = string.length_in_code_units(); @@ -674,7 +674,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::replace_all) DeprecatedString replacement; if (replace_value.is_function()) { - auto result = TRY(call(vm, replace_value.as_function(), js_undefined(), js_string(vm, search_string), Value(position), js_string(vm, string))); + auto result = TRY(call(vm, replace_value.as_function(), js_undefined(), PrimitiveString::create(vm, search_string), Value(position), PrimitiveString::create(vm, string))); replacement = TRY(result.to_string(vm)); } else { replacement = TRY(get_substitution(vm, search_string.view(), string.view(), position, {}, js_undefined(), replace_value)); @@ -689,7 +689,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::replace_all) if (end_of_last_match < string_length) result.append(string.substring_view(end_of_last_match)); - return js_string(vm, result.build()); + return PrimitiveString::create(vm, result.build()); } // 22.1.3.20 String.prototype.search ( regexp ), https://tc39.es/ecma262/#sec-string.prototype.search @@ -705,7 +705,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::search) auto string = TRY(this_object.to_utf16_string(vm)); auto rx = TRY(regexp_create(vm, regexp, js_undefined())); - return TRY(Value(rx).invoke(vm, *vm.well_known_symbol_search(), js_string(vm, move(string)))); + return TRY(Value(rx).invoke(vm, *vm.well_known_symbol_search(), PrimitiveString::create(vm, move(string)))); } // 22.1.3.21 String.prototype.slice ( start, end ), https://tc39.es/ecma262/#sec-string.prototype.slice @@ -734,9 +734,9 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::slice) } if (int_start >= int_end) - return js_string(vm, DeprecatedString::empty()); + return PrimitiveString::create(vm, DeprecatedString::empty()); - return js_string(vm, string.substring_view(int_start, int_end - int_start)); + return PrimitiveString::create(vm, string.substring_view(int_start, int_end - int_start)); } // 22.1.3.22 String.prototype.split ( separator, limit ), https://tc39.es/ecma262/#sec-string.prototype.split @@ -773,13 +773,13 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::split) auto separator_length = separator.length_in_code_units(); if (separator_argument.is_undefined()) { - MUST(array->create_data_property_or_throw(0, js_string(vm, move(string)))); + MUST(array->create_data_property_or_throw(0, PrimitiveString::create(vm, move(string)))); return array; } if (string_length == 0) { if (separator_length > 0) - MUST(array->create_data_property_or_throw(0, js_string(vm, move(string)))); + MUST(array->create_data_property_or_throw(0, PrimitiveString::create(vm, move(string)))); return array; } @@ -793,7 +793,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::split) } auto segment = string.substring_view(start, position - start); - MUST(array->create_data_property_or_throw(array_length, js_string(vm, segment))); + MUST(array->create_data_property_or_throw(array_length, PrimitiveString::create(vm, segment))); ++array_length; if (array_length == limit) return array; @@ -802,7 +802,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::split) } auto rest = string.substring_view(start); - MUST(array->create_data_property_or_throw(array_length, js_string(vm, rest))); + MUST(array->create_data_property_or_throw(array_length, PrimitiveString::create(vm, rest))); return array; } @@ -867,7 +867,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::substring) size_t to = max(final_start, final_end); // 10. Return the substring of S from from to to. - return js_string(vm, string.substring_view(from, to - from)); + return PrimitiveString::create(vm, string.substring_view(from, to - from)); } enum class TargetCase { @@ -942,7 +942,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::to_locale_lowercase) auto string = TRY(ak_string_from(vm)); // 3. Return ? TransformCase(S, locales, lower). - return js_string(vm, TRY(transform_case(vm, string, locales, TargetCase::Lower))); + return PrimitiveString::create(vm, TRY(transform_case(vm, string, locales, TargetCase::Lower))); } // 22.1.3.26 String.prototype.toLocaleUpperCase ( [ reserved1 [ , reserved2 ] ] ), https://tc39.es/ecma262/#sec-string.prototype.tolocaleuppercase @@ -956,7 +956,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::to_locale_uppercase) auto string = TRY(ak_string_from(vm)); // 3. Return ? TransformCase(S, locales, upper). - return js_string(vm, TRY(transform_case(vm, string, locales, TargetCase::Upper))); + return PrimitiveString::create(vm, TRY(transform_case(vm, string, locales, TargetCase::Upper))); } // 22.1.3.27 String.prototype.toLowerCase ( ), https://tc39.es/ecma262/#sec-string.prototype.tolowercase @@ -964,7 +964,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::to_lowercase) { auto string = TRY(ak_string_from(vm)); auto lowercase = Unicode::to_unicode_lowercase_full(string); - return js_string(vm, move(lowercase)); + return PrimitiveString::create(vm, move(lowercase)); } // 22.1.3.28 String.prototype.toString ( ), https://tc39.es/ecma262/#sec-string.prototype.tostring @@ -978,7 +978,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::to_uppercase) { auto string = TRY(ak_string_from(vm)); auto uppercase = Unicode::to_unicode_uppercase_full(string); - return js_string(vm, move(uppercase)); + return PrimitiveString::create(vm, move(uppercase)); } // 22.1.3.11 String.prototype.toWellFormed ( ), https://tc39.es/proposal-is-usv-string/#sec-string.prototype.towellformed @@ -1018,7 +1018,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::to_well_formed) } // 7. Return result. - return js_string(vm, result.build()); + return PrimitiveString::create(vm, result.build()); } ThrowCompletionOr trim_string(VM& vm, Value input_value, TrimMode where) @@ -1043,19 +1043,19 @@ ThrowCompletionOr trim_string(VM& vm, Value input_value, TrimM // 22.1.3.30 String.prototype.trim ( ), https://tc39.es/ecma262/#sec-string.prototype.trim JS_DEFINE_NATIVE_FUNCTION(StringPrototype::trim) { - return js_string(vm, TRY(trim_string(vm, vm.this_value(), TrimMode::Both))); + return PrimitiveString::create(vm, TRY(trim_string(vm, vm.this_value(), TrimMode::Both))); } // 22.1.3.31 String.prototype.trimEnd ( ), https://tc39.es/ecma262/#sec-string.prototype.trimend JS_DEFINE_NATIVE_FUNCTION(StringPrototype::trim_end) { - return js_string(vm, TRY(trim_string(vm, vm.this_value(), TrimMode::Right))); + return PrimitiveString::create(vm, TRY(trim_string(vm, vm.this_value(), TrimMode::Right))); } // 22.1.3.32 String.prototype.trimStart ( ), https://tc39.es/ecma262/#sec-string.prototype.trimstart JS_DEFINE_NATIVE_FUNCTION(StringPrototype::trim_start) { - return js_string(vm, TRY(trim_string(vm, vm.this_value(), TrimMode::Left))); + return PrimitiveString::create(vm, TRY(trim_string(vm, vm.this_value(), TrimMode::Left))); } // 22.1.3.33 String.prototype.valueOf ( ), https://tc39.es/ecma262/#sec-string.prototype.valueof @@ -1108,10 +1108,10 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::substr) auto int_end = min((i32)(int_start + int_length), size); if (int_start >= int_end) - return js_string(vm, DeprecatedString::empty()); + return PrimitiveString::create(vm, DeprecatedString::empty()); // 11. Return the substring of S from intStart to intEnd. - return js_string(vm, string.substring_view(int_start, int_end - int_start)); + return PrimitiveString::create(vm, string.substring_view(int_start, int_end - int_start)); } // B.2.2.2.1 CreateHTML ( string, tag, attribute, value ), https://tc39.es/ecma262/#sec-createhtml @@ -1135,7 +1135,7 @@ static ThrowCompletionOr create_html(VM& vm, Value string, DeprecatedStri builder.append("'); - return js_string(vm, builder.build()); + return PrimitiveString::create(vm, builder.build()); } // B.2.2.2 String.prototype.anchor ( name ), https://tc39.es/ecma262/#sec-string.prototype.anchor diff --git a/Userland/Libraries/LibJS/Runtime/SymbolConstructor.cpp b/Userland/Libraries/LibJS/Runtime/SymbolConstructor.cpp index 4e814ba565e..1bffcc08266 100644 --- a/Userland/Libraries/LibJS/Runtime/SymbolConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/SymbolConstructor.cpp @@ -85,7 +85,7 @@ JS_DEFINE_NATIVE_FUNCTION(SymbolConstructor::key_for) auto& symbol = argument.as_symbol(); if (symbol.is_global()) - return js_string(vm, symbol.description()); + return PrimitiveString::create(vm, symbol.description()); return js_undefined(); } diff --git a/Userland/Libraries/LibJS/Runtime/SymbolPrototype.cpp b/Userland/Libraries/LibJS/Runtime/SymbolPrototype.cpp index ae33feff44f..a2550d85eb0 100644 --- a/Userland/Libraries/LibJS/Runtime/SymbolPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/SymbolPrototype.cpp @@ -34,7 +34,7 @@ void SymbolPrototype::initialize(Realm& realm) define_native_function(realm, *vm.well_known_symbol_to_primitive(), symbol_to_primitive, 1, Attribute::Configurable); // 20.4.3.6 Symbol.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-symbol.prototype-@@tostringtag - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Symbol"), Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Symbol"), Attribute::Configurable); } // thisSymbolValue ( value ), https://tc39.es/ecma262/#thissymbolvalue @@ -54,14 +54,14 @@ JS_DEFINE_NATIVE_FUNCTION(SymbolPrototype::description_getter) auto& description = symbol->raw_description(); if (!description.has_value()) return js_undefined(); - return js_string(vm, *description); + return PrimitiveString::create(vm, *description); } // 20.4.3.3 Symbol.prototype.toString ( ), https://tc39.es/ecma262/#sec-symbol.prototype.tostring JS_DEFINE_NATIVE_FUNCTION(SymbolPrototype::to_string) { auto* symbol = TRY(this_symbol_value(vm, vm.this_value())); - return js_string(vm, symbol->to_deprecated_string()); + return PrimitiveString::create(vm, symbol->to_deprecated_string()); } // 20.4.3.4 Symbol.prototype.valueOf ( ), https://tc39.es/ecma262/#sec-symbol.prototype.valueof diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp index 430a98e44e2..b99067d21d7 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp @@ -117,7 +117,7 @@ ThrowCompletionOr get_option(VM& vm, Object const& options, PropertyKey c [](Empty) { return js_undefined(); }, [](bool b) { return Value(b); }, [](double d) { return Value(d); }, - [&vm](StringView s) { return Value(js_string(vm, s)); }); + [&vm](StringView s) { return Value(PrimitiveString::create(vm, s)); }); } // 5. If type is "boolean", then @@ -603,7 +603,7 @@ ThrowCompletionOr to_relative_temporal_object(VM& vm, Object const& optio auto* date_options = Object::create(realm, nullptr); // g. Perform ! CreateDataPropertyOrThrow(dateOptions, "overflow", "constrain"). - MUST(date_options->create_data_property_or_throw(vm.names.overflow, js_string(vm, "constrain"sv))); + MUST(date_options->create_data_property_or_throw(vm.names.overflow, PrimitiveString::create(vm, "constrain"sv))); // h. Let result be ? InterpretTemporalDateTimeFields(calendar, fields, dateOptions). result = TRY(interpret_temporal_date_time_fields(vm, *calendar, *fields, *date_options)); @@ -635,10 +635,10 @@ ThrowCompletionOr to_relative_temporal_object(VM& vm, Object const& optio result = TRY(parse_temporal_relative_to_string(vm, string)); // c. Let calendar be ? ToTemporalCalendarWithISODefault(result.[[Calendar]]). - calendar = TRY(to_temporal_calendar_with_iso_default(vm, result.calendar.has_value() ? js_string(vm, *result.calendar) : js_undefined())); + calendar = TRY(to_temporal_calendar_with_iso_default(vm, result.calendar.has_value() ? PrimitiveString::create(vm, *result.calendar) : js_undefined())); // d. Let offsetString be result.[[TimeZone]].[[OffsetString]]. - offset_string = result.time_zone.offset_string.has_value() ? js_string(vm, *result.time_zone.offset_string) : js_undefined(); + offset_string = result.time_zone.offset_string.has_value() ? PrimitiveString::create(vm, *result.time_zone.offset_string) : js_undefined(); // e. Let timeZoneName be result.[[TimeZone]].[[Name]]. auto time_zone_name = result.time_zone.name; @@ -757,7 +757,7 @@ ThrowCompletionOr merge_largest_unit_option(VM& vm, Object const& optio } // 4. Perform ! CreateDataPropertyOrThrow(merged, "largestUnit", largestUnit). - MUST(merged->create_data_property_or_throw(vm.names.largestUnit, js_string(vm, move(largest_unit)))); + MUST(merged->create_data_property_or_throw(vm.names.largestUnit, PrimitiveString::create(vm, move(largest_unit)))); // 5. Return merged. return merged; diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp index 25b4dcaf57d..6c21cbd3bbe 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp @@ -119,7 +119,7 @@ ThrowCompletionOr> calendar_fields(VM& vm, Object& cale } // 3. Let fieldsArray be ? Call(fields, calendar, « CreateArrayFromList(fieldNames) »). - auto fields_array = TRY(call(vm, *fields, &calendar, Array::create_from(realm, field_names, [&](auto value) { return js_string(vm, value); }))); + auto fields_array = TRY(call(vm, *fields, &calendar, Array::create_from(realm, field_names, [&](auto value) { return PrimitiveString::create(vm, value); }))); // 4. Return ? IterableToListOfType(fieldsArray, « String »). auto list = TRY(iterable_to_list_of_type(vm, fields_array, { OptionType::String })); @@ -397,7 +397,7 @@ ThrowCompletionOr calendar_era(VM& vm, Object& calendar, Object& date_lik // 3. If result is not undefined, set result to ? ToString(result). if (!result.is_undefined()) - result = js_string(vm, TRY(result.to_string(vm))); + result = PrimitiveString::create(vm, TRY(result.to_string(vm))); // 4. Return result. return result; @@ -811,7 +811,7 @@ ThrowCompletionOr resolve_iso_month(VM& vm, Object const& fields) return vm.throw_completion(ErrorType::TemporalInvalidMonthCode); // 11. Let monthCodeNumber be ! ToIntegerOrInfinity(monthCodeDigits). - auto month_code_number = MUST(Value(js_string(vm, move(month_code_digits))).to_integer_or_infinity(vm)); + auto month_code_number = MUST(Value(PrimitiveString::create(vm, move(month_code_digits))).to_integer_or_infinity(vm)); // 12. Assert: SameValue(monthCode, ISOMonthCode(monthCodeNumber)) is true. VERIFY(month_code_string == iso_month_code(month_code_number)); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.cpp index 091fd039919..81d03f54291 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.cpp @@ -36,7 +36,7 @@ void CalendarPrototype::initialize(Realm& realm) auto& vm = this->vm(); // 12.4.2 Temporal.Calendar.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.calendar.prototype-@@tostringtag - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Temporal.Calendar"), Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal.Calendar"), Attribute::Configurable); define_native_accessor(realm, vm.names.id, id_getter, {}, Attribute::Configurable); @@ -74,7 +74,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::id_getter) auto* calendar = TRY(typed_this_object(vm)); // 3. Return calendar.[[Identifier]]. - return { js_string(vm, calendar->identifier()) }; + return { PrimitiveString::create(vm, calendar->identifier()) }; } // 12.4.4 Temporal.Calendar.prototype.dateFromFields ( fields [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.calendar.prototype.datefromfields @@ -300,7 +300,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::month_code) // NOTE: The assertion happens in iso_month() call. // 6. Return ISOMonthCode(temporalDateLike.[[ISOMonth]]). - return js_string(vm, iso_month_code(iso_month(temporal_date_like.as_object()))); + return PrimitiveString::create(vm, iso_month_code(iso_month(temporal_date_like.as_object()))); } // 12.4.12 Temporal.Calendar.prototype.day ( temporalDateLike ), https://tc39.es/proposal-temporal/#sec-temporal.calendar.prototype.day @@ -589,7 +589,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::to_string) auto* calendar = TRY(typed_this_object(vm)); // 3. Return calendar.[[Identifier]]. - return js_string(vm, calendar->identifier()); + return PrimitiveString::create(vm, calendar->identifier()); } // 12.4.24 Temporal.Calendar.prototype.toJSON ( ), https://tc39.es/proposal-temporal/#sec-temporal.calendar.prototype.tojson @@ -600,7 +600,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::to_json) auto* calendar = TRY(typed_this_object(vm)); // 3. Return ? ToString(calendar). - return js_string(vm, TRY(Value(calendar).to_string(vm))); + return PrimitiveString::create(vm, TRY(Value(calendar).to_string(vm))); } // 15.6.2.6 Temporal.Calendar.prototype.era ( temporalDateLike ), https://tc39.es/proposal-temporal/#sec-temporal.calendar.prototype.era diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp index ad9be9e7aba..3ffa0a1982f 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp @@ -692,7 +692,7 @@ ThrowCompletionOr unbalance_duration_relative(VM& vm, double auto* until_options = Object::create(realm, nullptr); // iii. Perform ! CreateDataPropertyOrThrow(untilOptions, "largestUnit", "month"). - MUST(until_options->create_data_property_or_throw(vm.names.largestUnit, js_string(vm, "month"sv))); + MUST(until_options->create_data_property_or_throw(vm.names.largestUnit, PrimitiveString::create(vm, "month"sv))); // iv. Let untilResult be ? CalendarDateUntil(calendar, relativeTo, newRelativeTo, untilOptions, dateUntil). auto* until_result = TRY(calendar_date_until(vm, *calendar, relative_to, new_relative_to, *until_options, date_until)); @@ -928,7 +928,7 @@ ThrowCompletionOr balance_duration_relative(VM& vm, double y auto* until_options = Object::create(realm, nullptr); // m. Perform ! CreateDataPropertyOrThrow(untilOptions, "largestUnit", "month"). - MUST(until_options->create_data_property_or_throw(vm.names.largestUnit, js_string(vm, "month"sv))); + MUST(until_options->create_data_property_or_throw(vm.names.largestUnit, PrimitiveString::create(vm, "month"sv))); // n. Let untilResult be ? CalendarDateUntil(calendar, relativeTo, newRelativeTo, untilOptions, dateUntil). auto* until_result = TRY(calendar_date_until(vm, calendar, relative_to, new_relative_to, *until_options, date_until)); @@ -954,7 +954,7 @@ ThrowCompletionOr balance_duration_relative(VM& vm, double y until_options = Object::create(realm, nullptr); // vi. Perform ! CreateDataPropertyOrThrow(untilOptions, "largestUnit", "month"). - MUST(until_options->create_data_property_or_throw(vm.names.largestUnit, js_string(vm, "month"sv))); + MUST(until_options->create_data_property_or_throw(vm.names.largestUnit, PrimitiveString::create(vm, "month"sv))); // vii. Set untilResult to ? CalendarDateUntil(calendar, relativeTo, newRelativeTo, untilOptions, dateUntil). until_result = TRY(calendar_date_until(vm, calendar, relative_to, new_relative_to, *until_options, date_until)); @@ -1109,7 +1109,7 @@ ThrowCompletionOr add_duration(VM& vm, double years1, double mon auto* difference_options = Object::create(realm, nullptr); // i. Perform ! CreateDataPropertyOrThrow(differenceOptions, "largestUnit", dateLargestUnit). - MUST(difference_options->create_data_property_or_throw(vm.names.largestUnit, js_string(vm, date_largest_unit))); + MUST(difference_options->create_data_property_or_throw(vm.names.largestUnit, PrimitiveString::create(vm, date_largest_unit))); // j. Let dateDifference be ? CalendarDateUntil(calendar, relativeTo, end, differenceOptions). auto* date_difference = TRY(calendar_date_until(vm, calendar, &relative_to, end, *difference_options)); @@ -1312,7 +1312,7 @@ ThrowCompletionOr round_duration(VM& vm, double years, double m auto* until_options = Object::create(realm, nullptr); // l. Perform ! CreateDataPropertyOrThrow(untilOptions, "largestUnit", "year"). - MUST(until_options->create_data_property_or_throw(vm.names.largestUnit, js_string(vm, "year"sv))); + MUST(until_options->create_data_property_or_throw(vm.names.largestUnit, PrimitiveString::create(vm, "year"sv))); // m. Let timePassed be ? CalendarDateUntil(calendar, relativeTo, daysLater, untilOptions). auto* time_passed = TRY(calendar_date_until(vm, *calendar, relative_to, days_later, *until_options)); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.cpp index f7c91f6c5ac..04398fdd9e0 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.cpp @@ -27,7 +27,7 @@ void DurationPrototype::initialize(Realm& realm) auto& vm = this->vm(); // 7.3.2 Temporal.Duration.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.duration.prototype-@@tostringtag - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Temporal.Duration"), Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal.Duration"), Attribute::Configurable); define_native_accessor(realm, vm.names.years, years_getter, {}, Attribute::Configurable); define_native_accessor(realm, vm.names.months, months_getter, {}, Attribute::Configurable); @@ -586,7 +586,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::to_string) auto result = TRY(round_duration(vm, duration->years(), duration->months(), duration->weeks(), duration->days(), duration->hours(), duration->minutes(), duration->seconds(), duration->milliseconds(), duration->microseconds(), duration->nanoseconds(), precision.increment, precision.unit, rounding_mode)).duration_record; // 8. Return ! TemporalDurationToString(result.[[Years]], result.[[Months]], result.[[Weeks]], result.[[Days]], result.[[Hours]], result.[[Minutes]], result.[[Seconds]], result.[[Milliseconds]], result.[[Microseconds]], result.[[Nanoseconds]], precision.[[Precision]]). - return js_string(vm, temporal_duration_to_string(result.years, result.months, result.weeks, result.days, result.hours, result.minutes, result.seconds, result.milliseconds, result.microseconds, result.nanoseconds, precision.precision)); + return PrimitiveString::create(vm, temporal_duration_to_string(result.years, result.months, result.weeks, result.days, result.hours, result.minutes, result.seconds, result.milliseconds, result.microseconds, result.nanoseconds, precision.precision)); } // 7.3.23 Temporal.Duration.prototype.toJSON ( ), https://tc39.es/proposal-temporal/#sec-temporal.duration.prototype.tojson @@ -597,7 +597,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::to_json) auto* duration = TRY(typed_this_object(vm)); // 3. Return ! TemporalDurationToString(duration.[[Years]], duration.[[Months]], duration.[[Weeks]], duration.[[Days]], duration.[[Hours]], duration.[[Minutes]], duration.[[Seconds]], duration.[[Milliseconds]], duration.[[Microseconds]], duration.[[Nanoseconds]], "auto"). - return js_string(vm, temporal_duration_to_string(duration->years(), duration->months(), duration->weeks(), duration->days(), duration->hours(), duration->minutes(), duration->seconds(), duration->milliseconds(), duration->microseconds(), duration->nanoseconds(), "auto"sv)); + return PrimitiveString::create(vm, temporal_duration_to_string(duration->years(), duration->months(), duration->weeks(), duration->days(), duration->hours(), duration->minutes(), duration->seconds(), duration->milliseconds(), duration->microseconds(), duration->nanoseconds(), "auto"sv)); } // 7.3.24 Temporal.Duration.prototype.toLocaleString ( [ locales [ , options ] ] ), https://tc39.es/proposal-temporal/#sec-temporal.duration.prototype.tolocalestring @@ -609,7 +609,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::to_locale_string) auto* duration = TRY(typed_this_object(vm)); // 3. Return ! TemporalDurationToString(duration.[[Years]], duration.[[Months]], duration.[[Weeks]], duration.[[Days]], duration.[[Hours]], duration.[[Minutes]], duration.[[Seconds]], duration.[[Milliseconds]], duration.[[Microseconds]], duration.[[Nanoseconds]], "auto"). - return js_string(vm, temporal_duration_to_string(duration->years(), duration->months(), duration->weeks(), duration->days(), duration->hours(), duration->minutes(), duration->seconds(), duration->milliseconds(), duration->microseconds(), duration->nanoseconds(), "auto"sv)); + return PrimitiveString::create(vm, temporal_duration_to_string(duration->years(), duration->months(), duration->weeks(), duration->days(), duration->hours(), duration->minutes(), duration->seconds(), duration->milliseconds(), duration->microseconds(), duration->nanoseconds(), "auto"sv)); } // 7.3.25 Temporal.Duration.prototype.valueOf ( ), https://tc39.es/proposal-temporal/#sec-temporal.duration.prototype.valueof diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp index 37d40bd3690..591fd696678 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp @@ -31,7 +31,7 @@ void InstantPrototype::initialize(Realm& realm) auto& vm = this->vm(); // 8.3.2 Temporal.Instant.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.instant.prototype-@@tostringtag - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Temporal.Instant"), Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal.Instant"), Attribute::Configurable); define_native_accessor(realm, vm.names.epochSeconds, epoch_seconds_getter, {}, Attribute::Configurable); define_native_accessor(realm, vm.names.epochMilliseconds, epoch_milliseconds_getter, {}, Attribute::Configurable); @@ -312,7 +312,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::to_string) auto* rounded_instant = MUST(create_temporal_instant(vm, *rounded_ns)); // 10. Return ? TemporalInstantToString(roundedInstant, timeZone, precision.[[Precision]]). - return js_string(vm, TRY(temporal_instant_to_string(vm, *rounded_instant, time_zone, precision.precision))); + return PrimitiveString::create(vm, TRY(temporal_instant_to_string(vm, *rounded_instant, time_zone, precision.precision))); } // 8.3.14 Temporal.Instant.prototype.toLocaleString ( [ locales [ , options ] ] ), https://tc39.es/proposal-temporal/#sec-temporal.instant.prototype.tolocalestring @@ -324,7 +324,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::to_locale_string) auto* instant = TRY(typed_this_object(vm)); // 3. Return ? TemporalInstantToString(instant, undefined, "auto"). - return js_string(vm, TRY(temporal_instant_to_string(vm, *instant, js_undefined(), "auto"sv))); + return PrimitiveString::create(vm, TRY(temporal_instant_to_string(vm, *instant, js_undefined(), "auto"sv))); } // 8.3.15 Temporal.Instant.prototype.toJSON ( ), https://tc39.es/proposal-temporal/#sec-temporal.instant.prototype.tojson @@ -335,7 +335,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::to_json) auto* instant = TRY(typed_this_object(vm)); // 3. Return ? TemporalInstantToString(instant, undefined, "auto"). - return js_string(vm, TRY(temporal_instant_to_string(vm, *instant, js_undefined(), "auto"sv))); + return PrimitiveString::create(vm, TRY(temporal_instant_to_string(vm, *instant, js_undefined(), "auto"sv))); } // 8.3.16 Temporal.Instant.prototype.valueOf ( ), https://tc39.es/proposal-temporal/#sec-temporal.instant.prototype.valueof diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Now.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/Now.cpp index 2b27e1be6ea..2602079f20f 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/Now.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/Now.cpp @@ -33,7 +33,7 @@ void Now::initialize(Realm& realm) auto& vm = this->vm(); // 2.1.1 Temporal.Now [ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal-now-@@tostringtag - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Temporal.Now"), Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal.Now"), Attribute::Configurable); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.names.timeZone, time_zone, 0, attr); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDate.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDate.cpp index 5b4cd4970bd..d13b934fd15 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDate.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDate.cpp @@ -149,7 +149,7 @@ ThrowCompletionOr to_temporal_date(VM& vm, Value item, Object const* VERIFY(is_valid_iso_date(result.year, result.month, result.day)); // 8. Let calendar be ? ToTemporalCalendarWithISODefault(result.[[Calendar]]). - auto* calendar = TRY(to_temporal_calendar_with_iso_default(vm, result.calendar.has_value() ? js_string(vm, *result.calendar) : js_undefined())); + auto* calendar = TRY(to_temporal_calendar_with_iso_default(vm, result.calendar.has_value() ? PrimitiveString::create(vm, *result.calendar) : js_undefined())); // 9. Return ? CreateTemporalDate(result.[[Year]], result.[[Month]], result.[[Day]], calendar). return create_temporal_date(vm, result.year, result.month, result.day, *calendar); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.cpp index d39b163a7ba..c3ec137ac98 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.cpp @@ -32,7 +32,7 @@ void PlainDatePrototype::initialize(Realm& realm) auto& vm = this->vm(); // 3.3.2 Temporal.PlainDate.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.plaindate.prototype-@@tostringtag - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Temporal.PlainDate"), Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal.PlainDate"), Attribute::Configurable); define_native_accessor(realm, vm.names.calendar, calendar_getter, {}, Attribute::Configurable); define_native_accessor(realm, vm.names.year, year_getter, {}, Attribute::Configurable); @@ -119,7 +119,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::month_code_getter) auto& calendar = temporal_date->calendar(); // 4. Return ? CalendarMonthCode(calendar, temporalDate). - return js_string(vm, TRY(calendar_month_code(vm, calendar, *temporal_date))); + return PrimitiveString::create(vm, TRY(calendar_month_code(vm, calendar, *temporal_date))); } // 3.3.7 get Temporal.PlainDate.prototype.day, https://tc39.es/proposal-temporal/#sec-get-temporal.plaindate.prototype.day @@ -599,7 +599,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::to_string) auto show_calendar = TRY(to_calendar_name_option(vm, *options)); // 5. Return ? TemporalDateToString(temporalDate, showCalendar). - return js_string(vm, TRY(temporal_date_to_string(vm, *temporal_date, show_calendar))); + return PrimitiveString::create(vm, TRY(temporal_date_to_string(vm, *temporal_date, show_calendar))); } // 3.3.29 Temporal.PlainDate.prototype.toLocaleString ( [ locales [ , options ] ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaindate.prototype.tolocalestring @@ -611,7 +611,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::to_locale_string) auto* temporal_date = TRY(typed_this_object(vm)); // 3. Return ? TemporalDateToString(temporalDate, "auto"). - return js_string(vm, TRY(temporal_date_to_string(vm, *temporal_date, "auto"sv))); + return PrimitiveString::create(vm, TRY(temporal_date_to_string(vm, *temporal_date, "auto"sv))); } // 3.3.30 Temporal.PlainDate.prototype.toJSON ( ), https://tc39.es/proposal-temporal/#sec-temporal.plaindate.prototype.tojson @@ -622,7 +622,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::to_json) auto* temporal_date = TRY(typed_this_object(vm)); // 3. Return ? TemporalDateToString(temporalDate, "auto"). - return js_string(vm, TRY(temporal_date_to_string(vm, *temporal_date, "auto"sv))); + return PrimitiveString::create(vm, TRY(temporal_date_to_string(vm, *temporal_date, "auto"sv))); } // 3.3.31 Temporal.PlainDate.prototype.valueOf ( ), https://tc39.es/proposal-temporal/#sec-temporal.plaindate.prototype.valueof diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTime.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTime.cpp index beff49f146c..fc5771ddf8f 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTime.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTime.cpp @@ -177,7 +177,7 @@ ThrowCompletionOr to_temporal_date_time(VM& vm, Value item, Obje VERIFY(is_valid_time(result.hour, result.minute, result.second, result.millisecond, result.microsecond, result.nanosecond)); // f. Let calendar be ? ToTemporalCalendarWithISODefault(result.[[Calendar]]). - calendar = TRY(to_temporal_calendar_with_iso_default(vm, result.calendar.has_value() ? js_string(vm, *result.calendar) : js_undefined())); + calendar = TRY(to_temporal_calendar_with_iso_default(vm, result.calendar.has_value() ? PrimitiveString::create(vm, *result.calendar) : js_undefined())); } // 5. Return ? CreateTemporalDateTime(result.[[Year]], result.[[Month]], result.[[Day]], result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]], calendar). diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.cpp index 02e1ded6412..bd0c8ad8bea 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.cpp @@ -33,7 +33,7 @@ void PlainDateTimePrototype::initialize(Realm& realm) auto& vm = this->vm(); // 5.3.2 Temporal.PlainDateTime.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.plaindatetime.prototype-@@tostringtag - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Temporal.PlainDateTime"), Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal.PlainDateTime"), Attribute::Configurable); define_native_accessor(realm, vm.names.calendar, calendar_getter, {}, Attribute::Configurable); define_native_accessor(realm, vm.names.year, year_getter, {}, Attribute::Configurable); @@ -130,7 +130,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::month_code_getter) auto& calendar = date_time->calendar(); // 4. Return ? CalendarMonthCode(calendar, dateTime). - return js_string(vm, TRY(calendar_month_code(vm, calendar, *date_time))); + return PrimitiveString::create(vm, TRY(calendar_month_code(vm, calendar, *date_time))); } // 5.3.7 get Temporal.PlainDateTime.prototype.day, https://tc39.es/proposal-temporal/#sec-get-temporal.plaindatetime.prototype.day @@ -607,7 +607,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::to_string) auto result = round_iso_date_time(date_time->iso_year(), date_time->iso_month(), date_time->iso_day(), date_time->iso_hour(), date_time->iso_minute(), date_time->iso_second(), date_time->iso_millisecond(), date_time->iso_microsecond(), date_time->iso_nanosecond(), precision.increment, precision.unit, rounding_mode); // 8. Return ? TemporalDateTimeToString(result.[[Year]], result.[[Month]], result.[[Day]], result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]], dateTime.[[Calendar]], precision.[[Precision]], showCalendar). - return js_string(vm, TRY(temporal_date_time_to_string(vm, result.year, result.month, result.day, result.hour, result.minute, result.second, result.millisecond, result.microsecond, result.nanosecond, &date_time->calendar(), precision.precision, show_calendar))); + return PrimitiveString::create(vm, TRY(temporal_date_time_to_string(vm, result.year, result.month, result.day, result.hour, result.minute, result.second, result.millisecond, result.microsecond, result.nanosecond, &date_time->calendar(), precision.precision, show_calendar))); } // 5.3.33 Temporal.PlainDateTime.prototype.toLocaleString ( [ locales [ , options ] ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaindatetime.prototype.tolocalestring @@ -619,7 +619,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::to_locale_string) auto* date_time = TRY(typed_this_object(vm)); // 3. Return ? TemporalDateTimeToString(dateTime.[[ISOYear]], dateTime.[[ISOMonth]], dateTime.[[ISODay]], dateTime.[[ISOHour]], dateTime.[[ISOMinute]], dateTime.[[ISOSecond]], dateTime.[[ISOMillisecond]], dateTime.[[ISOMicrosecond]], dateTime.[[ISONanosecond]], dateTime.[[Calendar]], "auto", "auto"). - return js_string(vm, TRY(temporal_date_time_to_string(vm, date_time->iso_year(), date_time->iso_month(), date_time->iso_day(), date_time->iso_hour(), date_time->iso_minute(), date_time->iso_second(), date_time->iso_millisecond(), date_time->iso_microsecond(), date_time->iso_nanosecond(), &date_time->calendar(), "auto"sv, "auto"sv))); + return PrimitiveString::create(vm, TRY(temporal_date_time_to_string(vm, date_time->iso_year(), date_time->iso_month(), date_time->iso_day(), date_time->iso_hour(), date_time->iso_minute(), date_time->iso_second(), date_time->iso_millisecond(), date_time->iso_microsecond(), date_time->iso_nanosecond(), &date_time->calendar(), "auto"sv, "auto"sv))); } // 5.3.34 Temporal.PlainDateTime.prototype.toJSON ( ), https://tc39.es/proposal-temporal/#sec-temporal.plaindatetime.prototype.tojson @@ -630,7 +630,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::to_json) auto* date_time = TRY(typed_this_object(vm)); // 3. Return ? TemporalDateTimeToString(dateTime.[[ISOYear]], dateTime.[[ISOMonth]], dateTime.[[ISODay]], dateTime.[[ISOHour]], dateTime.[[ISOMinute]], dateTime.[[ISOSecond]], dateTime.[[ISOMillisecond]], dateTime.[[ISOMicrosecond]], dateTime.[[ISONanosecond]], dateTime.[[Calendar]], "auto", "auto"). - return js_string(vm, TRY(temporal_date_time_to_string(vm, date_time->iso_year(), date_time->iso_month(), date_time->iso_day(), date_time->iso_hour(), date_time->iso_minute(), date_time->iso_second(), date_time->iso_millisecond(), date_time->iso_microsecond(), date_time->iso_nanosecond(), &date_time->calendar(), "auto"sv, "auto"sv))); + return PrimitiveString::create(vm, TRY(temporal_date_time_to_string(vm, date_time->iso_year(), date_time->iso_month(), date_time->iso_day(), date_time->iso_hour(), date_time->iso_minute(), date_time->iso_second(), date_time->iso_millisecond(), date_time->iso_microsecond(), date_time->iso_nanosecond(), &date_time->calendar(), "auto"sv, "auto"sv))); } // 5.3.35 Temporal.PlainDateTime.prototype.valueOf ( ), https://tc39.es/proposal-temporal/#sec-temporal.plaindatetime.prototype.valueof diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDay.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDay.cpp index 04033ee121f..68f7e2adfb3 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDay.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDay.cpp @@ -126,7 +126,7 @@ ThrowCompletionOr to_temporal_month_day(VM& vm, Value item, Obje auto result = TRY(parse_temporal_month_day_string(vm, string)); // 8. Let calendar be ? ToTemporalCalendarWithISODefault(result.[[Calendar]]). - auto* calendar = TRY(to_temporal_calendar_with_iso_default(vm, result.calendar.has_value() ? js_string(vm, move(*result.calendar)) : js_undefined())); + auto* calendar = TRY(to_temporal_calendar_with_iso_default(vm, result.calendar.has_value() ? PrimitiveString::create(vm, move(*result.calendar)) : js_undefined())); // 9. If result.[[Year]] is undefined, then if (!result.year.has_value()) { diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.cpp index 7fa22e4e64c..58c793506d4 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.cpp @@ -27,7 +27,7 @@ void PlainMonthDayPrototype::initialize(Realm& realm) auto& vm = this->vm(); // 10.3.2 Temporal.PlainMonthDay.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.plainmonthday.prototype-@@tostringtag - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Temporal.PlainMonthDay"), Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal.PlainMonthDay"), Attribute::Configurable); define_native_accessor(realm, vm.names.calendar, calendar_getter, {}, Attribute::Configurable); define_native_accessor(realm, vm.names.monthCode, month_code_getter, {}, Attribute::Configurable); @@ -66,7 +66,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::month_code_getter) auto& calendar = month_day->calendar(); // 4. Return ? CalendarMonthCode(calendar, monthDay). - return js_string(vm, TRY(calendar_month_code(vm, calendar, *month_day))); + return PrimitiveString::create(vm, TRY(calendar_month_code(vm, calendar, *month_day))); } // 10.3.5 get Temporal.PlainMonthDay.prototype.day, https://tc39.es/proposal-temporal/#sec-get-temporal.plainmonthday.prototype.day @@ -166,7 +166,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::to_string) auto show_calendar = TRY(to_calendar_name_option(vm, *options)); // 5. Return ? TemporalMonthDayToString(monthDay, showCalendar). - return js_string(vm, TRY(temporal_month_day_to_string(vm, *month_day, show_calendar))); + return PrimitiveString::create(vm, TRY(temporal_month_day_to_string(vm, *month_day, show_calendar))); } // 10.3.9 Temporal.PlainMonthDay.prototype.toLocaleString ( [ locales [ , options ] ] ), https://tc39.es/proposal-temporal/#sec-temporal.plainmonthday.prototype.tolocalestring @@ -178,7 +178,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::to_locale_string) auto* month_day = TRY(typed_this_object(vm)); // 3. Return ? TemporalMonthDayToString(monthDay, "auto"). - return js_string(vm, TRY(temporal_month_day_to_string(vm, *month_day, "auto"sv))); + return PrimitiveString::create(vm, TRY(temporal_month_day_to_string(vm, *month_day, "auto"sv))); } // 10.3.10 Temporal.PlainMonthDay.prototype.toJSON ( ), https://tc39.es/proposal-temporal/#sec-temporal.plainmonthday.prototype.tojson @@ -189,7 +189,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::to_json) auto* month_day = TRY(typed_this_object(vm)); // 3. Return ? TemporalMonthDayToString(monthDay, "auto"). - return js_string(vm, TRY(temporal_month_day_to_string(vm, *month_day, "auto"sv))); + return PrimitiveString::create(vm, TRY(temporal_month_day_to_string(vm, *month_day, "auto"sv))); } // 10.3.11 Temporal.PlainMonthDay.prototype.valueOf ( ), https://tc39.es/proposal-temporal/#sec-temporal.plainmonthday.prototype.valueof @@ -244,7 +244,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::to_plain_date) auto* options = Object::create(realm, nullptr); // 13. Perform ! CreateDataPropertyOrThrow(options, "overflow", "reject"). - MUST(options->create_data_property_or_throw(vm.names.overflow, js_string(vm, vm.names.reject.as_string()))); + MUST(options->create_data_property_or_throw(vm.names.overflow, PrimitiveString::create(vm, vm.names.reject.as_string()))); // 14. Return ? CalendarDateFromFields(calendar, mergedFields, options). return TRY(calendar_date_from_fields(vm, calendar, *merged_fields, options)); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.cpp index 215b27c59f5..49ebe1d98a2 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.cpp @@ -32,7 +32,7 @@ void PlainTimePrototype::initialize(Realm& realm) auto& vm = this->vm(); // 4.3.2 Temporal.PlainTime.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.plaintime.prototype-@@tostringtag - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Temporal.PlainTime"), Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal.PlainTime"), Attribute::Configurable); define_native_accessor(realm, vm.names.calendar, calendar_getter, {}, Attribute::Configurable); define_native_accessor(realm, vm.names.hour, hour_getter, {}, Attribute::Configurable); @@ -473,7 +473,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::to_string) // 7. Return ! TemporalTimeToString(roundResult.[[Hour]], roundResult.[[Minute]], roundResult.[[Second]], roundResult.[[Millisecond]], roundResult.[[Microsecond]], roundResult.[[Nanosecond]], precision.[[Precision]]). auto string = temporal_time_to_string(round_result.hour, round_result.minute, round_result.second, round_result.millisecond, round_result.microsecond, round_result.nanosecond, precision.precision); - return js_string(vm, move(string)); + return PrimitiveString::create(vm, move(string)); } // 4.3.21 Temporal.PlainTime.prototype.toLocaleString ( [ locales [ , options ] ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime.prototype.tolocalestring @@ -485,7 +485,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::to_locale_string) // 3. Return ! TemporalTimeToString(temporalTime.[[ISOHour]], temporalTime.[[ISOMinute]], temporalTime.[[ISOSecond]], temporalTime.[[ISOMillisecond]], temporalTime.[[ISOMicrosecond]], temporalTime.[[ISONanosecond]], "auto"). auto string = temporal_time_to_string(temporal_time->iso_hour(), temporal_time->iso_minute(), temporal_time->iso_second(), temporal_time->iso_millisecond(), temporal_time->iso_microsecond(), temporal_time->iso_nanosecond(), "auto"sv); - return js_string(vm, move(string)); + return PrimitiveString::create(vm, move(string)); } // 4.3.22 Temporal.PlainTime.prototype.toJSON ( ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime.prototype.tojson @@ -497,7 +497,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::to_json) // 3. Return ! TemporalTimeToString(temporalTime.[[ISOHour]], temporalTime.[[ISOMinute]], temporalTime.[[ISOSecond]], temporalTime.[[ISOMillisecond]], temporalTime.[[ISOMicrosecond]], temporalTime.[[ISONanosecond]], "auto"). auto string = temporal_time_to_string(temporal_time->iso_hour(), temporal_time->iso_minute(), temporal_time->iso_second(), temporal_time->iso_millisecond(), temporal_time->iso_microsecond(), temporal_time->iso_nanosecond(), "auto"sv); - return js_string(vm, move(string)); + return PrimitiveString::create(vm, move(string)); } // 4.3.23 Temporal.PlainTime.prototype.valueOf ( ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime.prototype.valueof diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonth.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonth.cpp index 9548bc99f15..9bd283d64a4 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonth.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonth.cpp @@ -72,7 +72,7 @@ ThrowCompletionOr to_temporal_year_month(VM& vm, Value item, Ob auto result = TRY(parse_temporal_year_month_string(vm, string)); // 7. Let calendar be ? ToTemporalCalendarWithISODefault(result.[[Calendar]]). - auto* calendar = TRY(to_temporal_calendar_with_iso_default(vm, result.calendar.has_value() ? js_string(vm, *result.calendar) : js_undefined())); + auto* calendar = TRY(to_temporal_calendar_with_iso_default(vm, result.calendar.has_value() ? PrimitiveString::create(vm, *result.calendar) : js_undefined())); // 8. Set result to ? CreateTemporalYearMonth(result.[[Year]], result.[[Month]], calendar, result.[[Day]]). auto* creation_result = TRY(create_temporal_year_month(vm, result.year, result.month, *calendar, result.day)); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.cpp index 7726e8bf995..0700b982056 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.cpp @@ -29,7 +29,7 @@ void PlainYearMonthPrototype::initialize(Realm& realm) auto& vm = this->vm(); // 9.3.2 Temporal.PlainYearMonth.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.plainyearmonth.prototype-@@tostringtag - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Temporal.PlainYearMonth"), Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal.PlainYearMonth"), Attribute::Configurable); define_native_accessor(realm, vm.names.calendar, calendar_getter, {}, Attribute::Configurable); define_native_accessor(realm, vm.names.year, year_getter, {}, Attribute::Configurable); @@ -107,7 +107,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::month_code_getter) auto& calendar = year_month->calendar(); // 4. Return ? CalendarMonthCode(calendar, yearMonth). - return js_string(vm, TRY(calendar_month_code(vm, calendar, *year_month))); + return PrimitiveString::create(vm, TRY(calendar_month_code(vm, calendar, *year_month))); } // 9.3.7 get Temporal.PlainYearMonth.prototype.daysInYear, https://tc39.es/proposal-temporal/#sec-get-temporal.plainyearmonth.prototype.daysinyear @@ -333,7 +333,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::to_string) auto show_calendar = TRY(to_calendar_name_option(vm, *options)); // 5. Return ? TemporalYearMonthToString(yearMonth, showCalendar). - return js_string(vm, TRY(temporal_year_month_to_string(vm, *year_month, show_calendar))); + return PrimitiveString::create(vm, TRY(temporal_year_month_to_string(vm, *year_month, show_calendar))); } // 9.3.18 Temporal.PlainYearMonth.prototype.toLocaleString ( [ locales [ , options ] ] ), https://tc39.es/proposal-temporal/#sec-temporal.plainyearmonth.prototype.tolocalestring @@ -345,7 +345,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::to_locale_string) auto* year_month = TRY(typed_this_object(vm)); // 3. Return ? TemporalYearMonthToString(yearMonth, "auto"). - return js_string(vm, TRY(temporal_year_month_to_string(vm, *year_month, "auto"sv))); + return PrimitiveString::create(vm, TRY(temporal_year_month_to_string(vm, *year_month, "auto"sv))); } // 9.3.19 Temporal.PlainYearMonth.prototype.toJSON ( ), https://tc39.es/proposal-temporal/#sec-temporal.plainyearmonth.prototype.tojson @@ -356,7 +356,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::to_json) auto* year_month = TRY(typed_this_object(vm)); // 3. Return ? TemporalYearMonthToString(yearMonth, "auto"). - return js_string(vm, TRY(temporal_year_month_to_string(vm, *year_month, "auto"sv))); + return PrimitiveString::create(vm, TRY(temporal_year_month_to_string(vm, *year_month, "auto"sv))); } // 9.3.20 Temporal.PlainYearMonth.prototype.valueOf ( ), https://tc39.es/proposal-temporal/#sec-temporal.plainyearmonth.prototype.valueof @@ -411,7 +411,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::to_plain_date) auto* options = Object::create(realm, nullptr); // 13. Perform ! CreateDataPropertyOrThrow(options, "overflow", "reject"). - MUST(options->create_data_property_or_throw(vm.names.overflow, js_string(vm, vm.names.reject.as_string()))); + MUST(options->create_data_property_or_throw(vm.names.overflow, PrimitiveString::create(vm, vm.names.reject.as_string()))); // 14. Return ? CalendarDateFromFields(calendar, mergedFields, options). return TRY(calendar_date_from_fields(vm, calendar, *merged_fields, options)); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Temporal.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/Temporal.cpp index faf2b3441e8..5d22c434f27 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/Temporal.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/Temporal.cpp @@ -33,7 +33,7 @@ void Temporal::initialize(Realm& realm) auto& vm = this->vm(); // 1.1.1 Temporal [ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal-@@tostringtag - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Temporal"), Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal"), Attribute::Configurable); u8 attr = Attribute::Writable | Attribute::Configurable; define_direct_property(vm.names.Now, heap().allocate(realm, realm), attr); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.cpp index 289d8116678..f259fbb5622 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.cpp @@ -42,7 +42,7 @@ void TimeZonePrototype::initialize(Realm& realm) define_native_function(realm, vm.names.toJSON, to_json, 0, attr); // 11.4.2 Temporal.TimeZone.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.timezone.prototype-@@tostringtag - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Temporal.TimeZone"), Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal.TimeZone"), Attribute::Configurable); } // 11.4.3 get Temporal.TimeZone.prototype.id, https://tc39.es/proposal-temporal/#sec-get-temporal.timezone.prototype.id @@ -53,7 +53,7 @@ JS_DEFINE_NATIVE_FUNCTION(TimeZonePrototype::id_getter) auto* time_zone = TRY(typed_this_object(vm)); // 3. Return timeZone.[[Identifier]]. - return js_string(vm, time_zone->identifier()); + return PrimitiveString::create(vm, time_zone->identifier()); } // 11.4.4 Temporal.TimeZone.prototype.getOffsetNanosecondsFor ( instant ), https://tc39.es/proposal-temporal/#sec-temporal.timezone.prototype.getoffsetnanosecondsfor @@ -86,7 +86,7 @@ JS_DEFINE_NATIVE_FUNCTION(TimeZonePrototype::get_offset_string_for) // 4. Return ? BuiltinTimeZoneGetOffsetStringFor(timeZone, instant). auto offset_string = TRY(builtin_time_zone_get_offset_string_for(vm, time_zone, *instant)); - return js_string(vm, move(offset_string)); + return PrimitiveString::create(vm, move(offset_string)); } // 11.4.6 Temporal.TimeZone.prototype.getPlainDateTimeFor ( instant [ , calendarLike ] ), https://tc39.es/proposal-temporal/#sec-temporal.timezone.prototype.getplaindatetimefor @@ -233,7 +233,7 @@ JS_DEFINE_NATIVE_FUNCTION(TimeZonePrototype::to_string) auto* time_zone = TRY(typed_this_object(vm)); // 3. Return timeZone.[[Identifier]]. - return js_string(vm, time_zone->identifier()); + return PrimitiveString::create(vm, time_zone->identifier()); } // 11.4.12 Temporal.TimeZone.prototype.toJSON ( ), https://tc39.es/proposal-temporal/#sec-temporal.timezone.prototype.tojson @@ -244,7 +244,7 @@ JS_DEFINE_NATIVE_FUNCTION(TimeZonePrototype::to_json) auto* time_zone = TRY(typed_this_object(vm)); // 3. Return ? ToString(timeZone). - return js_string(vm, TRY(Value(time_zone).to_string(vm))); + return PrimitiveString::create(vm, TRY(Value(time_zone).to_string(vm))); } } diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp index da2514b6555..9f752e5f845 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp @@ -227,7 +227,7 @@ ThrowCompletionOr to_temporal_zoned_date_time(VM& vm, Value item // k. Let calendar be ? ToTemporalCalendarWithISODefault(result.[[Calendar]]). auto temporal_calendar_like = result.calendar.has_value() - ? js_string(vm, result.calendar.value()) + ? PrimitiveString::create(vm, result.calendar.value()) : js_undefined(); calendar = TRY(to_temporal_calendar_with_iso_default(vm, temporal_calendar_like)); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp index 71a6f65127f..c530e5db8c5 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp @@ -33,7 +33,7 @@ void ZonedDateTimePrototype::initialize(Realm& realm) auto& vm = this->vm(); // 6.3.2 Temporal.ZonedDateTime.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.prototype-@@tostringtag - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Temporal.ZonedDateTime"), Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal.ZonedDateTime"), Attribute::Configurable); define_native_accessor(realm, vm.names.calendar, calendar_getter, {}, Attribute::Configurable); define_native_accessor(realm, vm.names.timeZone, time_zone_getter, {}, Attribute::Configurable); @@ -179,7 +179,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::month_code_getter) auto* temporal_date_time = TRY(builtin_time_zone_get_plain_date_time_for(vm, &time_zone, *instant, calendar)); // 7. Return ? CalendarMonthCode(calendar, temporalDateTime). - return js_string(vm, TRY(calendar_month_code(vm, calendar, *temporal_date_time))); + return PrimitiveString::create(vm, TRY(calendar_month_code(vm, calendar, *temporal_date_time))); } // 6.3.8 get Temporal.ZonedDateTime.prototype.day, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.day @@ -669,7 +669,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::offset_getter) // 4. Return ? BuiltinTimeZoneGetOffsetStringFor(zonedDateTime.[[TimeZone]], instant). auto offset_string = TRY(builtin_time_zone_get_offset_string_for(vm, &zoned_date_time->time_zone(), *instant)); - return js_string(vm, move(offset_string)); + return PrimitiveString::create(vm, move(offset_string)); } // 15.6.10.2 get Temporal.ZonedDateTime.prototype.era, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.era @@ -1093,7 +1093,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::to_string) auto show_offset = TRY(to_show_offset_option(vm, *options)); // 9. Return ? TemporalZonedDateTimeToString(zonedDateTime, precision.[[Precision]], showCalendar, showTimeZone, showOffset, precision.[[Increment]], precision.[[Unit]], roundingMode). - return js_string(vm, TRY(temporal_zoned_date_time_to_string(vm, *zoned_date_time, precision.precision, show_calendar, show_time_zone, show_offset, precision.increment, precision.unit, rounding_mode))); + return PrimitiveString::create(vm, TRY(temporal_zoned_date_time_to_string(vm, *zoned_date_time, precision.precision, show_calendar, show_time_zone, show_offset, precision.increment, precision.unit, rounding_mode))); } // 6.3.42 Temporal.ZonedDateTime.prototype.toLocaleString ( [ locales [ , options ] ] ), https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.prototype.tolocalestring @@ -1105,7 +1105,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::to_locale_string) auto* zoned_date_time = TRY(typed_this_object(vm)); // 3. Return ? TemporalZonedDateTimeToString(zonedDateTime, "auto", "auto", "auto", "auto"). - return js_string(vm, TRY(temporal_zoned_date_time_to_string(vm, *zoned_date_time, "auto"sv, "auto"sv, "auto"sv, "auto"sv))); + return PrimitiveString::create(vm, TRY(temporal_zoned_date_time_to_string(vm, *zoned_date_time, "auto"sv, "auto"sv, "auto"sv, "auto"sv))); } // 6.3.43 Temporal.ZonedDateTime.prototype.toJSON ( ), https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.prototype.tojson @@ -1116,7 +1116,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::to_json) auto* zoned_date_time = TRY(typed_this_object(vm)); // 3. Return ? TemporalZonedDateTimeToString(zonedDateTime, "auto", "auto", "auto", "auto"). - return js_string(vm, TRY(temporal_zoned_date_time_to_string(vm, *zoned_date_time, "auto"sv, "auto"sv, "auto"sv, "auto"sv))); + return PrimitiveString::create(vm, TRY(temporal_zoned_date_time_to_string(vm, *zoned_date_time, "auto"sv, "auto"sv, "auto"sv, "auto"sv))); } // 6.3.44 Temporal.ZonedDateTime.prototype.valueOf ( ), https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.prototype.valueof @@ -1345,7 +1345,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::get_iso_fields) MUST(fields->create_data_property_or_throw(vm.names.isoYear, Value(date_time->iso_year()))); // 19. Perform ! CreateDataPropertyOrThrow(fields, "offset", offset). - MUST(fields->create_data_property_or_throw(vm.names.offset, js_string(vm, offset))); + MUST(fields->create_data_property_or_throw(vm.names.offset, PrimitiveString::create(vm, offset))); // 20. Perform ! CreateDataPropertyOrThrow(fields, "timeZone", timeZone). MUST(fields->create_data_property_or_throw(vm.names.timeZone, Value(&time_zone))); diff --git a/Userland/Libraries/LibJS/Runtime/TypedArray.h b/Userland/Libraries/LibJS/Runtime/TypedArray.h index 9af87fb9980..60268897549 100644 --- a/Userland/Libraries/LibJS/Runtime/TypedArray.h +++ b/Userland/Libraries/LibJS/Runtime/TypedArray.h @@ -390,7 +390,7 @@ public: // a. For each integer i starting with 0 such that i < O.[[ArrayLength]], in ascending order, do for (size_t i = 0; i < m_array_length; ++i) { // i. Add ! ToString(𝔽(i)) as the last element of keys. - keys.append(js_string(vm, DeprecatedString::number(i))); + keys.append(PrimitiveString::create(vm, DeprecatedString::number(i))); } } diff --git a/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp b/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp index 185d3e22833..eea9610e4a7 100644 --- a/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp @@ -780,7 +780,7 @@ JS_DEFINE_NATIVE_FUNCTION(TypedArrayPrototype::join) } // 9. Return R. - return js_string(vm, builder.to_deprecated_string()); + return PrimitiveString::create(vm, builder.to_deprecated_string()); } // 23.2.3.19 %TypedArray%.prototype.keys ( ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.keys @@ -1565,7 +1565,7 @@ JS_DEFINE_NATIVE_FUNCTION(TypedArrayPrototype::to_locale_string) } // 7. Return R. - return js_string(vm, builder.to_deprecated_string()); + return PrimitiveString::create(vm, builder.to_deprecated_string()); } // 1.2.2.1.3 %TypedArray%.prototype.toReversed ( ), https://tc39.es/proposal-change-array-by-copy/#sec-%typedarray%.prototype.toReversed @@ -1733,7 +1733,7 @@ JS_DEFINE_NATIVE_FUNCTION(TypedArrayPrototype::to_string_tag_getter) auto& this_object = this_value.as_object(); if (!this_object.is_typed_array()) return js_undefined(); - return js_string(vm, static_cast(this_object).element_name()); + return PrimitiveString::create(vm, static_cast(this_object).element_name()); } } diff --git a/Userland/Libraries/LibJS/Runtime/Value.cpp b/Userland/Libraries/LibJS/Runtime/Value.cpp index 6513492394b..8244f92ef3d 100644 --- a/Userland/Libraries/LibJS/Runtime/Value.cpp +++ b/Userland/Libraries/LibJS/Runtime/Value.cpp @@ -334,7 +334,7 @@ ThrowCompletionOr Value::to_primitive_string(VM& vm) if (is_string()) return &as_string(); auto string = TRY(to_string(vm)); - return js_string(vm, string); + return PrimitiveString::create(vm, string).ptr(); } // 7.1.17 ToString ( argument ), https://tc39.es/ecma262/#sec-tostring @@ -428,7 +428,7 @@ ThrowCompletionOr Value::to_primitive(VM& vm, PreferredType preferred_typ auto to_primitive_method = TRY(get_method(vm, *vm.well_known_symbol_to_primitive())); if (to_primitive_method) { auto hint = get_hint_for_preferred_type(); - auto result = TRY(call(vm, *to_primitive_method, *this, js_string(vm, hint))); + auto result = TRY(call(vm, *to_primitive_method, *this, PrimitiveString::create(vm, hint))); if (!result.is_object()) return result; return vm.throw_completion(ErrorType::ToPrimitiveReturnedObject, to_string_without_side_effects(), hint); @@ -1182,7 +1182,7 @@ ThrowCompletionOr add(VM& vm, Value lhs, Value rhs) if (lhs_primitive.is_string() || rhs_primitive.is_string()) { auto lhs_string = TRY(lhs_primitive.to_primitive_string(vm)); auto rhs_string = TRY(rhs_primitive.to_primitive_string(vm)); - return js_rope_string(vm, *lhs_string, *rhs_string); + return PrimitiveString::create(vm, *lhs_string, *rhs_string); } auto lhs_numeric = TRY(lhs_primitive.to_numeric(vm)); diff --git a/Userland/Libraries/LibJS/Runtime/WeakMapPrototype.cpp b/Userland/Libraries/LibJS/Runtime/WeakMapPrototype.cpp index 08538e9d538..abbcd24a12d 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakMapPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/WeakMapPrototype.cpp @@ -28,7 +28,7 @@ void WeakMapPrototype::initialize(Realm& realm) define_native_function(realm, vm.names.set, set, 2, attr); // 24.3.3.6 WeakMap.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-weakmap.prototype-@@tostringtag - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, vm.names.WeakMap.as_string()), Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.WeakMap.as_string()), Attribute::Configurable); } // 24.3.3.2 WeakMap.prototype.delete ( key ), https://tc39.es/ecma262/#sec-weakmap.prototype.delete diff --git a/Userland/Libraries/LibJS/Runtime/WeakRefPrototype.cpp b/Userland/Libraries/LibJS/Runtime/WeakRefPrototype.cpp index 5b7b818407a..437c9ec30a1 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakRefPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/WeakRefPrototype.cpp @@ -21,7 +21,7 @@ void WeakRefPrototype::initialize(Realm& realm) define_native_function(realm, vm.names.deref, deref, 0, Attribute::Writable | Attribute::Configurable); - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, vm.names.WeakRef.as_string()), Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.WeakRef.as_string()), Attribute::Configurable); } // 26.1.3.2 WeakRef.prototype.deref ( ), https://tc39.es/ecma262/#sec-weak-ref.prototype.deref diff --git a/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.cpp b/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.cpp index 1d536fcb3eb..d779963ca1e 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.cpp @@ -27,7 +27,7 @@ void WeakSetPrototype::initialize(Realm& realm) define_native_function(realm, vm.names.has, has, 1, attr); // 24.4.3.5 WeakSet.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-weakset.prototype-@@tostringtag - define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, vm.names.WeakSet.as_string()), Attribute::Configurable); + define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.WeakSet.as_string()), Attribute::Configurable); } // 24.4.3.1 WeakSet.prototype.add ( value ), https://tc39.es/ecma262/#sec-weakset.prototype.add diff --git a/Userland/Libraries/LibJS/SyntheticModule.cpp b/Userland/Libraries/LibJS/SyntheticModule.cpp index 65f0ee9a488..c446f93ca5e 100644 --- a/Userland/Libraries/LibJS/SyntheticModule.cpp +++ b/Userland/Libraries/LibJS/SyntheticModule.cpp @@ -151,7 +151,7 @@ ThrowCompletionOr> parse_json_module(StringView source_text auto* json_parse = realm.intrinsics().json_parse_function(); // 2. Let json be ? Call(jsonParse, undefined, « sourceText »). - auto json = TRY(call(vm, *json_parse, js_undefined(), js_string(realm.vm(), source_text))); + auto json = TRY(call(vm, *json_parse, js_undefined(), PrimitiveString::create(realm.vm(), source_text))); // 3. Return CreateDefaultExportSyntheticModule(json, realm, hostDefined). return SyntheticModule::create_default_export_synthetic_module(json, realm, filename); diff --git a/Userland/Libraries/LibWeb/Bindings/CSSNamespace.cpp b/Userland/Libraries/LibWeb/Bindings/CSSNamespace.cpp index 79a8f2a9749..a2d0cea678c 100644 --- a/Userland/Libraries/LibWeb/Bindings/CSSNamespace.cpp +++ b/Userland/Libraries/LibWeb/Bindings/CSSNamespace.cpp @@ -33,7 +33,7 @@ JS_DEFINE_NATIVE_FUNCTION(CSSNamespace::escape) return vm.throw_completion(JS::ErrorType::BadArgCountAtLeastOne, "CSS.escape"); auto identifier = TRY(vm.argument(0).to_string(vm)); - return JS::js_string(vm, Web::CSS::serialize_an_identifier(identifier)); + return JS::PrimitiveString::create(vm, Web::CSS::serialize_an_identifier(identifier)); } // https://www.w3.org/TR/css-conditional-3/#dom-css-supports diff --git a/Userland/Libraries/LibWeb/Bindings/LegacyPlatformObject.cpp b/Userland/Libraries/LibWeb/Bindings/LegacyPlatformObject.cpp index 35bb08f32b8..29856802453 100644 --- a/Userland/Libraries/LibWeb/Bindings/LegacyPlatformObject.cpp +++ b/Userland/Libraries/LibWeb/Bindings/LegacyPlatformObject.cpp @@ -269,14 +269,14 @@ JS::ThrowCompletionOr> LegacyPlatformObject::interna for (u64 index = 0; index <= NumericLimits::max(); ++index) { if (is_supported_property_index(index)) - keys.append(js_string(vm, DeprecatedString::number(index))); + keys.append(JS::PrimitiveString::create(vm, DeprecatedString::number(index))); else break; } for (auto& named_property : supported_property_names()) { if (TRY(is_named_property_exposed_on_object(named_property))) - keys.append(js_string(vm, named_property)); + keys.append(JS::PrimitiveString::create(vm, named_property)); } // 4. For each P of O’s own property keys that is a String, in ascending chronological order of property creation, append P to keys. diff --git a/Userland/Libraries/LibWeb/Bindings/LocationObject.cpp b/Userland/Libraries/LibWeb/Bindings/LocationObject.cpp index 1f7bfaa2bda..b8d994e77d9 100644 --- a/Userland/Libraries/LibWeb/Bindings/LocationObject.cpp +++ b/Userland/Libraries/LibWeb/Bindings/LocationObject.cpp @@ -97,7 +97,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocationObject::href_getter) // FIXME: 1. If this's relevant Document is non-null and its origin is not same origin-domain with the entry settings object's origin, then throw a "SecurityError" DOMException. // 2. Return this's url, serialized. - return JS::js_string(vm, location_object->url().to_deprecated_string()); + return JS::PrimitiveString::create(vm, location_object->url().to_deprecated_string()); } // https://html.spec.whatwg.org/multipage/history.html#the-location-interface:dom-location-href-2 @@ -127,7 +127,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocationObject::pathname_getter) // FIXME: 1. If this's relevant Document is non-null and its origin is not same origin-domain with the entry settings object's origin, then throw a "SecurityError" DOMException. // 2. Return the result of URL path serializing this Location object's url. - return JS::js_string(vm, location_object->url().path()); + return JS::PrimitiveString::create(vm, location_object->url().path()); } // https://html.spec.whatwg.org/multipage/history.html#dom-location-hostname @@ -139,10 +139,10 @@ JS_DEFINE_NATIVE_FUNCTION(LocationObject::hostname_getter) // 2. If this's url's host is null, return the empty string. if (location_object->url().host().is_null()) - return JS::js_string(vm, DeprecatedString::empty()); + return JS::PrimitiveString::create(vm, DeprecatedString::empty()); // 3. Return this's url's host, serialized. - return JS::js_string(vm, location_object->url().host()); + return JS::PrimitiveString::create(vm, location_object->url().host()); } // https://html.spec.whatwg.org/multipage/history.html#dom-location-host @@ -157,14 +157,14 @@ JS_DEFINE_NATIVE_FUNCTION(LocationObject::host_getter) // 3. If url's host is null, return the empty string. if (url.host().is_null()) - return JS::js_string(vm, DeprecatedString::empty()); + return JS::PrimitiveString::create(vm, DeprecatedString::empty()); // 4. If url's port is null, return url's host, serialized. if (!url.port().has_value()) - return JS::js_string(vm, url.host()); + return JS::PrimitiveString::create(vm, url.host()); // 5. Return url's host, serialized, followed by ":" and url's port, serialized. - return JS::js_string(vm, DeprecatedString::formatted("{}:{}", url.host(), *url.port())); + return JS::PrimitiveString::create(vm, DeprecatedString::formatted("{}:{}", url.host(), *url.port())); } // https://html.spec.whatwg.org/multipage/history.html#dom-location-hash @@ -176,10 +176,10 @@ JS_DEFINE_NATIVE_FUNCTION(LocationObject::hash_getter) // 2. If this's url's fragment is either null or the empty string, return the empty string. if (location_object->url().fragment().is_empty()) - return JS::js_string(vm, DeprecatedString::empty()); + return JS::PrimitiveString::create(vm, DeprecatedString::empty()); // 3. Return "#", followed by this's url's fragment. - return JS::js_string(vm, DeprecatedString::formatted("#{}", location_object->url().fragment())); + return JS::PrimitiveString::create(vm, DeprecatedString::formatted("#{}", location_object->url().fragment())); } // https://html.spec.whatwg.org/multipage/history.html#dom-location-search @@ -191,10 +191,10 @@ JS_DEFINE_NATIVE_FUNCTION(LocationObject::search_getter) // 2. If this's url's query is either null or the empty string, return the empty string. if (location_object->url().query().is_empty()) - return JS::js_string(vm, DeprecatedString::empty()); + return JS::PrimitiveString::create(vm, DeprecatedString::empty()); // 3. Return "?", followed by this's url's query. - return JS::js_string(vm, DeprecatedString::formatted("?{}", location_object->url().query())); + return JS::PrimitiveString::create(vm, DeprecatedString::formatted("?{}", location_object->url().query())); } // https://html.spec.whatwg.org/multipage/history.html#dom-location-protocol @@ -205,7 +205,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocationObject::protocol_getter) // FIXME: 1. If this's relevant Document is non-null and its origin is not same origin-domain with the entry settings object's origin, then throw a "SecurityError" DOMException. // 2. Return this's url's scheme, followed by ":". - return JS::js_string(vm, DeprecatedString::formatted("{}:", location_object->url().scheme())); + return JS::PrimitiveString::create(vm, DeprecatedString::formatted("{}:", location_object->url().scheme())); } // https://html.spec.whatwg.org/multipage/history.html#dom-location-port @@ -217,10 +217,10 @@ JS_DEFINE_NATIVE_FUNCTION(LocationObject::port_getter) // 2. If this's url's port is null, return the empty string. if (!location_object->url().port().has_value()) - return JS::js_string(vm, DeprecatedString::empty()); + return JS::PrimitiveString::create(vm, DeprecatedString::empty()); // 3. Return this's url's port, serialized. - return JS::js_string(vm, DeprecatedString::number(*location_object->url().port())); + return JS::PrimitiveString::create(vm, DeprecatedString::number(*location_object->url().port())); } // https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-location-origin @@ -231,7 +231,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocationObject::origin_getter) // FIXME: 1. If this's relevant Document is non-null and its origin is not same origin-domain with the entry settings object's origin, then throw a "SecurityError" DOMException. // 2. Return the serialization of this's url's origin. - return JS::js_string(vm, location_object->url().serialize_origin()); + return JS::PrimitiveString::create(vm, location_object->url().serialize_origin()); } // https://html.spec.whatwg.org/multipage/history.html#dom-location-reload @@ -297,7 +297,7 @@ JS::ThrowCompletionOr> LocationObject::internal // 2. If the value of the [[DefaultProperties]] internal slot of this contains P, then set desc.[[Configurable]] to true. auto property_key_value = property_key.is_symbol() ? JS::Value { property_key.as_symbol() } - : JS::js_string(vm, property_key.to_string()); + : JS::PrimitiveString::create(vm, property_key.to_string()); if (m_default_properties.contains_slow(property_key_value)) descriptor->configurable = true; diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp index d5c4d286543..d3dc1b1dc93 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp @@ -340,8 +340,8 @@ JS::ThrowCompletionOr CSSStyleDeclaration::internal_get(JS::PropertyK if (property_id == CSS::PropertyID::Invalid) return Base::internal_get(name, receiver); if (auto maybe_property = property(property_id); maybe_property.has_value()) - return { js_string(vm(), maybe_property->value->to_deprecated_string()) }; - return { js_string(vm(), DeprecatedString::empty()) }; + return { JS::PrimitiveString::create(vm(), maybe_property->value->to_deprecated_string()) }; + return { JS::PrimitiveString::create(vm(), DeprecatedString::empty()) }; } JS::ThrowCompletionOr CSSStyleDeclaration::internal_set(JS::PropertyKey const& name, JS::Value value, JS::Value receiver) diff --git a/Userland/Libraries/LibWeb/CSS/MediaList.cpp b/Userland/Libraries/LibWeb/CSS/MediaList.cpp index 1d4ec36ede1..20dfecca36a 100644 --- a/Userland/Libraries/LibWeb/CSS/MediaList.cpp +++ b/Userland/Libraries/LibWeb/CSS/MediaList.cpp @@ -100,7 +100,7 @@ JS::Value MediaList::item_value(size_t index) const { if (index >= m_media.size()) return JS::js_undefined(); - return JS::js_string(vm(), m_media[index].to_deprecated_string()); + return JS::PrimitiveString::create(vm(), m_media[index].to_deprecated_string()); } } diff --git a/Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp b/Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp index a8a09ef73b1..883e39e48e6 100644 --- a/Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp +++ b/Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp @@ -259,7 +259,7 @@ JS::Value DOMTokenList::item_value(size_t index) const auto const& string = item(index); if (string.is_null()) return JS::js_undefined(); - return JS::js_string(vm(), string); + return JS::PrimitiveString::create(vm(), string); } } diff --git a/Userland/Libraries/LibWeb/DOM/EventTarget.cpp b/Userland/Libraries/LibWeb/DOM/EventTarget.cpp index ed54f665210..b31c0e78aae 100644 --- a/Userland/Libraries/LibWeb/DOM/EventTarget.cpp +++ b/Userland/Libraries/LibWeb/DOM/EventTarget.cpp @@ -624,8 +624,8 @@ JS::ThrowCompletionOr EventTarget::process_event_handler_for_event(FlyStri // the fourth having the value of event's colno attribute, the fifth having the value of event's error attribute, and with the callback this value set to event's currentTarget. // Let return value be the callback's return value. [WEBIDL] auto& error_event = verify_cast(event); - auto* wrapped_message = JS::js_string(vm(), error_event.message()); - auto* wrapped_filename = JS::js_string(vm(), error_event.filename()); + auto wrapped_message = JS::PrimitiveString::create(vm(), error_event.message()); + auto wrapped_filename = JS::PrimitiveString::create(vm(), error_event.filename()); auto wrapped_lineno = JS::Value(error_event.lineno()); auto wrapped_colno = JS::Value(error_event.colno()); diff --git a/Userland/Libraries/LibWeb/Fetch/Body.cpp b/Userland/Libraries/LibWeb/Fetch/Body.cpp index 45ab82ed806..3209b38b46c 100644 --- a/Userland/Libraries/LibWeb/Fetch/Body.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Body.cpp @@ -134,7 +134,7 @@ WebIDL::ExceptionOr package_data(JS::Realm& realm, ByteBuffer bytes, return Infra::parse_json_bytes_to_javascript_value(vm, bytes); case PackageDataType::Text: // Return the result of running UTF-8 decode on bytes. - return JS::js_string(vm, DeprecatedString::copy(bytes)); + return JS::PrimitiveString::create(vm, DeprecatedString::copy(bytes)); default: VERIFY_NOT_REACHED(); } @@ -152,7 +152,7 @@ JS::NonnullGCPtr 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::js_string(vm, DeprecatedString::empty())); + auto promise = WebIDL::create_resolved_promise(realm, JS::PrimitiveString::create(vm, DeprecatedString::empty())); // 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(); diff --git a/Userland/Libraries/LibWeb/Fetch/HeadersIterator.cpp b/Userland/Libraries/LibWeb/Fetch/HeadersIterator.cpp index 9410eae43ef..00afcce5bff 100644 --- a/Userland/Libraries/LibWeb/Fetch/HeadersIterator.cpp +++ b/Userland/Libraries/LibWeb/Fetch/HeadersIterator.cpp @@ -53,11 +53,11 @@ JS::ThrowCompletionOr HeadersIterator::next() switch (m_iteration_kind) { case JS::Object::PropertyKind::Key: - return create_iterator_result_object(vm(), JS::js_string(vm(), StringView { pair.name }), false); + return create_iterator_result_object(vm(), JS::PrimitiveString::create(vm(), StringView { pair.name }), false); case JS::Object::PropertyKind::Value: - return create_iterator_result_object(vm(), JS::js_string(vm(), StringView { pair.value }), false); + return create_iterator_result_object(vm(), JS::PrimitiveString::create(vm(), StringView { pair.value }), false); case JS::Object::PropertyKind::KeyAndValue: { - auto* array = JS::Array::create_from(realm(), { JS::js_string(vm(), StringView { pair.name }), JS::js_string(vm(), StringView { pair.value }) }); + auto* array = JS::Array::create_from(realm(), { JS::PrimitiveString::create(vm(), StringView { pair.name }), JS::PrimitiveString::create(vm(), StringView { pair.value }) }); return create_iterator_result_object(vm(), array, false); } default: diff --git a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Bodies.cpp b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Bodies.cpp index e717ae55dd6..475da2f53f1 100644 --- a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Bodies.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Bodies.cpp @@ -49,7 +49,7 @@ JS::NonnullGCPtr Body::fully_read_as_promise() const // FIXME: Implement the streams spec - this is completely made up for now :^) if (auto const* byte_buffer = m_source.get_pointer()) { auto result = DeprecatedString::copy(*byte_buffer); - return WebIDL::create_resolved_promise(realm, JS::js_string(vm, move(result))); + return WebIDL::create_resolved_promise(realm, JS::PrimitiveString::create(vm, move(result))); } // Empty, Blob, FormData return WebIDL::create_rejected_promise(realm, JS::InternalError::create(realm, "Reading body isn't fully implemented"sv)); diff --git a/Userland/Libraries/LibWeb/FileAPI/Blob.cpp b/Userland/Libraries/LibWeb/FileAPI/Blob.cpp index fe00283ae54..180b8344579 100644 --- a/Userland/Libraries/LibWeb/FileAPI/Blob.cpp +++ b/Userland/Libraries/LibWeb/FileAPI/Blob.cpp @@ -245,7 +245,7 @@ JS::Promise* Blob::text() // FIXME: We still need to implement ReadableStream for this step to be fully valid. // 3. Let promise be the result of reading all bytes from stream with reader auto* promise = JS::Promise::create(realm()); - auto* result = JS::js_string(vm(), DeprecatedString { m_byte_buffer.bytes() }); + auto result = JS::PrimitiveString::create(vm(), DeprecatedString { m_byte_buffer.bytes() }); // 4. Return the result of transforming promise by a fulfillment handler that returns the result of running UTF-8 decode on its first argument. promise->fulfill(result); diff --git a/Userland/Libraries/LibWeb/HTML/CrossOrigin/AbstractOperations.cpp b/Userland/Libraries/LibWeb/HTML/CrossOrigin/AbstractOperations.cpp index a109b92f32c..f1dcf32c692 100644 --- a/Userland/Libraries/LibWeb/HTML/CrossOrigin/AbstractOperations.cpp +++ b/Userland/Libraries/LibWeb/HTML/CrossOrigin/AbstractOperations.cpp @@ -236,10 +236,10 @@ JS::MarkedVector cross_origin_own_property_keys(Variantprompt_impl(message, default_); if (response.is_null()) return JS::js_null(); - return JS::js_string(vm, response); + return JS::PrimitiveString::create(vm, response); } static JS::ThrowCompletionOr make_timer_handler(JS::VM& vm, JS::Value handler) @@ -1406,7 +1406,7 @@ JS_DEFINE_NATIVE_FUNCTION(Window::atob) // decode_base64() returns a byte string. LibJS uses UTF-8 for strings. Use Latin1Decoder to convert bytes 128-255 to UTF-8. auto decoder = TextCodec::decoder_for("windows-1252"); VERIFY(decoder); - return JS::js_string(vm, decoder->to_utf8(decoded.value())); + return JS::PrimitiveString::create(vm, decoder->to_utf8(decoded.value())); } JS_DEFINE_NATIVE_FUNCTION(Window::btoa) @@ -1424,7 +1424,7 @@ JS_DEFINE_NATIVE_FUNCTION(Window::btoa) } auto encoded = encode_base64(byte_string.span()); - return JS::js_string(vm, move(encoded)); + return JS::PrimitiveString::create(vm, move(encoded)); } // https://html.spec.whatwg.org/multipage/interaction.html#dom-window-focus @@ -1752,7 +1752,7 @@ JS_DEFINE_NATIVE_FUNCTION(Window::scroll_by) options = JS::Object::create(realm, nullptr); MUST(options->set("left", vm.argument(0), ShouldThrowExceptions::No)); MUST(options->set("top", vm.argument(1), ShouldThrowExceptions::No)); - MUST(options->set("behavior", JS::js_string(vm, "auto"), ShouldThrowExceptions::No)); + MUST(options->set("behavior", JS::PrimitiveString::create(vm, "auto"), ShouldThrowExceptions::No)); } auto left_value = TRY(options->get("left")); @@ -1845,7 +1845,7 @@ JS_DEFINE_NATIVE_FUNCTION(Window::structured_clone) JS_DEFINE_NATIVE_FUNCTION(Window::origin_getter) { auto* impl = TRY(impl_from(vm)); - return JS::js_string(vm, impl->associated_document().origin().serialize()); + return JS::PrimitiveString::create(vm, impl->associated_document().origin().serialize()); } JS_DEFINE_NATIVE_FUNCTION(Window::local_storage_getter) @@ -1863,7 +1863,7 @@ JS_DEFINE_NATIVE_FUNCTION(Window::session_storage_getter) JS_DEFINE_NATIVE_FUNCTION(Window::name_getter) { auto* impl = TRY(impl_from(vm)); - return JS::js_string(vm, impl->name()); + return JS::PrimitiveString::create(vm, impl->name()); } JS_DEFINE_NATIVE_FUNCTION(Window::name_setter) diff --git a/Userland/Libraries/LibWeb/HTML/WindowProxy.cpp b/Userland/Libraries/LibWeb/HTML/WindowProxy.cpp index 835a8565904..0a741b73ec9 100644 --- a/Userland/Libraries/LibWeb/HTML/WindowProxy.cpp +++ b/Userland/Libraries/LibWeb/HTML/WindowProxy.cpp @@ -233,7 +233,7 @@ JS::ThrowCompletionOr> WindowProxy::internal_own_pro // 5. Repeat while index < maxProperties, for (size_t i = 0; i < max_properties; ++i) { // 1. Add ! ToString(index) as the last element of keys. - keys.append(JS::js_string(vm, DeprecatedString::number(i))); + keys.append(JS::PrimitiveString::create(vm, DeprecatedString::number(i))); // 2. Increment index by 1. } diff --git a/Userland/Libraries/LibWeb/Infra/JSON.cpp b/Userland/Libraries/LibWeb/Infra/JSON.cpp index 66d2b3e74e2..3d39d719ce2 100644 --- a/Userland/Libraries/LibWeb/Infra/JSON.cpp +++ b/Userland/Libraries/LibWeb/Infra/JSON.cpp @@ -18,7 +18,7 @@ WebIDL::ExceptionOr parse_json_string_to_javascript_value(JS::VM& vm, auto& realm = *vm.current_realm(); // 1. Return ? Call(%JSON.parse%, undefined, « string »). - return TRY(JS::call(vm, realm.intrinsics().json_parse_function(), JS::js_undefined(), JS::js_string(vm, string))); + return TRY(JS::call(vm, realm.intrinsics().json_parse_function(), JS::js_undefined(), JS::PrimitiveString::create(vm, string))); } // https://infra.spec.whatwg.org/#parse-json-bytes-to-a-javascript-value diff --git a/Userland/Libraries/LibWeb/URL/URLSearchParamsIterator.cpp b/Userland/Libraries/LibWeb/URL/URLSearchParamsIterator.cpp index 9d1cb1a3da8..f8cc777bfa2 100644 --- a/Userland/Libraries/LibWeb/URL/URLSearchParamsIterator.cpp +++ b/Userland/Libraries/LibWeb/URL/URLSearchParamsIterator.cpp @@ -40,11 +40,11 @@ JS::Object* URLSearchParamsIterator::next() auto& entry = m_url_search_params.m_list[m_index++]; if (m_iteration_kind == JS::Object::PropertyKind::Key) - return create_iterator_result_object(vm(), JS::js_string(vm(), entry.name), false); + return create_iterator_result_object(vm(), JS::PrimitiveString::create(vm(), entry.name), false); else if (m_iteration_kind == JS::Object::PropertyKind::Value) - return create_iterator_result_object(vm(), JS::js_string(vm(), entry.value), false); + return create_iterator_result_object(vm(), JS::PrimitiveString::create(vm(), entry.value), false); - return create_iterator_result_object(vm(), JS::Array::create_from(realm(), { JS::js_string(vm(), entry.name), JS::js_string(vm(), entry.value) }), false); + return create_iterator_result_object(vm(), JS::Array::create_from(realm(), { JS::PrimitiveString::create(vm(), entry.name), JS::PrimitiveString::create(vm(), entry.value) }), false); } } diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryPrototype.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryPrototype.cpp index 1a246656fad..0bf52aff156 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryPrototype.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryPrototype.cpp @@ -51,7 +51,7 @@ JS_DEFINE_NATIVE_FUNCTION(WebAssemblyMemoryPrototype::buffer_getter) return JS::js_undefined(); auto* array_buffer = JS::ArrayBuffer::create(realm, &memory->data()); - array_buffer->set_detach_key(JS::js_string(vm, "WebAssembly.Memory")); + array_buffer->set_detach_key(JS::PrimitiveString::create(vm, "WebAssembly.Memory")); return array_buffer; } diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.cpp index 4d28a8362e4..b2830f18eb5 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.cpp @@ -43,25 +43,25 @@ void WebAssemblyObject::initialize(JS::Realm& realm) auto& vm = this->vm(); auto& memory_constructor = Bindings::ensure_web_constructor(realm, "WebAssembly.Memory"); - memory_constructor.define_direct_property(vm.names.name, js_string(vm, "WebAssembly.Memory"), JS::Attribute::Configurable); + memory_constructor.define_direct_property(vm.names.name, JS::PrimitiveString::create(vm, "WebAssembly.Memory"), JS::Attribute::Configurable); auto& memory_prototype = Bindings::ensure_web_prototype(realm, "WebAssemblyMemoryPrototype"); memory_prototype.define_direct_property(vm.names.constructor, &memory_constructor, JS::Attribute::Writable | JS::Attribute::Configurable); define_direct_property("Memory", &memory_constructor, JS::Attribute::Writable | JS::Attribute::Configurable); auto& instance_constructor = Bindings::ensure_web_constructor(realm, "WebAssembly.Instance"); - instance_constructor.define_direct_property(vm.names.name, js_string(vm, "WebAssembly.Instance"), JS::Attribute::Configurable); + instance_constructor.define_direct_property(vm.names.name, JS::PrimitiveString::create(vm, "WebAssembly.Instance"), JS::Attribute::Configurable); auto& instance_prototype = Bindings::ensure_web_prototype(realm, "WebAssemblyInstancePrototype"); instance_prototype.define_direct_property(vm.names.constructor, &instance_constructor, JS::Attribute::Writable | JS::Attribute::Configurable); define_direct_property("Instance", &instance_constructor, JS::Attribute::Writable | JS::Attribute::Configurable); auto& module_constructor = Bindings::ensure_web_constructor(realm, "WebAssembly.Module"); - module_constructor.define_direct_property(vm.names.name, js_string(vm, "WebAssembly.Module"), JS::Attribute::Configurable); + module_constructor.define_direct_property(vm.names.name, JS::PrimitiveString::create(vm, "WebAssembly.Module"), JS::Attribute::Configurable); auto& module_prototype = Bindings::ensure_web_prototype(realm, "WebAssemblyModulePrototype"); module_prototype.define_direct_property(vm.names.constructor, &module_constructor, JS::Attribute::Writable | JS::Attribute::Configurable); define_direct_property("Module", &module_constructor, JS::Attribute::Writable | JS::Attribute::Configurable); auto& table_constructor = Bindings::ensure_web_constructor(realm, "WebAssembly.Table"); - table_constructor.define_direct_property(vm.names.name, js_string(vm, "WebAssembly.Table"), JS::Attribute::Configurable); + table_constructor.define_direct_property(vm.names.name, JS::PrimitiveString::create(vm, "WebAssembly.Table"), JS::Attribute::Configurable); auto& table_prototype = Bindings::ensure_web_prototype(realm, "WebAssemblyTablePrototype"); table_prototype.define_direct_property(vm.names.constructor, &table_constructor, JS::Attribute::Writable | JS::Attribute::Configurable); define_direct_property("Table", &table_constructor, JS::Attribute::Writable | JS::Attribute::Configurable); diff --git a/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp b/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp index 6eeb08e3d31..a2f8ff618b5 100644 --- a/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp +++ b/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp @@ -207,7 +207,7 @@ void WebSocket::on_message(ByteBuffer message, bool is_text) if (is_text) { auto text_message = DeprecatedString(ReadonlyBytes(message)); HTML::MessageEventInit event_init; - event_init.data = JS::js_string(vm(), text_message); + event_init.data = JS::PrimitiveString::create(vm(), text_message); event_init.origin = url(); dispatch_event(*HTML::MessageEvent::create(realm(), HTML::EventNames::message, event_init)); return; diff --git a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp index a5885d1a0c8..4d9a9f5138e 100644 --- a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp +++ b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp @@ -121,10 +121,10 @@ WebIDL::ExceptionOr XMLHttpRequest::response() if (m_response_type == Bindings::XMLHttpRequestResponseType::Empty || m_response_type == Bindings::XMLHttpRequestResponseType::Text) { // 1. If this’s state is not loading or done, then return the empty string. if (m_state != State::Loading && m_state != State::Done) - return JS::js_string(vm, ""); + return JS::PrimitiveString::create(vm, ""); // 2. Return the result of getting a text response for this. - return JS::js_string(vm, get_text_response()); + return JS::PrimitiveString::create(vm, get_text_response()); } // 2. If this’s state is not done, then return null. if (m_state != State::Done) diff --git a/Userland/Utilities/js.cpp b/Userland/Utilities/js.cpp index 2f58e5c49fa..fb0965debf5 100644 --- a/Userland/Utilities/js.cpp +++ b/Userland/Utilities/js.cpp @@ -356,7 +356,7 @@ static JS::ThrowCompletionOr load_ini_impl(JS::VM& vm) auto* group_object = JS::Object::create(realm, realm.intrinsics().object_prototype()); for (auto const& key : config_file->keys(group)) { auto entry = config_file->read_entry(group, key); - group_object->define_direct_property(key, js_string(vm, move(entry)), JS::Attribute::Enumerable | JS::Attribute::Configurable | JS::Attribute::Writable); + group_object->define_direct_property(key, JS::PrimitiveString::create(vm, move(entry)), JS::Attribute::Enumerable | JS::Attribute::Configurable | JS::Attribute::Writable); } object->define_direct_property(group, group_object, JS::Attribute::Enumerable | JS::Attribute::Configurable | JS::Attribute::Writable); }