From f4867572b7bdc13c3d868b297257c23de3d1aee0 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Fri, 25 Jun 2021 18:37:14 +0100 Subject: [PATCH] LibJS: Change PropertyName(Symbol*) => PropertyName(Symbol&) Requires a bunch of find-and-replace updates across LibJS, but constructing a PropertyName from a nullptr Symbol* should not be possible - let's enforce this at the compiler level instead of using VERIFY() (and already dereference Symbol pointers at the call site). --- .../Libraries/LibJS/Runtime/AbstractOperations.cpp | 2 +- .../Libraries/LibJS/Runtime/ArrayBufferConstructor.cpp | 2 +- .../Libraries/LibJS/Runtime/ArrayBufferPrototype.cpp | 2 +- Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp | 2 +- .../Libraries/LibJS/Runtime/ArrayIteratorPrototype.cpp | 2 +- Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp | 8 ++++---- Userland/Libraries/LibJS/Runtime/BigIntPrototype.cpp | 2 +- Userland/Libraries/LibJS/Runtime/DataViewPrototype.cpp | 2 +- Userland/Libraries/LibJS/Runtime/DatePrototype.cpp | 2 +- .../LibJS/Runtime/FinalizationRegistryPrototype.cpp | 2 +- Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp | 2 +- .../LibJS/Runtime/GeneratorFunctionPrototype.cpp | 2 +- .../LibJS/Runtime/GeneratorObjectPrototype.cpp | 2 +- .../Libraries/LibJS/Runtime/IteratorOperations.cpp | 2 +- Userland/Libraries/LibJS/Runtime/IteratorPrototype.cpp | 4 +++- Userland/Libraries/LibJS/Runtime/JSONObject.cpp | 2 +- Userland/Libraries/LibJS/Runtime/MapConstructor.cpp | 2 +- .../Libraries/LibJS/Runtime/MapIteratorPrototype.cpp | 2 +- Userland/Libraries/LibJS/Runtime/MapPrototype.cpp | 4 ++-- Userland/Libraries/LibJS/Runtime/MathObject.cpp | 2 +- Userland/Libraries/LibJS/Runtime/ObjectPrototype.cpp | 2 +- .../Libraries/LibJS/Runtime/PromiseConstructor.cpp | 2 +- Userland/Libraries/LibJS/Runtime/PromisePrototype.cpp | 2 +- Userland/Libraries/LibJS/Runtime/PropertyName.h | 7 +++---- Userland/Libraries/LibJS/Runtime/ReflectObject.cpp | 2 +- Userland/Libraries/LibJS/Runtime/RegExpConstructor.cpp | 2 +- Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp | 4 ++-- Userland/Libraries/LibJS/Runtime/SetConstructor.cpp | 2 +- .../Libraries/LibJS/Runtime/SetIteratorPrototype.cpp | 2 +- Userland/Libraries/LibJS/Runtime/SetPrototype.cpp | 4 ++-- .../LibJS/Runtime/StringIteratorPrototype.cpp | 2 +- Userland/Libraries/LibJS/Runtime/StringPrototype.cpp | 10 +++++----- Userland/Libraries/LibJS/Runtime/SymbolPrototype.cpp | 4 ++-- Userland/Libraries/LibJS/Runtime/TypedArray.cpp | 2 +- .../Libraries/LibJS/Runtime/TypedArrayConstructor.cpp | 2 +- .../Libraries/LibJS/Runtime/TypedArrayPrototype.cpp | 2 +- Userland/Libraries/LibJS/Runtime/Value.cpp | 9 +++++---- Userland/Libraries/LibJS/Runtime/WeakMapPrototype.cpp | 2 +- Userland/Libraries/LibJS/Runtime/WeakRefPrototype.cpp | 2 +- Userland/Libraries/LibJS/Runtime/WeakSetPrototype.cpp | 2 +- 40 files changed, 59 insertions(+), 57 deletions(-) diff --git a/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp b/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp index 83c9c9ee4f6..a675a4992f2 100644 --- a/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp +++ b/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp @@ -112,7 +112,7 @@ Function* species_constructor(GlobalObject& global_object, Object const& object, vm.throw_exception(global_object, ErrorType::NotAConstructor, constructor.to_string_without_side_effects()); return nullptr; } - auto species = constructor.as_object().get(vm.well_known_symbol_species()).value_or(js_undefined()); + auto species = constructor.as_object().get(*vm.well_known_symbol_species()).value_or(js_undefined()); if (species.is_nullish()) return &default_constructor; if (species.is_constructor()) diff --git a/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.cpp index 2b28e49bd53..1b35ef78e23 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.cpp @@ -31,7 +31,7 @@ void ArrayBufferConstructor::initialize(GlobalObject& global_object) define_native_function(vm.names.isView, is_view, 1, attr); // 25.1.5.4 ArrayBuffer.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-arraybuffer.prototype-@@tostringtag - define_native_accessor(vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable); + define_native_accessor(*vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable); } ArrayBufferConstructor::~ArrayBufferConstructor() diff --git a/Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.cpp index 388870406fa..2df5dfb1b4a 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.cpp @@ -28,7 +28,7 @@ void ArrayBufferPrototype::initialize(GlobalObject& global_object) define_native_accessor(vm.names.byteLength, byte_length_getter, {}, Attribute::Configurable); // 25.1.5.4 ArrayBuffer.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-arraybuffer.prototype-@@tostringtag - define_property(vm.well_known_symbol_to_string_tag(), js_string(vm.heap(), vm.names.ArrayBuffer.as_string()), Attribute::Configurable); + define_property(*vm.well_known_symbol_to_string_tag(), js_string(vm.heap(), vm.names.ArrayBuffer.as_string()), Attribute::Configurable); } ArrayBufferPrototype::~ArrayBufferPrototype() diff --git a/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp index f55b25ef2f8..10e1f915949 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp @@ -41,7 +41,7 @@ void ArrayConstructor::initialize(GlobalObject& global_object) define_native_function(vm.names.of, of, 0, attr); // 23.1.2.5 get Array [ @@species ], https://tc39.es/ecma262/#sec-get-array-@@species - define_native_accessor(vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable); + define_native_accessor(*vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable); } // 23.1.1.1 Array ( ...values ), https://tc39.es/ecma262/#sec-array diff --git a/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.cpp index 9662b7557da..fdec91b0a4c 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.cpp @@ -26,7 +26,7 @@ void ArrayIteratorPrototype::initialize(GlobalObject& global_object) define_native_function(vm.names.next, next, 0, Attribute::Configurable | Attribute::Writable); // 23.1.5.2.2 %ArrayIteratorPrototype% [ @@toStringTag ], https://tc39.es/ecma262/#sec-%arrayiteratorprototype%-@@tostringtag - define_property(vm.well_known_symbol_to_string_tag(), js_string(global_object.heap(), "Array Iterator"), Attribute::Configurable); + define_property(*vm.well_known_symbol_to_string_tag(), js_string(global_object.heap(), "Array Iterator"), Attribute::Configurable); } ArrayIteratorPrototype::~ArrayIteratorPrototype() diff --git a/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp index 595571d8014..29cf5f6f5e8 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp @@ -73,7 +73,7 @@ void ArrayPrototype::initialize(GlobalObject& global_object) // Object.is(Array.prototype[Symbol.iterator], Array.prototype.values) // evaluates to true // 23.1.3.33 Array.prototype [ @@iterator ] ( ), https://tc39.es/ecma262/#sec-array.prototype-@@iterator - define_property(vm.well_known_symbol_iterator(), get(vm.names.values), attr); + define_property(*vm.well_known_symbol_iterator(), get(vm.names.values), attr); // 23.1.3.34 Array.prototype [ @@unscopables ], https://tc39.es/ecma262/#sec-array.prototype-@@unscopables auto* unscopable_list = Object::create(global_object, nullptr); @@ -88,7 +88,7 @@ void ArrayPrototype::initialize(GlobalObject& global_object) unscopable_list->define_property(vm.names.keys, Value(true)); unscopable_list->define_property(vm.names.values, Value(true)); - define_property(vm.well_known_symbol_unscopables(), unscopable_list, Attribute::Configurable); + define_property(*vm.well_known_symbol_unscopables(), unscopable_list, Attribute::Configurable); } ArrayPrototype::~ArrayPrototype() @@ -161,7 +161,7 @@ static Object* array_species_create(GlobalObject& global_object, Object& origina } if (constructor.is_object()) { - constructor = constructor.as_object().get(vm.well_known_symbol_species()).value_or(js_undefined()); + constructor = constructor.as_object().get(*vm.well_known_symbol_species()).value_or(js_undefined()); if (vm.exception()) return {}; if (constructor.is_null()) @@ -524,7 +524,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::concat) if (vm.exception()) return false; - auto spreadable = object->get(vm.well_known_symbol_is_concat_spreadable()).value_or(js_undefined()); + auto spreadable = object->get(*vm.well_known_symbol_is_concat_spreadable()).value_or(js_undefined()); if (vm.exception()) return false; diff --git a/Userland/Libraries/LibJS/Runtime/BigIntPrototype.cpp b/Userland/Libraries/LibJS/Runtime/BigIntPrototype.cpp index 8d973784bca..87a1b6832ae 100644 --- a/Userland/Libraries/LibJS/Runtime/BigIntPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/BigIntPrototype.cpp @@ -27,7 +27,7 @@ void BigIntPrototype::initialize(GlobalObject& global_object) define_native_function(vm.names.valueOf, value_of, 0, attr); // 21.2.3.5 BigInt.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-bigint.prototype-@@tostringtag - define_property(vm.well_known_symbol_to_string_tag(), js_string(global_object.heap(), vm.names.BigInt.as_string()), Attribute::Configurable); + define_property(*vm.well_known_symbol_to_string_tag(), js_string(global_object.heap(), vm.names.BigInt.as_string()), Attribute::Configurable); } BigIntPrototype::~BigIntPrototype() diff --git a/Userland/Libraries/LibJS/Runtime/DataViewPrototype.cpp b/Userland/Libraries/LibJS/Runtime/DataViewPrototype.cpp index b221f172d84..ce5171016a4 100644 --- a/Userland/Libraries/LibJS/Runtime/DataViewPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/DataViewPrototype.cpp @@ -45,7 +45,7 @@ void DataViewPrototype::initialize(GlobalObject& global_object) define_native_accessor(vm.names.byteOffset, byte_offset_getter, {}, Attribute::Configurable); // 25.3.4.25 DataView.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-dataview.prototype-@@tostringtag - define_property(vm.well_known_symbol_to_string_tag(), js_string(global_object.heap(), vm.names.DataView.as_string()), Attribute::Configurable); + define_property(*vm.well_known_symbol_to_string_tag(), js_string(global_object.heap(), vm.names.DataView.as_string()), Attribute::Configurable); } DataViewPrototype::~DataViewPrototype() diff --git a/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp b/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp index 450c83244e0..8456b6f0828 100644 --- a/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp @@ -85,7 +85,7 @@ void DatePrototype::initialize(GlobalObject& global_object) define_native_function(vm.names.toJSON, to_json, 1, attr); // 21.4.4.45 Date.prototype [ @@toPrimitive ] ( hint ), https://tc39.es/ecma262/#sec-date.prototype-@@toprimitive - define_native_function(vm.well_known_symbol_to_primitive(), symbol_to_primitive, 1, Attribute::Configurable); + define_native_function(*vm.well_known_symbol_to_primitive(), symbol_to_primitive, 1, Attribute::Configurable); // Aliases. define_native_function(vm.names.valueOf, get_time, 0, attr); diff --git a/Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.cpp b/Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.cpp index 6993a08bb98..f1afa3863d3 100644 --- a/Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.cpp @@ -24,7 +24,7 @@ void FinalizationRegistryPrototype::initialize(GlobalObject& global_object) define_native_function(vm.names.unregister, unregister, 1, attr); // 26.2.3.4 FinalizationRegistry.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-finalization-registry.prototype-@@tostringtag - define_property(vm.well_known_symbol_to_string_tag(), js_string(global_object.heap(), vm.names.FinalizationRegistry.as_string()), Attribute::Configurable); + define_property(*vm.well_known_symbol_to_string_tag(), js_string(global_object.heap(), vm.names.FinalizationRegistry.as_string()), Attribute::Configurable); } FinalizationRegistryPrototype::~FinalizationRegistryPrototype() diff --git a/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp b/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp index 9a979a98d4f..c2b5ced0aa9 100644 --- a/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp @@ -34,7 +34,7 @@ void FunctionPrototype::initialize(GlobalObject& global_object) define_native_function(vm.names.bind, bind, 1, attr); define_native_function(vm.names.call, call, 1, attr); define_native_function(vm.names.toString, to_string, 0, attr); - define_native_function(vm.well_known_symbol_has_instance(), symbol_has_instance, 1, 0); + define_native_function(*vm.well_known_symbol_has_instance(), symbol_has_instance, 1, 0); define_property(vm.names.length, Value(0), Attribute::Configurable); define_property(vm.names.name, js_string(heap(), ""), Attribute::Configurable); } diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorFunctionPrototype.cpp b/Userland/Libraries/LibJS/Runtime/GeneratorFunctionPrototype.cpp index a2c7c6efa64..df7226ad303 100644 --- a/Userland/Libraries/LibJS/Runtime/GeneratorFunctionPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/GeneratorFunctionPrototype.cpp @@ -23,7 +23,7 @@ void GeneratorFunctionPrototype::initialize(GlobalObject& global_object) // 27.3.3.2 %GeneratorFunction.prototype% prototype, https://tc39.es/ecma262/#sec-generatorfunction.prototype.prototype define_property(vm.names.prototype, global_object.generator_object_prototype(), Attribute::Configurable); // 27.3.3.3 %GeneratorFunction.prototype% [ @@toStringTag ], https://tc39.es/ecma262/#sec-generatorfunction.prototype-@@tostringtag - define_property(vm.well_known_symbol_to_string_tag(), js_string(vm, "GeneratorFunction"), Attribute::Configurable); + define_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "GeneratorFunction"), Attribute::Configurable); } GeneratorFunctionPrototype::~GeneratorFunctionPrototype() diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorObjectPrototype.cpp b/Userland/Libraries/LibJS/Runtime/GeneratorObjectPrototype.cpp index 48141a0751b..780950c3199 100644 --- a/Userland/Libraries/LibJS/Runtime/GeneratorObjectPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/GeneratorObjectPrototype.cpp @@ -37,7 +37,7 @@ void GeneratorObjectPrototype::initialize(GlobalObject& global_object) define_native_function(vm.names.throw_, throw_, 1, attr); // 27.5.1.5 Generator.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-generator.prototype-@@tostringtag - define_property(vm.well_known_symbol_to_string_tag(), js_string(vm, "Generator"), Attribute::Configurable); + define_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Generator"), Attribute::Configurable); } GeneratorObjectPrototype::~GeneratorObjectPrototype() diff --git a/Userland/Libraries/LibJS/Runtime/IteratorOperations.cpp b/Userland/Libraries/LibJS/Runtime/IteratorOperations.cpp index f7e6a1a9c93..c8770a96829 100644 --- a/Userland/Libraries/LibJS/Runtime/IteratorOperations.cpp +++ b/Userland/Libraries/LibJS/Runtime/IteratorOperations.cpp @@ -21,7 +21,7 @@ Object* get_iterator(GlobalObject& global_object, Value value, IteratorHint hint auto object = value.to_object(global_object); if (!object) return {}; - method = object->get(global_object.vm().well_known_symbol_iterator()); + method = object->get(*vm.well_known_symbol_iterator()); if (vm.exception()) return {}; } diff --git a/Userland/Libraries/LibJS/Runtime/IteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/IteratorPrototype.cpp index 8f55186e513..61eb25c11b6 100644 --- a/Userland/Libraries/LibJS/Runtime/IteratorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/IteratorPrototype.cpp @@ -17,8 +17,10 @@ IteratorPrototype::IteratorPrototype(GlobalObject& global_object) void IteratorPrototype::initialize(GlobalObject& global_object) { + auto& vm = this->vm(); Object::initialize(global_object); - define_native_function(global_object.vm().well_known_symbol_iterator(), symbol_iterator, 0, Attribute::Writable | Attribute::Enumerable); + u8 attr = Attribute::Writable | Attribute::Enumerable; + define_native_function(*vm.well_known_symbol_iterator(), symbol_iterator, 0, attr); } IteratorPrototype::~IteratorPrototype() diff --git a/Userland/Libraries/LibJS/Runtime/JSONObject.cpp b/Userland/Libraries/LibJS/Runtime/JSONObject.cpp index 736941d39bf..0147aa345c4 100644 --- a/Userland/Libraries/LibJS/Runtime/JSONObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/JSONObject.cpp @@ -36,7 +36,7 @@ void JSONObject::initialize(GlobalObject& global_object) define_native_function(vm.names.parse, parse, 2, attr); // 25.5.3 JSON [ @@toStringTag ], https://tc39.es/ecma262/#sec-json-@@tostringtag - define_property(vm.well_known_symbol_to_string_tag(), js_string(global_object.heap(), "JSON"), Attribute::Configurable); + define_property(*vm.well_known_symbol_to_string_tag(), js_string(global_object.heap(), "JSON"), Attribute::Configurable); } JSONObject::~JSONObject() diff --git a/Userland/Libraries/LibJS/Runtime/MapConstructor.cpp b/Userland/Libraries/LibJS/Runtime/MapConstructor.cpp index efc3a6e3d07..cea85d6d42a 100644 --- a/Userland/Libraries/LibJS/Runtime/MapConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/MapConstructor.cpp @@ -28,7 +28,7 @@ void MapConstructor::initialize(GlobalObject& global_object) define_property(vm.names.length, Value(0), Attribute::Configurable); - define_native_accessor(vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable); + define_native_accessor(*vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable); } MapConstructor::~MapConstructor() diff --git a/Userland/Libraries/LibJS/Runtime/MapIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/MapIteratorPrototype.cpp index 927b3de61a0..a90a90e6d73 100644 --- a/Userland/Libraries/LibJS/Runtime/MapIteratorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/MapIteratorPrototype.cpp @@ -24,7 +24,7 @@ void MapIteratorPrototype::initialize(GlobalObject& global_object) Object::initialize(global_object); define_native_function(vm.names.next, next, 0, Attribute::Configurable | Attribute::Writable); - define_property(vm.well_known_symbol_to_string_tag(), js_string(global_object.heap(), "Map Iterator"), Attribute::Configurable); + define_property(*vm.well_known_symbol_to_string_tag(), js_string(global_object.heap(), "Map Iterator"), Attribute::Configurable); } MapIteratorPrototype::~MapIteratorPrototype() diff --git a/Userland/Libraries/LibJS/Runtime/MapPrototype.cpp b/Userland/Libraries/LibJS/Runtime/MapPrototype.cpp index 10d9f64f207..07760674ec3 100644 --- a/Userland/Libraries/LibJS/Runtime/MapPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/MapPrototype.cpp @@ -33,8 +33,8 @@ void MapPrototype::initialize(GlobalObject& global_object) define_native_accessor(vm.names.size, size_getter, {}, Attribute::Configurable); - define_property(vm.well_known_symbol_iterator(), Object::get(vm.names.entries), attr); - define_property(vm.well_known_symbol_to_string_tag(), js_string(global_object.heap(), vm.names.Map.as_string()), Attribute::Configurable); + define_property(*vm.well_known_symbol_iterator(), Object::get(vm.names.entries), attr); + define_property(*vm.well_known_symbol_to_string_tag(), js_string(global_object.heap(), vm.names.Map.as_string()), Attribute::Configurable); } MapPrototype::~MapPrototype() diff --git a/Userland/Libraries/LibJS/Runtime/MathObject.cpp b/Userland/Libraries/LibJS/Runtime/MathObject.cpp index b20491b7975..cf15d6e280f 100644 --- a/Userland/Libraries/LibJS/Runtime/MathObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/MathObject.cpp @@ -71,7 +71,7 @@ void MathObject::initialize(GlobalObject& global_object) define_property(vm.names.SQRT2, Value(M_SQRT2), 0); // 21.3.1.9 Math [ @@toStringTag ], https://tc39.es/ecma262/#sec-math-@@tostringtag - define_property(vm.well_known_symbol_to_string_tag(), js_string(vm.heap(), vm.names.Math.as_string()), Attribute::Configurable); + define_property(*vm.well_known_symbol_to_string_tag(), js_string(vm.heap(), vm.names.Math.as_string()), Attribute::Configurable); } MathObject::~MathObject() diff --git a/Userland/Libraries/LibJS/Runtime/ObjectPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ObjectPrototype.cpp index d69b2427382..863315cf9fa 100644 --- a/Userland/Libraries/LibJS/Runtime/ObjectPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/ObjectPrototype.cpp @@ -76,7 +76,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectPrototype::to_string) VERIFY(this_object); String tag; - auto to_string_tag = this_object->get(vm.well_known_symbol_to_string_tag()); + auto to_string_tag = this_object->get(*vm.well_known_symbol_to_string_tag()); if (to_string_tag.is_string()) { tag = to_string_tag.as_string().string(); diff --git a/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp b/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp index e71d37135e1..beda396b18e 100644 --- a/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp @@ -39,7 +39,7 @@ void PromiseConstructor::initialize(GlobalObject& global_object) define_native_function(vm.names.reject, reject, 1, attr); define_native_function(vm.names.resolve, resolve, 1, attr); - define_native_accessor(vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable); + define_native_accessor(*vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable); } // 27.2.3.1 Promise ( executor ), https://tc39.es/ecma262/#sec-promise-executor diff --git a/Userland/Libraries/LibJS/Runtime/PromisePrototype.cpp b/Userland/Libraries/LibJS/Runtime/PromisePrototype.cpp index b071633dcd4..7ff00b4f4bc 100644 --- a/Userland/Libraries/LibJS/Runtime/PromisePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/PromisePrototype.cpp @@ -32,7 +32,7 @@ void PromisePrototype::initialize(GlobalObject& global_object) define_native_function(vm.names.finally, finally, 1, attr); // 27.2.5.5 Promise.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-promise.prototype-@@tostringtag - define_property(vm.well_known_symbol_to_string_tag(), js_string(vm.heap(), vm.names.Promise.as_string()), Attribute::Configurable); + define_property(*vm.well_known_symbol_to_string_tag(), js_string(vm.heap(), vm.names.Promise.as_string()), Attribute::Configurable); } static Promise* promise_from(VM& vm, GlobalObject& global_object) diff --git a/Userland/Libraries/LibJS/Runtime/PropertyName.h b/Userland/Libraries/LibJS/Runtime/PropertyName.h index 7e9e791020f..7b625241848 100644 --- a/Userland/Libraries/LibJS/Runtime/PropertyName.h +++ b/Userland/Libraries/LibJS/Runtime/PropertyName.h @@ -30,7 +30,7 @@ public: if (value.is_empty()) return {}; if (value.is_symbol()) - return &value.as_symbol(); + return value.as_symbol(); if (value.is_integral_number() && value.as_i32() >= 0) return value.as_i32(); auto string = value.to_string(global_object); @@ -69,11 +69,10 @@ public: VERIFY(!string.is_null()); } - PropertyName(Symbol* symbol) + PropertyName(Symbol& symbol) : m_type(Type::Symbol) - , m_symbol(symbol) + , m_symbol(&symbol) { - VERIFY(symbol); } PropertyName(StringOrSymbol const& string_or_symbol) diff --git a/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp b/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp index 8598c3f546d..aa2b9b5cf5b 100644 --- a/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp @@ -62,7 +62,7 @@ void ReflectObject::initialize(GlobalObject& global_object) define_native_function(vm.names.setPrototypeOf, set_prototype_of, 2, attr); // 28.1.14 Reflect [ @@toStringTag ], https://tc39.es/ecma262/#sec-reflect-@@tostringtag - Object::define_property(vm.well_known_symbol_to_string_tag(), js_string(vm.heap(), vm.names.Reflect.as_string()), Attribute::Configurable); + Object::define_property(*vm.well_known_symbol_to_string_tag(), js_string(vm.heap(), vm.names.Reflect.as_string()), Attribute::Configurable); } ReflectObject::~ReflectObject() diff --git a/Userland/Libraries/LibJS/Runtime/RegExpConstructor.cpp b/Userland/Libraries/LibJS/Runtime/RegExpConstructor.cpp index 0f85ca53e47..b556a121c93 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/RegExpConstructor.cpp @@ -26,7 +26,7 @@ void RegExpConstructor::initialize(GlobalObject& global_object) define_property(vm.names.length, Value(2), Attribute::Configurable); - define_native_accessor(vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable); + define_native_accessor(*vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable); } RegExpConstructor::~RegExpConstructor() diff --git a/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp b/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp index f4ee2a6117d..3471d5e39e9 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp @@ -30,8 +30,8 @@ void RegExpPrototype::initialize(GlobalObject& global_object) define_native_function(vm.names.test, test, 1, attr); define_native_function(vm.names.exec, exec, 1, attr); - define_native_function(vm.well_known_symbol_match(), symbol_match, 1, attr); - define_native_function(vm.well_known_symbol_replace(), symbol_replace, 2, attr); + define_native_function(*vm.well_known_symbol_match(), symbol_match, 1, attr); + define_native_function(*vm.well_known_symbol_replace(), symbol_replace, 2, attr); define_native_accessor(vm.names.flags, flags, {}, Attribute::Configurable); define_native_accessor(vm.names.source, source, {}, Attribute::Configurable); diff --git a/Userland/Libraries/LibJS/Runtime/SetConstructor.cpp b/Userland/Libraries/LibJS/Runtime/SetConstructor.cpp index fa53125d868..cddf37dca15 100644 --- a/Userland/Libraries/LibJS/Runtime/SetConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/SetConstructor.cpp @@ -28,7 +28,7 @@ void SetConstructor::initialize(GlobalObject& global_object) define_property(vm.names.length, Value(0), Attribute::Configurable); - define_native_accessor(vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable); + define_native_accessor(*vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable); } SetConstructor::~SetConstructor() diff --git a/Userland/Libraries/LibJS/Runtime/SetIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/SetIteratorPrototype.cpp index b1d9f3e0dd3..4de14bb529a 100644 --- a/Userland/Libraries/LibJS/Runtime/SetIteratorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/SetIteratorPrototype.cpp @@ -27,7 +27,7 @@ void SetIteratorPrototype::initialize(GlobalObject& global_object) define_native_function(vm.names.next, next, 0, Attribute::Configurable | Attribute::Writable); // 24.2.5.2.2 %SetIteratorPrototype% [ @@toStringTag ], https://tc39.es/ecma262/#sec-%setiteratorprototype%-@@tostringtag - define_property(vm.well_known_symbol_to_string_tag(), js_string(global_object.heap(), "Set Iterator"), Attribute::Configurable); + define_property(*vm.well_known_symbol_to_string_tag(), js_string(global_object.heap(), "Set Iterator"), Attribute::Configurable); } SetIteratorPrototype::~SetIteratorPrototype() diff --git a/Userland/Libraries/LibJS/Runtime/SetPrototype.cpp b/Userland/Libraries/LibJS/Runtime/SetPrototype.cpp index 91a9d82c3d1..b2d14baf652 100644 --- a/Userland/Libraries/LibJS/Runtime/SetPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/SetPrototype.cpp @@ -33,10 +33,10 @@ void SetPrototype::initialize(GlobalObject& global_object) define_property(vm.names.keys, get(vm.names.values), attr); // 24.2.3.11 Set.prototype [ @@iterator ] ( ), https://tc39.es/ecma262/#sec-set.prototype-@@iterator - define_property(vm.well_known_symbol_iterator(), get(vm.names.values), attr); + define_property(*vm.well_known_symbol_iterator(), get(vm.names.values), attr); // 24.2.3.12 Set.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-set.prototype-@@tostringtag - define_property(vm.well_known_symbol_to_string_tag(), js_string(vm.heap(), vm.names.Set.as_string()), Attribute::Configurable); + define_property(*vm.well_known_symbol_to_string_tag(), js_string(vm.heap(), vm.names.Set.as_string()), Attribute::Configurable); } SetPrototype::~SetPrototype() diff --git a/Userland/Libraries/LibJS/Runtime/StringIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/StringIteratorPrototype.cpp index 8aa0163494a..080b7f9908b 100644 --- a/Userland/Libraries/LibJS/Runtime/StringIteratorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/StringIteratorPrototype.cpp @@ -25,7 +25,7 @@ void StringIteratorPrototype::initialize(GlobalObject& global_object) define_native_function(vm.names.next, next, 0, Attribute::Configurable | Attribute::Writable); // 22.1.5.1.2 %StringIteratorPrototype% [ @@toStringTag ], https://tc39.es/ecma262/#sec-%stringiteratorprototype%-@@tostringtag - define_property(vm.well_known_symbol_to_string_tag(), js_string(global_object.heap(), "String Iterator"), Attribute::Configurable); + define_property(*vm.well_known_symbol_to_string_tag(), js_string(global_object.heap(), "String Iterator"), Attribute::Configurable); } StringIteratorPrototype::~StringIteratorPrototype() diff --git a/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp b/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp index e324fbb05c2..008dcef34b1 100644 --- a/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp @@ -96,7 +96,7 @@ void StringPrototype::initialize(GlobalObject& global_object) define_native_function(vm.names.strike, strike, 0, attr); define_native_function(vm.names.sub, sub, 0, attr); define_native_function(vm.names.sup, sup, 0, attr); - define_native_function(vm.well_known_symbol_iterator(), symbol_iterator, 0, attr); + define_native_function(*vm.well_known_symbol_iterator(), symbol_iterator, 0, attr); } StringPrototype::~StringPrototype() @@ -702,7 +702,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::match) return {}; auto regexp = vm.argument(0); if (!regexp.is_nullish()) { - if (auto* matcher = get_method(global_object, regexp, vm.well_known_symbol_match())) + if (auto* matcher = get_method(global_object, regexp, *vm.well_known_symbol_match())) return vm.call(*matcher, regexp, this_object); } auto s = this_object.to_string(global_object); @@ -740,7 +740,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::match_all) return {}; } } - if (auto* matcher = get_method(global_object, regexp, vm.well_known_symbol_match_all())) + if (auto* matcher = get_method(global_object, regexp, *vm.well_known_symbol_match_all())) return vm.call(*matcher, regexp, this_object); if (vm.exception()) return {}; @@ -764,7 +764,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::replace) auto replace_value = vm.argument(1); if (!search_value.is_nullish()) { - if (auto* replacer = get_method(global_object, search_value, vm.well_known_symbol_replace())) + if (auto* replacer = get_method(global_object, search_value, *vm.well_known_symbol_replace())) return vm.call(*replacer, search_value, this_object, replace_value); } @@ -812,7 +812,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::search) return {}; auto regexp = vm.argument(0); if (!regexp.is_nullish()) { - if (auto* searcher = get_method(global_object, regexp, vm.well_known_symbol_search())) + if (auto* searcher = get_method(global_object, regexp, *vm.well_known_symbol_search())) return vm.call(*searcher, regexp, this_object); if (vm.exception()) return {}; diff --git a/Userland/Libraries/LibJS/Runtime/SymbolPrototype.cpp b/Userland/Libraries/LibJS/Runtime/SymbolPrototype.cpp index 5780bba5c4a..8c21729e04e 100644 --- a/Userland/Libraries/LibJS/Runtime/SymbolPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/SymbolPrototype.cpp @@ -30,10 +30,10 @@ void SymbolPrototype::initialize(GlobalObject& global_object) define_native_function(vm.names.toString, to_string, 0, attr); define_native_function(vm.names.valueOf, value_of, 0, attr); define_native_accessor(vm.names.description, description_getter, {}, Attribute::Configurable); - define_native_function(vm.well_known_symbol_to_primitive(), symbol_to_primitive, 1, Attribute::Configurable); + define_native_function(*vm.well_known_symbol_to_primitive(), symbol_to_primitive, 1, Attribute::Configurable); // 20.4.3.6 Symbol.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-symbol.prototype-@@tostringtag - define_property(vm.well_known_symbol_to_string_tag(), js_string(global_object.heap(), "Symbol"), Attribute::Configurable); + define_property(*vm.well_known_symbol_to_string_tag(), js_string(global_object.heap(), "Symbol"), Attribute::Configurable); } SymbolPrototype::~SymbolPrototype() diff --git a/Userland/Libraries/LibJS/Runtime/TypedArray.cpp b/Userland/Libraries/LibJS/Runtime/TypedArray.cpp index 9df1b56c2c8..a3c50fd3d14 100644 --- a/Userland/Libraries/LibJS/Runtime/TypedArray.cpp +++ b/Userland/Libraries/LibJS/Runtime/TypedArray.cpp @@ -266,7 +266,7 @@ void TypedArrayBase::visit_edges(Visitor& visitor) if (vm.exception()) \ return {}; \ } else { \ - auto iterator = first_argument.as_object().get(vm.well_known_symbol_iterator()); \ + auto iterator = first_argument.as_object().get(*vm.well_known_symbol_iterator()); \ if (vm.exception()) \ return {}; \ if (iterator.is_function()) { \ diff --git a/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp b/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp index fa045b9c59a..b1ff8ae7e72 100644 --- a/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp @@ -33,7 +33,7 @@ void TypedArrayConstructor::initialize(GlobalObject& global_object) u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(vm.names.of, of, 0, attr); - define_native_accessor(vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable); + define_native_accessor(*vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable); } TypedArrayConstructor::~TypedArrayConstructor() diff --git a/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp b/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp index e438a069db0..6819c7367a1 100644 --- a/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp @@ -34,7 +34,7 @@ void TypedArrayPrototype::initialize(GlobalObject& object) define_native_function(vm.names.some, some, 1, attr); define_native_function(vm.names.join, join, 1, attr); - define_native_accessor(vm.well_known_symbol_to_string_tag(), to_string_tag_getter, nullptr, Attribute::Configurable); + define_native_accessor(*vm.well_known_symbol_to_string_tag(), to_string_tag_getter, nullptr, Attribute::Configurable); // 23.2.3.29 %TypedArray%.prototype.toString ( ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.tostring define_property(vm.names.toString, global_object().array_prototype()->get_without_side_effects(vm.names.toString), attr); diff --git a/Userland/Libraries/LibJS/Runtime/Value.cpp b/Userland/Libraries/LibJS/Runtime/Value.cpp index 8461966fac9..a640ccc58c7 100644 --- a/Userland/Libraries/LibJS/Runtime/Value.cpp +++ b/Userland/Libraries/LibJS/Runtime/Value.cpp @@ -252,8 +252,9 @@ bool Value::is_regexp(GlobalObject& global_object) const if (!is_object()) return false; - auto matcher = as_object().get(global_object.vm().well_known_symbol_match()); - if (global_object.vm().exception()) + auto& vm = global_object.vm(); + auto matcher = as_object().get(*vm.well_known_symbol_match()); + if (vm.exception()) return false; if (!matcher.is_empty() && !matcher.is_undefined()) return matcher.to_boolean(); @@ -412,7 +413,7 @@ Value Value::to_primitive(GlobalObject& global_object, PreferredType preferred_t }; if (is_object()) { auto& vm = global_object.vm(); - auto to_primitive_method = get_method(global_object, *this, vm.well_known_symbol_to_primitive()); + auto to_primitive_method = get_method(global_object, *this, *vm.well_known_symbol_to_primitive()); if (vm.exception()) return {}; if (to_primitive_method) { @@ -1187,7 +1188,7 @@ Value instance_of(GlobalObject& global_object, Value lhs, Value rhs) vm.throw_exception(global_object, ErrorType::NotAnObject, rhs.to_string_without_side_effects()); return {}; } - auto has_instance_method = get_method(global_object, Value(&rhs.as_object()), vm.well_known_symbol_has_instance()); + auto has_instance_method = get_method(global_object, Value(&rhs.as_object()), *vm.well_known_symbol_has_instance()); if (vm.exception()) return {}; if (has_instance_method) { diff --git a/Userland/Libraries/LibJS/Runtime/WeakMapPrototype.cpp b/Userland/Libraries/LibJS/Runtime/WeakMapPrototype.cpp index f70453006c6..64476736a88 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakMapPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/WeakMapPrototype.cpp @@ -26,7 +26,7 @@ void WeakMapPrototype::initialize(GlobalObject& global_object) define_native_function(vm.names.set, set, 2, attr); // 24.3.3.6 WeakMap.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-weakmap.prototype-@@tostringtag - define_property(vm.well_known_symbol_to_string_tag(), js_string(vm.heap(), vm.names.WeakMap.as_string()), Attribute::Configurable); + define_property(*vm.well_known_symbol_to_string_tag(), js_string(vm.heap(), vm.names.WeakMap.as_string()), Attribute::Configurable); } WeakMapPrototype::~WeakMapPrototype() diff --git a/Userland/Libraries/LibJS/Runtime/WeakRefPrototype.cpp b/Userland/Libraries/LibJS/Runtime/WeakRefPrototype.cpp index 3ccd52092ad..1b4c210d5dd 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakRefPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/WeakRefPrototype.cpp @@ -20,7 +20,7 @@ void WeakRefPrototype::initialize(GlobalObject& global_object) define_native_function(vm.names.deref, deref, 0, Attribute::Writable | Attribute::Configurable); - define_property(vm.well_known_symbol_to_string_tag(), js_string(vm.heap(), vm.names.WeakRef.as_string()), Attribute::Configurable); + define_property(*vm.well_known_symbol_to_string_tag(), js_string(vm.heap(), vm.names.WeakRef.as_string()), Attribute::Configurable); } WeakRefPrototype::~WeakRefPrototype() diff --git a/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.cpp b/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.cpp index 20e068f2737..96d78b2f219 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.cpp @@ -25,7 +25,7 @@ void WeakSetPrototype::initialize(GlobalObject& global_object) define_native_function(vm.names.has, has, 1, attr); // 24.4.3.5 WeakSet.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-weakset.prototype-@@tostringtag - define_property(vm.well_known_symbol_to_string_tag(), js_string(global_object.heap(), vm.names.WeakSet.as_string()), Attribute::Configurable); + define_property(*vm.well_known_symbol_to_string_tag(), js_string(global_object.heap(), vm.names.WeakSet.as_string()), Attribute::Configurable); } WeakSetPrototype::~WeakSetPrototype()