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).
This commit is contained in:
Linus Groh 2021-06-25 18:37:14 +01:00
parent 3d5340d033
commit f4867572b7
Notes: sideshowbarker 2024-07-18 11:30:34 +09:00
40 changed files with 59 additions and 57 deletions

View file

@ -112,7 +112,7 @@ Function* species_constructor(GlobalObject& global_object, Object const& object,
vm.throw_exception<TypeError>(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())

View file

@ -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()

View file

@ -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()

View file

@ -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

View file

@ -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()

View file

@ -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;

View file

@ -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()

View file

@ -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()

View file

@ -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);

View file

@ -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()

View file

@ -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);
}

View file

@ -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()

View file

@ -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()

View file

@ -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 {};
}

View file

@ -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()

View file

@ -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()

View file

@ -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()

View file

@ -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()

View file

@ -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()

View file

@ -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()

View file

@ -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();

View file

@ -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

View file

@ -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)

View file

@ -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)

View file

@ -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()

View file

@ -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()

View file

@ -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);

View file

@ -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()

View file

@ -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()

View file

@ -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()

View file

@ -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()

View file

@ -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 {};

View file

@ -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()

View file

@ -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()) { \

View file

@ -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()

View file

@ -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);

View file

@ -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<TypeError>(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) {

View file

@ -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()

View file

@ -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()

View file

@ -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()