1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 07:37:35 +00:00

LibJS: Move Object::invoke to Value::invoke and fix it for primitives

This is a tiny difference and only changes anything for primitives in
strict mode. However this is tested in test262 and can be noticed by
overriding toString of primitive values.

This does now require one to wrap an object in a Value to call invoke
but all code using invoke has been migrated.
This commit is contained in:
davidot 2021-08-09 16:45:43 +02:00 committed by Linus Groh
parent 74e6a70958
commit 151447bdf7
12 changed files with 61 additions and 76 deletions

View file

@ -150,20 +150,6 @@ public:
IndexedProperties& indexed_properties() { return m_indexed_properties; }
void set_indexed_property_elements(Vector<Value>&& values) { m_indexed_properties = IndexedProperties(move(values)); }
[[nodiscard]] Value invoke_internal(PropertyName const&, Optional<MarkedValueList> arguments);
template<typename... Args>
[[nodiscard]] ALWAYS_INLINE Value invoke(PropertyName const& property_name, Args... args)
{
if constexpr (sizeof...(Args) > 0) {
MarkedValueList arglist { heap() };
(..., arglist.append(move(args)));
return invoke(property_name, move(arglist));
}
return invoke(property_name);
}
Shape& shape() { return *m_shape; }
Shape const& shape() const { return *m_shape; }
@ -201,13 +187,4 @@ private:
IndexedProperties m_indexed_properties;
};
template<>
[[nodiscard]] ALWAYS_INLINE Value Object::invoke(PropertyName const& property_name, MarkedValueList arguments) { return invoke_internal(property_name, move(arguments)); }
template<>
[[nodiscard]] ALWAYS_INLINE Value Object::invoke(PropertyName const& property_name, Optional<MarkedValueList> arguments) { return invoke_internal(property_name, move(arguments)); }
template<>
[[nodiscard]] ALWAYS_INLINE Value Object::invoke(PropertyName const& property_name) { return invoke(property_name, Optional<MarkedValueList> {}); }
}