mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 19:38:12 +00:00
LibJS: Port Symbol to String
This includes the VM's global_symbol_registry HashMap, which can now store String keys.
This commit is contained in:
parent
5e72fde954
commit
a8bf2f8e4c
11 changed files with 27 additions and 27 deletions
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2020, Matthew Olsson <mattco@serenityos.org>
|
||||
* Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
|
||||
* Copyright (c) 2022-2023, Linus Groh <linusg@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -44,7 +44,7 @@ ThrowCompletionOr<Value> SymbolConstructor::call()
|
|||
auto& vm = this->vm();
|
||||
if (vm.argument(0).is_undefined())
|
||||
return Symbol::create(vm, {}, false);
|
||||
return Symbol::create(vm, TRY(vm.argument(0).to_deprecated_string(vm)), false);
|
||||
return Symbol::create(vm, TRY(vm.argument(0).to_string(vm)), false);
|
||||
}
|
||||
|
||||
// 20.4.1.1 Symbol ( [ description ] ), https://tc39.es/ecma262/#sec-symbol-description
|
||||
|
@ -57,7 +57,7 @@ ThrowCompletionOr<NonnullGCPtr<Object>> SymbolConstructor::construct(FunctionObj
|
|||
JS_DEFINE_NATIVE_FUNCTION(SymbolConstructor::for_)
|
||||
{
|
||||
// 1. Let stringKey be ? ToString(key).
|
||||
auto string_key = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
auto string_key = TRY(vm.argument(0).to_string(vm));
|
||||
|
||||
// 2. For each element e of the GlobalSymbolRegistry List, do
|
||||
auto result = vm.global_symbol_registry().get(string_key);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue