diff options
author | Linus Groh <mail@linusgroh.de> | 2023-04-13 14:34:00 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-04-14 09:59:29 +0200 |
commit | e79f5b6e857d8f6b79eec5aad3d524237ea0a23b (patch) | |
tree | bdd0c3bbb333234bfbf1336c534b246bbf38ca33 /Userland/Libraries/LibJS/Runtime | |
parent | 04198a29a841085a64b0b077e1431008e04bfadd (diff) | |
download | serenity-e79f5b6e857d8f6b79eec5aad3d524237ea0a23b.zip |
LibJS: Port Value::to_primitive_string() to NonnullGCPtr
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime')
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/StringPrototype.cpp | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/Value.cpp | 8 | ||||
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/Value.h | 2 |
3 files changed, 8 insertions, 8 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp b/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp index 0d452174cc..2dbfa9de30 100644 --- a/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp @@ -301,15 +301,15 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::concat) auto object = TRY(require_object_coercible(vm, vm.this_value())); // 2. Let S be ? ToString(O). - auto* string = TRY(object.to_primitive_string(vm)); + auto string = TRY(object.to_primitive_string(vm)); // 3. Let R be S. - auto* result = string; + auto result = string; // 4. For each element next of args, do for (size_t i = 0; i < vm.argument_count(); ++i) { // a. Let nextString be ? ToString(next). - auto* next_string = TRY(vm.argument(i).to_primitive_string(vm)); + auto next_string = TRY(vm.argument(i).to_primitive_string(vm)); // b. Set R to the string-concatenation of R and nextString. result = PrimitiveString::create(vm, *result, *next_string); diff --git a/Userland/Libraries/LibJS/Runtime/Value.cpp b/Userland/Libraries/LibJS/Runtime/Value.cpp index 100327c78f..0c8de4df19 100644 --- a/Userland/Libraries/LibJS/Runtime/Value.cpp +++ b/Userland/Libraries/LibJS/Runtime/Value.cpp @@ -397,12 +397,12 @@ ErrorOr<String> Value::to_string_without_side_effects() const } } -ThrowCompletionOr<PrimitiveString*> Value::to_primitive_string(VM& vm) +ThrowCompletionOr<NonnullGCPtr<PrimitiveString>> Value::to_primitive_string(VM& vm) { if (is_string()) - return &as_string(); + return as_string(); auto string = TRY(to_string(vm)); - return PrimitiveString::create(vm, move(string)).ptr(); + return PrimitiveString::create(vm, move(string)); } // 7.1.17 ToString ( argument ), https://tc39.es/ecma262/#sec-tostring @@ -1728,7 +1728,7 @@ ThrowCompletionOr<Value> add(VM& vm, Value lhs, Value rhs) auto rhs_string = TRY(rhs_primitive.to_primitive_string(vm)); // iii. Return the string-concatenation of lstr and rstr. - return PrimitiveString::create(vm, *lhs_string, *rhs_string); + return PrimitiveString::create(vm, lhs_string, rhs_string); } // d. Set lval to lprim. diff --git a/Userland/Libraries/LibJS/Runtime/Value.h b/Userland/Libraries/LibJS/Runtime/Value.h index 81ac4c57ec..351b850556 100644 --- a/Userland/Libraries/LibJS/Runtime/Value.h +++ b/Userland/Libraries/LibJS/Runtime/Value.h @@ -369,7 +369,7 @@ public: ThrowCompletionOr<String> to_string(VM&) const; ThrowCompletionOr<DeprecatedString> to_deprecated_string(VM&) const; ThrowCompletionOr<Utf16String> to_utf16_string(VM&) const; - ThrowCompletionOr<PrimitiveString*> to_primitive_string(VM&); + ThrowCompletionOr<NonnullGCPtr<PrimitiveString>> to_primitive_string(VM&); ThrowCompletionOr<Value> to_primitive(VM&, PreferredType preferred_type = PreferredType::Default) const; ThrowCompletionOr<Object*> to_object(VM&) const; ThrowCompletionOr<Value> to_numeric(VM&) const; |