From 398c181c799f728739c1ee2184b8638554b3353c Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 24 Oct 2021 16:01:24 +0200 Subject: [PATCH] LibJS: Rename PropertyName to PropertyKey Let's use the same name as the spec. :^) --- .../LibWeb/WrapperGenerator.cpp | 38 +++++----- .../Spreadsheet/JSIntegration.cpp | 6 +- .../Applications/Spreadsheet/JSIntegration.h | 6 +- .../Applications/Spreadsheet/Spreadsheet.cpp | 2 +- .../Debugger/DebuggerGlobalJSObject.cpp | 4 +- .../Debugger/DebuggerGlobalJSObject.h | 4 +- .../Debugger/DebuggerVariableJSObject.cpp | 4 +- .../Debugger/DebuggerVariableJSObject.h | 2 +- Userland/Libraries/LibJS/AST.cpp | 24 +++--- Userland/Libraries/LibJS/AST.h | 6 +- Userland/Libraries/LibJS/Bytecode/Op.cpp | 2 +- Userland/Libraries/LibJS/Forward.h | 2 +- Userland/Libraries/LibJS/Parser.cpp | 2 +- .../LibJS/Runtime/AbstractOperations.cpp | 10 +-- .../LibJS/Runtime/AbstractOperations.h | 4 +- .../LibJS/Runtime/ArgumentsObject.cpp | 10 +-- .../Libraries/LibJS/Runtime/ArgumentsObject.h | 10 +-- Userland/Libraries/LibJS/Runtime/Array.cpp | 6 +- Userland/Libraries/LibJS/Runtime/Array.h | 6 +- .../LibJS/Runtime/ArrayPrototype.cpp | 30 ++++---- .../LibJS/Runtime/CommonPropertyNames.h | 30 ++++---- .../Runtime/ECMAScriptFunctionObject.cpp | 2 +- .../LibJS/Runtime/ECMAScriptFunctionObject.h | 4 +- .../Libraries/LibJS/Runtime/GlobalObject.h | 10 +-- .../LibJS/Runtime/Intl/AbstractOperations.cpp | 6 +- .../LibJS/Runtime/Intl/AbstractOperations.h | 4 +- .../LibJS/Runtime/Intl/LocaleConstructor.cpp | 2 +- .../Libraries/LibJS/Runtime/JSONObject.cpp | 8 +- Userland/Libraries/LibJS/Runtime/JSONObject.h | 4 +- Userland/Libraries/LibJS/Runtime/Object.cpp | 76 +++++++++---------- Userland/Libraries/LibJS/Runtime/Object.h | 62 +++++++-------- .../LibJS/Runtime/ObjectConstructor.cpp | 4 +- .../Runtime/{PropertyName.h => PropertyKey.h} | 40 +++++----- .../Libraries/LibJS/Runtime/ProxyObject.cpp | 16 ++-- .../Libraries/LibJS/Runtime/ProxyObject.h | 12 +-- Userland/Libraries/LibJS/Runtime/Reference.h | 10 +-- Userland/Libraries/LibJS/Runtime/Shape.cpp | 2 +- Userland/Libraries/LibJS/Runtime/Shape.h | 2 +- .../Libraries/LibJS/Runtime/StringObject.cpp | 8 +- .../Libraries/LibJS/Runtime/StringObject.h | 4 +- .../Runtime/Temporal/AbstractOperations.cpp | 6 +- .../Runtime/Temporal/AbstractOperations.h | 4 +- .../LibJS/Runtime/Temporal/Calendar.cpp | 4 +- .../LibJS/Runtime/Temporal/Duration.h | 2 +- .../LibJS/Runtime/Temporal/PlainTime.h | 2 +- Userland/Libraries/LibJS/Runtime/TypedArray.h | 16 ++-- Userland/Libraries/LibJS/Runtime/VM.cpp | 4 +- Userland/Libraries/LibJS/Runtime/VM.h | 2 +- Userland/Libraries/LibJS/Runtime/Value.cpp | 6 +- Userland/Libraries/LibJS/Runtime/Value.h | 8 +- .../CSSStyleDeclarationWrapperCustom.cpp | 6 +- .../LibWeb/Bindings/IDLAbstractOperations.cpp | 4 +- .../LibWeb/Bindings/IDLAbstractOperations.h | 2 +- .../WebContent/ConsoleGlobalObject.cpp | 12 +-- .../Services/WebContent/ConsoleGlobalObject.h | 12 +-- 55 files changed, 287 insertions(+), 287 deletions(-) rename Userland/Libraries/LibJS/Runtime/{PropertyName.h => PropertyKey.h} (84%) diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp index 361981ea59..63b772bc91 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp @@ -1384,7 +1384,7 @@ static void generate_wrap_statement(SourceGenerator& generator, String const& va generate_wrap_statement(scoped_generator, String::formatted("element{}", recursion_depth), sequence_generic_type.parameters.first(), String::formatted("auto wrapped_element{} =", recursion_depth), WrappingReference::Yes, recursion_depth + 1); scoped_generator.append(R"~~~( - auto property_index@recursion_depth@ = JS::PropertyName { i@recursion_depth@ }; + auto property_index@recursion_depth@ = JS::PropertyKey { i@recursion_depth@ }; MUST(new_array@recursion_depth@->create_data_property(property_index@recursion_depth@, wrapped_element@recursion_depth@)); } @@ -1577,18 +1577,18 @@ public: if (interface.extended_attributes.contains("CustomGet")) { generator.append(R"~~~( - virtual JS::ThrowCompletionOr internal_get(JS::PropertyName const&, JS::Value receiver) const override; + virtual JS::ThrowCompletionOr internal_get(JS::PropertyKey const&, JS::Value receiver) const override; )~~~"); } if (interface.extended_attributes.contains("CustomSet")) { generator.append(R"~~~( - virtual JS::ThrowCompletionOr internal_set(JS::PropertyName const&, JS::Value, JS::Value receiver) override; + virtual JS::ThrowCompletionOr internal_set(JS::PropertyKey const&, JS::Value, JS::Value receiver) override; )~~~"); } if (interface.extended_attributes.contains("CustomHasProperty")) { generator.append(R"~~~( - virtual JS::ThrowCompletionOr internal_has_property(JS::PropertyName const&) const override; + virtual JS::ThrowCompletionOr internal_has_property(JS::PropertyKey const&) const override; )~~~"); } @@ -1600,10 +1600,10 @@ public: if (interface.is_legacy_platform_object()) { generator.append(R"~~~( - virtual JS::ThrowCompletionOr> internal_get_own_property(JS::PropertyName const&) const override; - virtual JS::ThrowCompletionOr internal_set(JS::PropertyName const&, JS::Value, JS::Value) override; - virtual JS::ThrowCompletionOr internal_define_own_property(JS::PropertyName const&, JS::PropertyDescriptor const&) override; - virtual JS::ThrowCompletionOr internal_delete(JS::PropertyName const&) override; + virtual JS::ThrowCompletionOr> internal_get_own_property(JS::PropertyKey const&) const override; + virtual JS::ThrowCompletionOr internal_set(JS::PropertyKey const&, JS::Value, JS::Value) override; + virtual JS::ThrowCompletionOr internal_define_own_property(JS::PropertyKey const&, JS::PropertyDescriptor const&) override; + virtual JS::ThrowCompletionOr internal_delete(JS::PropertyKey const&) override; virtual JS::ThrowCompletionOr internal_prevent_extensions() override; virtual JS::ThrowCompletionOr internal_own_property_keys() const override; )~~~"); @@ -1627,9 +1627,9 @@ private: if (interface.is_legacy_platform_object()) { generator.append(R"~~~( - bool is_named_property_exposed_on_object(JS::PropertyName const&) const; - Optional legacy_platform_object_get_own_property_for_get_own_property_slot(JS::PropertyName const&) const; - Optional legacy_platform_object_get_own_property_for_set_slot(JS::PropertyName const&) const; + bool is_named_property_exposed_on_object(JS::PropertyKey const&) const; + Optional legacy_platform_object_get_own_property_for_get_own_property_slot(JS::PropertyKey const&) const; + Optional legacy_platform_object_get_own_property_for_set_slot(JS::PropertyKey const&) const; )~~~"); } @@ -1807,7 +1807,7 @@ static JS::Value wrap_for_legacy_platform_object_get_own_property(JS::GlobalObje // https://webidl.spec.whatwg.org/#dfn-named-property-visibility scoped_generator.append(R"~~~( -bool @class_name@::is_named_property_exposed_on_object(JS::PropertyName const& property_name) const +bool @class_name@::is_named_property_exposed_on_object(JS::PropertyKey const& property_name) const { [[maybe_unused]] auto& vm = this->vm(); @@ -1877,7 +1877,7 @@ bool @class_name@::is_named_property_exposed_on_object(JS::PropertyName const& p get_own_property_generator.set("internal_method"sv, for_which_internal_method); get_own_property_generator.append(R"~~~( -Optional @class_name@::legacy_platform_object_get_own_property_for_@internal_method@_slot(JS::PropertyName const& property_name) const +Optional @class_name@::legacy_platform_object_get_own_property_for_@internal_method@_slot(JS::PropertyKey const& property_name) const { )~~~"); @@ -2049,7 +2049,7 @@ Optional @class_name@::legacy_platform_object_get_own_pr if (interface.named_property_setter.has_value()) { // https://webidl.spec.whatwg.org/#invoke-named-setter - // NOTE: All users of invoke_named_property_setter check that JS::PropertyName is a String before calling it. + // NOTE: All users of invoke_named_property_setter check that JS::PropertyKey is a String before calling it. // FIXME: It's not necessary to determine "creating" if the named property setter specifies an identifier. // Try avoiding it somehow, e.g. by enforcing supported_property_names doesn't have side effects so it can be skipped. scoped_generator.append(R"~~~( @@ -2109,7 +2109,7 @@ static void invoke_named_property_setter(JS::GlobalObject& global_object, @fully // FIXME: It's not necessary to determine "creating" if the indexed property setter specifies an identifier. // Try avoiding it somehow, e.g. by enforcing supported_property_indices doesn't have side effects so it can be skipped. scoped_generator.append(R"~~~( -static void invoke_indexed_property_setter(JS::GlobalObject& global_object, @fully_qualified_name@& impl, JS::PropertyName const& property_name, JS::Value value) +static void invoke_indexed_property_setter(JS::GlobalObject& global_object, @fully_qualified_name@& impl, JS::PropertyKey const& property_name, JS::Value value) { auto& vm = global_object.vm(); @@ -2165,7 +2165,7 @@ static void invoke_indexed_property_setter(JS::GlobalObject& global_object, @ful // 3.9.1. [[GetOwnProperty]], https://webidl.spec.whatwg.org/#legacy-platform-object-getownproperty scoped_generator.append(R"~~~( -JS::ThrowCompletionOr> @class_name@::internal_get_own_property(JS::PropertyName const& property_name) const +JS::ThrowCompletionOr> @class_name@::internal_get_own_property(JS::PropertyKey const& property_name) const { // 1. Return LegacyPlatformObjectGetOwnProperty(O, P, false). return legacy_platform_object_get_own_property_for_get_own_property_slot(property_name); @@ -2174,7 +2174,7 @@ JS::ThrowCompletionOr> @class_name@::internal_g // 3.9.2. [[Set]], https://webidl.spec.whatwg.org/#legacy-platform-object-set scoped_generator.append(R"~~~( -JS::ThrowCompletionOr @class_name@::internal_set(JS::PropertyName const& property_name, JS::Value value, JS::Value receiver) +JS::ThrowCompletionOr @class_name@::internal_set(JS::PropertyKey const& property_name, JS::Value value, JS::Value receiver) { auto& vm = this->vm(); [[maybe_unused]] auto& global_object = this->global_object(); @@ -2239,7 +2239,7 @@ JS::ThrowCompletionOr @class_name@::internal_set(JS::PropertyName const& p // 3.9.3. [[DefineOwnProperty]], https://webidl.spec.whatwg.org/#legacy-platform-object-defineownproperty scoped_generator.append(R"~~~( -JS::ThrowCompletionOr @class_name@::internal_define_own_property(JS::PropertyName const& property_name, JS::PropertyDescriptor const& property_descriptor) +JS::ThrowCompletionOr @class_name@::internal_define_own_property(JS::PropertyKey const& property_name, JS::PropertyDescriptor const& property_descriptor) { [[maybe_unused]] auto& vm = this->vm(); auto& global_object = this->global_object(); @@ -2363,7 +2363,7 @@ JS::ThrowCompletionOr @class_name@::internal_define_own_property(JS::Prope // 3.9.4. [[Delete]], https://webidl.spec.whatwg.org/#legacy-platform-object-delete scoped_generator.append(R"~~~( -JS::ThrowCompletionOr @class_name@::internal_delete(JS::PropertyName const& property_name) +JS::ThrowCompletionOr @class_name@::internal_delete(JS::PropertyKey const& property_name) { [[maybe_unused]] auto& vm = this->vm(); auto& global_object = this->global_object(); diff --git a/Userland/Applications/Spreadsheet/JSIntegration.cpp b/Userland/Applications/Spreadsheet/JSIntegration.cpp index 13982e5142..24ab6c4fc2 100644 --- a/Userland/Applications/Spreadsheet/JSIntegration.cpp +++ b/Userland/Applications/Spreadsheet/JSIntegration.cpp @@ -101,7 +101,7 @@ SheetGlobalObject::~SheetGlobalObject() { } -JS::ThrowCompletionOr SheetGlobalObject::internal_has_property(JS::PropertyName const& name) const +JS::ThrowCompletionOr SheetGlobalObject::internal_has_property(JS::PropertyKey const& name) const { if (name.is_string()) { if (name.as_string() == "value") @@ -112,7 +112,7 @@ JS::ThrowCompletionOr SheetGlobalObject::internal_has_property(JS::Propert return Object::internal_has_property(name); } -JS::ThrowCompletionOr SheetGlobalObject::internal_get(const JS::PropertyName& property_name, JS::Value receiver) const +JS::ThrowCompletionOr SheetGlobalObject::internal_get(const JS::PropertyKey& property_name, JS::Value receiver) const { if (property_name.is_string()) { if (property_name.as_string() == "value") { @@ -131,7 +131,7 @@ JS::ThrowCompletionOr SheetGlobalObject::internal_get(const JS::Prope return Base::internal_get(property_name, receiver); } -JS::ThrowCompletionOr SheetGlobalObject::internal_set(const JS::PropertyName& property_name, JS::Value value, JS::Value receiver) +JS::ThrowCompletionOr SheetGlobalObject::internal_set(const JS::PropertyKey& property_name, JS::Value value, JS::Value receiver) { if (property_name.is_string()) { if (auto pos = m_sheet.parse_cell_name(property_name.as_string()); pos.has_value()) { diff --git a/Userland/Applications/Spreadsheet/JSIntegration.h b/Userland/Applications/Spreadsheet/JSIntegration.h index 264fb7af01..4519f22f88 100644 --- a/Userland/Applications/Spreadsheet/JSIntegration.h +++ b/Userland/Applications/Spreadsheet/JSIntegration.h @@ -27,9 +27,9 @@ public: virtual ~SheetGlobalObject() override; - virtual JS::ThrowCompletionOr internal_has_property(JS::PropertyName const& name) const override; - virtual JS::ThrowCompletionOr internal_get(JS::PropertyName const&, JS::Value receiver) const override; - virtual JS::ThrowCompletionOr internal_set(JS::PropertyName const&, JS::Value value, JS::Value receiver) override; + virtual JS::ThrowCompletionOr internal_has_property(JS::PropertyKey const& name) const override; + virtual JS::ThrowCompletionOr internal_get(JS::PropertyKey const&, JS::Value receiver) const override; + virtual JS::ThrowCompletionOr internal_set(JS::PropertyKey const&, JS::Value value, JS::Value receiver) override; virtual void initialize_global_object() override; JS_DECLARE_OLD_NATIVE_FUNCTION(get_real_cell_contents); diff --git a/Userland/Applications/Spreadsheet/Spreadsheet.cpp b/Userland/Applications/Spreadsheet/Spreadsheet.cpp index 84900d3b66..539c953d6e 100644 --- a/Userland/Applications/Spreadsheet/Spreadsheet.cpp +++ b/Userland/Applications/Spreadsheet/Spreadsheet.cpp @@ -648,7 +648,7 @@ RefPtr Sheet::from_xsv(const Reader::XSV& xsv, Workbook& workbook) JsonObject Sheet::gather_documentation() const { JsonObject object; - const JS::PropertyName doc_name { "__documentation" }; + const JS::PropertyKey doc_name { "__documentation" }; auto add_docs_from = [&](auto& it, auto& global_object) { auto value = global_object.get(it.key).release_value(); diff --git a/Userland/DevTools/HackStudio/Debugger/DebuggerGlobalJSObject.cpp b/Userland/DevTools/HackStudio/Debugger/DebuggerGlobalJSObject.cpp index 547fdfb9b6..aad5c923bf 100644 --- a/Userland/DevTools/HackStudio/Debugger/DebuggerGlobalJSObject.cpp +++ b/Userland/DevTools/HackStudio/Debugger/DebuggerGlobalJSObject.cpp @@ -22,7 +22,7 @@ DebuggerGlobalJSObject::DebuggerGlobalJSObject() m_variables = lib->debug_info->get_variables_in_current_scope(regs); } -JS::ThrowCompletionOr DebuggerGlobalJSObject::internal_get(JS::PropertyName const& property_name, JS::Value receiver) const +JS::ThrowCompletionOr DebuggerGlobalJSObject::internal_get(JS::PropertyKey const& property_name, JS::Value receiver) const { if (m_variables.is_empty() || !property_name.is_string()) return Base::internal_get(property_name, receiver); @@ -40,7 +40,7 @@ JS::ThrowCompletionOr DebuggerGlobalJSObject::internal_get(JS::Proper return vm().throw_completion(const_cast(*this), move(error_string)); } -JS::ThrowCompletionOr DebuggerGlobalJSObject::internal_set(JS::PropertyName const& property_name, JS::Value value, JS::Value receiver) +JS::ThrowCompletionOr DebuggerGlobalJSObject::internal_set(JS::PropertyKey const& property_name, JS::Value value, JS::Value receiver) { if (m_variables.is_empty() || !property_name.is_string()) return Base::internal_set(property_name, value, receiver); diff --git a/Userland/DevTools/HackStudio/Debugger/DebuggerGlobalJSObject.h b/Userland/DevTools/HackStudio/Debugger/DebuggerGlobalJSObject.h index 389de879ed..cb1560ab28 100644 --- a/Userland/DevTools/HackStudio/Debugger/DebuggerGlobalJSObject.h +++ b/Userland/DevTools/HackStudio/Debugger/DebuggerGlobalJSObject.h @@ -21,8 +21,8 @@ class DebuggerGlobalJSObject final public: DebuggerGlobalJSObject(); - virtual JS::ThrowCompletionOr internal_get(JS::PropertyName const&, JS::Value receiver) const override; - virtual JS::ThrowCompletionOr internal_set(JS::PropertyName const&, JS::Value value, JS::Value receiver) override; + virtual JS::ThrowCompletionOr internal_get(JS::PropertyKey const&, JS::Value receiver) const override; + virtual JS::ThrowCompletionOr internal_set(JS::PropertyKey const&, JS::Value value, JS::Value receiver) override; Optional debugger_to_js(const Debug::DebugInfo::VariableInfo&) const; Optional js_to_debugger(JS::Value value, const Debug::DebugInfo::VariableInfo&) const; diff --git a/Userland/DevTools/HackStudio/Debugger/DebuggerVariableJSObject.cpp b/Userland/DevTools/HackStudio/Debugger/DebuggerVariableJSObject.cpp index be2477e809..5e5e59e902 100644 --- a/Userland/DevTools/HackStudio/Debugger/DebuggerVariableJSObject.cpp +++ b/Userland/DevTools/HackStudio/Debugger/DebuggerVariableJSObject.cpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include namespace HackStudio { @@ -29,7 +29,7 @@ DebuggerVariableJSObject::~DebuggerVariableJSObject() { } -JS::ThrowCompletionOr DebuggerVariableJSObject::internal_set(const JS::PropertyName& property_name, JS::Value value, JS::Value) +JS::ThrowCompletionOr DebuggerVariableJSObject::internal_set(const JS::PropertyKey& property_name, JS::Value value, JS::Value) { auto& vm = this->vm(); diff --git a/Userland/DevTools/HackStudio/Debugger/DebuggerVariableJSObject.h b/Userland/DevTools/HackStudio/Debugger/DebuggerVariableJSObject.h index 84c1ec5bc4..2d88074313 100644 --- a/Userland/DevTools/HackStudio/Debugger/DebuggerVariableJSObject.h +++ b/Userland/DevTools/HackStudio/Debugger/DebuggerVariableJSObject.h @@ -25,7 +25,7 @@ public: virtual const char* class_name() const override { return m_variable_info.type_name.characters(); } - JS::ThrowCompletionOr internal_set(JS::PropertyName const&, JS::Value value, JS::Value receiver) override; + JS::ThrowCompletionOr internal_set(JS::PropertyKey const&, JS::Value value, JS::Value receiver) override; private: DebuggerGlobalJSObject& debugger_object() const; diff --git a/Userland/Libraries/LibJS/AST.cpp b/Userland/Libraries/LibJS/AST.cpp index 913a3c1516..84e7681b1c 100644 --- a/Userland/Libraries/LibJS/AST.cpp +++ b/Userland/Libraries/LibJS/AST.cpp @@ -1084,7 +1084,7 @@ Reference MemberExpression::to_reference(Interpreter& interpreter, GlobalObject& // From here on equivalent to // 13.3.4 EvaluatePropertyAccessWithIdentifierKey ( baseValue, identifierName, strict ), https://tc39.es/ecma262/#sec-evaluate-property-access-with-identifier-key - PropertyName property_name; + PropertyKey property_name; if (is_computed()) { // Weird order which I can't quite find from the specs. auto value = m_property->execute(interpreter, global_object); @@ -1094,7 +1094,7 @@ Reference MemberExpression::to_reference(Interpreter& interpreter, GlobalObject& TRY_OR_DISCARD(require_object_coercible(global_object, base_value)); VERIFY(!value.is_empty()); - property_name = PropertyName::from_value(global_object, value); + property_name = PropertyKey::from_value(global_object, value); if (interpreter.exception()) return Reference {}; } else if (is(*m_property)) { @@ -1191,7 +1191,7 @@ static ThrowCompletionOr class_key_to_property_n if (prop_key.is_object()) prop_key = TRY(prop_key.to_primitive(global_object, Value::PreferredType::String)); - auto property_key = PropertyName::from_value(global_object, prop_key); + auto property_key = PropertyKey::from_value(global_object, prop_key); if (auto* exception = interpreter.exception()) return throw_completion(exception->value()); return ClassElement::ClassElementName { property_key }; @@ -1211,7 +1211,7 @@ ThrowCompletionOr ClassMethod::class_element_evaluatio auto set_function_name = [&](String prefix = "") { auto property_name = property_key.visit( - [&](PropertyName const& property_name) -> String { + [&](PropertyKey const& property_name) -> String { if (property_name.is_symbol()) { auto description = property_name.as_symbol()->description(); if (description.is_empty()) @@ -1228,8 +1228,8 @@ ThrowCompletionOr ClassMethod::class_element_evaluatio update_function_name(method_value, String::formatted("{}{}{}", prefix, prefix.is_empty() ? "" : " ", property_name)); }; - if (property_key.has()) { - auto& property_name = property_key.get(); + if (property_key.has()) { + auto& property_name = property_key.get(); switch (kind()) { case ClassMethod::Kind::Method: set_function_name(); @@ -1303,7 +1303,7 @@ ThrowCompletionOr ClassField::class_element_evaluation if (m_initializer) { auto copy_initializer = m_initializer; auto name = property_key.visit( - [&](PropertyName const& property_name) -> String { + [&](PropertyKey const& property_name) -> String { return property_name.is_number() ? property_name.to_string() : property_name.to_string_or_symbol().to_display_string(); }, [&](PrivateName const& private_name) -> String { @@ -2600,14 +2600,14 @@ Value ObjectExpression::execute(Interpreter& interpreter, GlobalObject& global_o switch (property.type()) { case ObjectProperty::Type::Getter: VERIFY(value.is_function()); - object->define_direct_accessor(PropertyName::from_value(global_object, key), &value.as_function(), nullptr, Attribute::Configurable | Attribute::Enumerable); + object->define_direct_accessor(PropertyKey::from_value(global_object, key), &value.as_function(), nullptr, Attribute::Configurable | Attribute::Enumerable); break; case ObjectProperty::Type::Setter: VERIFY(value.is_function()); - object->define_direct_accessor(PropertyName::from_value(global_object, key), nullptr, &value.as_function(), Attribute::Configurable | Attribute::Enumerable); + object->define_direct_accessor(PropertyKey::from_value(global_object, key), nullptr, &value.as_function(), Attribute::Configurable | Attribute::Enumerable); break; case ObjectProperty::Type::KeyValue: - object->define_direct_property(PropertyName::from_value(global_object, key), value, JS::default_attributes); + object->define_direct_property(PropertyKey::from_value(global_object, key), value, JS::default_attributes); break; case ObjectProperty::Type::Spread: default: @@ -2627,7 +2627,7 @@ void MemberExpression::dump(int indent) const m_property->dump(indent + 1); } -PropertyName MemberExpression::computed_property_name(Interpreter& interpreter, GlobalObject& global_object) const +PropertyKey MemberExpression::computed_property_name(Interpreter& interpreter, GlobalObject& global_object) const { if (!is_computed()) return verify_cast(*m_property).string(); @@ -2636,7 +2636,7 @@ PropertyName MemberExpression::computed_property_name(Interpreter& interpreter, if (interpreter.exception()) return {}; VERIFY(!value.is_empty()); - return PropertyName::from_value(global_object, value); + return PropertyKey::from_value(global_object, value); } String MemberExpression::to_string_approximation() const diff --git a/Userland/Libraries/LibJS/AST.h b/Userland/Libraries/LibJS/AST.h index 47ba73e5c5..b8e7036385 100644 --- a/Userland/Libraries/LibJS/AST.h +++ b/Userland/Libraries/LibJS/AST.h @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include #include @@ -1036,7 +1036,7 @@ public: virtual ElementKind class_element_kind() const = 0; bool is_static() const { return m_is_static; } - using ClassElementName = Variant; + using ClassElementName = Variant; struct ClassFieldDefinition { ClassElementName name; @@ -1558,7 +1558,7 @@ public: Expression const& object() const { return *m_object; } Expression const& property() const { return *m_property; } - PropertyName computed_property_name(Interpreter&, GlobalObject&) const; + PropertyKey computed_property_name(Interpreter&, GlobalObject&) const; String to_string_approximation() const; diff --git a/Userland/Libraries/LibJS/Bytecode/Op.cpp b/Userland/Libraries/LibJS/Bytecode/Op.cpp index 8dff0a17bc..49855b1f38 100644 --- a/Userland/Libraries/LibJS/Bytecode/Op.cpp +++ b/Userland/Libraries/LibJS/Bytecode/Op.cpp @@ -216,7 +216,7 @@ void CopyObjectExcludingProperties::execute_impl(Bytecode::Interpreter& interpre auto property_name_or_error = key.to_property_key(interpreter.global_object()); if (property_name_or_error.is_error()) return; - PropertyName property_name = property_name_or_error.release_value(); + PropertyKey property_name = property_name_or_error.release_value(); auto property_value_or_error = from_object->get(property_name); if (property_value_or_error.is_error()) return; diff --git a/Userland/Libraries/LibJS/Forward.h b/Userland/Libraries/LibJS/Forward.h index a10569b2d5..3e49f8dcf8 100644 --- a/Userland/Libraries/LibJS/Forward.h +++ b/Userland/Libraries/LibJS/Forward.h @@ -163,7 +163,7 @@ class PromiseReactionJob; class PromiseResolveThenableJob; class PropertyAttributes; class PropertyDescriptor; -class PropertyName; +class PropertyKey; class Realm; class Reference; class ScopeNode; diff --git a/Userland/Libraries/LibJS/Parser.cpp b/Userland/Libraries/LibJS/Parser.cpp index 0bfdefb1ed..f2f275dd44 100644 --- a/Userland/Libraries/LibJS/Parser.cpp +++ b/Userland/Libraries/LibJS/Parser.cpp @@ -1384,7 +1384,7 @@ NonnullRefPtr Parser::parse_object_expression() // It is a Syntax Error if PropertyNameList of PropertyDefinitionList contains any duplicate // entries for "__proto__" and at least two of those entries were obtained from productions of - // the form PropertyDefinition : PropertyName : AssignmentExpression . + // the form PropertyDefinition : PropertyKey : AssignmentExpression . bool has_direct_proto_property = false; while (!done() && !match(TokenType::CurlyClose)) { diff --git a/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp b/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp index 6b6dc82baa..d3f95a1e92 100644 --- a/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp +++ b/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include @@ -106,7 +106,7 @@ ThrowCompletionOr create_list_from_array_like(GlobalObject& glo // 6. Repeat, while index < len, for (size_t i = 0; i < length; ++i) { // a. Let indexName be ! ToString(𝔽(index)). - auto index_name = PropertyName { i }; + auto index_name = PropertyKey { i }; // b. Let next be ? Get(obj, indexName). auto next = TRY(array_like.get(index_name)); @@ -206,7 +206,7 @@ bool is_compatible_property_descriptor(bool extensible, PropertyDescriptor const } // 10.1.6.3 ValidateAndApplyPropertyDescriptor ( O, P, extensible, Desc, current ), https://tc39.es/ecma262/#sec-validateandapplypropertydescriptor -bool validate_and_apply_property_descriptor(Object* object, PropertyName const& property_name, bool extensible, PropertyDescriptor const& descriptor, Optional const& current) +bool validate_and_apply_property_descriptor(Object* object, PropertyKey const& property_name, bool extensible, PropertyDescriptor const& descriptor, Optional const& current) { // 1. Assert: If O is not undefined, then IsPropertyKey(P) is true. if (object) @@ -835,7 +835,7 @@ Object* create_mapped_arguments_object(GlobalObject& global_object, FunctionObje // 2. Let p be MakeArgSetter(name, env). // 3. Perform map.[[DefineOwnProperty]](! ToString(𝔽(index)), PropertyDescriptor { [[Set]]: p, [[Get]]: g, [[Enumerable]]: false, [[Configurable]]: true }). object->parameter_map().define_old_native_accessor( - PropertyName { index }, + PropertyKey { index }, [&environment, name](VM&, GlobalObject& global_object_getter) -> Value { return MUST(environment.get_binding_value(global_object_getter, name, false)); }, @@ -859,7 +859,7 @@ Object* create_mapped_arguments_object(GlobalObject& global_object, FunctionObje } // 7.1.21 CanonicalNumericIndexString ( argument ), https://tc39.es/ecma262/#sec-canonicalnumericindexstring -Value canonical_numeric_index_string(GlobalObject& global_object, PropertyName const& property_name) +Value canonical_numeric_index_string(GlobalObject& global_object, PropertyKey const& property_name) { // NOTE: If the property name is a number type (An implementation-defined optimized // property key type), it can be treated as a string property that has already been diff --git a/Userland/Libraries/LibJS/Runtime/AbstractOperations.h b/Userland/Libraries/LibJS/Runtime/AbstractOperations.h index bb3f7ead8f..e84cedddf7 100644 --- a/Userland/Libraries/LibJS/Runtime/AbstractOperations.h +++ b/Userland/Libraries/LibJS/Runtime/AbstractOperations.h @@ -30,11 +30,11 @@ ThrowCompletionOr create_list_from_array_like(GlobalObject&, Va ThrowCompletionOr species_constructor(GlobalObject&, Object const&, FunctionObject& default_constructor); ThrowCompletionOr get_function_realm(GlobalObject&, FunctionObject const&); bool is_compatible_property_descriptor(bool extensible, PropertyDescriptor const&, Optional const& current); -bool validate_and_apply_property_descriptor(Object*, PropertyName const&, bool extensible, PropertyDescriptor const&, Optional const& current); +bool validate_and_apply_property_descriptor(Object*, PropertyKey const&, bool extensible, PropertyDescriptor const&, Optional const& current); ThrowCompletionOr get_prototype_from_constructor(GlobalObject&, FunctionObject const& constructor, Object* (GlobalObject::*intrinsic_default_prototype)()); Object* create_unmapped_arguments_object(GlobalObject&, Span arguments); Object* create_mapped_arguments_object(GlobalObject&, FunctionObject&, Vector const&, Span arguments, Environment&); -Value canonical_numeric_index_string(GlobalObject&, PropertyName const&); +Value canonical_numeric_index_string(GlobalObject&, PropertyKey const&); ThrowCompletionOr get_substitution(GlobalObject&, Utf16View const& matched, Utf16View const& str, size_t position, Span captures, Value named_captures, Value replacement); enum class CallerMode { diff --git a/Userland/Libraries/LibJS/Runtime/ArgumentsObject.cpp b/Userland/Libraries/LibJS/Runtime/ArgumentsObject.cpp index 66509f627c..44fb59da2d 100644 --- a/Userland/Libraries/LibJS/Runtime/ArgumentsObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArgumentsObject.cpp @@ -35,7 +35,7 @@ void ArgumentsObject::visit_edges(Cell::Visitor& visitor) } // 10.4.4.3 [[Get]] ( P, Receiver ), https://tc39.es/ecma262/#sec-arguments-exotic-objects-get-p-receiver -ThrowCompletionOr ArgumentsObject::internal_get(PropertyName const& property_name, Value receiver) const +ThrowCompletionOr ArgumentsObject::internal_get(PropertyKey const& property_name, Value receiver) const { // 1. Let map be args.[[ParameterMap]]. auto& map = *m_parameter_map; @@ -56,7 +56,7 @@ ThrowCompletionOr ArgumentsObject::internal_get(PropertyName const& prope } // 10.4.4.4 [[Set]] ( P, V, Receiver ), https://tc39.es/ecma262/#sec-arguments-exotic-objects-set-p-v-receiver -ThrowCompletionOr ArgumentsObject::internal_set(PropertyName const& property_name, Value value, Value receiver) +ThrowCompletionOr ArgumentsObject::internal_set(PropertyKey const& property_name, Value value, Value receiver) { bool is_mapped = false; @@ -84,7 +84,7 @@ ThrowCompletionOr ArgumentsObject::internal_set(PropertyName const& proper } // 10.4.4.5 [[Delete]] ( P ), https://tc39.es/ecma262/#sec-arguments-exotic-objects-delete-p -ThrowCompletionOr ArgumentsObject::internal_delete(PropertyName const& property_name) +ThrowCompletionOr ArgumentsObject::internal_delete(PropertyKey const& property_name) { // 1. Let map be args.[[ParameterMap]]. auto& map = parameter_map(); @@ -106,7 +106,7 @@ ThrowCompletionOr ArgumentsObject::internal_delete(PropertyName const& pro } // 10.4.4.1 [[GetOwnProperty]] ( P ), https://tc39.es/ecma262/#sec-arguments-exotic-objects-getownproperty-p -ThrowCompletionOr> ArgumentsObject::internal_get_own_property(PropertyName const& property_name) const +ThrowCompletionOr> ArgumentsObject::internal_get_own_property(PropertyKey const& property_name) const { // 1. Let desc be OrdinaryGetOwnProperty(args, P). auto desc = MUST(Object::internal_get_own_property(property_name)); @@ -130,7 +130,7 @@ ThrowCompletionOr> ArgumentsObject::internal_get_ow } // 10.4.4.2 [[DefineOwnProperty]] ( P, Desc ), https://tc39.es/ecma262/#sec-arguments-exotic-objects-defineownproperty-p-desc -ThrowCompletionOr ArgumentsObject::internal_define_own_property(PropertyName const& property_name, PropertyDescriptor const& descriptor) +ThrowCompletionOr ArgumentsObject::internal_define_own_property(PropertyKey const& property_name, PropertyDescriptor const& descriptor) { // 1. Let map be args.[[ParameterMap]]. auto& map = parameter_map(); diff --git a/Userland/Libraries/LibJS/Runtime/ArgumentsObject.h b/Userland/Libraries/LibJS/Runtime/ArgumentsObject.h index 8fec73ecfe..6d0e9d2351 100644 --- a/Userland/Libraries/LibJS/Runtime/ArgumentsObject.h +++ b/Userland/Libraries/LibJS/Runtime/ArgumentsObject.h @@ -23,11 +23,11 @@ public: Environment& environment() { return m_environment; } - virtual ThrowCompletionOr> internal_get_own_property(PropertyName const&) const override; - virtual ThrowCompletionOr internal_define_own_property(PropertyName const&, PropertyDescriptor const&) override; - virtual ThrowCompletionOr internal_get(PropertyName const&, Value receiver) const override; - virtual ThrowCompletionOr internal_set(PropertyName const&, Value value, Value receiver) override; - virtual ThrowCompletionOr internal_delete(PropertyName const&) override; + virtual ThrowCompletionOr> internal_get_own_property(PropertyKey const&) const override; + virtual ThrowCompletionOr internal_define_own_property(PropertyKey const&, PropertyDescriptor const&) override; + virtual ThrowCompletionOr internal_get(PropertyKey const&, Value receiver) const override; + virtual ThrowCompletionOr internal_set(PropertyKey const&, Value value, Value receiver) override; + virtual ThrowCompletionOr internal_delete(PropertyKey const&) override; // [[ParameterMap]] Object& parameter_map() { return *m_parameter_map; } diff --git a/Userland/Libraries/LibJS/Runtime/Array.cpp b/Userland/Libraries/LibJS/Runtime/Array.cpp index be5aa049ca..8c52d9856c 100644 --- a/Userland/Libraries/LibJS/Runtime/Array.cpp +++ b/Userland/Libraries/LibJS/Runtime/Array.cpp @@ -151,7 +151,7 @@ ThrowCompletionOr Array::set_length(PropertyDescriptor const& property_des } // NON-STANDARD: Used to return the value of the ephemeral length property -ThrowCompletionOr> Array::internal_get_own_property(PropertyName const& property_name) const +ThrowCompletionOr> Array::internal_get_own_property(PropertyKey const& property_name) const { auto& vm = this->vm(); if (property_name.is_string() && property_name.as_string() == vm.names.length.as_string()) @@ -161,7 +161,7 @@ ThrowCompletionOr> Array::internal_get_own_property } // 10.4.2.1 [[DefineOwnProperty]] ( P, Desc ), https://tc39.es/ecma262/#sec-array-exotic-objects-defineownproperty-p-desc -ThrowCompletionOr Array::internal_define_own_property(PropertyName const& property_name, PropertyDescriptor const& property_descriptor) +ThrowCompletionOr Array::internal_define_own_property(PropertyKey const& property_name, PropertyDescriptor const& property_descriptor) { auto& vm = this->vm(); @@ -208,7 +208,7 @@ ThrowCompletionOr Array::internal_define_own_property(PropertyName const& } // NON-STANDARD: Used to reject deletes to ephemeral (non-configurable) length property -ThrowCompletionOr Array::internal_delete(PropertyName const& property_name) +ThrowCompletionOr Array::internal_delete(PropertyKey const& property_name) { auto& vm = this->vm(); if (property_name.is_string() && property_name.as_string() == vm.names.length.as_string()) diff --git a/Userland/Libraries/LibJS/Runtime/Array.h b/Userland/Libraries/LibJS/Runtime/Array.h index b1e394f571..d06d607079 100644 --- a/Userland/Libraries/LibJS/Runtime/Array.h +++ b/Userland/Libraries/LibJS/Runtime/Array.h @@ -38,9 +38,9 @@ public: explicit Array(Object& prototype); virtual ~Array() override; - virtual ThrowCompletionOr> internal_get_own_property(PropertyName const&) const override; - virtual ThrowCompletionOr internal_define_own_property(PropertyName const&, PropertyDescriptor const&) override; - virtual ThrowCompletionOr internal_delete(PropertyName const&) override; + virtual ThrowCompletionOr> internal_get_own_property(PropertyKey const&) const override; + virtual ThrowCompletionOr internal_define_own_property(PropertyKey const&, PropertyDescriptor const&) override; + virtual ThrowCompletionOr internal_delete(PropertyKey const&) override; virtual ThrowCompletionOr internal_own_property_keys() const override; [[nodiscard]] bool length_is_writable() const { return m_length_writable; }; diff --git a/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp index 9d5cfbe02c..81598d904e 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp @@ -169,7 +169,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::filter) // 7. Repeat, while k < len, for (; k < length; ++k) { // a. Let Pk be ! ToString(𝔽(k)). - auto property_name = PropertyName { k }; + auto property_name = PropertyKey { k }; // b. Let kPresent be ? HasProperty(O, Pk). auto k_present = TRY(object->has_property(property_name)); @@ -219,7 +219,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::for_each) // 5. Repeat, while k < len, for (size_t k = 0; k < length; ++k) { // a. Let Pk be ! ToString(𝔽(k)). - auto property_name = PropertyName { k }; + auto property_name = PropertyKey { k }; // b. Let kPresent be ? HasProperty(O, Pk). auto k_present = TRY(object->has_property(property_name)); @@ -263,7 +263,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::map) // 6. Repeat, while k < len, for (size_t k = 0; k < length; ++k) { // a. Let Pk be ! ToString(𝔽(k)). - auto property_name = PropertyName { k }; + auto property_name = PropertyKey { k }; // b. Let kPresent be ? HasProperty(O, Pk). auto k_present = TRY(object->has_property(property_name)); @@ -611,7 +611,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::index_of) // 10. Repeat, while k < len, for (; k < length; ++k) { - auto property_name = PropertyName { k }; + auto property_name = PropertyKey { k }; // a. Let kPresent be ? HasProperty(O, ! ToString(𝔽(k))). auto k_present = TRY(object->has_property(property_name)); @@ -675,7 +675,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::reduce) // b. Repeat, while kPresent is false and k < len, for (; !k_present && k < length; ++k) { // i. Let Pk be ! ToString(𝔽(k)). - auto property_name = PropertyName { k }; + auto property_name = PropertyKey { k }; // ii. Set kPresent to ? HasProperty(O, Pk). k_present = TRY(object->has_property(property_name)); @@ -697,7 +697,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::reduce) // 9. Repeat, while k < len, for (; k < length; ++k) { // a. Let Pk be ! ToString(𝔽(k)). - auto property_name = PropertyName { k }; + auto property_name = PropertyKey { k }; // b. Let kPresent be ? HasProperty(O, Pk). auto k_present = TRY(object->has_property(property_name)); @@ -757,7 +757,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::reduce_right) // b. Repeat, while kPresent is false and k ≥ 0, for (; !k_present && k >= 0; --k) { // i. Let Pk be ! ToString(𝔽(k)). - auto property_name = PropertyName { k }; + auto property_name = PropertyKey { k }; // ii. Set kPresent to ? HasProperty(O, Pk). k_present = TRY(object->has_property(property_name)); @@ -779,7 +779,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::reduce_right) // 9. Repeat, while k ≥ 0, for (; k >= 0; --k) { // a. Let Pk be ! ToString(𝔽(k)). - auto property_name = PropertyName { k }; + auto property_name = PropertyKey { k }; // b. Let kPresent be ? HasProperty(O, Pk). auto k_present = TRY(object->has_property(property_name)); @@ -1015,7 +1015,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::last_index_of) // 8. Repeat, while k ≥ 0, for (; k >= 0; --k) { - auto property_name = PropertyName { k }; + auto property_name = PropertyKey { k }; // a. Let kPresent be ? HasProperty(O, ! ToString(𝔽(k))). auto k_present = TRY(object->has_property(property_name)); @@ -1091,7 +1091,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::find) // 5. Repeat, while k < len, for (size_t k = 0; k < length; ++k) { // a. Let Pk be ! ToString(𝔽(k)). - auto property_name = PropertyName { k }; + auto property_name = PropertyKey { k }; // b. Let kValue be ? Get(O, Pk). auto k_value = TRY(object->get(property_name)); @@ -1130,7 +1130,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::find_index) // 5. Repeat, while k < len, for (size_t k = 0; k < length; ++k) { // a. Let Pk be ! ToString(𝔽(k)). - auto property_name = PropertyName { k }; + auto property_name = PropertyKey { k }; // b. Let kValue be ? Get(O, Pk). auto k_value = TRY(object->get(property_name)); @@ -1169,7 +1169,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::find_last) // 5. Repeat, while k ≥ 0, for (i64 k = static_cast(length) - 1; k >= 0; --k) { // a. Let Pk be ! ToString(𝔽(k)). - auto property_name = PropertyName { k }; + auto property_name = PropertyKey { k }; // b. Let kValue be ? Get(O, Pk). auto k_value = TRY(object->get(property_name)); @@ -1208,7 +1208,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::find_last_index) // 5. Repeat, while k ≥ 0, for (i64 k = static_cast(length) - 1; k >= 0; --k) { // a. Let Pk be ! ToString(𝔽(k)). - auto property_name = PropertyName { k }; + auto property_name = PropertyKey { k }; // b. Let kValue be ? Get(O, Pk). auto k_value = TRY(object->get(property_name)); @@ -1247,7 +1247,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::some) // 5. Repeat, while k < len, for (size_t k = 0; k < length; ++k) { // a. Let Pk be ! ToString(𝔽(k)). - auto property_name = PropertyName { k }; + auto property_name = PropertyKey { k }; // b. Let kPresent be ? HasProperty(O, Pk). auto k_present = TRY(object->has_property(property_name)); @@ -1292,7 +1292,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::every) // 5. Repeat, while k < len, for (size_t k = 0; k < length; ++k) { // a. Let Pk be ! ToString(𝔽(k)). - auto property_name = PropertyName { k }; + auto property_name = PropertyKey { k }; // b. Let kPresent be ? HasProperty(O, Pk). auto k_present = TRY(object->has_property(property_name)); diff --git a/Userland/Libraries/LibJS/Runtime/CommonPropertyNames.h b/Userland/Libraries/LibJS/Runtime/CommonPropertyNames.h index cd57be17e1..069c356071 100644 --- a/Userland/Libraries/LibJS/Runtime/CommonPropertyNames.h +++ b/Userland/Libraries/LibJS/Runtime/CommonPropertyNames.h @@ -8,7 +8,7 @@ #include #include -#include +#include namespace JS { @@ -487,28 +487,28 @@ namespace JS { P(zonedDateTimeISO) struct CommonPropertyNames { - PropertyName and_ { "and", PropertyName::StringMayBeNumber::No }; - PropertyName catch_ { "catch", PropertyName::StringMayBeNumber::No }; - PropertyName delete_ { "delete", PropertyName::StringMayBeNumber::No }; - PropertyName for_ { "for", PropertyName::StringMayBeNumber::No }; - PropertyName or_ { "or", PropertyName::StringMayBeNumber::No }; - PropertyName register_ { "register", PropertyName::StringMayBeNumber::No }; - PropertyName return_ { "return", PropertyName::StringMayBeNumber::No }; - PropertyName throw_ { "throw", PropertyName::StringMayBeNumber::No }; - PropertyName xor_ { "xor", PropertyName::StringMayBeNumber::No }; -#define __ENUMERATE(x) PropertyName x { #x, PropertyName::StringMayBeNumber::No }; + PropertyKey and_ { "and", PropertyKey::StringMayBeNumber::No }; + PropertyKey catch_ { "catch", PropertyKey::StringMayBeNumber::No }; + PropertyKey delete_ { "delete", PropertyKey::StringMayBeNumber::No }; + PropertyKey for_ { "for", PropertyKey::StringMayBeNumber::No }; + PropertyKey or_ { "or", PropertyKey::StringMayBeNumber::No }; + PropertyKey register_ { "register", PropertyKey::StringMayBeNumber::No }; + PropertyKey return_ { "return", PropertyKey::StringMayBeNumber::No }; + PropertyKey throw_ { "throw", PropertyKey::StringMayBeNumber::No }; + PropertyKey xor_ { "xor", PropertyKey::StringMayBeNumber::No }; +#define __ENUMERATE(x) PropertyKey x { #x, PropertyKey::StringMayBeNumber::No }; ENUMERATE_STANDARD_PROPERTY_NAMES(__ENUMERATE) #undef __ENUMERATE -#define __JS_ENUMERATE(x, a, b, c, t) PropertyName x { #x, PropertyName::StringMayBeNumber::No }; +#define __JS_ENUMERATE(x, a, b, c, t) PropertyKey x { #x, PropertyKey::StringMayBeNumber::No }; JS_ENUMERATE_BUILTIN_TYPES #undef __JS_ENUMERATE -#define __JS_ENUMERATE(x, a, b, c) PropertyName x { #x, PropertyName::StringMayBeNumber::No }; +#define __JS_ENUMERATE(x, a, b, c) PropertyKey x { #x, PropertyKey::StringMayBeNumber::No }; JS_ENUMERATE_INTL_OBJECTS #undef __JS_ENUMERATE -#define __JS_ENUMERATE(x, a, b, c) PropertyName x { #x, PropertyName::StringMayBeNumber::No }; +#define __JS_ENUMERATE(x, a, b, c) PropertyKey x { #x, PropertyKey::StringMayBeNumber::No }; JS_ENUMERATE_TEMPORAL_OBJECTS #undef __JS_ENUMERATE -#define __JS_ENUMERATE(x, a) PropertyName x { #x, PropertyName::StringMayBeNumber::No }; +#define __JS_ENUMERATE(x, a) PropertyKey x { #x, PropertyKey::StringMayBeNumber::No }; JS_ENUMERATE_WELL_KNOWN_SYMBOLS #undef __JS_ENUMERATE }; diff --git a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp index accd057046..648e25254e 100644 --- a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp @@ -276,7 +276,7 @@ void ECMAScriptFunctionObject::visit_edges(Visitor& visitor) visitor.visit(m_home_object); for (auto& field : m_fields) { - if (auto* property_name_ptr = field.name.get_pointer(); property_name_ptr && property_name_ptr->is_symbol()) + if (auto* property_name_ptr = field.name.get_pointer(); property_name_ptr && property_name_ptr->is_symbol()) visitor.visit(property_name_ptr->as_symbol()); visitor.visit(field.initializer); diff --git a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.h b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.h index ac313c205e..dfe121f844 100644 --- a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.h +++ b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.h @@ -59,12 +59,12 @@ public: void set_home_object(Object* home_object) { m_home_object = home_object; } struct InstanceField { - Variant name; + Variant name; ECMAScriptFunctionObject* initializer { nullptr }; }; Vector const& fields() const { return m_fields; } - void add_field(Variant property_key, ECMAScriptFunctionObject* initializer); + void add_field(Variant property_key, ECMAScriptFunctionObject* initializer); Vector const& private_methods() const { return m_private_methods; } void add_private_method(PrivateElement method) { m_private_methods.append(move(method)); }; diff --git a/Userland/Libraries/LibJS/Runtime/GlobalObject.h b/Userland/Libraries/LibJS/Runtime/GlobalObject.h index e39bbe538c..eb6d2b3bad 100644 --- a/Userland/Libraries/LibJS/Runtime/GlobalObject.h +++ b/Userland/Libraries/LibJS/Runtime/GlobalObject.h @@ -69,9 +69,9 @@ protected: virtual void visit_edges(Visitor&) override; template - void initialize_constructor(PropertyName const&, ConstructorType*&, Object* prototype); + void initialize_constructor(PropertyKey const&, ConstructorType*&, Object* prototype); template - void add_constructor(PropertyName const&, ConstructorType*&, Object* prototype); + void add_constructor(PropertyKey const&, ConstructorType*&, Object* prototype); private: virtual bool is_global_object() const final { return true; } @@ -133,7 +133,7 @@ private: }; template -inline void GlobalObject::initialize_constructor(PropertyName const& property_name, ConstructorType*& constructor, Object* prototype) +inline void GlobalObject::initialize_constructor(PropertyKey const& property_name, ConstructorType*& constructor, Object* prototype) { auto& vm = this->vm(); constructor = heap().allocate(*this, *this); @@ -148,7 +148,7 @@ inline void GlobalObject::initialize_constructor(PropertyName const& property_na } template -inline void GlobalObject::add_constructor(PropertyName const& property_name, ConstructorType*& constructor, Object* prototype) +inline void GlobalObject::add_constructor(PropertyKey const& property_name, ConstructorType*& constructor, Object* prototype) { // Some constructors are pre-initialized separately. if (!constructor) @@ -165,7 +165,7 @@ template<> inline bool Object::fast_is() const { return is_global_object(); } template -[[nodiscard]] ALWAYS_INLINE ThrowCompletionOr Value::invoke(GlobalObject& global_object, PropertyName const& property_name, Args... args) +[[nodiscard]] ALWAYS_INLINE ThrowCompletionOr Value::invoke(GlobalObject& global_object, PropertyKey const& property_name, Args... args) { if constexpr (sizeof...(Args) > 0) { MarkedValueList arglist { global_object.vm().heap() }; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.cpp b/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.cpp index b1eb98f082..5e14a77690 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.cpp @@ -219,7 +219,7 @@ ThrowCompletionOr> canonicalize_locale_list(GlobalObject& global_ // 7. Repeat, while k < len, for (size_t k = 0; k < length; ++k) { // a. Let Pk be ToString(k). - auto property_key = PropertyName { k }; + auto property_key = PropertyKey { k }; // b. Let kPresent be ? HasProperty(O, Pk). auto key_present = TRY(object->has_property(property_key)); @@ -597,7 +597,7 @@ ThrowCompletionOr coerce_options_to_object(GlobalObject& global_object, } // 9.2.13 GetOption ( options, property, type, values, fallback ), https://tc39.es/ecma402/#sec-getoption -ThrowCompletionOr get_option(GlobalObject& global_object, Object const& options, PropertyName const& property, Value::Type type, Vector const& values, Fallback fallback) +ThrowCompletionOr get_option(GlobalObject& global_object, Object const& options, PropertyKey const& property, Value::Type type, Vector const& values, Fallback fallback) { auto& vm = global_object.vm(); @@ -661,7 +661,7 @@ ThrowCompletionOr> default_number_option(GlobalObject& global_obje } // 9.2.15 GetNumberOption ( options, property, minimum, maximum, fallback ), https://tc39.es/ecma402/#sec-getnumberoption -ThrowCompletionOr> get_number_option(GlobalObject& global_object, Object const& options, PropertyName const& property, int minimum, int maximum, Optional fallback) +ThrowCompletionOr> get_number_option(GlobalObject& global_object, Object const& options, PropertyKey const& property, int minimum, int maximum, Optional fallback) { // 1. Assert: Type(options) is Object. diff --git a/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.h b/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.h index f69977c183..16e5391053 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.h @@ -46,9 +46,9 @@ Vector lookup_supported_locales(Vector const& requested_locales) Vector best_fit_supported_locales(Vector const& requested_locales); ThrowCompletionOr supported_locales(GlobalObject&, Vector const& requested_locales, Value options); ThrowCompletionOr coerce_options_to_object(GlobalObject& global_object, Value options); -ThrowCompletionOr get_option(GlobalObject& global_object, Object const& options, PropertyName const& property, Value::Type type, Vector const& values, Fallback fallback); +ThrowCompletionOr get_option(GlobalObject& global_object, Object const& options, PropertyKey const& property, Value::Type type, Vector const& values, Fallback fallback); ThrowCompletionOr> default_number_option(GlobalObject& global_object, Value value, int minimum, int maximum, Optional fallback); -ThrowCompletionOr> get_number_option(GlobalObject& global_object, Object const& options, PropertyName const& property, int minimum, int maximum, Optional fallback); +ThrowCompletionOr> get_number_option(GlobalObject& global_object, Object const& options, PropertyKey const& property, int minimum, int maximum, Optional fallback); Vector partition_pattern(StringView pattern); } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp index e12b0ee80f..25cd2946d4 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp @@ -26,7 +26,7 @@ struct LocaleAndKeys { }; // Note: This is not an AO in the spec. This just serves to abstract very similar steps in ApplyOptionsToTag and the Intl.Locale constructor. -static ThrowCompletionOr> get_string_option(GlobalObject& global_object, Object const& options, PropertyName const& property, Function validator, Vector const& values = {}) +static ThrowCompletionOr> get_string_option(GlobalObject& global_object, Object const& options, PropertyKey const& property, Function validator, Vector const& values = {}) { auto& vm = global_object.vm(); diff --git a/Userland/Libraries/LibJS/Runtime/JSONObject.cpp b/Userland/Libraries/LibJS/Runtime/JSONObject.cpp index 4993d382eb..cc990fd28b 100644 --- a/Userland/Libraries/LibJS/Runtime/JSONObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/JSONObject.cpp @@ -129,7 +129,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(JSONObject::stringify) } // 25.5.2.1 SerializeJSONProperty ( state, key, holder ), https://tc39.es/ecma262/#sec-serializejsonproperty -String JSONObject::serialize_json_property(GlobalObject& global_object, StringifyState& state, const PropertyName& key, Object* holder) +String JSONObject::serialize_json_property(GlobalObject& global_object, StringifyState& state, const PropertyKey& key, Object* holder) { auto& vm = global_object.vm(); auto value = TRY_OR_DISCARD(holder->get(key)); @@ -200,7 +200,7 @@ String JSONObject::serialize_json_object(GlobalObject& global_object, StringifyS state.indent = String::formatted("{}{}", state.indent, state.gap); Vector property_strings; - auto process_property = [&](const PropertyName& key) { + auto process_property = [&](const PropertyKey& key) { if (key.is_symbol()) return; auto serialized_property_string = serialize_json_property(global_object, state, key, &object); @@ -437,7 +437,7 @@ Array* JSONObject::parse_json_array(GlobalObject& global_object, const JsonArray } // 25.5.1.1 InternalizeJSONProperty ( holder, name, reviver ), https://tc39.es/ecma262/#sec-internalizejsonproperty -Value JSONObject::internalize_json_property(GlobalObject& global_object, Object* holder, PropertyName const& name, FunctionObject& reviver) +Value JSONObject::internalize_json_property(GlobalObject& global_object, Object* holder, PropertyKey const& name, FunctionObject& reviver) { auto& vm = global_object.vm(); auto value = TRY_OR_DISCARD(holder->get(name)); @@ -445,7 +445,7 @@ Value JSONObject::internalize_json_property(GlobalObject& global_object, Object* auto is_array = TRY_OR_DISCARD(value.is_array(global_object)); auto& value_object = value.as_object(); - auto process_property = [&](const PropertyName& key) -> ThrowCompletionOr { + auto process_property = [&](const PropertyKey& key) -> ThrowCompletionOr { auto element = internalize_json_property(global_object, &value_object, key, reviver); if (auto* exception = vm.exception()) return throw_completion(exception->value()); diff --git a/Userland/Libraries/LibJS/Runtime/JSONObject.h b/Userland/Libraries/LibJS/Runtime/JSONObject.h index 6d717b22be..10ac77a2e2 100644 --- a/Userland/Libraries/LibJS/Runtime/JSONObject.h +++ b/Userland/Libraries/LibJS/Runtime/JSONObject.h @@ -34,7 +34,7 @@ private: }; // Stringify helpers - static String serialize_json_property(GlobalObject&, StringifyState&, const PropertyName& key, Object* holder); + static String serialize_json_property(GlobalObject&, StringifyState&, const PropertyKey& key, Object* holder); static String serialize_json_object(GlobalObject&, StringifyState&, Object&); static String serialize_json_array(GlobalObject&, StringifyState&, Object&); static String quote_json_string(String); @@ -42,7 +42,7 @@ private: // Parse helpers static Object* parse_json_object(GlobalObject&, const JsonObject&); static Array* parse_json_array(GlobalObject&, const JsonArray&); - static Value internalize_json_property(GlobalObject&, Object* holder, PropertyName const& name, FunctionObject& reviver); + static Value internalize_json_property(GlobalObject&, Object* holder, PropertyKey const& name, FunctionObject& reviver); JS_DECLARE_OLD_NATIVE_FUNCTION(stringify); JS_DECLARE_OLD_NATIVE_FUNCTION(parse); diff --git a/Userland/Libraries/LibJS/Runtime/Object.cpp b/Userland/Libraries/LibJS/Runtime/Object.cpp index 600dfb5365..94d93da5aa 100644 --- a/Userland/Libraries/LibJS/Runtime/Object.cpp +++ b/Userland/Libraries/LibJS/Runtime/Object.cpp @@ -77,7 +77,7 @@ ThrowCompletionOr Object::is_extensible() const // 7.3 Operations on Objects, https://tc39.es/ecma262/#sec-operations-on-objects // 7.3.2 Get ( O, P ), https://tc39.es/ecma262/#sec-get-o-p -ThrowCompletionOr Object::get(PropertyName const& property_name) const +ThrowCompletionOr Object::get(PropertyKey const& property_name) const { // 1. Assert: Type(O) is Object. @@ -91,7 +91,7 @@ ThrowCompletionOr Object::get(PropertyName const& property_name) const // 7.3.3 GetV ( V, P ) is defined as Value::get(). // 7.3.4 Set ( O, P, V, Throw ), https://tc39.es/ecma262/#sec-set-o-p-v-throw -ThrowCompletionOr Object::set(PropertyName const& property_name, Value value, ShouldThrowExceptions throw_exceptions) +ThrowCompletionOr Object::set(PropertyKey const& property_name, Value value, ShouldThrowExceptions throw_exceptions) { VERIFY(!value.is_empty()); auto& vm = this->vm(); @@ -117,7 +117,7 @@ ThrowCompletionOr Object::set(PropertyName const& property_name, Value val } // 7.3.5 CreateDataProperty ( O, P, V ), https://tc39.es/ecma262/#sec-createdataproperty -ThrowCompletionOr Object::create_data_property(PropertyName const& property_name, Value value) +ThrowCompletionOr Object::create_data_property(PropertyKey const& property_name, Value value) { // 1. Assert: Type(O) is Object. @@ -137,7 +137,7 @@ ThrowCompletionOr Object::create_data_property(PropertyName const& propert } // 7.3.6 CreateMethodProperty ( O, P, V ), https://tc39.es/ecma262/#sec-createmethodproperty -ThrowCompletionOr Object::create_method_property(PropertyName const& property_name, Value value) +ThrowCompletionOr Object::create_method_property(PropertyKey const& property_name, Value value) { VERIFY(!value.is_empty()); @@ -159,7 +159,7 @@ ThrowCompletionOr Object::create_method_property(PropertyName const& prope } // 7.3.7 CreateDataPropertyOrThrow ( O, P, V ), https://tc39.es/ecma262/#sec-createdatapropertyorthrow -ThrowCompletionOr Object::create_data_property_or_throw(PropertyName const& property_name, Value value) +ThrowCompletionOr Object::create_data_property_or_throw(PropertyKey const& property_name, Value value) { VERIFY(!value.is_empty()); auto& vm = this->vm(); @@ -183,7 +183,7 @@ ThrowCompletionOr Object::create_data_property_or_throw(PropertyName const } // 7.3.6 CreateNonEnumerableDataPropertyOrThrow ( O, P, V ), https://tc39.es/proposal-error-cause/#sec-createnonenumerabledatapropertyorthrow -ThrowCompletionOr Object::create_non_enumerable_data_property_or_throw(PropertyName const& property_name, Value value) +ThrowCompletionOr Object::create_non_enumerable_data_property_or_throw(PropertyKey const& property_name, Value value) { VERIFY(!value.is_empty()); VERIFY(property_name.is_valid()); @@ -196,7 +196,7 @@ ThrowCompletionOr Object::create_non_enumerable_data_property_or_throw(Pro } // 7.3.8 DefinePropertyOrThrow ( O, P, desc ), https://tc39.es/ecma262/#sec-definepropertyorthrow -ThrowCompletionOr Object::define_property_or_throw(PropertyName const& property_name, PropertyDescriptor const& property_descriptor) +ThrowCompletionOr Object::define_property_or_throw(PropertyKey const& property_name, PropertyDescriptor const& property_descriptor) { auto& vm = this->vm(); @@ -219,7 +219,7 @@ ThrowCompletionOr Object::define_property_or_throw(PropertyName const& pro } // 7.3.9 DeletePropertyOrThrow ( O, P ), https://tc39.es/ecma262/#sec-deletepropertyorthrow -ThrowCompletionOr Object::delete_property_or_throw(PropertyName const& property_name) +ThrowCompletionOr Object::delete_property_or_throw(PropertyKey const& property_name) { auto& vm = this->vm(); @@ -242,7 +242,7 @@ ThrowCompletionOr Object::delete_property_or_throw(PropertyName const& pro } // 7.3.11 HasProperty ( O, P ), https://tc39.es/ecma262/#sec-hasproperty -ThrowCompletionOr Object::has_property(PropertyName const& property_name) const +ThrowCompletionOr Object::has_property(PropertyKey const& property_name) const { // 1. Assert: Type(O) is Object. @@ -254,7 +254,7 @@ ThrowCompletionOr Object::has_property(PropertyName const& property_name) } // 7.3.12 HasOwnProperty ( O, P ), https://tc39.es/ecma262/#sec-hasownproperty -ThrowCompletionOr Object::has_own_property(PropertyName const& property_name) const +ThrowCompletionOr Object::has_own_property(PropertyKey const& property_name) const { // 1. Assert: Type(O) is Object. @@ -296,7 +296,7 @@ ThrowCompletionOr Object::set_integrity_level(IntegrityLevel level) if (level == IntegrityLevel::Sealed) { // a. For each element k of keys, do for (auto& key : keys) { - auto property_name = PropertyName::from_value(global_object, key); + auto property_name = PropertyKey::from_value(global_object, key); // i. Perform ? DefinePropertyOrThrow(O, k, PropertyDescriptor { [[Configurable]]: false }). TRY(define_property_or_throw(property_name, { .configurable = false })); @@ -308,7 +308,7 @@ ThrowCompletionOr Object::set_integrity_level(IntegrityLevel level) // b. For each element k of keys, do for (auto& key : keys) { - auto property_name = PropertyName::from_value(global_object, key); + auto property_name = PropertyKey::from_value(global_object, key); // i. Let currentDesc be ? O.[[GetOwnProperty]](k). auto current_descriptor = TRY(internal_get_own_property(property_name)); @@ -360,7 +360,7 @@ ThrowCompletionOr Object::test_integrity_level(IntegrityLevel level) const // 7. For each element k of keys, do for (auto& key : keys) { - auto property_name = PropertyName::from_value(global_object(), key); + auto property_name = PropertyKey::from_value(global_object(), key); // a. Let currentDesc be ? O.[[GetOwnProperty]](k). auto current_descriptor = TRY(internal_get_own_property(property_name)); @@ -405,7 +405,7 @@ ThrowCompletionOr Object::enumerable_own_property_names(Propert // a. If Type(key) is String, then if (!key.is_string()) continue; - auto property_name = PropertyName::from_value(global_object, key); + auto property_name = PropertyKey::from_value(global_object, key); // i. Let desc be ? O.[[GetOwnProperty]](key). auto descriptor = TRY(internal_get_own_property(property_name)); @@ -445,7 +445,7 @@ ThrowCompletionOr Object::enumerable_own_property_names(Propert } // 7.3.25 CopyDataProperties ( target, source, excludedItems ), https://tc39.es/ecma262/#sec-copydataproperties -ThrowCompletionOr Object::copy_data_properties(Value source, HashTable const& seen_names, GlobalObject& global_object) +ThrowCompletionOr Object::copy_data_properties(Value source, HashTable const& seen_names, GlobalObject& global_object) { if (source.is_nullish()) return this; @@ -453,7 +453,7 @@ ThrowCompletionOr Object::copy_data_properties(Value source, HashTable< auto* from_object = MUST(source.to_object(global_object)); for (auto& next_key_value : TRY(from_object->internal_own_property_keys())) { - auto next_key = PropertyName::from_value(global_object, next_key_value); + auto next_key = PropertyKey::from_value(global_object, next_key_value); if (seen_names.contains(next_key)) continue; @@ -547,13 +547,13 @@ ThrowCompletionOr Object::private_set(PrivateName const& name, Value value } // 7.3.31 DefineField ( receiver, fieldRecord ), https://tc39.es/ecma262/#sec-definefield -ThrowCompletionOr Object::define_field(Variant name, ECMAScriptFunctionObject* initializer) +ThrowCompletionOr Object::define_field(Variant name, ECMAScriptFunctionObject* initializer) { Value init_value = js_undefined(); if (initializer) init_value = TRY(vm().call(*initializer, this)); - if (auto* property_name_ptr = name.get_pointer()) + if (auto* property_name_ptr = name.get_pointer()) TRY(create_data_property_or_throw(*property_name_ptr, init_value)); else TRY(private_field_add(name.get(), init_value)); @@ -634,7 +634,7 @@ ThrowCompletionOr Object::internal_prevent_extensions() } // 10.1.5 [[GetOwnProperty]] ( P ), https://tc39.es/ecma262/#sec-ordinary-object-internal-methods-and-internal-slots-getownproperty-p -ThrowCompletionOr> Object::internal_get_own_property(PropertyName const& property_name) const +ThrowCompletionOr> Object::internal_get_own_property(PropertyKey const& property_name) const { // 1. Assert: IsPropertyKey(P) is true. VERIFY(property_name.is_valid()); @@ -680,7 +680,7 @@ ThrowCompletionOr> Object::internal_get_own_propert } // 10.1.6 [[DefineOwnProperty]] ( P, Desc ), https://tc39.es/ecma262/#sec-ordinary-object-internal-methods-and-internal-slots-defineownproperty-p-desc -ThrowCompletionOr Object::internal_define_own_property(PropertyName const& property_name, PropertyDescriptor const& property_descriptor) +ThrowCompletionOr Object::internal_define_own_property(PropertyKey const& property_name, PropertyDescriptor const& property_descriptor) { VERIFY(property_name.is_valid()); // 1. Let current be ? O.[[GetOwnProperty]](P). @@ -694,7 +694,7 @@ ThrowCompletionOr Object::internal_define_own_property(PropertyName const& } // 10.1.7 [[HasProperty]] ( P ), https://tc39.es/ecma262/#sec-ordinary-object-internal-methods-and-internal-slots-hasproperty-p -ThrowCompletionOr Object::internal_has_property(PropertyName const& property_name) const +ThrowCompletionOr Object::internal_has_property(PropertyKey const& property_name) const { auto& vm = this->vm(); @@ -725,7 +725,7 @@ ThrowCompletionOr Object::internal_has_property(PropertyName const& proper } // 10.1.8 [[Get]] ( P, Receiver ), https://tc39.es/ecma262/#sec-ordinary-object-internal-methods-and-internal-slots-get-p-receiver -ThrowCompletionOr Object::internal_get(PropertyName const& property_name, Value receiver) const +ThrowCompletionOr Object::internal_get(PropertyKey const& property_name, Value receiver) const { VERIFY(!receiver.is_empty()); auto& vm = this->vm(); @@ -768,7 +768,7 @@ ThrowCompletionOr Object::internal_get(PropertyName const& property_name, } // 10.1.9 [[Set]] ( P, V, Receiver ), https://tc39.es/ecma262/#sec-ordinary-object-internal-methods-and-internal-slots-set-p-v-receiver -ThrowCompletionOr Object::internal_set(PropertyName const& property_name, Value value, Value receiver) +ThrowCompletionOr Object::internal_set(PropertyKey const& property_name, Value value, Value receiver) { VERIFY(!value.is_empty()); VERIFY(!receiver.is_empty()); @@ -784,7 +784,7 @@ ThrowCompletionOr Object::internal_set(PropertyName const& property_name, } // 10.1.9.2 OrdinarySetWithOwnDescriptor ( O, P, V, Receiver, ownDesc ), https://tc39.es/ecma262/#sec-ordinarysetwithowndescriptor -ThrowCompletionOr Object::ordinary_set_with_own_descriptor(PropertyName const& property_name, Value value, Value receiver, Optional own_descriptor) +ThrowCompletionOr Object::ordinary_set_with_own_descriptor(PropertyKey const& property_name, Value value, Value receiver, Optional own_descriptor) { auto& vm = this->vm(); @@ -870,7 +870,7 @@ ThrowCompletionOr Object::ordinary_set_with_own_descriptor(PropertyName co } // 10.1.10 [[Delete]] ( P ), https://tc39.es/ecma262/#sec-ordinary-object-internal-methods-and-internal-slots-delete-p -ThrowCompletionOr Object::internal_delete(PropertyName const& property_name) +ThrowCompletionOr Object::internal_delete(PropertyKey const& property_name) { // 1. Assert: IsPropertyKey(P) is true. VERIFY(property_name.is_valid()); @@ -945,7 +945,7 @@ ThrowCompletionOr Object::set_immutable_prototype(Object* prototype) return false; } -Optional Object::storage_get(PropertyName const& property_name) const +Optional Object::storage_get(PropertyKey const& property_name) const { VERIFY(property_name.is_valid()); @@ -968,7 +968,7 @@ Optional Object::storage_get(PropertyName const& property_na return ValueAndAttributes { .value = value, .attributes = attributes }; } -bool Object::storage_has(PropertyName const& property_name) const +bool Object::storage_has(PropertyKey const& property_name) const { VERIFY(property_name.is_valid()); if (property_name.is_number()) @@ -976,7 +976,7 @@ bool Object::storage_has(PropertyName const& property_name) const return shape().lookup(property_name.to_string_or_symbol()).has_value(); } -void Object::storage_set(PropertyName const& property_name, ValueAndAttributes const& value_and_attributes) +void Object::storage_set(PropertyKey const& property_name, ValueAndAttributes const& value_and_attributes) { VERIFY(property_name.is_valid()); @@ -1017,7 +1017,7 @@ void Object::storage_set(PropertyName const& property_name, ValueAndAttributes c m_storage[metadata->offset] = value; } -void Object::storage_delete(PropertyName const& property_name) +void Object::storage_delete(PropertyKey const& property_name) { VERIFY(property_name.is_valid()); VERIFY(storage_has(property_name)); @@ -1045,7 +1045,7 @@ void Object::set_prototype(Object* new_prototype) m_shape = shape.create_prototype_transition(new_prototype); } -void Object::define_old_native_accessor(PropertyName const& property_name, Function getter, Function setter, PropertyAttributes attribute) +void Object::define_old_native_accessor(PropertyKey const& property_name, Function getter, Function setter, PropertyAttributes attribute) { Function(VM&, GlobalObject&)> completion_getter = {}; if (getter) { @@ -1068,7 +1068,7 @@ void Object::define_old_native_accessor(PropertyName const& property_name, Funct define_native_accessor(property_name, move(completion_getter), move(completion_setter), attribute); } -void Object::define_native_accessor(PropertyName const& property_name, Function(VM&, GlobalObject&)> getter, Function(VM&, GlobalObject&)> setter, PropertyAttributes attribute) +void Object::define_native_accessor(PropertyKey const& property_name, Function(VM&, GlobalObject&)> getter, Function(VM&, GlobalObject&)> setter, PropertyAttributes attribute) { auto& vm = this->vm(); String formatted_property_name; @@ -1096,7 +1096,7 @@ void Object::define_native_accessor(PropertyName const& property_name, Function< return define_direct_accessor(property_name, getter_function, setter_function, attribute); } -void Object::define_direct_accessor(PropertyName const& property_name, FunctionObject* getter, FunctionObject* setter, PropertyAttributes attributes) +void Object::define_direct_accessor(PropertyKey const& property_name, FunctionObject* getter, FunctionObject* setter, PropertyAttributes attributes) { VERIFY(property_name.is_valid()); @@ -1122,7 +1122,7 @@ void Object::ensure_shape_is_unique() } // Simple side-effect free property lookup, following the prototype chain. Non-standard. -Value Object::get_without_side_effects(const PropertyName& property_name) const +Value Object::get_without_side_effects(const PropertyKey& property_name) const { auto* object = this; while (object) { @@ -1134,7 +1134,7 @@ Value Object::get_without_side_effects(const PropertyName& property_name) const return {}; } -void Object::define_old_native_function(PropertyName const& property_name, Function native_function, i32 length, PropertyAttributes attribute) +void Object::define_old_native_function(PropertyKey const& property_name, Function native_function, i32 length, PropertyAttributes attribute) { auto completion_native_function = [native_function = move(native_function), property_name](auto& vm, auto& global_object) -> ThrowCompletionOr { auto result = native_function(vm, global_object); @@ -1145,7 +1145,7 @@ void Object::define_old_native_function(PropertyName const& property_name, Funct define_native_function(property_name, move(completion_native_function), length, attribute); } -void Object::define_native_function(PropertyName const& property_name, Function(VM&, GlobalObject&)> native_function, i32 length, PropertyAttributes attribute) +void Object::define_native_function(PropertyKey const& property_name, Function(VM&, GlobalObject&)> native_function, i32 length, PropertyAttributes attribute) { auto& vm = this->vm(); String function_name; @@ -1174,7 +1174,7 @@ ThrowCompletionOr Object::define_properties(Value properties) auto keys = TRY(props->internal_own_property_keys()); struct NameAndDescriptor { - PropertyName name; + PropertyKey name; PropertyDescriptor descriptor; }; @@ -1183,7 +1183,7 @@ ThrowCompletionOr Object::define_properties(Value properties) // 5. For each element nextKey of keys, do for (auto& next_key : keys) { - auto property_name = PropertyName::from_value(global_object, next_key); + auto property_name = PropertyKey::from_value(global_object, next_key); // a. Let propDesc be ? props.[[GetOwnProperty]](nextKey). auto property_descriptor = TRY(props->internal_get_own_property(property_name)); @@ -1237,7 +1237,7 @@ ThrowCompletionOr Object::ordinary_to_primitive(Value::PreferredType pref auto& vm = this->vm(); - AK::Array method_names; + AK::Array method_names; // 1. If hint is string, then if (preferred_type == Value::PreferredType::String) { diff --git a/Userland/Libraries/LibJS/Runtime/Object.h b/Userland/Libraries/LibJS/Runtime/Object.h index 3ca024cf38..472a2c7e8e 100644 --- a/Userland/Libraries/LibJS/Runtime/Object.h +++ b/Userland/Libraries/LibJS/Runtime/Object.h @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include @@ -88,27 +88,27 @@ public: // 7.3 Operations on Objects, https://tc39.es/ecma262/#sec-operations-on-objects - ThrowCompletionOr get(PropertyName const&) const; - ThrowCompletionOr set(PropertyName const&, Value, ShouldThrowExceptions); - ThrowCompletionOr create_data_property(PropertyName const&, Value); - ThrowCompletionOr create_method_property(PropertyName const&, Value); - ThrowCompletionOr create_data_property_or_throw(PropertyName const&, Value); - ThrowCompletionOr create_non_enumerable_data_property_or_throw(PropertyName const&, Value); - ThrowCompletionOr define_property_or_throw(PropertyName const&, PropertyDescriptor const&); - ThrowCompletionOr delete_property_or_throw(PropertyName const&); - ThrowCompletionOr has_property(PropertyName const&) const; - ThrowCompletionOr has_own_property(PropertyName const&) const; + ThrowCompletionOr get(PropertyKey const&) const; + ThrowCompletionOr set(PropertyKey const&, Value, ShouldThrowExceptions); + ThrowCompletionOr create_data_property(PropertyKey const&, Value); + ThrowCompletionOr create_method_property(PropertyKey const&, Value); + ThrowCompletionOr create_data_property_or_throw(PropertyKey const&, Value); + ThrowCompletionOr create_non_enumerable_data_property_or_throw(PropertyKey const&, Value); + ThrowCompletionOr define_property_or_throw(PropertyKey const&, PropertyDescriptor const&); + ThrowCompletionOr delete_property_or_throw(PropertyKey const&); + ThrowCompletionOr has_property(PropertyKey const&) const; + ThrowCompletionOr has_own_property(PropertyKey const&) const; ThrowCompletionOr set_integrity_level(IntegrityLevel); ThrowCompletionOr test_integrity_level(IntegrityLevel) const; ThrowCompletionOr enumerable_own_property_names(PropertyKind kind) const; - ThrowCompletionOr copy_data_properties(Value source, HashTable const& seen_names, GlobalObject& global_object); + ThrowCompletionOr copy_data_properties(Value source, HashTable const& seen_names, GlobalObject& global_object); PrivateElement* private_element_find(PrivateName const& name); ThrowCompletionOr private_field_add(PrivateName const& name, Value value); ThrowCompletionOr private_method_or_accessor_add(PrivateElement element); ThrowCompletionOr private_get(PrivateName const& name); ThrowCompletionOr private_set(PrivateName const& name, Value value); - ThrowCompletionOr define_field(Variant name, ECMAScriptFunctionObject* initializer); + ThrowCompletionOr define_field(Variant name, ECMAScriptFunctionObject* initializer); // 10.1 Ordinary Object Internal Methods and Internal Slots, https://tc39.es/ecma262/#sec-ordinary-object-internal-methods-and-internal-slots @@ -116,15 +116,15 @@ public: virtual ThrowCompletionOr internal_set_prototype_of(Object* prototype); virtual ThrowCompletionOr internal_is_extensible() const; virtual ThrowCompletionOr internal_prevent_extensions(); - virtual ThrowCompletionOr> internal_get_own_property(PropertyName const&) const; - virtual ThrowCompletionOr internal_define_own_property(PropertyName const&, PropertyDescriptor const&); - virtual ThrowCompletionOr internal_has_property(PropertyName const&) const; - virtual ThrowCompletionOr internal_get(PropertyName const&, Value receiver) const; - virtual ThrowCompletionOr internal_set(PropertyName const&, Value value, Value receiver); - virtual ThrowCompletionOr internal_delete(PropertyName const&); + virtual ThrowCompletionOr> internal_get_own_property(PropertyKey const&) const; + virtual ThrowCompletionOr internal_define_own_property(PropertyKey const&, PropertyDescriptor const&); + virtual ThrowCompletionOr internal_has_property(PropertyKey const&) const; + virtual ThrowCompletionOr internal_get(PropertyKey const&, Value receiver) const; + virtual ThrowCompletionOr internal_set(PropertyKey const&, Value value, Value receiver); + virtual ThrowCompletionOr internal_delete(PropertyKey const&); virtual ThrowCompletionOr internal_own_property_keys() const; - ThrowCompletionOr ordinary_set_with_own_descriptor(PropertyName const&, Value, Value, Optional); + ThrowCompletionOr ordinary_set_with_own_descriptor(PropertyKey const&, Value, Value, Optional); // 10.4.7 Immutable Prototype Exotic Objects, https://tc39.es/ecma262/#sec-immutable-prototype-exotic-objects @@ -136,24 +136,24 @@ public: // Implementation-specific storage abstractions - Optional storage_get(PropertyName const&) const; - bool storage_has(PropertyName const&) const; - void storage_set(PropertyName const&, ValueAndAttributes const&); - void storage_delete(PropertyName const&); + Optional storage_get(PropertyKey const&) const; + bool storage_has(PropertyKey const&) const; + void storage_set(PropertyKey const&, ValueAndAttributes const&); + void storage_delete(PropertyKey const&); // Non-standard methods - Value get_without_side_effects(const PropertyName&) const; + Value get_without_side_effects(const PropertyKey&) const; - void define_direct_property(PropertyName const& property_name, Value value, PropertyAttributes attributes) { storage_set(property_name, { value, attributes }); }; - void define_direct_accessor(PropertyName const&, FunctionObject* getter, FunctionObject* setter, PropertyAttributes attributes); + void define_direct_property(PropertyKey const& property_name, Value value, PropertyAttributes attributes) { storage_set(property_name, { value, attributes }); }; + void define_direct_accessor(PropertyKey const&, FunctionObject* getter, FunctionObject* setter, PropertyAttributes attributes); // Legacy methods - Remove once JS_DECLARE_OLD_NATIVE_FUNCTION is removed - void define_old_native_function(PropertyName const&, Function, i32 length, PropertyAttributes attributes); - void define_old_native_accessor(PropertyName const&, Function getter, Function setter, PropertyAttributes attributes); + void define_old_native_function(PropertyKey const&, Function, i32 length, PropertyAttributes attributes); + void define_old_native_accessor(PropertyKey const&, Function getter, Function setter, PropertyAttributes attributes); - void define_native_function(PropertyName const&, Function(VM&, GlobalObject&)>, i32 length, PropertyAttributes attributes); - void define_native_accessor(PropertyName const&, Function(VM&, GlobalObject&)> getter, Function(VM&, GlobalObject&)> setter, PropertyAttributes attributes); + void define_native_function(PropertyKey const&, Function(VM&, GlobalObject&)>, i32 length, PropertyAttributes attributes); + void define_native_accessor(PropertyKey const&, Function(VM&, GlobalObject&)> getter, Function(VM&, GlobalObject&)> setter, PropertyAttributes attributes); virtual bool is_function() const { return false; } virtual bool is_typed_array() const { return false; } diff --git a/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp index 831bc5d00d..b8f577a097 100644 --- a/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp @@ -285,7 +285,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(ObjectConstructor::get_own_property_descriptors) // 4. For each element key of ownKeys, do for (auto& key : own_keys) { - auto property_name = PropertyName::from_value(global_object, key); + auto property_name = PropertyKey::from_value(global_object, key); // a. Let desc be ? obj.[[GetOwnProperty]](key). auto desc = TRY_OR_DISCARD(object->internal_get_own_property(property_name)); @@ -425,7 +425,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(ObjectConstructor::assign) // iii. For each element nextKey of keys, do for (auto& next_key : keys) { - auto property_name = PropertyName::from_value(global_object, next_key); + auto property_name = PropertyKey::from_value(global_object, next_key); // 1. Let desc be ? from.[[GetOwnProperty]](nextKey). auto desc = TRY_OR_DISCARD(from->internal_get_own_property(property_name)); diff --git a/Userland/Libraries/LibJS/Runtime/PropertyName.h b/Userland/Libraries/LibJS/Runtime/PropertyKey.h similarity index 84% rename from Userland/Libraries/LibJS/Runtime/PropertyName.h rename to Userland/Libraries/LibJS/Runtime/PropertyKey.h index 2bbb606033..29679b3ebb 100644 --- a/Userland/Libraries/LibJS/Runtime/PropertyName.h +++ b/Userland/Libraries/LibJS/Runtime/PropertyKey.h @@ -12,7 +12,7 @@ namespace JS { -class PropertyName { +class PropertyKey { public: enum class Type : u8 { Invalid, @@ -26,7 +26,7 @@ public: No, }; - static PropertyName from_value(GlobalObject& global_object, Value value) + static PropertyKey from_value(GlobalObject& global_object, Value value) { if (value.is_empty()) return {}; @@ -37,10 +37,10 @@ public: return TRY_OR_DISCARD(value.to_string(global_object)); } - PropertyName() { } + PropertyKey() { } template - PropertyName(T index) + PropertyKey(T index) { // FIXME: Replace this with requires(IsUnsigned)? // Needs changes in various places using `int` (but not actually being in the negative range) @@ -58,20 +58,20 @@ public: m_number = index; } - PropertyName(char const* chars) + PropertyKey(char const* chars) : m_type(Type::String) , m_string(FlyString(chars)) { } - PropertyName(String const& string) + PropertyKey(String const& string) : m_type(Type::String) , m_string(FlyString(string)) { VERIFY(!m_string.is_null()); } - PropertyName(FlyString string, StringMayBeNumber string_may_be_number = StringMayBeNumber::Yes) + PropertyKey(FlyString string, StringMayBeNumber string_may_be_number = StringMayBeNumber::Yes) : m_string_may_be_number(string_may_be_number == StringMayBeNumber::Yes) , m_type(Type::String) , m_string(move(string)) @@ -79,13 +79,13 @@ public: VERIFY(!m_string.is_null()); } - PropertyName(Symbol& symbol) + PropertyKey(Symbol& symbol) : m_type(Type::Symbol) , m_symbol(&symbol) { } - PropertyName(StringOrSymbol const& string_or_symbol) + PropertyKey(StringOrSymbol const& string_or_symbol) { if (string_or_symbol.is_string()) { m_string = string_or_symbol.as_string(); @@ -106,7 +106,7 @@ public: if (m_type != Type::String || !m_string_may_be_number) return false; - return const_cast(this)->try_coerce_into_number(); + return const_cast(this)->try_coerce_into_number(); } bool is_string() const { @@ -115,7 +115,7 @@ public: if (!m_string_may_be_number) return true; - return !const_cast(this)->try_coerce_into_number(); + return !const_cast(this)->try_coerce_into_number(); } bool is_symbol() const { return m_type == Type::Symbol; } @@ -189,8 +189,8 @@ private: Symbol* m_symbol { nullptr }; }; -struct PropertyNameTraits : public Traits { - static unsigned hash(PropertyName const& name) +struct PropertyNameTraits : public Traits { + static unsigned hash(PropertyKey const& name) { VERIFY(name.is_valid()); if (name.is_string()) @@ -200,17 +200,17 @@ struct PropertyNameTraits : public Traits { return ptr_hash(name.as_symbol()); } - static bool equals(PropertyName const& a, PropertyName const& b) + static bool equals(PropertyKey const& a, PropertyKey const& b) { if (a.type() != b.type()) return false; switch (a.type()) { - case PropertyName::Type::Number: + case PropertyKey::Type::Number: return a.as_number() == b.as_number(); - case PropertyName::Type::String: + case PropertyKey::Type::String: return a.as_string() == b.as_string(); - case PropertyName::Type::Symbol: + case PropertyKey::Type::Symbol: return a.as_symbol() == b.as_symbol(); default: VERIFY_NOT_REACHED(); @@ -223,11 +223,11 @@ struct PropertyNameTraits : public Traits { namespace AK { template<> -struct Formatter : Formatter { - void format(FormatBuilder& builder, JS::PropertyName const& property_name) +struct Formatter : Formatter { + void format(FormatBuilder& builder, JS::PropertyKey const& property_name) { if (!property_name.is_valid()) - Formatter::format(builder, ""); + Formatter::format(builder, ""); else if (property_name.is_number()) Formatter::format(builder, String::number(property_name.as_number())); else diff --git a/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp b/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp index 9d7b0c208d..f57e763c56 100644 --- a/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp @@ -31,7 +31,7 @@ ProxyObject::~ProxyObject() { } -static Value property_name_to_value(VM& vm, PropertyName const& name) +static Value property_name_to_value(VM& vm, PropertyKey const& name) { VERIFY(name.is_valid()); if (name.is_symbol()) @@ -223,7 +223,7 @@ ThrowCompletionOr ProxyObject::internal_prevent_extensions() } // 10.5.5 [[GetOwnProperty]] ( P ), https://tc39.es/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-getownproperty-p -ThrowCompletionOr> ProxyObject::internal_get_own_property(const PropertyName& property_name) const +ThrowCompletionOr> ProxyObject::internal_get_own_property(const PropertyKey& property_name) const { auto& vm = this->vm(); auto& global_object = this->global_object(); @@ -316,7 +316,7 @@ ThrowCompletionOr> ProxyObject::internal_get_own_pr } // 10.5.6 [[DefineOwnProperty]] ( P, Desc ), https://tc39.es/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-defineownproperty-p-desc -ThrowCompletionOr ProxyObject::internal_define_own_property(PropertyName const& property_name, PropertyDescriptor const& property_descriptor) +ThrowCompletionOr ProxyObject::internal_define_own_property(PropertyKey const& property_name, PropertyDescriptor const& property_descriptor) { auto& vm = this->vm(); auto& global_object = this->global_object(); @@ -400,7 +400,7 @@ ThrowCompletionOr ProxyObject::internal_define_own_property(PropertyName c } // 10.5.7 [[HasProperty]] ( P ), https://tc39.es/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-hasproperty-p -ThrowCompletionOr ProxyObject::internal_has_property(PropertyName const& property_name) const +ThrowCompletionOr ProxyObject::internal_has_property(PropertyKey const& property_name) const { auto& vm = this->vm(); auto& global_object = this->global_object(); @@ -454,7 +454,7 @@ ThrowCompletionOr ProxyObject::internal_has_property(PropertyName const& p } // 10.5.8 [[Get]] ( P, Receiver ), https://tc39.es/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-get-p-receiver -ThrowCompletionOr ProxyObject::internal_get(PropertyName const& property_name, Value receiver) const +ThrowCompletionOr ProxyObject::internal_get(PropertyKey const& property_name, Value receiver) const { VERIFY(!receiver.is_empty()); @@ -525,7 +525,7 @@ ThrowCompletionOr ProxyObject::internal_get(PropertyName const& property_ } // 10.5.9 [[Set]] ( P, V, Receiver ), https://tc39.es/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-set-p-v-receiver -ThrowCompletionOr ProxyObject::internal_set(PropertyName const& property_name, Value value, Value receiver) +ThrowCompletionOr ProxyObject::internal_set(PropertyKey const& property_name, Value value, Value receiver) { VERIFY(!value.is_empty()); VERIFY(!receiver.is_empty()); @@ -585,7 +585,7 @@ ThrowCompletionOr ProxyObject::internal_set(PropertyName const& property_n } // 10.5.10 [[Delete]] ( P ), https://tc39.es/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-delete-p -ThrowCompletionOr ProxyObject::internal_delete(PropertyName const& property_name) +ThrowCompletionOr ProxyObject::internal_delete(PropertyKey const& property_name) { auto& vm = this->vm(); auto& global_object = this->global_object(); @@ -700,7 +700,7 @@ ThrowCompletionOr ProxyObject::internal_own_property_keys() con // 16. For each element key of targetKeys, do for (auto& key : target_keys) { // a. Let desc be ? target.[[GetOwnProperty]](key). - auto descriptor = TRY(m_target.internal_get_own_property(PropertyName::from_value(global_object, key))); + auto descriptor = TRY(m_target.internal_get_own_property(PropertyKey::from_value(global_object, key))); // b. If desc is not undefined and desc.[[Configurable]] is false, then if (descriptor.has_value() && !*descriptor->configurable) { diff --git a/Userland/Libraries/LibJS/Runtime/ProxyObject.h b/Userland/Libraries/LibJS/Runtime/ProxyObject.h index 6a72dd73db..e727b57952 100644 --- a/Userland/Libraries/LibJS/Runtime/ProxyObject.h +++ b/Userland/Libraries/LibJS/Runtime/ProxyObject.h @@ -36,12 +36,12 @@ public: virtual ThrowCompletionOr internal_set_prototype_of(Object* prototype) override; virtual ThrowCompletionOr internal_is_extensible() const override; virtual ThrowCompletionOr internal_prevent_extensions() override; - virtual ThrowCompletionOr> internal_get_own_property(PropertyName const&) const override; - virtual ThrowCompletionOr internal_define_own_property(PropertyName const&, PropertyDescriptor const&) override; - virtual ThrowCompletionOr internal_has_property(PropertyName const&) const override; - virtual ThrowCompletionOr internal_get(PropertyName const&, Value receiver) const override; - virtual ThrowCompletionOr internal_set(PropertyName const&, Value value, Value receiver) override; - virtual ThrowCompletionOr internal_delete(PropertyName const&) override; + virtual ThrowCompletionOr> internal_get_own_property(PropertyKey const&) const override; + virtual ThrowCompletionOr internal_define_own_property(PropertyKey const&, PropertyDescriptor const&) override; + virtual ThrowCompletionOr internal_has_property(PropertyKey const&) const override; + virtual ThrowCompletionOr internal_get(PropertyKey const&, Value receiver) const override; + virtual ThrowCompletionOr internal_set(PropertyKey const&, Value value, Value receiver) override; + virtual ThrowCompletionOr internal_delete(PropertyKey const&) override; virtual ThrowCompletionOr internal_own_property_keys() const override; virtual ThrowCompletionOr internal_call(Value this_argument, MarkedValueList arguments_list) override; virtual ThrowCompletionOr internal_construct(MarkedValueList arguments_list, FunctionObject& new_target) override; diff --git a/Userland/Libraries/LibJS/Runtime/Reference.h b/Userland/Libraries/LibJS/Runtime/Reference.h index 39793af82b..b202869e35 100644 --- a/Userland/Libraries/LibJS/Runtime/Reference.h +++ b/Userland/Libraries/LibJS/Runtime/Reference.h @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include namespace JS { @@ -26,14 +26,14 @@ public: }; Reference() { } - Reference(BaseType type, PropertyName name, bool strict) + Reference(BaseType type, PropertyKey name, bool strict) : m_base_type(type) , m_name(move(name)) , m_strict(strict) { } - Reference(Value base, PropertyName name, Value this_value, bool strict = false) + Reference(Value base, PropertyKey name, Value this_value, bool strict = false) : m_base_type(BaseType::Value) , m_base_value(base) , m_name(move(name)) @@ -79,7 +79,7 @@ public: return *m_base_environment; } - PropertyName const& name() const { return m_name; } + PropertyKey const& name() const { return m_name; } bool is_strict() const { return m_strict; } // 6.2.4.2 IsUnresolvableReference ( V ), https://tc39.es/ecma262/#sec-isunresolvablereference @@ -147,7 +147,7 @@ private: Value m_base_value {}; mutable Environment* m_base_environment; }; - PropertyName m_name; + PropertyKey m_name; Value m_this_value; bool m_strict { false }; diff --git a/Userland/Libraries/LibJS/Runtime/Shape.cpp b/Userland/Libraries/LibJS/Runtime/Shape.cpp index e937d540b0..58b187be05 100644 --- a/Userland/Libraries/LibJS/Runtime/Shape.cpp +++ b/Userland/Libraries/LibJS/Runtime/Shape.cpp @@ -232,7 +232,7 @@ void Shape::add_property_without_transition(StringOrSymbol const& property_name, ++m_property_count; } -FLATTEN void Shape::add_property_without_transition(PropertyName const& property_name, PropertyAttributes attributes) +FLATTEN void Shape::add_property_without_transition(PropertyKey const& property_name, PropertyAttributes attributes) { VERIFY(property_name.is_valid()); add_property_without_transition(property_name.to_string_or_symbol(), attributes); diff --git a/Userland/Libraries/LibJS/Runtime/Shape.h b/Userland/Libraries/LibJS/Runtime/Shape.h index bfec255572..74278b1bf3 100644 --- a/Userland/Libraries/LibJS/Runtime/Shape.h +++ b/Userland/Libraries/LibJS/Runtime/Shape.h @@ -58,7 +58,7 @@ public: Shape* create_prototype_transition(Object* new_prototype); void add_property_without_transition(const StringOrSymbol&, PropertyAttributes); - void add_property_without_transition(PropertyName const&, PropertyAttributes); + void add_property_without_transition(PropertyKey const&, PropertyAttributes); bool is_unique() const { return m_unique; } Shape* create_unique_clone() const; diff --git a/Userland/Libraries/LibJS/Runtime/StringObject.cpp b/Userland/Libraries/LibJS/Runtime/StringObject.cpp index f061abedbf..83ca4a0ed1 100644 --- a/Userland/Libraries/LibJS/Runtime/StringObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/StringObject.cpp @@ -44,7 +44,7 @@ void StringObject::visit_edges(Cell::Visitor& visitor) } // 10.4.3.5 StringGetOwnProperty ( S, P ),https://tc39.es/ecma262/#sec-stringgetownproperty -static Optional string_get_own_property(GlobalObject& global_object, StringObject const& string, PropertyName const& property_name) +static Optional string_get_own_property(GlobalObject& global_object, StringObject const& string, PropertyKey const& property_name) { // 1. Assert: S is an Object that has a [[StringData]] internal slot. // 2. Assert: IsPropertyKey(P) is true. @@ -52,7 +52,7 @@ static Optional string_get_own_property(GlobalObject& global // 3. If Type(P) is not String, return undefined. // NOTE: The spec only uses string and symbol keys, and later coerces to numbers - - // this is not the case for PropertyName, so '!property_name.is_string()' would be wrong. + // this is not the case for PropertyKey, so '!property_name.is_string()' would be wrong. if (property_name.is_symbol()) return {}; @@ -92,7 +92,7 @@ static Optional string_get_own_property(GlobalObject& global } // 10.4.3.1 [[GetOwnProperty]] ( P ), https://tc39.es/ecma262/#sec-string-exotic-objects-getownproperty-p -ThrowCompletionOr> StringObject::internal_get_own_property(PropertyName const& property_name) const +ThrowCompletionOr> StringObject::internal_get_own_property(PropertyKey const& property_name) const { // Assert: IsPropertyKey(P) is true. @@ -108,7 +108,7 @@ ThrowCompletionOr> StringObject::internal_get_own_p } // 10.4.3.2 [[DefineOwnProperty]] ( P, Desc ), https://tc39.es/ecma262/#sec-string-exotic-objects-defineownproperty-p-desc -ThrowCompletionOr StringObject::internal_define_own_property(PropertyName const& property_name, PropertyDescriptor const& property_descriptor) +ThrowCompletionOr StringObject::internal_define_own_property(PropertyKey const& property_name, PropertyDescriptor const& property_descriptor) { // 1. Assert: IsPropertyKey(P) is true. VERIFY(property_name.is_valid()); diff --git a/Userland/Libraries/LibJS/Runtime/StringObject.h b/Userland/Libraries/LibJS/Runtime/StringObject.h index 3d82be4ffa..5ffef5da21 100644 --- a/Userland/Libraries/LibJS/Runtime/StringObject.h +++ b/Userland/Libraries/LibJS/Runtime/StringObject.h @@ -29,8 +29,8 @@ public: } private: - virtual ThrowCompletionOr> internal_get_own_property(PropertyName const&) const override; - virtual ThrowCompletionOr internal_define_own_property(PropertyName const&, PropertyDescriptor const&) override; + virtual ThrowCompletionOr> internal_get_own_property(PropertyKey const&) const override; + virtual ThrowCompletionOr internal_define_own_property(PropertyKey const&, PropertyDescriptor const&) override; virtual ThrowCompletionOr internal_own_property_keys() const override; virtual bool is_string_object() const final { return true; } diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp index ab8b08e67a..0b9ce82e5c 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include #include @@ -96,7 +96,7 @@ ThrowCompletionOr get_options_object(GlobalObject& global_object, Value } // 13.3 GetOption ( options, property, types, values, fallback ), https://tc39.es/proposal-temporal/#sec-getoption -ThrowCompletionOr get_option(GlobalObject& global_object, Object const& options, PropertyName const& property, Vector const& types, Vector const& values, Value fallback) +ThrowCompletionOr get_option(GlobalObject& global_object, Object const& options, PropertyKey const& property, Vector const& types, Vector const& values, Value fallback) { VERIFY(property.is_string()); @@ -158,7 +158,7 @@ ThrowCompletionOr get_option(GlobalObject& global_object, Object const& o // 13.4 GetStringOrNumberOption ( options, property, stringValues, minimum, maximum, fallback ), https://tc39.es/proposal-temporal/#sec-getstringornumberoption template -ThrowCompletionOr> get_string_or_number_option(GlobalObject& global_object, Object const& options, PropertyName const& property, Vector const& string_values, NumberType minimum, NumberType maximum, Value fallback) +ThrowCompletionOr> get_string_or_number_option(GlobalObject& global_object, Object const& options, PropertyKey const& property, Vector const& string_values, NumberType minimum, NumberType maximum, Value fallback) { auto& vm = global_object.vm(); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.h b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.h index 86de950d1c..c1f413b569 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.h @@ -86,9 +86,9 @@ struct SecondsStringPrecision { ThrowCompletionOr iterable_to_list_of_type(GlobalObject&, Value items, Vector const& element_types); ThrowCompletionOr get_options_object(GlobalObject&, Value options); -ThrowCompletionOr get_option(GlobalObject&, Object const& options, PropertyName const& property, Vector const& types, Vector const& values, Value fallback); +ThrowCompletionOr get_option(GlobalObject&, Object const& options, PropertyKey const& property, Vector const& types, Vector const& values, Value fallback); template -ThrowCompletionOr> get_string_or_number_option(GlobalObject&, Object const& options, PropertyName const& property, Vector const& string_values, NumberType minimum, NumberType maximum, Value fallback); +ThrowCompletionOr> get_string_or_number_option(GlobalObject&, Object const& options, PropertyKey const& property, Vector const& string_values, NumberType minimum, NumberType maximum, Value fallback); ThrowCompletionOr to_temporal_overflow(GlobalObject&, Object const& normalized_options); ThrowCompletionOr to_temporal_rounding_mode(GlobalObject&, Object const& normalized_options, String const& fallback); ThrowCompletionOr to_show_calendar_option(GlobalObject&, Object const& normalized_options); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp index 1ba7b47e17..d76ca6825f 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp @@ -939,7 +939,7 @@ ThrowCompletionOr default_merge_fields(GlobalObject& global_object, Obj for (auto& next_key : original_keys) { // a. If nextKey is not "month" or "monthCode", then if (next_key.as_string().string() != vm.names.month.as_string() && next_key.as_string().string() != vm.names.monthCode.as_string()) { - auto property_name = PropertyName::from_value(global_object, next_key); + auto property_name = PropertyKey::from_value(global_object, next_key); // i. Let propValue be ? Get(fields, nextKey). auto prop_value = TRY(fields.get(property_name)); @@ -960,7 +960,7 @@ ThrowCompletionOr default_merge_fields(GlobalObject& global_object, Obj // 5. For each element nextKey of newKeys, do for (auto& next_key : new_keys) { - auto property_name = PropertyName::from_value(global_object, next_key); + auto property_name = PropertyKey::from_value(global_object, next_key); // a. Let propValue be ? Get(additionalFields, nextKey). auto prop_value = TRY(additional_fields.get(property_name)); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Duration.h b/Userland/Libraries/LibJS/Runtime/Temporal/Duration.h index 50bb479312..d9e6bc2bc3 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/Duration.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/Duration.h @@ -89,7 +89,7 @@ struct BalancedDuration { template struct TemporalDurationLikeProperty { ValueT StructT::*internal_slot { nullptr }; - PropertyName property; + PropertyKey property; }; template diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTime.h b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTime.h index 111b653ff7..49867e8e97 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTime.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTime.h @@ -76,7 +76,7 @@ struct PartialUnregulatedTemporalTime { template struct TemporalTimeLikeProperty { ValueT StructT::*internal_slot { nullptr }; - PropertyName property; + PropertyKey property; }; template diff --git a/Userland/Libraries/LibJS/Runtime/TypedArray.h b/Userland/Libraries/LibJS/Runtime/TypedArray.h index a19c9e2b29..3e3fd5c2f3 100644 --- a/Userland/Libraries/LibJS/Runtime/TypedArray.h +++ b/Userland/Libraries/LibJS/Runtime/TypedArray.h @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include @@ -80,7 +80,7 @@ inline bool is_valid_integer_index(TypedArrayBase const& typed_array, Value prop return false; // TODO: This can be optimized by skipping the following 3 out of 4 checks if property_index - // came from a number-type PropertyName instead of a canonicalized string-type PropertyName + // came from a number-type PropertyKey instead of a canonicalized string-type PropertyKey // If ! IsIntegralNumber(index) is false, return false. if (!property_index.is_integral_number()) @@ -190,7 +190,7 @@ class TypedArray : public TypedArrayBase { public: // 10.4.5.1 [[GetOwnProperty]] ( P ), https://tc39.es/ecma262/#sec-integer-indexed-exotic-objects-getownproperty-p - virtual ThrowCompletionOr> internal_get_own_property(PropertyName const& property_name) const override + virtual ThrowCompletionOr> internal_get_own_property(PropertyKey const& property_name) const override { // 1. Assert: IsPropertyKey(P) is true. VERIFY(property_name.is_valid()); @@ -230,7 +230,7 @@ public: } // 10.4.5.2 [[HasProperty]] ( P ), https://tc39.es/ecma262/#sec-integer-indexed-exotic-objects-hasproperty-p - virtual ThrowCompletionOr internal_has_property(PropertyName const& property_name) const override + virtual ThrowCompletionOr internal_has_property(PropertyKey const& property_name) const override { // 1. Assert: IsPropertyKey(P) is true. VERIFY(property_name.is_valid()); @@ -256,7 +256,7 @@ public: } // 10.4.5.3 [[DefineOwnProperty]] ( P, Desc ), https://tc39.es/ecma262/#sec-integer-indexed-exotic-objects-defineownproperty-p-desc - virtual ThrowCompletionOr internal_define_own_property(PropertyName const& property_name, PropertyDescriptor const& property_descriptor) override + virtual ThrowCompletionOr internal_define_own_property(PropertyKey const& property_name, PropertyDescriptor const& property_descriptor) override { // 1. Assert: IsPropertyKey(P) is true. VERIFY(property_name.is_valid()); @@ -311,7 +311,7 @@ public: } // 10.4.5.4 [[Get]] ( P, Receiver ), 10.4.5.4 [[Get]] ( P, Receiver ) - virtual ThrowCompletionOr internal_get(PropertyName const& property_name, Value receiver) const override + virtual ThrowCompletionOr internal_get(PropertyKey const& property_name, Value receiver) const override { VERIFY(!receiver.is_empty()); @@ -338,7 +338,7 @@ public: } // 10.4.5.5 [[Set]] ( P, V, Receiver ), https://tc39.es/ecma262/#sec-integer-indexed-exotic-objects-set-p-v-receiver - virtual ThrowCompletionOr internal_set(PropertyName const& property_name, Value value, Value receiver) override + virtual ThrowCompletionOr internal_set(PropertyKey const& property_name, Value value, Value receiver) override { VERIFY(!value.is_empty()); VERIFY(!receiver.is_empty()); @@ -371,7 +371,7 @@ public: } // 10.4.5.6 [[Delete]] ( P ), https://tc39.es/ecma262/#sec-integer-indexed-exotic-objects-delete-p - virtual ThrowCompletionOr internal_delete(PropertyName const& property_name) override + virtual ThrowCompletionOr internal_delete(PropertyKey const& property_name) override { // 1. Assert: IsPropertyKey(P) is true. VERIFY(property_name.is_valid()); diff --git a/Userland/Libraries/LibJS/Runtime/VM.cpp b/Userland/Libraries/LibJS/Runtime/VM.cpp index f43485aa23..b4f7b3f889 100644 --- a/Userland/Libraries/LibJS/Runtime/VM.cpp +++ b/Userland/Libraries/LibJS/Runtime/VM.cpp @@ -219,7 +219,7 @@ ThrowCompletionOr VM::property_binding_initialization(BindingPattern const { auto* object = TRY(value.to_object(global_object)); - HashTable seen_names; + HashTable seen_names; for (auto& property : binding.entries) { VERIFY(!property.is_elision()); @@ -249,7 +249,7 @@ ThrowCompletionOr VM::property_binding_initialization(BindingPattern const break; } - PropertyName name; + PropertyKey name; property.name.visit( [&](Empty) { VERIFY_NOT_REACHED(); }, diff --git a/Userland/Libraries/LibJS/Runtime/VM.h b/Userland/Libraries/LibJS/Runtime/VM.h index d54f0ec15c..970acaf67f 100644 --- a/Userland/Libraries/LibJS/Runtime/VM.h +++ b/Userland/Libraries/LibJS/Runtime/VM.h @@ -279,7 +279,7 @@ private: [[nodiscard]] ThrowCompletionOr call_internal(FunctionObject&, Value this_value, Optional arguments); - ThrowCompletionOr copy_data_properties(Object& rest_object, Object const& source, HashTable const& seen_names, GlobalObject& global_object); + ThrowCompletionOr copy_data_properties(Object& rest_object, Object const& source, HashTable const& seen_names, GlobalObject& global_object); ThrowCompletionOr property_binding_initialization(BindingPattern const& binding, Value value, Environment* environment, GlobalObject& global_object); ThrowCompletionOr iterator_binding_initialization(BindingPattern const& binding, Object* iterator, bool& iterator_done, Environment* environment, GlobalObject& global_object); diff --git a/Userland/Libraries/LibJS/Runtime/Value.cpp b/Userland/Libraries/LibJS/Runtime/Value.cpp index 0c843433d0..44474144b2 100644 --- a/Userland/Libraries/LibJS/Runtime/Value.cpp +++ b/Userland/Libraries/LibJS/Runtime/Value.cpp @@ -733,7 +733,7 @@ ThrowCompletionOr Value::to_integer_or_infinity(GlobalObject& global_obj } // 7.3.3 GetV ( V, P ), https://tc39.es/ecma262/#sec-getv -ThrowCompletionOr Value::get(GlobalObject& global_object, PropertyName const& property_name) const +ThrowCompletionOr Value::get(GlobalObject& global_object, PropertyKey const& property_name) const { // 1. Assert: IsPropertyKey(P) is true. VERIFY(property_name.is_valid()); @@ -746,7 +746,7 @@ ThrowCompletionOr Value::get(GlobalObject& global_object, PropertyName co } // 7.3.10 GetMethod ( V, P ), https://tc39.es/ecma262/#sec-getmethod -ThrowCompletionOr Value::get_method(GlobalObject& global_object, PropertyName const& property_name) const +ThrowCompletionOr Value::get_method(GlobalObject& global_object, PropertyKey const& property_name) const { auto& vm = global_object.vm(); @@ -1455,7 +1455,7 @@ ThrowCompletionOr is_less_than(GlobalObject& global_object, bool left_ } // 7.3.20 Invoke ( V, P [ , argumentsList ] ), https://tc39.es/ecma262/#sec-invoke -ThrowCompletionOr Value::invoke_internal(GlobalObject& global_object, JS::PropertyName const& property_name, Optional arguments) +ThrowCompletionOr Value::invoke_internal(GlobalObject& global_object, JS::PropertyKey const& property_name, Optional arguments) { auto& vm = global_object.vm(); auto property = TRY(get(global_object, property_name)); diff --git a/Userland/Libraries/LibJS/Runtime/Value.h b/Userland/Libraries/LibJS/Runtime/Value.h index c66e028f58..cb1bc76642 100644 --- a/Userland/Libraries/LibJS/Runtime/Value.h +++ b/Userland/Libraries/LibJS/Runtime/Value.h @@ -327,8 +327,8 @@ public: ThrowCompletionOr to_integer_or_infinity(GlobalObject&) const; bool to_boolean() const; - ThrowCompletionOr get(GlobalObject&, PropertyName const&) const; - ThrowCompletionOr get_method(GlobalObject&, PropertyName const&) const; + ThrowCompletionOr get(GlobalObject&, PropertyKey const&) const; + ThrowCompletionOr get_method(GlobalObject&, PropertyKey const&) const; String to_string_without_side_effects() const; @@ -344,12 +344,12 @@ public: bool operator==(Value const&) const; template - [[nodiscard]] ALWAYS_INLINE ThrowCompletionOr invoke(GlobalObject& global_object, PropertyName const& property_name, Args... args); + [[nodiscard]] ALWAYS_INLINE ThrowCompletionOr invoke(GlobalObject& global_object, PropertyKey const& property_name, Args... args); private: Type m_type { Type::Empty }; - [[nodiscard]] ThrowCompletionOr invoke_internal(GlobalObject& global_object, PropertyName const&, Optional arguments); + [[nodiscard]] ThrowCompletionOr invoke_internal(GlobalObject& global_object, PropertyKey const&, Optional arguments); ThrowCompletionOr to_i32_slow_case(GlobalObject&) const; diff --git a/Userland/Libraries/LibWeb/Bindings/CSSStyleDeclarationWrapperCustom.cpp b/Userland/Libraries/LibWeb/Bindings/CSSStyleDeclarationWrapperCustom.cpp index 92ccd88c5b..5d056f3d5a 100644 --- a/Userland/Libraries/LibWeb/Bindings/CSSStyleDeclarationWrapperCustom.cpp +++ b/Userland/Libraries/LibWeb/Bindings/CSSStyleDeclarationWrapperCustom.cpp @@ -21,14 +21,14 @@ static CSS::PropertyID property_id_from_name(StringView name) return CSS::PropertyID::Invalid; } -JS::ThrowCompletionOr CSSStyleDeclarationWrapper::internal_has_property(JS::PropertyName const& name) const +JS::ThrowCompletionOr CSSStyleDeclarationWrapper::internal_has_property(JS::PropertyKey const& name) const { if (!name.is_string()) return Base::internal_has_property(name); return property_id_from_name(name.to_string()) != CSS::PropertyID::Invalid; } -JS::ThrowCompletionOr CSSStyleDeclarationWrapper::internal_get(JS::PropertyName const& name, JS::Value receiver) const +JS::ThrowCompletionOr CSSStyleDeclarationWrapper::internal_get(JS::PropertyKey const& name, JS::Value receiver) const { if (!name.is_string()) return Base::internal_get(name, receiver); @@ -40,7 +40,7 @@ JS::ThrowCompletionOr CSSStyleDeclarationWrapper::internal_get(JS::Pr return { js_string(vm(), String::empty()) }; } -JS::ThrowCompletionOr CSSStyleDeclarationWrapper::internal_set(JS::PropertyName const& name, JS::Value value, JS::Value receiver) +JS::ThrowCompletionOr CSSStyleDeclarationWrapper::internal_set(JS::PropertyKey const& name, JS::Value value, JS::Value receiver) { if (!name.is_string()) return Base::internal_set(name, value, receiver); diff --git a/Userland/Libraries/LibWeb/Bindings/IDLAbstractOperations.cpp b/Userland/Libraries/LibWeb/Bindings/IDLAbstractOperations.cpp index 35a25a778c..f87ea04f61 100644 --- a/Userland/Libraries/LibWeb/Bindings/IDLAbstractOperations.cpp +++ b/Userland/Libraries/LibWeb/Bindings/IDLAbstractOperations.cpp @@ -6,13 +6,13 @@ #include #include -#include +#include #include namespace Web::Bindings::IDL { // https://webidl.spec.whatwg.org/#is-an-array-index -bool is_an_array_index(JS::GlobalObject& global_object, JS::PropertyName const& property_name) +bool is_an_array_index(JS::GlobalObject& global_object, JS::PropertyKey const& property_name) { // 1. If Type(P) is not String, then return false. if (!property_name.is_number()) diff --git a/Userland/Libraries/LibWeb/Bindings/IDLAbstractOperations.h b/Userland/Libraries/LibWeb/Bindings/IDLAbstractOperations.h index 8a58adee70..b3157b5eba 100644 --- a/Userland/Libraries/LibWeb/Bindings/IDLAbstractOperations.h +++ b/Userland/Libraries/LibWeb/Bindings/IDLAbstractOperations.h @@ -10,6 +10,6 @@ namespace Web::Bindings::IDL { -bool is_an_array_index(JS::GlobalObject&, JS::PropertyName const&); +bool is_an_array_index(JS::GlobalObject&, JS::PropertyKey const&); } diff --git a/Userland/Services/WebContent/ConsoleGlobalObject.cpp b/Userland/Services/WebContent/ConsoleGlobalObject.cpp index d889710bf7..82ad66fd56 100644 --- a/Userland/Services/WebContent/ConsoleGlobalObject.cpp +++ b/Userland/Services/WebContent/ConsoleGlobalObject.cpp @@ -57,7 +57,7 @@ JS::ThrowCompletionOr ConsoleGlobalObject::internal_prevent_extensions() return m_window_object->internal_prevent_extensions(); } -JS::ThrowCompletionOr> ConsoleGlobalObject::internal_get_own_property(JS::PropertyName const& property_name) const +JS::ThrowCompletionOr> ConsoleGlobalObject::internal_get_own_property(JS::PropertyKey const& property_name) const { if (auto result = TRY(m_window_object->internal_get_own_property(property_name)); result.has_value()) return result; @@ -65,17 +65,17 @@ JS::ThrowCompletionOr> ConsoleGlobalObject::int return Base::internal_get_own_property(property_name); } -JS::ThrowCompletionOr ConsoleGlobalObject::internal_define_own_property(JS::PropertyName const& property_name, JS::PropertyDescriptor const& descriptor) +JS::ThrowCompletionOr ConsoleGlobalObject::internal_define_own_property(JS::PropertyKey const& property_name, JS::PropertyDescriptor const& descriptor) { return m_window_object->internal_define_own_property(property_name, descriptor); } -JS::ThrowCompletionOr ConsoleGlobalObject::internal_has_property(JS::PropertyName const& property_name) const +JS::ThrowCompletionOr ConsoleGlobalObject::internal_has_property(JS::PropertyKey const& property_name) const { return TRY(Object::internal_has_property(property_name)) || TRY(m_window_object->internal_has_property(property_name)); } -JS::ThrowCompletionOr ConsoleGlobalObject::internal_get(JS::PropertyName const& property_name, JS::Value receiver) const +JS::ThrowCompletionOr ConsoleGlobalObject::internal_get(JS::PropertyKey const& property_name, JS::Value receiver) const { if (TRY(m_window_object->has_own_property(property_name))) return m_window_object->internal_get(property_name, (receiver == this) ? m_window_object : receiver); @@ -83,12 +83,12 @@ JS::ThrowCompletionOr ConsoleGlobalObject::internal_get(JS::PropertyN return Base::internal_get(property_name, receiver); } -JS::ThrowCompletionOr ConsoleGlobalObject::internal_set(JS::PropertyName const& property_name, JS::Value value, JS::Value receiver) +JS::ThrowCompletionOr ConsoleGlobalObject::internal_set(JS::PropertyKey const& property_name, JS::Value value, JS::Value receiver) { return m_window_object->internal_set(property_name, value, (receiver == this) ? m_window_object : receiver); } -JS::ThrowCompletionOr ConsoleGlobalObject::internal_delete(JS::PropertyName const& property_name) +JS::ThrowCompletionOr ConsoleGlobalObject::internal_delete(JS::PropertyKey const& property_name) { return m_window_object->internal_delete(property_name); } diff --git a/Userland/Services/WebContent/ConsoleGlobalObject.h b/Userland/Services/WebContent/ConsoleGlobalObject.h index c25708d1e9..055f8290ff 100644 --- a/Userland/Services/WebContent/ConsoleGlobalObject.h +++ b/Userland/Services/WebContent/ConsoleGlobalObject.h @@ -27,12 +27,12 @@ public: virtual JS::ThrowCompletionOr internal_set_prototype_of(Object* prototype) override; virtual JS::ThrowCompletionOr internal_is_extensible() const override; virtual JS::ThrowCompletionOr internal_prevent_extensions() override; - virtual JS::ThrowCompletionOr> internal_get_own_property(JS::PropertyName const& name) const override; - virtual JS::ThrowCompletionOr internal_define_own_property(JS::PropertyName const& name, JS::PropertyDescriptor const& descriptor) override; - virtual JS::ThrowCompletionOr internal_has_property(JS::PropertyName const& name) const override; - virtual JS::ThrowCompletionOr internal_get(JS::PropertyName const&, JS::Value) const override; - virtual JS::ThrowCompletionOr internal_set(JS::PropertyName const&, JS::Value value, JS::Value receiver) override; - virtual JS::ThrowCompletionOr internal_delete(JS::PropertyName const& name) override; + virtual JS::ThrowCompletionOr> internal_get_own_property(JS::PropertyKey const& name) const override; + virtual JS::ThrowCompletionOr internal_define_own_property(JS::PropertyKey const& name, JS::PropertyDescriptor const& descriptor) override; + virtual JS::ThrowCompletionOr internal_has_property(JS::PropertyKey const& name) const override; + virtual JS::ThrowCompletionOr internal_get(JS::PropertyKey const&, JS::Value) const override; + virtual JS::ThrowCompletionOr internal_set(JS::PropertyKey const&, JS::Value value, JS::Value receiver) override; + virtual JS::ThrowCompletionOr internal_delete(JS::PropertyKey const& name) override; virtual JS::ThrowCompletionOr internal_own_property_keys() const override; virtual void initialize_global_object() override;