LibJS: Make well-known symbol getters return NonnullGCPtr

None of these are ever null after the VM has been initialized, as proved
by virtually every caller immediately dereferencing the raw pointer.
This commit is contained in:
Linus Groh 2023-04-13 01:14:45 +02:00
parent b84f8fb55b
commit 2555d7a36a
78 changed files with 122 additions and 121 deletions

View file

@ -887,7 +887,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
if (!@js_name@@js_suffix@.is_object())
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, @js_name@@js_suffix@.to_string_without_side_effects()));
auto* iterator_method@recursion_depth@ = TRY(@js_name@@js_suffix@.get_method(vm, *vm.well_known_symbol_iterator()));
auto* iterator_method@recursion_depth@ = TRY(@js_name@@js_suffix@.get_method(vm, vm.well_known_symbol_iterator()));
if (!iterator_method@recursion_depth@)
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotIterable, TRY_OR_THROW_OOM(vm, @js_name@@js_suffix@.to_string_without_side_effects()));
)~~~");
@ -1169,7 +1169,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
if (sequence_type) {
// 1. Let method be ? GetMethod(V, @@iterator).
union_generator.append(R"~~~(
auto* method = TRY(@js_name@@js_suffix@.get_method(vm, *vm.well_known_symbol_iterator()));
auto* method = TRY(@js_name@@js_suffix@.get_method(vm, vm.well_known_symbol_iterator()));
)~~~");
// 2. If method is not undefined, return the result of creating a sequence of that type from V and method.
@ -2602,7 +2602,7 @@ JS::ThrowCompletionOr<void> @class_name@::initialize(JS::Realm& realm)
if (interface.indexed_property_getter.has_value()) {
auto iterator_generator = generator.fork();
iterator_generator.append(R"~~~(
define_direct_property(*vm.well_known_symbol_iterator(), realm.intrinsics().array_prototype()->get_without_side_effects(vm.names.values), JS::Attribute::Configurable | JS::Attribute::Writable);
define_direct_property(vm.well_known_symbol_iterator(), realm.intrinsics().array_prototype()->get_without_side_effects(vm.names.values), JS::Attribute::Configurable | JS::Attribute::Writable);
)~~~");
if (interface.value_iterator_type.has_value()) {
@ -2625,18 +2625,18 @@ JS::ThrowCompletionOr<void> @class_name@::initialize(JS::Realm& realm)
define_native_function(realm, vm.names.keys, keys, 0, default_attributes);
define_native_function(realm, vm.names.values, values, 0, default_attributes);
define_direct_property(*vm.well_known_symbol_iterator(), get_without_side_effects(vm.names.entries), JS::Attribute::Configurable | JS::Attribute::Writable);
define_direct_property(vm.well_known_symbol_iterator(), get_without_side_effects(vm.names.entries), JS::Attribute::Configurable | JS::Attribute::Writable);
)~~~");
}
if (interface.has_unscopable_member) {
generator.append(R"~~~(
define_direct_property(*vm.well_known_symbol_unscopables(), unscopable_object, JS::Attribute::Configurable);
define_direct_property(vm.well_known_symbol_unscopables(), unscopable_object, JS::Attribute::Configurable);
)~~~");
}
generator.append(R"~~~(
define_direct_property(*vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(JS::PrimitiveString::create(vm, "@namespaced_name@"sv)), JS::Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(JS::PrimitiveString::create(vm, "@namespaced_name@"sv)), JS::Attribute::Configurable);
)~~~");
if (!is_global_interface) {
@ -3835,7 +3835,7 @@ JS::ThrowCompletionOr<void> @prototype_class@::initialize(JS::Realm& realm)
MUST_OR_THROW_OOM(Base::initialize(realm));
define_native_function(realm, vm.names.next, next, 0, JS::Attribute::Writable | JS::Attribute::Enumerable | JS::Attribute::Configurable);
define_direct_property(*vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(JS::PrimitiveString::create(vm, "Iterator"sv)), JS::Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(JS::PrimitiveString::create(vm, "Iterator"sv)), JS::Attribute::Configurable);
return {};
}

View file

@ -147,7 +147,7 @@ ThrowCompletionOr<FunctionObject*> species_constructor(VM& vm, Object const& obj
return vm.throw_completion<TypeError>(ErrorType::NotAConstructor, TRY_OR_THROW_OOM(vm, constructor.to_string_without_side_effects()));
// 4. Let S be ? Get(C, @@species).
auto species = TRY(constructor.as_object().get(*vm.well_known_symbol_species()));
auto species = TRY(constructor.as_object().get(vm.well_known_symbol_species()));
// 5. If S is either undefined or null, return defaultConstructor.
if (species.is_nullish())
@ -1076,7 +1076,7 @@ Object* create_unmapped_arguments_object(VM& vm, Span<Value> arguments)
// 7. Perform ! DefinePropertyOrThrow(obj, @@iterator, PropertyDescriptor { [[Value]]: %Array.prototype.values%, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }).
auto array_prototype_values = realm.intrinsics().array_prototype_values_function();
MUST(object->define_property_or_throw(*vm.well_known_symbol_iterator(), { .value = array_prototype_values, .writable = true, .enumerable = false, .configurable = true }));
MUST(object->define_property_or_throw(vm.well_known_symbol_iterator(), { .value = array_prototype_values, .writable = true, .enumerable = false, .configurable = true }));
// 8. Perform ! DefinePropertyOrThrow(obj, "callee", PropertyDescriptor { [[Get]]: %ThrowTypeError%, [[Set]]: %ThrowTypeError%, [[Enumerable]]: false, [[Configurable]]: false }).
auto throw_type_error = realm.intrinsics().throw_type_error_function();
@ -1159,7 +1159,7 @@ Object* create_mapped_arguments_object(VM& vm, FunctionObject& function, Vector<
// 20. Perform ! DefinePropertyOrThrow(obj, @@iterator, PropertyDescriptor { [[Value]]: %Array.prototype.values%, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }).
auto array_prototype_values = realm.intrinsics().array_prototype_values_function();
MUST(object->define_property_or_throw(*vm.well_known_symbol_iterator(), { .value = array_prototype_values, .writable = true, .enumerable = false, .configurable = true }));
MUST(object->define_property_or_throw(vm.well_known_symbol_iterator(), { .value = array_prototype_values, .writable = true, .enumerable = false, .configurable = true }));
// 21. Perform ! DefinePropertyOrThrow(obj, "callee", PropertyDescriptor { [[Value]]: func, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }).
MUST(object->define_property_or_throw(vm.names.callee, { .value = &function, .writable = true, .enumerable = false, .configurable = true }));
@ -1401,7 +1401,7 @@ ThrowCompletionOr<GCPtr<FunctionObject>> get_dispose_method(VM& vm, Value value,
// 2. Else,
// a. Let method be ? GetMethod(V, @@dispose).
return GCPtr<FunctionObject> { TRY(value.get_method(vm, *vm.well_known_symbol_dispose())) };
return GCPtr<FunctionObject> { TRY(value.get_method(vm, vm.well_known_symbol_dispose())) };
}
// 2.1.5 Dispose ( V, hint, method ), https://tc39.es/proposal-explicit-resource-management/#sec-dispose

View file

@ -31,7 +31,7 @@ ThrowCompletionOr<void> ArrayBufferConstructor::initialize(Realm& realm)
define_native_function(realm, 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(realm, *vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable);
define_native_accessor(realm, vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable);
define_direct_property(vm.names.length, Value(1), Attribute::Configurable);

View file

@ -28,7 +28,7 @@ ThrowCompletionOr<void> ArrayBufferPrototype::initialize(Realm& realm)
define_native_accessor(realm, vm.names.byteLength, byte_length_getter, {}, Attribute::Configurable);
// 25.1.5.4 ArrayBuffer.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-arraybuffer.prototype-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.ArrayBuffer.as_string()), Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.ArrayBuffer.as_string()), Attribute::Configurable);
return {};
}

View file

@ -35,7 +35,7 @@ ThrowCompletionOr<void> ArrayConstructor::initialize(Realm& realm)
define_native_function(realm, vm.names.of, of, 0, attr);
// 23.1.2.5 get Array [ @@species ], https://tc39.es/ecma262/#sec-get-array-@@species
define_native_accessor(realm, *vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable);
define_native_accessor(realm, vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable);
define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
@ -155,7 +155,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayConstructor::from)
}
// 4. Let usingIterator be ? GetMethod(items, @@iterator).
auto using_iterator = TRY(items.get_method(vm, *vm.well_known_symbol_iterator()));
auto using_iterator = TRY(items.get_method(vm, vm.well_known_symbol_iterator()));
// 5. If usingIterator is not undefined, then
if (using_iterator) {

View file

@ -27,7 +27,7 @@ ThrowCompletionOr<void> ArrayIteratorPrototype::initialize(Realm& realm)
define_native_function(realm, vm.names.next, next, 0, Attribute::Configurable | Attribute::Writable);
// 23.1.5.2.2 %ArrayIteratorPrototype% [ @@toStringTag ], https://tc39.es/ecma262/#sec-%arrayiteratorprototype%-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Array Iterator"sv)), Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Array Iterator"sv)), Attribute::Configurable);
return {};
}

View file

@ -84,7 +84,7 @@ ThrowCompletionOr<void> ArrayPrototype::initialize(Realm& realm)
// Object.is(Array.prototype[Symbol.iterator], Array.prototype.values)
// evaluates to true
// 23.1.3.40 Array.prototype [ @@iterator ] ( ), https://tc39.es/ecma262/#sec-array.prototype-@@iterator
define_direct_property(*vm.well_known_symbol_iterator(), get_without_side_effects(vm.names.values), attr);
define_direct_property(vm.well_known_symbol_iterator(), get_without_side_effects(vm.names.values), attr);
// 23.1.3.41 Array.prototype [ @@unscopables ], https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
// With array grouping proposal, https://tc39.es/proposal-array-grouping/#sec-array.prototype-@@unscopables
@ -108,7 +108,7 @@ ThrowCompletionOr<void> ArrayPrototype::initialize(Realm& realm)
MUST(unscopable_list->create_data_property_or_throw(vm.names.toSpliced, Value(true)));
MUST(unscopable_list->create_data_property_or_throw(vm.names.values, Value(true)));
define_direct_property(*vm.well_known_symbol_unscopables(), unscopable_list, Attribute::Configurable);
define_direct_property(vm.well_known_symbol_unscopables(), unscopable_list, Attribute::Configurable);
return {};
}
@ -135,7 +135,7 @@ static ThrowCompletionOr<Object*> array_species_create(VM& vm, Object& original_
}
if (constructor.is_object()) {
constructor = TRY(constructor.as_object().get(*vm.well_known_symbol_species()));
constructor = TRY(constructor.as_object().get(vm.well_known_symbol_species()));
if (constructor.is_null())
constructor = js_undefined();
}
@ -183,7 +183,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::concat)
if (!val.is_object())
return false;
auto& object = val.as_object();
auto spreadable = TRY(object.get(*vm.well_known_symbol_is_concat_spreadable()));
auto spreadable = TRY(object.get(vm.well_known_symbol_is_concat_spreadable()));
if (!spreadable.is_undefined())
return spreadable.to_boolean();

View file

@ -20,7 +20,7 @@ ThrowCompletionOr<void> AsyncFunctionPrototype::initialize(Realm& realm)
MUST_OR_THROW_OOM(Base::initialize(realm));
// 27.7.3.2 AsyncFunction.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-async-function-prototype-properties-toStringTag
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.AsyncFunction.as_string()), Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.AsyncFunction.as_string()), Attribute::Configurable);
return {};
}

View file

@ -27,7 +27,7 @@ ThrowCompletionOr<void> AsyncGeneratorFunctionPrototype::initialize(Realm& realm
define_direct_property(vm.names.prototype, realm.intrinsics().async_generator_prototype(), Attribute::Configurable);
// 27.4.3.3 AsyncGeneratorFunction.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-asyncgeneratorfunction-prototype-tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.AsyncGeneratorFunction.as_string()), Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.AsyncGeneratorFunction.as_string()), Attribute::Configurable);
return {};
}

View file

@ -20,7 +20,7 @@ ThrowCompletionOr<void> AsyncGeneratorPrototype::initialize(Realm& realm)
MUST_OR_THROW_OOM(Base::initialize(realm));
// 27.6.1.5 AsyncGenerator.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-asyncgenerator-prototype-tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "AsyncGenerator"sv)), Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "AsyncGenerator"sv)), Attribute::Configurable);
return {};
}

View file

@ -18,7 +18,7 @@ ThrowCompletionOr<void> AsyncIteratorPrototype::initialize(Realm& realm)
auto& vm = this->vm();
MUST_OR_THROW_OOM(Base::initialize(realm));
u8 attr = Attribute::Writable | Attribute::Configurable;
define_native_function(realm, *vm.well_known_symbol_async_iterator(), symbol_async_iterator, 0, attr);
define_native_function(realm, vm.well_known_symbol_async_iterator(), symbol_async_iterator, 0, attr);
return {};
}

View file

@ -147,7 +147,7 @@ ThrowCompletionOr<void> AtomicsObject::initialize(Realm& realm)
define_native_function(realm, vm.names.xor_, xor_, 3, attr);
// 25.4.15 Atomics [ @@toStringTag ], https://tc39.es/ecma262/#sec-atomics-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Atomics"sv)), Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Atomics"sv)), Attribute::Configurable);
return {};
}

View file

@ -32,7 +32,7 @@ ThrowCompletionOr<void> BigIntPrototype::initialize(Realm& realm)
define_native_function(realm, vm.names.valueOf, value_of, 0, attr);
// 21.2.3.5 BigInt.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-bigint.prototype-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.BigInt.as_string()), Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.BigInt.as_string()), Attribute::Configurable);
return {};
}

View file

@ -47,7 +47,7 @@ ThrowCompletionOr<void> DataViewPrototype::initialize(Realm& realm)
define_native_accessor(realm, vm.names.byteOffset, byte_offset_getter, {}, Attribute::Configurable);
// 25.3.4.25 DataView.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-dataview.prototype-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.DataView.as_string()), Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.DataView.as_string()), Attribute::Configurable);
return {};
}

View file

@ -87,7 +87,7 @@ ThrowCompletionOr<void> DatePrototype::initialize(Realm& realm)
define_native_function(realm, vm.names.setYear, set_year, 1, attr);
// 21.4.4.45 Date.prototype [ @@toPrimitive ] ( hint ), https://tc39.es/ecma262/#sec-date.prototype-@@toprimitive
define_native_function(realm, *vm.well_known_symbol_to_primitive(), symbol_to_primitive, 1, Attribute::Configurable);
define_native_function(realm, vm.well_known_symbol_to_primitive(), symbol_to_primitive, 1, Attribute::Configurable);
// Aliases.
define_native_function(realm, vm.names.valueOf, get_time, 0, attr);

View file

@ -31,10 +31,10 @@ ThrowCompletionOr<void> DisposableStackPrototype::initialize(Realm& realm)
define_native_function(realm, vm.names.move, move_, 0, attr);
// 11.3.3.7 DisposableStack.prototype [ @@dispose ] (), https://tc39.es/proposal-explicit-resource-management/#sec-disposablestack.prototype-@@dispose
define_direct_property(*vm.well_known_symbol_dispose(), get_without_side_effects(vm.names.dispose), attr);
define_direct_property(vm.well_known_symbol_dispose(), get_without_side_effects(vm.names.dispose), attr);
// 11.3.3.8 DisposableStack.prototype [ @@toStringTag ], https://tc39.es/proposal-explicit-resource-management/#sec-disposablestack.prototype-@@toStringTag
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.DisposableStack.as_string()), Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.DisposableStack.as_string()), Attribute::Configurable);
return {};
}

View file

@ -26,7 +26,7 @@ ThrowCompletionOr<void> FinalizationRegistryPrototype::initialize(Realm& realm)
define_native_function(realm, vm.names.unregister, unregister, 1, attr);
// 26.2.3.4 FinalizationRegistry.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-finalization-registry.prototype-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.FinalizationRegistry.as_string()), Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.FinalizationRegistry.as_string()), Attribute::Configurable);
return {};
}

View file

@ -34,7 +34,7 @@ ThrowCompletionOr<void> FunctionPrototype::initialize(Realm& realm)
define_native_function(realm, vm.names.bind, bind, 1, attr);
define_native_function(realm, vm.names.call, call, 1, attr);
define_native_function(realm, vm.names.toString, to_string, 0, attr);
define_native_function(realm, *vm.well_known_symbol_has_instance(), symbol_has_instance, 1, 0);
define_native_function(realm, vm.well_known_symbol_has_instance(), symbol_has_instance, 1, 0);
define_direct_property(vm.names.length, Value(0), Attribute::Configurable);
define_direct_property(vm.names.name, PrimitiveString::create(vm, String {}), Attribute::Configurable);

View file

@ -23,7 +23,7 @@ ThrowCompletionOr<void> GeneratorFunctionPrototype::initialize(Realm& realm)
// 27.3.3.2 GeneratorFunction.prototype.prototype, https://tc39.es/ecma262/#sec-generatorfunction.prototype.prototype
define_direct_property(vm.names.prototype, realm.intrinsics().generator_prototype(), Attribute::Configurable);
// 27.3.3.3 GeneratorFunction.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-generatorfunction.prototype-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "GeneratorFunction"sv)), Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "GeneratorFunction"sv)), Attribute::Configurable);
return {};
}

View file

@ -24,7 +24,7 @@ ThrowCompletionOr<void> GeneratorPrototype::initialize(Realm& realm)
define_native_function(realm, vm.names.throw_, throw_, 1, attr);
// 27.5.1.5 Generator.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-generator.prototype-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Generator"sv)), Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Generator"sv)), Attribute::Configurable);
return {};
}

View file

@ -24,7 +24,7 @@ ThrowCompletionOr<void> CollatorPrototype::initialize(Realm& realm)
auto& vm = this->vm();
// 10.3.2 Intl.Collator.prototype [ @@toStringTag ], https://tc39.es/ecma402/#sec-intl.collator.prototype-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Intl.Collator"sv)), Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Intl.Collator"sv)), Attribute::Configurable);
u8 attr = Attribute::Writable | Attribute::Configurable;
define_native_accessor(realm, vm.names.compare, compare_getter, {}, attr);

View file

@ -26,7 +26,7 @@ ThrowCompletionOr<void> DateTimeFormatPrototype::initialize(Realm& realm)
auto& vm = this->vm();
// 11.3.2 Intl.DateTimeFormat.prototype [ @@toStringTag ], https://tc39.es/ecma402/#sec-intl.datetimeformat.prototype-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Intl.DateTimeFormat"sv)), Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Intl.DateTimeFormat"sv)), Attribute::Configurable);
define_native_accessor(realm, vm.names.format, format, nullptr, Attribute::Configurable);

View file

@ -26,7 +26,7 @@ ThrowCompletionOr<void> DisplayNamesPrototype::initialize(Realm& realm)
auto& vm = this->vm();
// 12.3.2 Intl.DisplayNames.prototype[ @@toStringTag ], https://tc39.es/ecma402/#sec-Intl.DisplayNames.prototype-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Intl.DisplayNames"sv)), Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Intl.DisplayNames"sv)), Attribute::Configurable);
u8 attr = Attribute::Writable | Attribute::Configurable;
define_native_function(realm, vm.names.of, of, 1, attr);

View file

@ -25,7 +25,7 @@ ThrowCompletionOr<void> DurationFormatPrototype::initialize(Realm& realm)
auto& vm = this->vm();
// 1.4.2 Intl.DurationFormat.prototype [ @@toStringTag ], https://tc39.es/proposal-intl-duration-format/#sec-Intl.DurationFormat.prototype-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Intl.DurationFormat"sv)), Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Intl.DurationFormat"sv)), Attribute::Configurable);
u8 attr = Attribute::Writable | Attribute::Configurable;
define_native_function(realm, vm.names.format, format, 1, attr);

View file

@ -39,7 +39,7 @@ ThrowCompletionOr<void> Intl::initialize(Realm& realm)
auto& vm = this->vm();
// 8.1.1 Intl[ @@toStringTag ], https://tc39.es/ecma402/#sec-Intl-toStringTag
define_direct_property(*vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Intl"sv)), Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Intl"sv)), Attribute::Configurable);
u8 attr = Attribute::Writable | Attribute::Configurable;
define_intrinsic_accessor(vm.names.Collator, attr, [](auto& realm) -> Value { return realm.intrinsics().intl_collator_constructor(); });

View file

@ -25,7 +25,7 @@ ThrowCompletionOr<void> ListFormatPrototype::initialize(Realm& realm)
auto& vm = this->vm();
// 13.3.2 Intl.ListFormat.prototype [ @@toStringTag ], https://tc39.es/ecma402/#sec-Intl.ListFormat.prototype-toStringTag
define_direct_property(*vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Intl.ListFormat"sv)), Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Intl.ListFormat"sv)), Attribute::Configurable);
u8 attr = Attribute::Writable | Attribute::Configurable;
define_native_function(realm, vm.names.format, format, 1, attr);

View file

@ -31,7 +31,7 @@ ThrowCompletionOr<void> LocalePrototype::initialize(Realm& realm)
define_native_function(realm, vm.names.toString, to_string, 0, attr);
// 14.3.2 Intl.Locale.prototype[ @@toStringTag ], https://tc39.es/ecma402/#sec-Intl.Locale.prototype-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Intl.Locale"sv)), Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Intl.Locale"sv)), Attribute::Configurable);
define_native_accessor(realm, vm.names.baseName, base_name, {}, Attribute::Configurable);
define_native_accessor(realm, vm.names.calendar, calendar, {}, Attribute::Configurable);

View file

@ -26,7 +26,7 @@ ThrowCompletionOr<void> NumberFormatPrototype::initialize(Realm& realm)
auto& vm = this->vm();
// 15.3.2 Intl.NumberFormat.prototype [ @@toStringTag ], https://tc39.es/ecma402/#sec-intl.numberformat.prototype-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Intl.NumberFormat"sv)), Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Intl.NumberFormat"sv)), Attribute::Configurable);
define_native_accessor(realm, vm.names.format, format, nullptr, Attribute::Configurable);

View file

@ -25,7 +25,7 @@ ThrowCompletionOr<void> PluralRulesPrototype::initialize(Realm& realm)
auto& vm = this->vm();
// 16.3.2 Intl.PluralRules.prototype [ @@toStringTag ], https://tc39.es/ecma402/#sec-intl.pluralrules.prototype-tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Intl.PluralRules"sv)), Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Intl.PluralRules"sv)), Attribute::Configurable);
u8 attr = Attribute::Writable | Attribute::Configurable;
define_native_function(realm, vm.names.select, select, 1, attr);

View file

@ -23,7 +23,7 @@ ThrowCompletionOr<void> RelativeTimeFormatPrototype::initialize(Realm& realm)
auto& vm = this->vm();
// 17.3.2 Intl.RelativeTimeFormat.prototype[ @@toStringTag ], https://tc39.es/ecma402/#sec-Intl.RelativeTimeFormat.prototype-toStringTag
define_direct_property(*vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Intl.RelativeTimeFormat"sv)), Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Intl.RelativeTimeFormat"sv)), Attribute::Configurable);
u8 attr = Attribute::Writable | Attribute::Configurable;
define_native_function(realm, vm.names.format, format, 2, attr);

View file

@ -25,7 +25,7 @@ ThrowCompletionOr<void> SegmentIteratorPrototype::initialize(Realm& realm)
auto& vm = this->vm();
// 18.6.2.2 %SegmentIteratorPrototype% [ @@toStringTag ], https://tc39.es/ecma402/#sec-%segmentiteratorprototype%.@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Segmenter String Iterator"sv)), Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Segmenter String Iterator"sv)), Attribute::Configurable);
u8 attr = Attribute::Writable | Attribute::Configurable;
define_native_function(realm, vm.names.next, next, 0, attr);

View file

@ -24,7 +24,7 @@ ThrowCompletionOr<void> SegmenterPrototype::initialize(Realm& realm)
auto& vm = this->vm();
// 18.3.2 Intl.Segmenter.prototype [ @@toStringTag ], https://tc39.es/ecma402/#sec-intl.segmenter.prototype-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Intl.Segmenter"sv)), Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Intl.Segmenter"sv)), Attribute::Configurable);
u8 attr = Attribute::Writable | Attribute::Configurable;
define_native_function(realm, vm.names.resolvedOptions, resolved_options, 0, attr);

View file

@ -24,7 +24,7 @@ ThrowCompletionOr<void> SegmentsPrototype::initialize(Realm& realm)
auto& vm = this->vm();
u8 attr = Attribute::Writable | Attribute::Configurable;
define_native_function(realm, *vm.well_known_symbol_iterator(), symbol_iterator, 0, attr);
define_native_function(realm, vm.well_known_symbol_iterator(), symbol_iterator, 0, attr);
define_native_function(realm, vm.names.containing, containing, 1, attr);
return {};

View file

@ -1,6 +1,6 @@
/*
* Copyright (c) 2020, Matthew Olsson <mattco@serenityos.org>
* Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
* Copyright (c) 2022-2023, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -24,12 +24,12 @@ ThrowCompletionOr<Iterator> get_iterator(VM& vm, Value value, IteratorHint hint,
// a. If hint is async, then
if (hint == IteratorHint::Async) {
// i. Set method to ? GetMethod(obj, @@asyncIterator).
auto* async_method = TRY(value.get_method(vm, *vm.well_known_symbol_async_iterator()));
auto* async_method = TRY(value.get_method(vm, vm.well_known_symbol_async_iterator()));
// ii. If method is undefined, then
if (async_method == nullptr) {
// 1. Let syncMethod be ? GetMethod(obj, @@iterator).
auto* sync_method = TRY(value.get_method(vm, *vm.well_known_symbol_iterator()));
auto* sync_method = TRY(value.get_method(vm, vm.well_known_symbol_iterator()));
// 2. Let syncIteratorRecord be ? GetIterator(obj, sync, syncMethod).
auto sync_iterator_record = TRY(get_iterator(vm, value, IteratorHint::Sync, sync_method));
@ -42,7 +42,7 @@ ThrowCompletionOr<Iterator> get_iterator(VM& vm, Value value, IteratorHint hint,
}
// b. Otherwise, set method to ? GetMethod(obj, @@iterator).
else {
method = TRY(value.get_method(vm, *vm.well_known_symbol_iterator()));
method = TRY(value.get_method(vm, vm.well_known_symbol_iterator()));
}
}

View file

@ -21,7 +21,7 @@ ThrowCompletionOr<void> IteratorPrototype::initialize(Realm& realm)
auto& vm = this->vm();
MUST_OR_THROW_OOM(Base::initialize(realm));
u8 attr = Attribute::Writable | Attribute::Configurable;
define_native_function(realm, *vm.well_known_symbol_iterator(), symbol_iterator, 0, attr);
define_native_function(realm, vm.well_known_symbol_iterator(), symbol_iterator, 0, attr);
return {};
}

View file

@ -40,7 +40,7 @@ ThrowCompletionOr<void> JSONObject::initialize(Realm& realm)
define_native_function(realm, vm.names.parse, parse, 2, attr);
// 25.5.3 JSON [ @@toStringTag ], https://tc39.es/ecma262/#sec-json-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "JSON"sv)), Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "JSON"sv)), Attribute::Configurable);
return {};
}

View file

@ -26,7 +26,7 @@ ThrowCompletionOr<void> MapConstructor::initialize(Realm& realm)
// 24.1.2.1 Map.prototype, https://tc39.es/ecma262/#sec-map.prototype
define_direct_property(vm.names.prototype, realm.intrinsics().map_prototype(), 0);
define_native_accessor(realm, *vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable);
define_native_accessor(realm, vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable);
define_direct_property(vm.names.length, Value(0), Attribute::Configurable);

View file

@ -24,7 +24,7 @@ ThrowCompletionOr<void> MapIteratorPrototype::initialize(Realm& realm)
MUST_OR_THROW_OOM(Base::initialize(realm));
define_native_function(realm, vm.names.next, next, 0, Attribute::Configurable | Attribute::Writable);
define_direct_property(*vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Map Iterator"sv)), Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Map Iterator"sv)), Attribute::Configurable);
return {};
}

View file

@ -35,8 +35,8 @@ ThrowCompletionOr<void> MapPrototype::initialize(Realm& realm)
define_native_accessor(realm, vm.names.size, size_getter, {}, Attribute::Configurable);
define_direct_property(*vm.well_known_symbol_iterator(), get_without_side_effects(vm.names.entries), attr);
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.Map.as_string()), Attribute::Configurable);
define_direct_property(vm.well_known_symbol_iterator(), get_without_side_effects(vm.names.entries), attr);
define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.Map.as_string()), Attribute::Configurable);
return {};
}

View file

@ -72,7 +72,7 @@ ThrowCompletionOr<void> MathObject::initialize(Realm& realm)
define_direct_property(vm.names.SQRT2, Value(M_SQRT2), 0);
// 21.3.1.9 Math [ @@toStringTag ], https://tc39.es/ecma262/#sec-math-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.Math.as_string()), Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.Math.as_string()), Attribute::Configurable);
return {};
}

View file

@ -24,10 +24,11 @@ ModuleNamespaceObject::ModuleNamespaceObject(Realm& realm, Module* module, Vecto
ThrowCompletionOr<void> ModuleNamespaceObject::initialize(Realm& realm)
{
auto& vm = this->vm();
MUST_OR_THROW_OOM(Base::initialize(realm));
// 28.3.1 @@toStringTag, https://tc39.es/ecma262/#sec-@@tostringtag
define_direct_property(*vm().well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm(), "Module"sv)), 0);
define_direct_property(vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Module"sv)), 0);
return {};
}

View file

@ -1,6 +1,6 @@
/*
* Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
* Copyright (c) 2021-2023, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -42,7 +42,7 @@ ThrowCompletionOr<bool> ObjectEnvironment::has_binding(DeprecatedFlyString const
return true;
// 5. Let unscopables be ? Get(bindingObject, @@unscopables).
auto unscopables = TRY(m_binding_object->get(*vm.well_known_symbol_unscopables()));
auto unscopables = TRY(m_binding_object->get(vm.well_known_symbol_unscopables()));
// 6. If Type(unscopables) is Object, then
if (unscopables.is_object()) {

View file

@ -1,6 +1,6 @@
/*
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2020-2022, Linus Groh <linusg@serenityos.org>
* Copyright (c) 2020-2023, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -118,7 +118,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectPrototype::to_string)
builtin_tag = "Object";
// 15. Let tag be ? Get(O, @@toStringTag).
auto to_string_tag = TRY(object->get(*vm.well_known_symbol_to_string_tag()));
auto to_string_tag = TRY(object->get(vm.well_known_symbol_to_string_tag()));
// Optimization: Instead of creating another PrimitiveString from builtin_tag, we separate tag and to_string_tag and add an additional branch to step 16.
DeprecatedString tag;

View file

@ -260,7 +260,7 @@ ThrowCompletionOr<void> PromiseConstructor::initialize(Realm& realm)
define_native_function(realm, vm.names.reject, reject, 1, attr);
define_native_function(realm, vm.names.resolve, resolve, 1, attr);
define_native_accessor(realm, *vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable);
define_native_accessor(realm, vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable);
define_direct_property(vm.names.length, Value(1), Attribute::Configurable);

View file

@ -32,7 +32,7 @@ ThrowCompletionOr<void> PromisePrototype::initialize(Realm& realm)
define_native_function(realm, vm.names.finally, finally, 1, attr);
// 27.2.5.5 Promise.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-promise.prototype-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.Promise.as_string()), Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.Promise.as_string()), Attribute::Configurable);
return {};
}

View file

@ -80,9 +80,9 @@ public:
VERIFY(!m_string.is_null());
}
PropertyKey(Symbol& symbol)
PropertyKey(NonnullGCPtr<Symbol> symbol)
: m_type(Type::Symbol)
, m_symbol(&symbol)
, m_symbol(symbol)
{
}

View file

@ -40,7 +40,7 @@ ThrowCompletionOr<void> ReflectObject::initialize(Realm& realm)
define_native_function(realm, vm.names.setPrototypeOf, set_prototype_of, 2, attr);
// 28.1.14 Reflect [ @@toStringTag ], https://tc39.es/ecma262/#sec-reflect-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.Reflect.as_string()), Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.Reflect.as_string()), Attribute::Configurable);
return {};
}

View file

@ -25,7 +25,7 @@ ThrowCompletionOr<void> RegExpConstructor::initialize(Realm& realm)
// 22.2.4.1 RegExp.prototype, https://tc39.es/ecma262/#sec-regexp.prototype
define_direct_property(vm.names.prototype, realm.intrinsics().regexp_prototype(), 0);
define_native_accessor(realm, *vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable);
define_native_accessor(realm, vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable);
define_direct_property(vm.names.length, Value(2), Attribute::Configurable);

View file

@ -37,11 +37,11 @@ ThrowCompletionOr<void> RegExpPrototype::initialize(Realm& realm)
define_native_function(realm, vm.names.exec, exec, 1, attr);
define_native_function(realm, vm.names.compile, compile, 2, attr);
define_native_function(realm, *vm.well_known_symbol_match(), symbol_match, 1, attr);
define_native_function(realm, *vm.well_known_symbol_match_all(), symbol_match_all, 1, attr);
define_native_function(realm, *vm.well_known_symbol_replace(), symbol_replace, 2, attr);
define_native_function(realm, *vm.well_known_symbol_search(), symbol_search, 1, attr);
define_native_function(realm, *vm.well_known_symbol_split(), symbol_split, 2, attr);
define_native_function(realm, vm.well_known_symbol_match(), symbol_match, 1, attr);
define_native_function(realm, vm.well_known_symbol_match_all(), symbol_match_all, 1, attr);
define_native_function(realm, vm.well_known_symbol_replace(), symbol_replace, 2, attr);
define_native_function(realm, vm.well_known_symbol_search(), symbol_search, 1, attr);
define_native_function(realm, vm.well_known_symbol_split(), symbol_split, 2, attr);
define_native_accessor(realm, vm.names.flags, flags, {}, Attribute::Configurable);
define_native_accessor(realm, vm.names.source, source, {}, Attribute::Configurable);

View file

@ -26,7 +26,7 @@ ThrowCompletionOr<void> RegExpStringIteratorPrototype::initialize(Realm& realm)
define_native_function(realm, vm.names.next, next, 0, attr);
// 22.2.7.2.2 %RegExpStringIteratorPrototype% [ @@toStringTag ], https://tc39.es/ecma262/#sec-%regexpstringiteratorprototype%-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "RegExp String Iterator"sv)), Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "RegExp String Iterator"sv)), Attribute::Configurable);
return {};
}

View file

@ -26,7 +26,7 @@ ThrowCompletionOr<void> SetConstructor::initialize(Realm& realm)
// 24.2.2.1 Set.prototype, https://tc39.es/ecma262/#sec-set.prototype
define_direct_property(vm.names.prototype, realm.intrinsics().set_prototype(), 0);
define_native_accessor(realm, *vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable);
define_native_accessor(realm, vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable);
define_direct_property(vm.names.length, Value(0), Attribute::Configurable);

View file

@ -26,7 +26,7 @@ ThrowCompletionOr<void> SetIteratorPrototype::initialize(Realm& realm)
define_native_function(realm, vm.names.next, next, 0, Attribute::Configurable | Attribute::Writable);
// 24.2.5.2.2 %SetIteratorPrototype% [ @@toStringTag ], https://tc39.es/ecma262/#sec-%setiteratorprototype%-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Set Iterator"sv)), Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Set Iterator"sv)), Attribute::Configurable);
return {};
}

View file

@ -44,10 +44,10 @@ ThrowCompletionOr<void> SetPrototype::initialize(Realm& realm)
define_direct_property(vm.names.keys, get_without_side_effects(vm.names.values), attr);
// 24.2.3.11 Set.prototype [ @@iterator ] ( ), https://tc39.es/ecma262/#sec-set.prototype-@@iterator
define_direct_property(*vm.well_known_symbol_iterator(), get_without_side_effects(vm.names.values), attr);
define_direct_property(vm.well_known_symbol_iterator(), get_without_side_effects(vm.names.values), attr);
// 24.2.3.12 Set.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-set.prototype-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.Set.as_string()), Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.Set.as_string()), Attribute::Configurable);
return {};
}

View file

@ -26,7 +26,7 @@ ThrowCompletionOr<void> ShadowRealmPrototype::initialize(Realm& realm)
define_native_function(realm, vm.names.importValue, import_value, 2, attr);
// 3.4.3 ShadowRealm.prototype [ @@toStringTag ], https://tc39.es/proposal-shadowrealm/#sec-shadowrealm.prototype-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.ShadowRealm.as_string()), Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.ShadowRealm.as_string()), Attribute::Configurable);
return {};
}

View file

@ -25,7 +25,7 @@ ThrowCompletionOr<void> StringIteratorPrototype::initialize(Realm& realm)
define_native_function(realm, vm.names.next, next, 0, Attribute::Configurable | Attribute::Writable);
// 22.1.5.1.2 %StringIteratorPrototype% [ @@toStringTag ], https://tc39.es/ecma262/#sec-%stringiteratorprototype%-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "String Iterator"sv)), Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "String Iterator"sv)), Attribute::Configurable);
return {};
}

View file

@ -194,7 +194,7 @@ ThrowCompletionOr<void> StringPrototype::initialize(Realm& realm)
define_native_function(realm, vm.names.trimEnd, trim_end, 0, attr);
define_native_function(realm, vm.names.trimStart, trim_start, 0, attr);
define_native_function(realm, vm.names.valueOf, value_of, 0, attr);
define_native_function(realm, *vm.well_known_symbol_iterator(), symbol_iterator, 0, attr);
define_native_function(realm, vm.well_known_symbol_iterator(), symbol_iterator, 0, attr);
// B.2.2 Additional Properties of the String.prototype Object, https://tc39.es/ecma262/#sec-additional-properties-of-the-string.prototype-object
define_native_function(realm, vm.names.substr, substr, 2, attr);
@ -464,14 +464,14 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::match)
auto this_object = TRY(require_object_coercible(vm, vm.this_value()));
auto regexp = vm.argument(0);
if (!regexp.is_nullish()) {
if (auto* matcher = TRY(regexp.get_method(vm, *vm.well_known_symbol_match())))
if (auto* matcher = TRY(regexp.get_method(vm, vm.well_known_symbol_match())))
return TRY(call(vm, *matcher, regexp, this_object));
}
auto string = TRY(this_object.to_utf16_string(vm));
auto rx = TRY(regexp_create(vm, regexp, js_undefined()));
return TRY(Value(rx).invoke(vm, *vm.well_known_symbol_match(), PrimitiveString::create(vm, move(string))));
return TRY(Value(rx).invoke(vm, vm.well_known_symbol_match(), PrimitiveString::create(vm, move(string))));
}
// 22.1.3.13 String.prototype.matchAll ( regexp ), https://tc39.es/ecma262/#sec-string.prototype.matchall
@ -488,14 +488,14 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::match_all)
if (!flags_string.contains('g'))
return vm.throw_completion<TypeError>(ErrorType::StringNonGlobalRegExp);
}
if (auto* matcher = TRY(regexp.get_method(vm, *vm.well_known_symbol_match_all())))
if (auto* matcher = TRY(regexp.get_method(vm, vm.well_known_symbol_match_all())))
return TRY(call(vm, *matcher, regexp, this_object));
}
auto string = TRY(this_object.to_utf16_string(vm));
auto rx = TRY(regexp_create(vm, regexp, PrimitiveString::create(vm, "g"_short_string)));
return TRY(Value(rx).invoke(vm, *vm.well_known_symbol_match_all(), PrimitiveString::create(vm, move(string))));
return TRY(Value(rx).invoke(vm, vm.well_known_symbol_match_all(), PrimitiveString::create(vm, move(string))));
}
// 22.1.3.14 String.prototype.normalize ( [ form ] ), https://tc39.es/ecma262/#sec-string.prototype.normalize
@ -613,7 +613,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::replace)
auto replace_value = vm.argument(1);
if (!search_value.is_nullish()) {
if (auto* replacer = TRY(search_value.get_method(vm, *vm.well_known_symbol_replace())))
if (auto* replacer = TRY(search_value.get_method(vm, vm.well_known_symbol_replace())))
return TRY(call(vm, *replacer, search_value, this_object, replace_value));
}
@ -665,7 +665,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::replace_all)
return vm.throw_completion<TypeError>(ErrorType::StringNonGlobalRegExp);
}
auto* replacer = TRY(search_value.get_method(vm, *vm.well_known_symbol_replace()));
auto* replacer = TRY(search_value.get_method(vm, vm.well_known_symbol_replace()));
if (replacer)
return TRY(call(vm, *replacer, search_value, this_object, replace_value));
}
@ -722,14 +722,14 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::search)
auto this_object = TRY(require_object_coercible(vm, vm.this_value()));
auto regexp = vm.argument(0);
if (!regexp.is_nullish()) {
if (auto* searcher = TRY(regexp.get_method(vm, *vm.well_known_symbol_search())))
if (auto* searcher = TRY(regexp.get_method(vm, vm.well_known_symbol_search())))
return TRY(call(vm, *searcher, regexp, this_object));
}
auto string = TRY(this_object.to_utf16_string(vm));
auto rx = TRY(regexp_create(vm, regexp, js_undefined()));
return TRY(Value(rx).invoke(vm, *vm.well_known_symbol_search(), PrimitiveString::create(vm, move(string))));
return TRY(Value(rx).invoke(vm, vm.well_known_symbol_search(), PrimitiveString::create(vm, move(string))));
}
// 22.1.3.21 String.prototype.slice ( start, end ), https://tc39.es/ecma262/#sec-string.prototype.slice
@ -774,7 +774,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::split)
auto limit_argument = vm.argument(1);
if (!separator_argument.is_nullish()) {
auto splitter = TRY(separator_argument.get_method(vm, *vm.well_known_symbol_split()));
auto splitter = TRY(separator_argument.get_method(vm, vm.well_known_symbol_split()));
if (splitter)
return TRY(call(vm, *splitter, separator_argument, object, limit_argument));
}

View file

@ -31,10 +31,10 @@ ThrowCompletionOr<void> SymbolPrototype::initialize(Realm& realm)
define_native_function(realm, vm.names.toString, to_string, 0, attr);
define_native_function(realm, vm.names.valueOf, value_of, 0, attr);
define_native_accessor(realm, vm.names.description, description_getter, {}, Attribute::Configurable);
define_native_function(realm, *vm.well_known_symbol_to_primitive(), symbol_to_primitive, 1, Attribute::Configurable);
define_native_function(realm, 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_direct_property(*vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Symbol"sv)), Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Symbol"sv)), Attribute::Configurable);
return {};
}

View file

@ -36,7 +36,7 @@ ThrowCompletionOr<void> CalendarPrototype::initialize(Realm& realm)
auto& vm = this->vm();
// 12.4.2 Temporal.Calendar.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.calendar.prototype-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Temporal.Calendar"sv)), Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Temporal.Calendar"sv)), Attribute::Configurable);
define_native_accessor(realm, vm.names.id, id_getter, {}, Attribute::Configurable);

View file

@ -27,7 +27,7 @@ ThrowCompletionOr<void> DurationPrototype::initialize(Realm& realm)
auto& vm = this->vm();
// 7.3.2 Temporal.Duration.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.duration.prototype-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Temporal.Duration"sv)), Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Temporal.Duration"sv)), Attribute::Configurable);
define_native_accessor(realm, vm.names.years, years_getter, {}, Attribute::Configurable);
define_native_accessor(realm, vm.names.months, months_getter, {}, Attribute::Configurable);

View file

@ -31,7 +31,7 @@ ThrowCompletionOr<void> InstantPrototype::initialize(Realm& realm)
auto& vm = this->vm();
// 8.3.2 Temporal.Instant.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.instant.prototype-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Temporal.Instant"sv)), Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Temporal.Instant"sv)), Attribute::Configurable);
define_native_accessor(realm, vm.names.epochSeconds, epoch_seconds_getter, {}, Attribute::Configurable);
define_native_accessor(realm, vm.names.epochMilliseconds, epoch_milliseconds_getter, {}, Attribute::Configurable);

View file

@ -33,7 +33,7 @@ ThrowCompletionOr<void> Now::initialize(Realm& realm)
auto& vm = this->vm();
// 2.1.1 Temporal.Now [ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal-now-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Temporal.Now"sv)), Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Temporal.Now"sv)), Attribute::Configurable);
u8 attr = Attribute::Writable | Attribute::Configurable;
define_native_function(realm, vm.names.timeZone, time_zone, 0, attr);

View file

@ -32,7 +32,7 @@ ThrowCompletionOr<void> PlainDatePrototype::initialize(Realm& realm)
auto& vm = this->vm();
// 3.3.2 Temporal.PlainDate.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.plaindate.prototype-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Temporal.PlainDate"sv)), Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Temporal.PlainDate"sv)), Attribute::Configurable);
define_native_accessor(realm, vm.names.calendar, calendar_getter, {}, Attribute::Configurable);
define_native_accessor(realm, vm.names.year, year_getter, {}, Attribute::Configurable);

View file

@ -33,7 +33,7 @@ ThrowCompletionOr<void> PlainDateTimePrototype::initialize(Realm& realm)
auto& vm = this->vm();
// 5.3.2 Temporal.PlainDateTime.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.plaindatetime.prototype-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Temporal.PlainDateTime"sv)), Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Temporal.PlainDateTime"sv)), Attribute::Configurable);
define_native_accessor(realm, vm.names.calendar, calendar_getter, {}, Attribute::Configurable);
define_native_accessor(realm, vm.names.year, year_getter, {}, Attribute::Configurable);

View file

@ -27,7 +27,7 @@ ThrowCompletionOr<void> PlainMonthDayPrototype::initialize(Realm& realm)
auto& vm = this->vm();
// 10.3.2 Temporal.PlainMonthDay.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.plainmonthday.prototype-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Temporal.PlainMonthDay"sv)), Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Temporal.PlainMonthDay"sv)), Attribute::Configurable);
define_native_accessor(realm, vm.names.calendar, calendar_getter, {}, Attribute::Configurable);
define_native_accessor(realm, vm.names.monthCode, month_code_getter, {}, Attribute::Configurable);

View file

@ -32,7 +32,7 @@ ThrowCompletionOr<void> PlainTimePrototype::initialize(Realm& realm)
auto& vm = this->vm();
// 4.3.2 Temporal.PlainTime.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.plaintime.prototype-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Temporal.PlainTime"sv)), Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Temporal.PlainTime"sv)), Attribute::Configurable);
define_native_accessor(realm, vm.names.calendar, calendar_getter, {}, Attribute::Configurable);
define_native_accessor(realm, vm.names.hour, hour_getter, {}, Attribute::Configurable);

View file

@ -29,7 +29,7 @@ ThrowCompletionOr<void> PlainYearMonthPrototype::initialize(Realm& realm)
auto& vm = this->vm();
// 9.3.2 Temporal.PlainYearMonth.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.plainyearmonth.prototype-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Temporal.PlainYearMonth"sv)), Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Temporal.PlainYearMonth"sv)), Attribute::Configurable);
define_native_accessor(realm, vm.names.calendar, calendar_getter, {}, Attribute::Configurable);
define_native_accessor(realm, vm.names.year, year_getter, {}, Attribute::Configurable);

View file

@ -33,7 +33,7 @@ ThrowCompletionOr<void> Temporal::initialize(Realm& realm)
auto& vm = this->vm();
// 1.1.1 Temporal [ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Temporal"sv)), Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Temporal"sv)), Attribute::Configurable);
u8 attr = Attribute::Writable | Attribute::Configurable;
define_direct_property(vm.names.Now, MUST_OR_THROW_OOM(heap().allocate<Now>(realm, realm)), attr);

View file

@ -42,7 +42,7 @@ ThrowCompletionOr<void> TimeZonePrototype::initialize(Realm& realm)
define_native_function(realm, vm.names.toJSON, to_json, 0, attr);
// 11.4.2 Temporal.TimeZone.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.timezone.prototype-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Temporal.TimeZone"sv)), Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Temporal.TimeZone"sv)), Attribute::Configurable);
return {};
}

View file

@ -33,7 +33,7 @@ ThrowCompletionOr<void> ZonedDateTimePrototype::initialize(Realm& realm)
auto& vm = this->vm();
// 6.3.2 Temporal.ZonedDateTime.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.prototype-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Temporal.ZonedDateTime"sv)), Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Temporal.ZonedDateTime"sv)), Attribute::Configurable);
define_native_accessor(realm, vm.names.calendar, calendar_getter, {}, Attribute::Configurable);
define_native_accessor(realm, vm.names.timeZone, time_zone_getter, {}, Attribute::Configurable);

View file

@ -527,7 +527,7 @@ void TypedArrayBase::visit_edges(Visitor& visitor)
TRY(initialize_typed_array_from_array_buffer(vm, *typed_array, array_buffer, \
vm.argument(1), vm.argument(2))); \
} else { \
auto iterator = TRY(first_argument.get_method(vm, *vm.well_known_symbol_iterator())); \
auto iterator = TRY(first_argument.get_method(vm, vm.well_known_symbol_iterator())); \
if (iterator) { \
auto values = TRY(iterable_to_list(vm, first_argument, iterator)); \
TRY(initialize_typed_array_from_list(vm, *typed_array, values)); \

View file

@ -33,7 +33,7 @@ ThrowCompletionOr<void> TypedArrayConstructor::initialize(Realm& realm)
define_native_function(realm, vm.names.from, from, 1, attr);
define_native_function(realm, vm.names.of, of, 0, attr);
define_native_accessor(realm, *vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable);
define_native_accessor(realm, vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable);
define_direct_property(vm.names.length, Value(0), Attribute::Configurable);
@ -81,7 +81,7 @@ JS_DEFINE_NATIVE_FUNCTION(TypedArrayConstructor::from)
}
// 5. Let usingIterator be ? GetMethod(source, @@iterator).
auto* using_iterator = TRY(source.get_method(vm, *vm.well_known_symbol_iterator()));
auto* using_iterator = TRY(source.get_method(vm, vm.well_known_symbol_iterator()));
// 6. If usingIterator is not undefined, then
if (using_iterator) {

View file

@ -63,13 +63,13 @@ ThrowCompletionOr<void> TypedArrayPrototype::initialize(Realm& realm)
define_native_function(realm, vm.names.with, with, 2, attr);
define_native_function(realm, vm.names.values, values, 0, attr);
define_native_accessor(realm, *vm.well_known_symbol_to_string_tag(), to_string_tag_getter, nullptr, Attribute::Configurable);
define_native_accessor(realm, vm.well_known_symbol_to_string_tag(), to_string_tag_getter, nullptr, Attribute::Configurable);
// 23.2.3.34 %TypedArray%.prototype.toString ( ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.tostring
define_direct_property(vm.names.toString, realm.intrinsics().array_prototype()->get_without_side_effects(vm.names.toString), attr);
// 23.2.3.37 %TypedArray%.prototype [ @@iterator ] ( ), https://tc39.es/ecma262/#sec-%typedarray%.prototype-@@iterator
define_direct_property(*vm.well_known_symbol_iterator(), get_without_side_effects(vm.names.values), attr);
define_direct_property(vm.well_known_symbol_iterator(), get_without_side_effects(vm.names.values), attr);
return {};
}

View file

@ -65,10 +65,10 @@ public:
void gather_roots(HashTable<Cell*>&);
#define __JS_ENUMERATE(SymbolName, snake_name) \
Symbol* well_known_symbol_##snake_name() const \
{ \
return m_well_known_symbols.snake_name; \
#define __JS_ENUMERATE(SymbolName, snake_name) \
NonnullGCPtr<Symbol> well_known_symbol_##snake_name() const \
{ \
return *m_well_known_symbols.snake_name; \
}
JS_ENUMERATE_WELL_KNOWN_SYMBOLS
#undef __JS_ENUMERATE

View file

@ -302,7 +302,7 @@ ThrowCompletionOr<bool> Value::is_regexp(VM& vm) const
return false;
// 2. Let matcher be ? Get(argument, @@match).
auto matcher = TRY(as_object().get(*vm.well_known_symbol_match()));
auto matcher = TRY(as_object().get(vm.well_known_symbol_match()));
// 3. If matcher is not undefined, return ToBoolean(matcher).
if (!matcher.is_undefined())
@ -508,7 +508,7 @@ ThrowCompletionOr<Value> Value::to_primitive(VM& vm, PreferredType preferred_typ
// 1. If input is an Object, then
if (is_object()) {
// a. Let exoticToPrim be ? GetMethod(input, @@toPrimitive).
auto* exotic_to_primitive = TRY(get_method(vm, *vm.well_known_symbol_to_primitive()));
auto* exotic_to_primitive = TRY(get_method(vm, vm.well_known_symbol_to_primitive()));
// b. If exoticToPrim is not undefined, then
if (exotic_to_primitive) {
@ -2062,7 +2062,7 @@ ThrowCompletionOr<Value> instance_of(VM& vm, Value value, Value target)
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, target.to_string_without_side_effects()));
// 2. Let instOfHandler be ? GetMethod(target, @@hasInstance).
auto* instance_of_handler = TRY(target.get_method(vm, *vm.well_known_symbol_has_instance()));
auto* instance_of_handler = TRY(target.get_method(vm, vm.well_known_symbol_has_instance()));
// 3. If instOfHandler is not undefined, then
if (instance_of_handler) {

View file

@ -28,7 +28,7 @@ ThrowCompletionOr<void> WeakMapPrototype::initialize(Realm& realm)
define_native_function(realm, vm.names.set, set, 2, attr);
// 24.3.3.6 WeakMap.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-weakmap.prototype-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.WeakMap.as_string()), Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.WeakMap.as_string()), Attribute::Configurable);
return {};
}

View file

@ -21,7 +21,7 @@ ThrowCompletionOr<void> WeakRefPrototype::initialize(Realm& realm)
define_native_function(realm, vm.names.deref, deref, 0, Attribute::Writable | Attribute::Configurable);
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.WeakRef.as_string()), Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.WeakRef.as_string()), Attribute::Configurable);
return {};
}

View file

@ -27,7 +27,7 @@ ThrowCompletionOr<void> WeakSetPrototype::initialize(Realm& realm)
define_native_function(realm, vm.names.has, has, 1, attr);
// 24.4.3.5 WeakSet.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-weakset.prototype-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.WeakSet.as_string()), Attribute::Configurable);
define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.WeakSet.as_string()), Attribute::Configurable);
return {};
}

View file

@ -55,7 +55,7 @@ static JS::ThrowCompletionOr<Vector<String>> convert_value_to_sequence_of_string
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, value.to_string_without_side_effects()));
// 2. Let method be ? GetMethod(V, @@iterator).
auto* method = TRY(value.get_method(vm, *vm.well_known_symbol_iterator()));
auto* method = TRY(value.get_method(vm, vm.well_known_symbol_iterator()));
// 3. If method is undefined, throw a TypeError.
if (!method)