From 2fe4285693d4d98fb15eb8a4024afb299d25df4b Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 20 Jun 2020 17:49:52 +0200 Subject: [PATCH] LibJS: Object::initialize() overrides must always call base class --- Libraries/LibJS/Runtime/ArrayPrototype.cpp | 3 ++- Libraries/LibJS/Runtime/BigIntConstructor.cpp | 3 ++- Libraries/LibJS/Runtime/BigIntPrototype.cpp | 3 ++- Libraries/LibJS/Runtime/BooleanConstructor.cpp | 3 ++- Libraries/LibJS/Runtime/BooleanPrototype.cpp | 3 ++- Libraries/LibJS/Runtime/BoundFunction.cpp | 3 ++- Libraries/LibJS/Runtime/ConsoleObject.cpp | 3 ++- Libraries/LibJS/Runtime/DateConstructor.cpp | 3 ++- Libraries/LibJS/Runtime/DatePrototype.cpp | 3 ++- Libraries/LibJS/Runtime/ErrorConstructor.cpp | 6 ++++-- Libraries/LibJS/Runtime/ErrorPrototype.cpp | 3 ++- Libraries/LibJS/Runtime/FunctionConstructor.cpp | 3 ++- Libraries/LibJS/Runtime/FunctionPrototype.cpp | 3 ++- Libraries/LibJS/Runtime/JSONObject.cpp | 3 ++- Libraries/LibJS/Runtime/MathObject.cpp | 3 ++- Libraries/LibJS/Runtime/NumberConstructor.cpp | 3 ++- Libraries/LibJS/Runtime/ObjectConstructor.cpp | 3 ++- Libraries/LibJS/Runtime/ObjectPrototype.cpp | 3 ++- Libraries/LibJS/Runtime/ProxyConstructor.cpp | 3 ++- Libraries/LibJS/Runtime/ReflectObject.cpp | 3 ++- Libraries/LibJS/Runtime/RegExpConstructor.cpp | 3 ++- Libraries/LibJS/Runtime/ScriptFunction.cpp | 1 + Libraries/LibJS/Runtime/StringConstructor.cpp | 3 ++- Libraries/LibJS/Runtime/StringPrototype.cpp | 3 ++- Libraries/LibJS/Runtime/SymbolConstructor.cpp | 1 + Libraries/LibJS/Runtime/SymbolPrototype.cpp | 4 ++-- 26 files changed, 52 insertions(+), 26 deletions(-) diff --git a/Libraries/LibJS/Runtime/ArrayPrototype.cpp b/Libraries/LibJS/Runtime/ArrayPrototype.cpp index 08d7a49a69a..56248b2e866 100644 --- a/Libraries/LibJS/Runtime/ArrayPrototype.cpp +++ b/Libraries/LibJS/Runtime/ArrayPrototype.cpp @@ -46,8 +46,9 @@ ArrayPrototype::ArrayPrototype(GlobalObject& global_object) { } -void ArrayPrototype::initialize(Interpreter&, GlobalObject&) +void ArrayPrototype::initialize(Interpreter& interpreter, GlobalObject& global_object) { + Object::initialize(interpreter, global_object); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function("filter", filter, 1, attr); diff --git a/Libraries/LibJS/Runtime/BigIntConstructor.cpp b/Libraries/LibJS/Runtime/BigIntConstructor.cpp index a8e888608db..b7d263d90be 100644 --- a/Libraries/LibJS/Runtime/BigIntConstructor.cpp +++ b/Libraries/LibJS/Runtime/BigIntConstructor.cpp @@ -39,8 +39,9 @@ BigIntConstructor::BigIntConstructor(GlobalObject& global_object) { } -void BigIntConstructor::initialize(Interpreter&, GlobalObject& global_object) +void BigIntConstructor::initialize(Interpreter& interpreter, GlobalObject& global_object) { + NativeFunction::initialize(interpreter, global_object); define_property("prototype", global_object.bigint_prototype(), 0); define_property("length", Value(1), Attribute::Configurable); diff --git a/Libraries/LibJS/Runtime/BigIntPrototype.cpp b/Libraries/LibJS/Runtime/BigIntPrototype.cpp index c0bafbf1bac..92011cc9311 100644 --- a/Libraries/LibJS/Runtime/BigIntPrototype.cpp +++ b/Libraries/LibJS/Runtime/BigIntPrototype.cpp @@ -37,8 +37,9 @@ BigIntPrototype::BigIntPrototype(GlobalObject& global_object) { } -void BigIntPrototype::initialize(Interpreter&, GlobalObject&) +void BigIntPrototype::initialize(Interpreter& interpreter, GlobalObject& global_object) { + Object::initialize(interpreter, global_object); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function("toString", to_string, 0, attr); define_native_function("toLocaleString", to_locale_string, 0, attr); diff --git a/Libraries/LibJS/Runtime/BooleanConstructor.cpp b/Libraries/LibJS/Runtime/BooleanConstructor.cpp index 95a7b82615b..b7b1bec89a9 100644 --- a/Libraries/LibJS/Runtime/BooleanConstructor.cpp +++ b/Libraries/LibJS/Runtime/BooleanConstructor.cpp @@ -38,8 +38,9 @@ BooleanConstructor::BooleanConstructor(GlobalObject& global_object) { } -void BooleanConstructor::initialize(Interpreter&, GlobalObject& global_object) +void BooleanConstructor::initialize(Interpreter& interpreter, GlobalObject& global_object) { + NativeFunction::initialize(interpreter, global_object); define_property("prototype", Value(global_object.boolean_prototype()), 0); define_property("length", Value(1), Attribute::Configurable); } diff --git a/Libraries/LibJS/Runtime/BooleanPrototype.cpp b/Libraries/LibJS/Runtime/BooleanPrototype.cpp index 1942730e257..96cfe96c5a2 100644 --- a/Libraries/LibJS/Runtime/BooleanPrototype.cpp +++ b/Libraries/LibJS/Runtime/BooleanPrototype.cpp @@ -37,8 +37,9 @@ BooleanPrototype::BooleanPrototype(GlobalObject& global_object) { } -void BooleanPrototype::initialize(Interpreter&, GlobalObject&) +void BooleanPrototype::initialize(Interpreter& interpreter, GlobalObject& global_object) { + BooleanObject::initialize(interpreter, global_object); define_native_function("toString", to_string, 0, Attribute::Writable | Attribute::Configurable); define_native_function("valueOf", value_of, 0, Attribute::Writable | Attribute::Configurable); } diff --git a/Libraries/LibJS/Runtime/BoundFunction.cpp b/Libraries/LibJS/Runtime/BoundFunction.cpp index c6efbbc0135..44f49859228 100644 --- a/Libraries/LibJS/Runtime/BoundFunction.cpp +++ b/Libraries/LibJS/Runtime/BoundFunction.cpp @@ -39,8 +39,9 @@ BoundFunction::BoundFunction(GlobalObject& global_object, Function& target_funct { } -void BoundFunction::initialize(Interpreter&, GlobalObject&) +void BoundFunction::initialize(Interpreter& interpreter, GlobalObject& global_object) { + Function::initialize(interpreter, global_object); define_property("length", Value(m_length), Attribute::Configurable); } diff --git a/Libraries/LibJS/Runtime/ConsoleObject.cpp b/Libraries/LibJS/Runtime/ConsoleObject.cpp index 449ab36dcf2..3b6297cc787 100644 --- a/Libraries/LibJS/Runtime/ConsoleObject.cpp +++ b/Libraries/LibJS/Runtime/ConsoleObject.cpp @@ -40,8 +40,9 @@ ConsoleObject::ConsoleObject(GlobalObject& global_object) { } -void ConsoleObject::initialize(Interpreter&, GlobalObject&) +void ConsoleObject::initialize(Interpreter& interpreter, GlobalObject& global_object) { + Object::initialize(interpreter, global_object); define_native_function("log", log); define_native_function("debug", debug); define_native_function("info", info); diff --git a/Libraries/LibJS/Runtime/DateConstructor.cpp b/Libraries/LibJS/Runtime/DateConstructor.cpp index bb680571225..068ac69c740 100644 --- a/Libraries/LibJS/Runtime/DateConstructor.cpp +++ b/Libraries/LibJS/Runtime/DateConstructor.cpp @@ -39,8 +39,9 @@ DateConstructor::DateConstructor(GlobalObject& global_object) { } -void DateConstructor::initialize(Interpreter&, GlobalObject& global_object) +void DateConstructor::initialize(Interpreter& interpreter, GlobalObject& global_object) { + NativeFunction::initialize(interpreter, global_object); define_property("prototype", global_object.date_prototype(), 0); define_property("length", Value(7), Attribute::Configurable); diff --git a/Libraries/LibJS/Runtime/DatePrototype.cpp b/Libraries/LibJS/Runtime/DatePrototype.cpp index 1032ae44b43..593baf579e8 100644 --- a/Libraries/LibJS/Runtime/DatePrototype.cpp +++ b/Libraries/LibJS/Runtime/DatePrototype.cpp @@ -53,8 +53,9 @@ DatePrototype::DatePrototype(GlobalObject& global_object) { } -void DatePrototype::initialize(Interpreter&, GlobalObject&) +void DatePrototype::initialize(Interpreter& interpreter, GlobalObject& global_object) { + Object::initialize(interpreter, global_object); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function("getDate", get_date, 0, attr); define_native_function("getDay", get_day, 0, attr); diff --git a/Libraries/LibJS/Runtime/ErrorConstructor.cpp b/Libraries/LibJS/Runtime/ErrorConstructor.cpp index b3213798efa..b90fe8d3915 100644 --- a/Libraries/LibJS/Runtime/ErrorConstructor.cpp +++ b/Libraries/LibJS/Runtime/ErrorConstructor.cpp @@ -36,8 +36,9 @@ ErrorConstructor::ErrorConstructor(GlobalObject& global_object) { } -void ErrorConstructor::initialize(Interpreter&, GlobalObject& global_object) +void ErrorConstructor::initialize(Interpreter& interpreter, GlobalObject& global_object) { + NativeFunction::initialize(interpreter, global_object); define_property("prototype", global_object.error_prototype(), 0); define_property("length", Value(1), Attribute::Configurable); } @@ -67,8 +68,9 @@ Value ErrorConstructor::construct(Interpreter& interpreter) : NativeFunction(*global_object.function_prototype()) \ { \ } \ - void ConstructorName::initialize(Interpreter&, GlobalObject& global_object) \ + void ConstructorName::initialize(Interpreter& interpreter, GlobalObject& global_object) \ { \ + NativeFunction::initialize(interpreter, global_object); \ define_property("prototype", global_object.snake_name##_prototype(), 0); \ define_property("length", Value(1), Attribute::Configurable); \ } \ diff --git a/Libraries/LibJS/Runtime/ErrorPrototype.cpp b/Libraries/LibJS/Runtime/ErrorPrototype.cpp index 26e43dc6ed9..64127c9ab84 100644 --- a/Libraries/LibJS/Runtime/ErrorPrototype.cpp +++ b/Libraries/LibJS/Runtime/ErrorPrototype.cpp @@ -40,8 +40,9 @@ ErrorPrototype::ErrorPrototype(GlobalObject& global_object) { } -void ErrorPrototype::initialize(Interpreter&, GlobalObject&) +void ErrorPrototype::initialize(Interpreter& interpreter, GlobalObject& global_object) { + Object::initialize(interpreter, global_object); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_property("name", name_getter, name_setter, attr); define_native_property("message", message_getter, nullptr, attr); diff --git a/Libraries/LibJS/Runtime/FunctionConstructor.cpp b/Libraries/LibJS/Runtime/FunctionConstructor.cpp index 69ae5bfecf1..4e2ebf01344 100644 --- a/Libraries/LibJS/Runtime/FunctionConstructor.cpp +++ b/Libraries/LibJS/Runtime/FunctionConstructor.cpp @@ -40,8 +40,9 @@ FunctionConstructor::FunctionConstructor(GlobalObject& global_object) { } -void FunctionConstructor::initialize(Interpreter&, GlobalObject& global_object) +void FunctionConstructor::initialize(Interpreter& interpreter, GlobalObject& global_object) { + NativeFunction::initialize(interpreter, global_object); define_property("prototype", global_object.function_prototype(), 0); define_property("length", Value(1), Attribute::Configurable); } diff --git a/Libraries/LibJS/Runtime/FunctionPrototype.cpp b/Libraries/LibJS/Runtime/FunctionPrototype.cpp index 97f51bc07c6..34f39061e48 100644 --- a/Libraries/LibJS/Runtime/FunctionPrototype.cpp +++ b/Libraries/LibJS/Runtime/FunctionPrototype.cpp @@ -43,8 +43,9 @@ FunctionPrototype::FunctionPrototype(GlobalObject& global_object) { } -void FunctionPrototype::initialize(Interpreter&, GlobalObject&) +void FunctionPrototype::initialize(Interpreter& interpreter, GlobalObject& global_object) { + Object::initialize(interpreter, global_object); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function("apply", apply, 2, attr); define_native_function("bind", bind, 1, attr); diff --git a/Libraries/LibJS/Runtime/JSONObject.cpp b/Libraries/LibJS/Runtime/JSONObject.cpp index 24f1e04f682..ca20bbe4eb2 100644 --- a/Libraries/LibJS/Runtime/JSONObject.cpp +++ b/Libraries/LibJS/Runtime/JSONObject.cpp @@ -42,8 +42,9 @@ JSONObject::JSONObject(GlobalObject& global_object) { } -void JSONObject::initialize(Interpreter&, GlobalObject&) +void JSONObject::initialize(Interpreter& interpreter, GlobalObject& global_object) { + Object::initialize(interpreter, global_object); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function("stringify", stringify, 3, attr); define_native_function("parse", parse, 2, attr); diff --git a/Libraries/LibJS/Runtime/MathObject.cpp b/Libraries/LibJS/Runtime/MathObject.cpp index eb1384331d0..7cf2432130c 100644 --- a/Libraries/LibJS/Runtime/MathObject.cpp +++ b/Libraries/LibJS/Runtime/MathObject.cpp @@ -39,8 +39,9 @@ MathObject::MathObject(GlobalObject& global_object) { } -void MathObject::initialize(Interpreter&, GlobalObject&) +void MathObject::initialize(Interpreter& interpreter, GlobalObject& global_object) { + Object::initialize(interpreter, global_object); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function("abs", abs, 1, attr); define_native_function("random", random, 0, attr); diff --git a/Libraries/LibJS/Runtime/NumberConstructor.cpp b/Libraries/LibJS/Runtime/NumberConstructor.cpp index 963aa4b0a2f..5e3c378104f 100644 --- a/Libraries/LibJS/Runtime/NumberConstructor.cpp +++ b/Libraries/LibJS/Runtime/NumberConstructor.cpp @@ -42,8 +42,9 @@ NumberConstructor::NumberConstructor(GlobalObject& global_object) { } -void NumberConstructor::initialize(Interpreter&, GlobalObject& global_object) +void NumberConstructor::initialize(Interpreter& interpreter, GlobalObject& global_object) { + NativeFunction::initialize(interpreter, global_object); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function("isFinite", is_finite, 1, attr); define_native_function("isInteger", is_integer, 1, attr); diff --git a/Libraries/LibJS/Runtime/ObjectConstructor.cpp b/Libraries/LibJS/Runtime/ObjectConstructor.cpp index d9e0cb01fe7..55efe1fb3f6 100644 --- a/Libraries/LibJS/Runtime/ObjectConstructor.cpp +++ b/Libraries/LibJS/Runtime/ObjectConstructor.cpp @@ -40,8 +40,9 @@ ObjectConstructor::ObjectConstructor(GlobalObject& global_object) { } -void ObjectConstructor::initialize(Interpreter&, GlobalObject& global_object) +void ObjectConstructor::initialize(Interpreter& interpreter, GlobalObject& global_object) { + NativeFunction::initialize(interpreter, global_object); define_property("prototype", global_object.object_prototype(), 0); define_property("length", Value(1), Attribute::Configurable); diff --git a/Libraries/LibJS/Runtime/ObjectPrototype.cpp b/Libraries/LibJS/Runtime/ObjectPrototype.cpp index 80bfb668fc0..562f67846fe 100644 --- a/Libraries/LibJS/Runtime/ObjectPrototype.cpp +++ b/Libraries/LibJS/Runtime/ObjectPrototype.cpp @@ -39,8 +39,9 @@ ObjectPrototype::ObjectPrototype(GlobalObject&) { } -void ObjectPrototype::initialize(Interpreter&, GlobalObject&) +void ObjectPrototype::initialize(Interpreter& interpreter, GlobalObject& global_object) { + Object::initialize(interpreter, global_object); // This must be called after the constructor has returned, so that the below code // can find the ObjectPrototype through normal paths. u8 attr = Attribute::Writable | Attribute::Configurable; diff --git a/Libraries/LibJS/Runtime/ProxyConstructor.cpp b/Libraries/LibJS/Runtime/ProxyConstructor.cpp index 5a715b73940..89605876fd2 100644 --- a/Libraries/LibJS/Runtime/ProxyConstructor.cpp +++ b/Libraries/LibJS/Runtime/ProxyConstructor.cpp @@ -38,8 +38,9 @@ ProxyConstructor::ProxyConstructor(GlobalObject& global_object) { } -void ProxyConstructor::initialize(Interpreter&, GlobalObject& global_object) +void ProxyConstructor::initialize(Interpreter& interpreter, GlobalObject& global_object) { + NativeFunction::initialize(interpreter, global_object); define_property("prototype", global_object.proxy_prototype(), 0); define_property("length", Value(2), Attribute::Configurable); } diff --git a/Libraries/LibJS/Runtime/ReflectObject.cpp b/Libraries/LibJS/Runtime/ReflectObject.cpp index b2fc5abf42e..284054e46cd 100644 --- a/Libraries/LibJS/Runtime/ReflectObject.cpp +++ b/Libraries/LibJS/Runtime/ReflectObject.cpp @@ -80,8 +80,9 @@ ReflectObject::ReflectObject(GlobalObject& global_object) { } -void ReflectObject::initialize(Interpreter&, GlobalObject&) +void ReflectObject::initialize(Interpreter& interpreter, GlobalObject& global_object) { + Object::initialize(interpreter, global_object); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function("apply", apply, 3, attr); define_native_function("construct", construct, 2, attr); diff --git a/Libraries/LibJS/Runtime/RegExpConstructor.cpp b/Libraries/LibJS/Runtime/RegExpConstructor.cpp index ad70bd051f8..4996f24a424 100644 --- a/Libraries/LibJS/Runtime/RegExpConstructor.cpp +++ b/Libraries/LibJS/Runtime/RegExpConstructor.cpp @@ -37,8 +37,9 @@ RegExpConstructor::RegExpConstructor(GlobalObject& global_object) { } -void RegExpConstructor::initialize(Interpreter&, GlobalObject& global_object) +void RegExpConstructor::initialize(Interpreter& interpreter, GlobalObject& global_object) { + NativeFunction::initialize(interpreter, global_object); define_property("prototype", global_object.regexp_prototype(), 0); define_property("length", Value(2), Attribute::Configurable); } diff --git a/Libraries/LibJS/Runtime/ScriptFunction.cpp b/Libraries/LibJS/Runtime/ScriptFunction.cpp index 368dbd21d19..650d7937da3 100644 --- a/Libraries/LibJS/Runtime/ScriptFunction.cpp +++ b/Libraries/LibJS/Runtime/ScriptFunction.cpp @@ -65,6 +65,7 @@ ScriptFunction::ScriptFunction(GlobalObject& global_object, const FlyString& nam void ScriptFunction::initialize(Interpreter& interpreter, GlobalObject& global_object) { + Function::initialize(interpreter, global_object); if (!m_is_arrow_function) define_property("prototype", Object::create_empty(interpreter, global_object), 0); define_native_property("length", length_getter, nullptr, Attribute::Configurable); diff --git a/Libraries/LibJS/Runtime/StringConstructor.cpp b/Libraries/LibJS/Runtime/StringConstructor.cpp index 06b46a48cb0..c5901ea8fde 100644 --- a/Libraries/LibJS/Runtime/StringConstructor.cpp +++ b/Libraries/LibJS/Runtime/StringConstructor.cpp @@ -40,8 +40,9 @@ StringConstructor::StringConstructor(GlobalObject& global_object) { } -void StringConstructor::initialize(Interpreter&, GlobalObject& global_object) +void StringConstructor::initialize(Interpreter& interpreter, GlobalObject& global_object) { + NativeFunction::initialize(interpreter, global_object); define_property("prototype", global_object.string_prototype(), 0); define_property("length", Value(1), Attribute::Configurable); diff --git a/Libraries/LibJS/Runtime/StringPrototype.cpp b/Libraries/LibJS/Runtime/StringPrototype.cpp index 73b67607053..29f06b61618 100644 --- a/Libraries/LibJS/Runtime/StringPrototype.cpp +++ b/Libraries/LibJS/Runtime/StringPrototype.cpp @@ -64,8 +64,9 @@ StringPrototype::StringPrototype(GlobalObject& global_object) { } -void StringPrototype::initialize(Interpreter&, GlobalObject&) +void StringPrototype::initialize(Interpreter& interpreter, GlobalObject& global_object) { + StringObject::initialize(interpreter, global_object); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_property("length", length_getter, nullptr, 0); diff --git a/Libraries/LibJS/Runtime/SymbolConstructor.cpp b/Libraries/LibJS/Runtime/SymbolConstructor.cpp index 6eb52a93cf5..4a74c4d0bcf 100644 --- a/Libraries/LibJS/Runtime/SymbolConstructor.cpp +++ b/Libraries/LibJS/Runtime/SymbolConstructor.cpp @@ -39,6 +39,7 @@ SymbolConstructor::SymbolConstructor(GlobalObject& global_object) void SymbolConstructor::initialize(Interpreter& interpreter, GlobalObject& global_object) { + NativeFunction::initialize(interpreter, global_object); define_property("prototype", global_object.symbol_prototype(), 0); define_property("length", Value(0), Attribute::Configurable); diff --git a/Libraries/LibJS/Runtime/SymbolPrototype.cpp b/Libraries/LibJS/Runtime/SymbolPrototype.cpp index a6bd6106a94..09238db05dc 100644 --- a/Libraries/LibJS/Runtime/SymbolPrototype.cpp +++ b/Libraries/LibJS/Runtime/SymbolPrototype.cpp @@ -44,10 +44,10 @@ SymbolPrototype::SymbolPrototype(GlobalObject& global_object) { } -void SymbolPrototype::initialize(Interpreter&, GlobalObject&) +void SymbolPrototype::initialize(Interpreter& interpreter, GlobalObject& global_object) { + Object::initialize(interpreter, global_object); define_native_property("description", description_getter, nullptr, Attribute::Configurable); - define_native_function("toString", to_string, 0, Attribute::Writable | Attribute::Configurable); define_native_function("valueOf", value_of, 0, Attribute::Writable | Attribute::Configurable); }