diff options
author | Idan Horowitz <idan.horowitz@gmail.com> | 2021-06-28 03:45:49 +0300 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-06-28 08:55:14 +0100 |
commit | 581f20e6f2425e1bdbee04218f6bfa1b859f0ed2 (patch) | |
tree | 3678fb22be5d98b0aec7f49e0956430f2d7b0587 /Userland | |
parent | 16eb0803fcc2c1b2235472a64b42fd2b9870a169 (diff) | |
download | serenity-581f20e6f2425e1bdbee04218f6bfa1b859f0ed2.zip |
LibJS: Accept FlyStrings in the NativeFunction constructors
This makes the implicit run-time assertion in PropertyName::to_string()
into an explicit compile-time requirement, removes a wasteful FlyString
-> PropertyName -> FlyString construction from NativeFunction::create()
and allows setting the function name to a null string for anonymous
native functions.
Diffstat (limited to 'Userland')
24 files changed, 28 insertions, 28 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.cpp index 19fb4b5b92..4689174065 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.cpp @@ -13,7 +13,7 @@ namespace JS { ArrayBufferConstructor::ArrayBufferConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.ArrayBuffer, *global_object.function_prototype()) + : NativeFunction(vm().names.ArrayBuffer.as_string(), *global_object.function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp index 0f6730c829..9af2ca31a4 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp @@ -17,7 +17,7 @@ namespace JS { ArrayConstructor::ArrayConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.Array, *global_object.function_prototype()) + : NativeFunction(vm().names.Array.as_string(), *global_object.function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/BigIntConstructor.cpp b/Userland/Libraries/LibJS/Runtime/BigIntConstructor.cpp index b61a725f97..321789a2d5 100644 --- a/Userland/Libraries/LibJS/Runtime/BigIntConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/BigIntConstructor.cpp @@ -15,7 +15,7 @@ namespace JS { BigIntConstructor::BigIntConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.BigInt, *global_object.function_prototype()) + : NativeFunction(vm().names.BigInt.as_string(), *global_object.function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/BooleanConstructor.cpp b/Userland/Libraries/LibJS/Runtime/BooleanConstructor.cpp index 0842380566..3376321bb8 100644 --- a/Userland/Libraries/LibJS/Runtime/BooleanConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/BooleanConstructor.cpp @@ -12,7 +12,7 @@ namespace JS { BooleanConstructor::BooleanConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.Boolean, *global_object.function_prototype()) + : NativeFunction(vm().names.Boolean.as_string(), *global_object.function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/DataViewConstructor.cpp b/Userland/Libraries/LibJS/Runtime/DataViewConstructor.cpp index 1e46111993..f72408ed5e 100644 --- a/Userland/Libraries/LibJS/Runtime/DataViewConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/DataViewConstructor.cpp @@ -13,7 +13,7 @@ namespace JS { DataViewConstructor::DataViewConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.DataView, *global_object.function_prototype()) + : NativeFunction(vm().names.DataView.as_string(), *global_object.function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp b/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp index 7ce27cd32c..cddd9a8e6c 100644 --- a/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp @@ -121,7 +121,7 @@ static Value parse_simplified_iso8601(const String& iso_8601) } DateConstructor::DateConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.Date, *global_object.function_prototype()) + : NativeFunction(vm().names.Date.as_string(), *global_object.function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/ErrorConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ErrorConstructor.cpp index 17b54eaebd..9bd61f9db3 100644 --- a/Userland/Libraries/LibJS/Runtime/ErrorConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/ErrorConstructor.cpp @@ -12,7 +12,7 @@ namespace JS { ErrorConstructor::ErrorConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.Error, *global_object.function_prototype()) + : NativeFunction(vm().names.Error.as_string(), *global_object.function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.cpp b/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.cpp index d15402f36f..e37ca80d64 100644 --- a/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.cpp @@ -13,7 +13,7 @@ namespace JS { FinalizationRegistryConstructor::FinalizationRegistryConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.FinalizationRegistry, *global_object.function_prototype()) + : NativeFunction(vm().names.FinalizationRegistry.as_string(), *global_object.function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/FunctionConstructor.cpp b/Userland/Libraries/LibJS/Runtime/FunctionConstructor.cpp index 5c945bca18..ad1d743f95 100644 --- a/Userland/Libraries/LibJS/Runtime/FunctionConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/FunctionConstructor.cpp @@ -16,7 +16,7 @@ namespace JS { FunctionConstructor::FunctionConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.Function, *global_object.function_prototype()) + : NativeFunction(vm().names.Function.as_string(), *global_object.function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/MapConstructor.cpp b/Userland/Libraries/LibJS/Runtime/MapConstructor.cpp index eceff0913f..2434a87ec1 100644 --- a/Userland/Libraries/LibJS/Runtime/MapConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/MapConstructor.cpp @@ -14,7 +14,7 @@ namespace JS { MapConstructor::MapConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.Map, *global_object.function_prototype()) + : NativeFunction(vm().names.Map.as_string(), *global_object.function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp b/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp index 61764b9b5b..c4e32f7812 100644 --- a/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp +++ b/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp @@ -20,16 +20,16 @@ NativeFunction::NativeFunction(Object& prototype) { } -NativeFunction::NativeFunction(PropertyName const& name, Function<Value(VM&, GlobalObject&)> native_function, Object& prototype) +NativeFunction::NativeFunction(FlyString name, Function<Value(VM&, GlobalObject&)> native_function, Object& prototype) : FunctionObject(prototype) - , m_name(name.as_string()) + , m_name(move(name)) , m_native_function(move(native_function)) { } -NativeFunction::NativeFunction(PropertyName const& name, Object& prototype) +NativeFunction::NativeFunction(FlyString name, Object& prototype) : FunctionObject(prototype) - , m_name(name.as_string()) + , m_name(move(name)) { } diff --git a/Userland/Libraries/LibJS/Runtime/NativeFunction.h b/Userland/Libraries/LibJS/Runtime/NativeFunction.h index 40415d8161..aa7899f456 100644 --- a/Userland/Libraries/LibJS/Runtime/NativeFunction.h +++ b/Userland/Libraries/LibJS/Runtime/NativeFunction.h @@ -17,7 +17,7 @@ class NativeFunction : public FunctionObject { public: static NativeFunction* create(GlobalObject&, const FlyString& name, Function<Value(VM&, GlobalObject&)>); - explicit NativeFunction(PropertyName const& name, Function<Value(VM&, GlobalObject&)>, Object& prototype); + explicit NativeFunction(FlyString name, Function<Value(VM&, GlobalObject&)>, Object& prototype); virtual void initialize(GlobalObject&) override { } virtual ~NativeFunction() override; @@ -30,7 +30,7 @@ public: virtual bool is_strict_mode() const override; protected: - NativeFunction(PropertyName const& name, Object& prototype); + NativeFunction(FlyString name, Object& prototype); explicit NativeFunction(Object& prototype); private: diff --git a/Userland/Libraries/LibJS/Runtime/NumberConstructor.cpp b/Userland/Libraries/LibJS/Runtime/NumberConstructor.cpp index 9e6b92ec04..977da1b552 100644 --- a/Userland/Libraries/LibJS/Runtime/NumberConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/NumberConstructor.cpp @@ -24,7 +24,7 @@ constexpr const double MIN_SAFE_INTEGER_VALUE { -(__builtin_pow(2, 53) - 1) }; namespace JS { NumberConstructor::NumberConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.Number, *global_object.function_prototype()) + : NativeFunction(vm().names.Number.as_string(), *global_object.function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp index 09a80f4132..df1bc62b19 100644 --- a/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp @@ -18,7 +18,7 @@ namespace JS { ObjectConstructor::ObjectConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.Object, *global_object.function_prototype()) + : NativeFunction(vm().names.Object.as_string(), *global_object.function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp b/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp index cfed178d24..16e46f6b52 100644 --- a/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp @@ -16,7 +16,7 @@ namespace JS { PromiseConstructor::PromiseConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.Promise, *global_object.function_prototype()) + : NativeFunction(vm().names.Promise.as_string(), *global_object.function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/ProxyConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ProxyConstructor.cpp index 65bda60eb2..13d6b76882 100644 --- a/Userland/Libraries/LibJS/Runtime/ProxyConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/ProxyConstructor.cpp @@ -29,7 +29,7 @@ static ProxyObject* proxy_create(GlobalObject& global_object, Value target, Valu } ProxyConstructor::ProxyConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.Proxy, *global_object.function_prototype()) + : NativeFunction(vm().names.Proxy.as_string(), *global_object.function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/RegExpConstructor.cpp b/Userland/Libraries/LibJS/Runtime/RegExpConstructor.cpp index d1252659bd..9502c0e7df 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/RegExpConstructor.cpp @@ -12,7 +12,7 @@ namespace JS { RegExpConstructor::RegExpConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.RegExp, *global_object.function_prototype()) + : NativeFunction(vm().names.RegExp.as_string(), *global_object.function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/SetConstructor.cpp b/Userland/Libraries/LibJS/Runtime/SetConstructor.cpp index d29eb4446f..017fec4dde 100644 --- a/Userland/Libraries/LibJS/Runtime/SetConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/SetConstructor.cpp @@ -14,7 +14,7 @@ namespace JS { SetConstructor::SetConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.Set, *global_object.function_prototype()) + : NativeFunction(vm().names.Set.as_string(), *global_object.function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp b/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp index 4876a07a85..7762f8c69e 100644 --- a/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp @@ -15,7 +15,7 @@ namespace JS { StringConstructor::StringConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.String, *global_object.function_prototype()) + : NativeFunction(vm().names.String.as_string(), *global_object.function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/SymbolConstructor.cpp b/Userland/Libraries/LibJS/Runtime/SymbolConstructor.cpp index 96fa5046b4..c51dccb4a0 100644 --- a/Userland/Libraries/LibJS/Runtime/SymbolConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/SymbolConstructor.cpp @@ -11,7 +11,7 @@ namespace JS { SymbolConstructor::SymbolConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.Symbol, *global_object.function_prototype()) + : NativeFunction(vm().names.Symbol.as_string(), *global_object.function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp b/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp index a1c108d726..3646bbb4dd 100644 --- a/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp @@ -16,7 +16,7 @@ TypedArrayConstructor::TypedArrayConstructor(const FlyString& name, Object& prot } TypedArrayConstructor::TypedArrayConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.TypedArray, *global_object.function_prototype()) + : NativeFunction(vm().names.TypedArray.as_string(), *global_object.function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.cpp b/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.cpp index 35fef084fd..3c811164dc 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.cpp @@ -14,7 +14,7 @@ namespace JS { WeakMapConstructor::WeakMapConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.WeakMap, *global_object.function_prototype()) + : NativeFunction(vm().names.WeakMap.as_string(), *global_object.function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.cpp b/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.cpp index ee9cbed6da..857a32c68e 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.cpp @@ -13,7 +13,7 @@ namespace JS { WeakRefConstructor::WeakRefConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.WeakRef, *global_object.function_prototype()) + : NativeFunction(vm().names.WeakRef.as_string(), *global_object.function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.cpp b/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.cpp index de5b8712bd..4227787fc7 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.cpp @@ -14,7 +14,7 @@ namespace JS { WeakSetConstructor::WeakSetConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.WeakSet, *global_object.function_prototype()) + : NativeFunction(vm().names.WeakSet.as_string(), *global_object.function_prototype()) { } |