mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:48:10 +00:00
LibJS: Remove Object(Object& prototype) footgun
This constructor was easily confused with a copy constructor, and it was possible to accidentally copy-construct Objects in at least one way that we dicovered (via generic ThrowCompletionOr construction). This patch adds a mandatory ConstructWithPrototypeTag parameter to the constructor to disambiguate it.
This commit is contained in:
parent
42b5c896e8
commit
4abdb68655
90 changed files with 100 additions and 99 deletions
|
@ -2436,15 +2436,15 @@ namespace Web::Bindings {
|
|||
// https://webidl.spec.whatwg.org/#es-DOMException-specialness
|
||||
// Object.getPrototypeOf(DOMException.prototype) === Error.prototype
|
||||
generator.append(R"~~~(
|
||||
: Object(*realm.intrinsics().error_prototype())
|
||||
: Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().error_prototype())
|
||||
)~~~");
|
||||
} else if (!interface.parent_name.is_empty()) {
|
||||
generator.append(R"~~~(
|
||||
: Object(ensure_web_prototype<@prototype_base_class@>(realm, "@parent_name@"))
|
||||
: Object(ConstructWithPrototypeTag::Tag, ensure_web_prototype<@prototype_base_class@>(realm, "@parent_name@"))
|
||||
)~~~");
|
||||
} else {
|
||||
generator.append(R"~~~(
|
||||
: Object(*realm.intrinsics().object_prototype())
|
||||
: Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().object_prototype())
|
||||
)~~~");
|
||||
}
|
||||
|
||||
|
@ -2873,7 +2873,7 @@ using namespace Web::WebIDL;
|
|||
namespace Web::Bindings {
|
||||
|
||||
@prototype_class@::@prototype_class@(JS::Realm& realm)
|
||||
: Object(*realm.intrinsics().iterator_prototype())
|
||||
: Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().iterator_prototype())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ class WebAssemblyModule final : public JS::Object {
|
|||
|
||||
public:
|
||||
explicit WebAssemblyModule(JS::Object& prototype)
|
||||
: JS::Object(prototype)
|
||||
: JS::Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
{
|
||||
m_machine.enable_instruction_count_limit();
|
||||
}
|
||||
|
|
|
@ -371,7 +371,7 @@ JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::get_column_bound)
|
|||
}
|
||||
|
||||
WorkbookObject::WorkbookObject(JS::Realm& realm, Workbook& workbook)
|
||||
: JS::Object(*realm.intrinsics().object_prototype())
|
||||
: JS::Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().object_prototype())
|
||||
, m_workbook(workbook)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
namespace JS {
|
||||
|
||||
AggregateErrorPrototype::AggregateErrorPrototype(Realm& realm)
|
||||
: Object(*realm.intrinsics().error_prototype())
|
||||
: Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().error_prototype())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
namespace JS {
|
||||
|
||||
ArgumentsObject::ArgumentsObject(Realm& realm, Environment& environment)
|
||||
: Object(*realm.intrinsics().object_prototype())
|
||||
: Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().object_prototype())
|
||||
, m_environment(environment)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ NonnullGCPtr<Array> Array::create_from(Realm& realm, Vector<Value> const& elemen
|
|||
}
|
||||
|
||||
Array::Array(Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -31,14 +31,14 @@ NonnullGCPtr<ArrayBuffer> ArrayBuffer::create(Realm& realm, ByteBuffer* buffer)
|
|||
}
|
||||
|
||||
ArrayBuffer::ArrayBuffer(ByteBuffer buffer, Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
, m_buffer(move(buffer))
|
||||
, m_detach_key(js_undefined())
|
||||
{
|
||||
}
|
||||
|
||||
ArrayBuffer::ArrayBuffer(ByteBuffer* buffer, Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
, m_buffer(buffer)
|
||||
, m_detach_key(js_undefined())
|
||||
{
|
||||
|
|
|
@ -15,7 +15,7 @@ NonnullGCPtr<ArrayIterator> ArrayIterator::create(Realm& realm, Value array, Obj
|
|||
}
|
||||
|
||||
ArrayIterator::ArrayIterator(Value array, Object::PropertyKind iteration_kind, Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
, m_array(array)
|
||||
, m_iteration_kind(iteration_kind)
|
||||
{
|
||||
|
|
|
@ -17,7 +17,7 @@ NonnullGCPtr<AsyncFromSyncIterator> AsyncFromSyncIterator::create(Realm& realm,
|
|||
}
|
||||
|
||||
AsyncFromSyncIterator::AsyncFromSyncIterator(Realm& realm, Iterator sync_iterator_record)
|
||||
: Object(*realm.intrinsics().async_from_sync_iterator_prototype())
|
||||
: Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().async_from_sync_iterator_prototype())
|
||||
, m_sync_iterator_record(sync_iterator_record)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
namespace JS {
|
||||
|
||||
AsyncFunctionPrototype::AsyncFunctionPrototype(Realm& realm)
|
||||
: Object(*realm.intrinsics().function_prototype())
|
||||
: Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().function_prototype())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
namespace JS {
|
||||
|
||||
AsyncGenerator::AsyncGenerator(Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
namespace JS {
|
||||
|
||||
AsyncIteratorPrototype::AsyncIteratorPrototype(Realm& realm)
|
||||
: Object(*realm.intrinsics().object_prototype())
|
||||
: Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().object_prototype())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -125,7 +125,7 @@ static ThrowCompletionOr<Value> perform_atomic_operation(VM& vm, TypedArrayBase&
|
|||
}
|
||||
|
||||
AtomicsObject::AtomicsObject(Realm& realm)
|
||||
: Object(*realm.intrinsics().object_prototype())
|
||||
: Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().object_prototype())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ NonnullGCPtr<BigIntObject> BigIntObject::create(Realm& realm, BigInt& bigint)
|
|||
}
|
||||
|
||||
BigIntObject::BigIntObject(BigInt& bigint, Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
, m_bigint(bigint)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
namespace JS {
|
||||
|
||||
BigIntPrototype::BigIntPrototype(Realm& realm)
|
||||
: Object(*realm.intrinsics().object_prototype())
|
||||
: Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().object_prototype())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ NonnullGCPtr<BooleanObject> BooleanObject::create(Realm& realm, bool value)
|
|||
}
|
||||
|
||||
BooleanObject::BooleanObject(bool value, Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
, m_value(value)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
namespace JS {
|
||||
|
||||
ConsoleObject::ConsoleObject(Realm& realm)
|
||||
: Object(*realm.intrinsics().object_prototype())
|
||||
: Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().object_prototype())
|
||||
, m_console(make<Console>(realm))
|
||||
{
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ NonnullGCPtr<DataView> DataView::create(Realm& realm, ArrayBuffer* viewed_buffer
|
|||
}
|
||||
|
||||
DataView::DataView(ArrayBuffer* viewed_buffer, size_t byte_length, size_t byte_offset, Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
, m_viewed_array_buffer(viewed_buffer)
|
||||
, m_byte_length(byte_length)
|
||||
, m_byte_offset(byte_offset)
|
||||
|
|
|
@ -27,7 +27,7 @@ NonnullGCPtr<Date> Date::create(Realm& realm, double date_value)
|
|||
}
|
||||
|
||||
Date::Date(double date_value, Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
, m_date_value(date_value)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -208,7 +208,7 @@ ThrowCompletionOr<Object*> ECMAScriptFunctionObject::internal_construct(MarkedVe
|
|||
// 3. If kind is base, then
|
||||
if (kind == ConstructorKind::Base) {
|
||||
// a. Let thisArgument be ? OrdinaryCreateFromConstructor(newTarget, "%Object.prototype%").
|
||||
this_argument = TRY(ordinary_create_from_constructor<Object>(vm, new_target, &Intrinsics::object_prototype));
|
||||
this_argument = TRY(ordinary_create_from_constructor<Object>(vm, new_target, &Intrinsics::object_prototype, ConstructWithPrototypeTag::Tag));
|
||||
}
|
||||
|
||||
ExecutionContext callee_context(heap());
|
||||
|
|
|
@ -29,7 +29,7 @@ NonnullGCPtr<Error> Error::create(Realm& realm, DeprecatedString const& message)
|
|||
}
|
||||
|
||||
Error::Error(Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
{
|
||||
populate_stack();
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
namespace JS {
|
||||
|
||||
FinalizationRegistry::FinalizationRegistry(Realm& realm, JobCallback cleanup_callback, Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
, WeakContainer(heap())
|
||||
, m_realm(realm)
|
||||
, m_cleanup_callback(move(cleanup_callback))
|
||||
|
|
|
@ -19,7 +19,7 @@ FunctionObject::FunctionObject(Realm& realm, Object* prototype)
|
|||
}
|
||||
|
||||
FunctionObject::FunctionObject(Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
namespace JS {
|
||||
|
||||
GeneratorFunctionPrototype::GeneratorFunctionPrototype(Realm& realm)
|
||||
: Object(*realm.intrinsics().function_prototype())
|
||||
: Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().function_prototype())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ ThrowCompletionOr<NonnullGCPtr<GeneratorObject>> GeneratorObject::create(Realm&
|
|||
}
|
||||
|
||||
GeneratorObject::GeneratorObject(Realm&, Object& prototype, ExecutionContext context)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
, m_execution_context(move(context))
|
||||
{
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace JS::Intl {
|
|||
|
||||
// 10 Collator Objects, https://tc39.es/ecma402/#collator-objects
|
||||
Collator::Collator(Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ static Crypto::SignedBigInteger const s_one_million_bigint { 1'000'000 };
|
|||
|
||||
// 11 DateTimeFormat Objects, https://tc39.es/ecma402/#datetimeformat-objects
|
||||
DateTimeFormat::DateTimeFormat(Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace JS::Intl {
|
|||
|
||||
// 12 DisplayNames Objects, https://tc39.es/ecma402/#intl-displaynames-objects
|
||||
DisplayNames::DisplayNames(Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace JS::Intl {
|
|||
|
||||
// 1 DurationFormat Objects, https://tc39.es/proposal-intl-duration-format/#durationformat-objects
|
||||
DurationFormat::DurationFormat(Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace JS::Intl {
|
|||
|
||||
// 8 The Intl Object, https://tc39.es/ecma402/#intl-object
|
||||
Intl::Intl(Realm& realm)
|
||||
: Object(*realm.intrinsics().object_prototype())
|
||||
: Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().object_prototype())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace JS::Intl {
|
|||
|
||||
// 13 ListFormat Objects, https://tc39.es/ecma402/#listformat-objects
|
||||
ListFormat::ListFormat(Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -21,12 +21,12 @@ NonnullGCPtr<Locale> Locale::create(Realm& realm, ::Locale::LocaleID const& loca
|
|||
|
||||
// 14 Locale Objects, https://tc39.es/ecma402/#locale-objects
|
||||
Locale::Locale(Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
{
|
||||
}
|
||||
|
||||
Locale::Locale(::Locale::LocaleID const& locale_id, Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
{
|
||||
set_locale(locale_id.to_deprecated_string());
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
namespace JS::Intl {
|
||||
|
||||
NumberFormatBase::NumberFormatBase(Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace JS::Intl {
|
|||
|
||||
// 17 RelativeTimeFormat Objects, https://tc39.es/ecma402/#relativetimeformat-objects
|
||||
RelativeTimeFormat::RelativeTimeFormat(Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ NonnullGCPtr<SegmentIterator> SegmentIterator::create(Realm& realm, Segmenter& s
|
|||
|
||||
// 18.6 Segment Iterator Objects, https://tc39.es/ecma402/#sec-segment-iterator-objects
|
||||
SegmentIterator::SegmentIterator(Realm& realm, Segmenter& segmenter, Utf16View const& string, Segments const& segments)
|
||||
: Object(*realm.intrinsics().intl_segment_iterator_prototype())
|
||||
: Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().intl_segment_iterator_prototype())
|
||||
, m_iterating_segmenter(segmenter)
|
||||
, m_iterated_string(string)
|
||||
, m_segments(segments)
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace JS::Intl {
|
|||
|
||||
// 18 Segmenter Objects, https://tc39.es/ecma402/#segmenter-objects
|
||||
Segmenter::Segmenter(Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ NonnullGCPtr<Segments> Segments::create(Realm& realm, Segmenter& segmenter, Utf1
|
|||
|
||||
// 18.5 Segments Objects, https://tc39.es/ecma402/#sec-segments-objects
|
||||
Segments::Segments(Realm& realm, Segmenter& segmenter, Utf16String string)
|
||||
: Object(*realm.intrinsics().intl_segments_prototype())
|
||||
: Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().intl_segments_prototype())
|
||||
, m_segments_segmenter(segmenter)
|
||||
, m_segments_string(move(string))
|
||||
{
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace JS {
|
|||
|
||||
// 27.1.2 The %IteratorPrototype% Object, https://tc39.es/ecma262/#sec-%iteratorprototype%-object
|
||||
IteratorPrototype::IteratorPrototype(Realm& realm)
|
||||
: Object(*realm.intrinsics().object_prototype())
|
||||
: Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().object_prototype())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
namespace JS {
|
||||
|
||||
JSONObject::JSONObject(Realm& realm)
|
||||
: Object(*realm.intrinsics().object_prototype())
|
||||
: Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().object_prototype())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ NonnullGCPtr<Map> Map::create(Realm& realm)
|
|||
}
|
||||
|
||||
Map::Map(Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ NonnullGCPtr<MapIterator> MapIterator::create(Realm& realm, Map& map, Object::Pr
|
|||
}
|
||||
|
||||
MapIterator::MapIterator(Map& map, Object::PropertyKind iteration_kind, Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
, m_map(map)
|
||||
, m_iteration_kind(iteration_kind)
|
||||
, m_iterator(static_cast<Map const&>(map).begin())
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
namespace JS {
|
||||
|
||||
MathObject::MathObject(Realm& realm)
|
||||
: Object(*realm.intrinsics().object_prototype())
|
||||
: Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().object_prototype())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
namespace JS {
|
||||
|
||||
ModuleNamespaceObject::ModuleNamespaceObject(Realm& realm, Module* module, Vector<FlyString> exports)
|
||||
: Object(*realm.intrinsics().object_prototype())
|
||||
: Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().object_prototype())
|
||||
, m_module(module)
|
||||
, m_exports(move(exports))
|
||||
{
|
||||
|
|
|
@ -15,7 +15,7 @@ NonnullGCPtr<NumberObject> NumberObject::create(Realm& realm, double value)
|
|||
}
|
||||
|
||||
NumberObject::NumberObject(double value, Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
, m_value(value)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ NonnullGCPtr<Object> Object::create(Realm& realm, Object* prototype)
|
|||
else if (prototype == realm.intrinsics().object_prototype())
|
||||
return *realm.heap().allocate<Object>(realm, *realm.intrinsics().new_object_shape());
|
||||
else
|
||||
return *realm.heap().allocate<Object>(realm, *prototype);
|
||||
return *realm.heap().allocate<Object>(realm, ConstructWithPrototypeTag::Tag, *prototype);
|
||||
}
|
||||
|
||||
Object::Object(GlobalObjectTag, Realm& realm)
|
||||
|
@ -56,7 +56,7 @@ Object::Object(Realm& realm, Object* prototype)
|
|||
set_prototype(prototype);
|
||||
}
|
||||
|
||||
Object::Object(Object& prototype)
|
||||
Object::Object(ConstructWithPrototypeTag, Object& prototype)
|
||||
{
|
||||
m_shape = prototype.shape().realm().intrinsics().empty_object_shape();
|
||||
VERIFY(m_shape);
|
||||
|
|
|
@ -191,11 +191,12 @@ public:
|
|||
protected:
|
||||
enum class GlobalObjectTag { Tag };
|
||||
enum class ConstructWithoutPrototypeTag { Tag };
|
||||
enum class ConstructWithPrototypeTag { Tag };
|
||||
|
||||
Object(GlobalObjectTag, Realm&);
|
||||
Object(ConstructWithoutPrototypeTag, Realm&);
|
||||
Object(Realm&, Object* prototype);
|
||||
explicit Object(Object& prototype);
|
||||
Object(ConstructWithPrototypeTag, Object& prototype);
|
||||
explicit Object(Shape&);
|
||||
|
||||
void set_prototype(Object*);
|
||||
|
|
|
@ -70,7 +70,7 @@ ThrowCompletionOr<Object*> ObjectConstructor::construct(FunctionObject& new_targ
|
|||
auto& realm = *vm.current_realm();
|
||||
|
||||
if (&new_target != this)
|
||||
return TRY(ordinary_create_from_constructor<Object>(vm, new_target, &Intrinsics::object_prototype));
|
||||
return TRY(ordinary_create_from_constructor<Object>(vm, new_target, &Intrinsics::object_prototype, ConstructWithPrototypeTag::Tag));
|
||||
auto value = vm.argument(0);
|
||||
if (value.is_nullish())
|
||||
return Object::create(realm, realm.intrinsics().object_prototype()).ptr();
|
||||
|
|
|
@ -49,7 +49,7 @@ NonnullGCPtr<Promise> Promise::create(Realm& realm)
|
|||
|
||||
// 27.2 Promise Objects, https://tc39.es/ecma262/#sec-promise-objects
|
||||
Promise::Promise(Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ public:
|
|||
|
||||
protected:
|
||||
explicit PrototypeObject(Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
namespace JS {
|
||||
|
||||
ReflectObject::ReflectObject(Realm& realm)
|
||||
: Object(*realm.intrinsics().object_prototype())
|
||||
: Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().object_prototype())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -135,12 +135,12 @@ NonnullGCPtr<RegExpObject> RegExpObject::create(Realm& realm, Regex<ECMA262> reg
|
|||
}
|
||||
|
||||
RegExpObject::RegExpObject(Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
{
|
||||
}
|
||||
|
||||
RegExpObject::RegExpObject(Regex<ECMA262> regex, DeprecatedString pattern, DeprecatedString flags, Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
, m_pattern(move(pattern))
|
||||
, m_flags(move(flags))
|
||||
, m_regex(move(regex))
|
||||
|
|
|
@ -16,7 +16,7 @@ NonnullGCPtr<RegExpStringIterator> RegExpStringIterator::create(Realm& realm, Ob
|
|||
}
|
||||
|
||||
RegExpStringIterator::RegExpStringIterator(Object& prototype, Object& regexp_object, Utf16String string, bool global, bool unicode)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
, m_regexp_object(regexp_object)
|
||||
, m_string(move(string))
|
||||
, m_global(global)
|
||||
|
|
|
@ -14,7 +14,7 @@ NonnullGCPtr<Set> Set::create(Realm& realm)
|
|||
}
|
||||
|
||||
Set::Set(Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ NonnullGCPtr<SetIterator> SetIterator::create(Realm& realm, Set& set, Object::Pr
|
|||
}
|
||||
|
||||
SetIterator::SetIterator(Set& set, Object::PropertyKind iteration_kind, Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
, m_set(set)
|
||||
, m_iteration_kind(iteration_kind)
|
||||
, m_iterator(static_cast<Set const&>(set).begin())
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
namespace JS {
|
||||
|
||||
ShadowRealm::ShadowRealm(Realm& shadow_realm, ExecutionContext execution_context, Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
, m_shadow_realm(shadow_realm)
|
||||
, m_execution_context(move(execution_context))
|
||||
{
|
||||
|
|
|
@ -16,7 +16,7 @@ NonnullGCPtr<StringIterator> StringIterator::create(Realm& realm, DeprecatedStri
|
|||
}
|
||||
|
||||
StringIterator::StringIterator(DeprecatedString string, Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
, m_string(move(string))
|
||||
, m_iterator(Utf8View(m_string).begin())
|
||||
{
|
||||
|
|
|
@ -21,7 +21,7 @@ NonnullGCPtr<StringObject> StringObject::create(Realm& realm, PrimitiveString& p
|
|||
}
|
||||
|
||||
StringObject::StringObject(PrimitiveString& string, Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
, m_string(string)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ NonnullGCPtr<SymbolObject> SymbolObject::create(Realm& realm, Symbol& primitive_
|
|||
}
|
||||
|
||||
SymbolObject::SymbolObject(Symbol& symbol, Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
, m_symbol(symbol)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
namespace JS {
|
||||
|
||||
SymbolPrototype::SymbolPrototype(Realm& realm)
|
||||
: Object(*realm.intrinsics().object_prototype())
|
||||
: Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().object_prototype())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace JS::Temporal {
|
|||
|
||||
// 12 Temporal.Calendar Objects, https://tc39.es/proposal-temporal/#sec-temporal-calendar-objects
|
||||
Calendar::Calendar(DeprecatedString identifier, Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
, m_identifier(move(identifier))
|
||||
{
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace JS::Temporal {
|
|||
|
||||
// 7 Temporal.Duration Objects, https://tc39.es/proposal-temporal/#sec-temporal-duration-objects
|
||||
Duration::Duration(double years, double months, double weeks, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds, Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
, m_years(years)
|
||||
, m_months(months)
|
||||
, m_weeks(weeks)
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace JS::Temporal {
|
|||
|
||||
// 8 Temporal.Instant Objects, https://tc39.es/proposal-temporal/#sec-temporal-instant-objects
|
||||
Instant::Instant(BigInt const& nanoseconds, Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
, m_nanoseconds(nanoseconds)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace JS::Temporal {
|
|||
|
||||
// 2 The Temporal.Now Object, https://tc39.es/proposal-temporal/#sec-temporal-now-object
|
||||
Now::Now(Realm& realm)
|
||||
: Object(*realm.intrinsics().object_prototype())
|
||||
: Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().object_prototype())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace JS::Temporal {
|
|||
|
||||
// 3 Temporal.PlainDate Objects, https://tc39.es/proposal-temporal/#sec-temporal-plaindate-objects
|
||||
PlainDate::PlainDate(i32 year, u8 month, u8 day, Object& calendar, Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
, m_iso_year(year)
|
||||
, m_iso_month(month)
|
||||
, m_iso_day(day)
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace JS::Temporal {
|
|||
|
||||
// 5 Temporal.PlainDateTime Objects, https://tc39.es/proposal-temporal/#sec-temporal-plaindatetime-objects
|
||||
PlainDateTime::PlainDateTime(i32 iso_year, u8 iso_month, u8 iso_day, u8 iso_hour, u8 iso_minute, u8 iso_second, u16 iso_millisecond, u16 iso_microsecond, u16 iso_nanosecond, Object& calendar, Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
, m_iso_year(iso_year)
|
||||
, m_iso_month(iso_month)
|
||||
, m_iso_day(iso_day)
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace JS::Temporal {
|
|||
|
||||
// 10 Temporal.PlainMonthDay Objects, https://tc39.es/proposal-temporal/#sec-temporal-plainmonthday-objects
|
||||
PlainMonthDay::PlainMonthDay(u8 iso_month, u8 iso_day, i32 iso_year, Object& calendar, Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
, m_iso_year(iso_year)
|
||||
, m_iso_month(iso_month)
|
||||
, m_iso_day(iso_day)
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace JS::Temporal {
|
|||
|
||||
// 4 Temporal.PlainTime Objects, https://tc39.es/proposal-temporal/#sec-temporal-plaintime-objects
|
||||
PlainTime::PlainTime(u8 iso_hour, u8 iso_minute, u8 iso_second, u16 iso_millisecond, u16 iso_microsecond, u16 iso_nanosecond, Calendar& calendar, Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
, m_iso_hour(iso_hour)
|
||||
, m_iso_minute(iso_minute)
|
||||
, m_iso_second(iso_second)
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace JS::Temporal {
|
|||
|
||||
// 9 Temporal.PlainYearMonth Objects, https://tc39.es/proposal-temporal/#sec-temporal-plainyearmonth-objects
|
||||
PlainYearMonth::PlainYearMonth(i32 iso_year, u8 iso_month, u8 iso_day, Object& calendar, Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
, m_iso_year(iso_year)
|
||||
, m_iso_month(iso_month)
|
||||
, m_iso_day(iso_day)
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace JS::Temporal {
|
|||
|
||||
// 1 The Temporal Object, https://tc39.es/proposal-temporal/#sec-temporal-objects
|
||||
Temporal::Temporal(Realm& realm)
|
||||
: Object(*realm.intrinsics().object_prototype())
|
||||
: Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().object_prototype())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace JS::Temporal {
|
|||
|
||||
// 11 Temporal.TimeZone Objects, https://tc39.es/proposal-temporal/#sec-temporal-timezone-objects
|
||||
TimeZone::TimeZone(Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace JS::Temporal {
|
|||
|
||||
// 6 Temporal.ZonedDateTime Objects, https://tc39.es/proposal-temporal/#sec-temporal-zoneddatetime-objects
|
||||
ZonedDateTime::ZonedDateTime(BigInt const& nanoseconds, Object& time_zone, Object& calendar, Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
, m_nanoseconds(nanoseconds)
|
||||
, m_time_zone(time_zone)
|
||||
, m_calendar(calendar)
|
||||
|
|
|
@ -459,7 +459,7 @@ void TypedArrayBase::visit_edges(Visitor& visitor)
|
|||
} \
|
||||
\
|
||||
PrototypeName::PrototypeName(Object& prototype) \
|
||||
: Object(prototype) \
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype) \
|
||||
{ \
|
||||
} \
|
||||
\
|
||||
|
|
|
@ -62,7 +62,7 @@ public:
|
|||
|
||||
protected:
|
||||
TypedArrayBase(Object& prototype, IntrinsicConstructor intrinsic_constructor)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
, m_intrinsic_constructor(intrinsic_constructor)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
namespace JS {
|
||||
|
||||
TypedArrayPrototype::TypedArrayPrototype(Realm& realm)
|
||||
: Object(*realm.intrinsics().object_prototype())
|
||||
: Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().object_prototype())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ NonnullGCPtr<WeakMap> WeakMap::create(Realm& realm)
|
|||
}
|
||||
|
||||
WeakMap::WeakMap(Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
, WeakContainer(heap())
|
||||
{
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ NonnullGCPtr<WeakRef> WeakRef::create(Realm& realm, Symbol& value)
|
|||
}
|
||||
|
||||
WeakRef::WeakRef(Object& value, Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
, WeakContainer(heap())
|
||||
, m_value(&value)
|
||||
, m_last_execution_generation(vm().execution_generation())
|
||||
|
@ -27,7 +27,7 @@ WeakRef::WeakRef(Object& value, Object& prototype)
|
|||
}
|
||||
|
||||
WeakRef::WeakRef(Symbol& value, Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
, WeakContainer(heap())
|
||||
, m_value(&value)
|
||||
, m_last_execution_generation(vm().execution_generation())
|
||||
|
|
|
@ -14,7 +14,7 @@ NonnullGCPtr<WeakSet> WeakSet::create(Realm& realm)
|
|||
}
|
||||
|
||||
WeakSet::WeakSet(Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
, WeakContainer(heap())
|
||||
{
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
namespace Web::Bindings {
|
||||
|
||||
CSSNamespace::CSSNamespace(JS::Realm& realm)
|
||||
: JS::Object(*realm.intrinsics().object_prototype())
|
||||
: JS::Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().object_prototype())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ class LocationPrototype final : public JS::Object {
|
|||
|
||||
public:
|
||||
explicit LocationPrototype(JS::Realm& realm)
|
||||
: JS::Object(*realm.intrinsics().object_prototype())
|
||||
: JS::Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().object_prototype())
|
||||
{
|
||||
}
|
||||
};
|
||||
|
|
|
@ -17,7 +17,7 @@ PlatformObject::PlatformObject(JS::Realm& realm)
|
|||
}
|
||||
|
||||
PlatformObject::PlatformObject(JS::Object& prototype)
|
||||
: JS::Object(prototype)
|
||||
: JS::Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ class WindowPrototype final : public JS::Object {
|
|||
|
||||
public:
|
||||
explicit WindowPrototype(JS::Realm& realm)
|
||||
: JS::Object(cached_web_prototype(realm, "EventTarget"))
|
||||
: JS::Object(ConstructWithPrototypeTag::Tag, cached_web_prototype(realm, "EventTarget"))
|
||||
{
|
||||
}
|
||||
};
|
||||
|
|
|
@ -14,7 +14,7 @@ JS::NonnullGCPtr<IDLEventListener> IDLEventListener::create(JS::Realm& realm, JS
|
|||
}
|
||||
|
||||
IDLEventListener::IDLEventListener(JS::Realm& realm, JS::NonnullGCPtr<WebIDL::CallbackType> callback)
|
||||
: JS::Object(*realm.intrinsics().object_prototype())
|
||||
: JS::Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().object_prototype())
|
||||
, m_callback(move(callback))
|
||||
{
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
namespace Web::Bindings {
|
||||
|
||||
WebAssemblyInstanceObject::WebAssemblyInstanceObject(JS::Realm& realm, size_t index)
|
||||
: Object(Bindings::ensure_web_prototype<WebAssemblyInstancePrototype>(realm, "WebAssemblyInstancePrototype"))
|
||||
: Object(ConstructWithPrototypeTag::Tag, Bindings::ensure_web_prototype<WebAssemblyInstancePrototype>(realm, "WebAssemblyInstancePrototype"))
|
||||
, m_index(index)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ class WebAssemblyInstancePrototype final : public JS::Object {
|
|||
|
||||
public:
|
||||
explicit WebAssemblyInstancePrototype(JS::Realm& realm)
|
||||
: JS::Object(*realm.intrinsics().object_prototype())
|
||||
: JS::Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().object_prototype())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ class WebAssemblyMemoryPrototype final : public JS::Object {
|
|||
|
||||
public:
|
||||
explicit WebAssemblyMemoryPrototype(JS::Realm& realm)
|
||||
: JS::Object(*realm.intrinsics().object_prototype())
|
||||
: JS::Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().object_prototype())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
namespace Web::Bindings {
|
||||
|
||||
WebAssemblyModuleObject::WebAssemblyModuleObject(JS::Realm& realm, size_t index)
|
||||
: Object(Bindings::ensure_web_prototype<WebAssemblyModulePrototype>(realm, "WebAssemblyModulePrototype"))
|
||||
: Object(ConstructWithPrototypeTag::Tag, Bindings::ensure_web_prototype<WebAssemblyModulePrototype>(realm, "WebAssemblyModulePrototype"))
|
||||
, m_index(index)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ class WebAssemblyModulePrototype final : public JS::Object {
|
|||
|
||||
public:
|
||||
explicit WebAssemblyModulePrototype(JS::Realm& realm)
|
||||
: JS::Object(*realm.intrinsics().object_prototype())
|
||||
: JS::Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().object_prototype())
|
||||
{
|
||||
}
|
||||
};
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
namespace Web::Bindings {
|
||||
|
||||
WebAssemblyObject::WebAssemblyObject(JS::Realm& realm)
|
||||
: Object(*realm.intrinsics().object_prototype())
|
||||
: Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().object_prototype())
|
||||
{
|
||||
s_abstract_machine.enable_instruction_count_limit();
|
||||
}
|
||||
|
@ -483,7 +483,7 @@ JS::NativeFunction* create_native_function(JS::VM& vm, Wasm::FunctionAddress add
|
|||
}
|
||||
|
||||
WebAssemblyMemoryObject::WebAssemblyMemoryObject(JS::Realm& realm, Wasm::MemoryAddress address)
|
||||
: Object(Bindings::ensure_web_prototype<WebAssemblyMemoryPrototype>(realm, "WebAssemblyMemoryPrototype"))
|
||||
: Object(ConstructWithPrototypeTag::Tag, Bindings::ensure_web_prototype<WebAssemblyMemoryPrototype>(realm, "WebAssemblyMemoryPrototype"))
|
||||
, m_address(address)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
namespace Web::Bindings {
|
||||
|
||||
WebAssemblyTableObject::WebAssemblyTableObject(JS::Realm& realm, Wasm::TableAddress address)
|
||||
: Object(Bindings::ensure_web_prototype<WebAssemblyTablePrototype>(realm, "WebAssemblyTablePrototype"))
|
||||
: Object(ConstructWithPrototypeTag::Tag, Bindings::ensure_web_prototype<WebAssemblyTablePrototype>(realm, "WebAssemblyTablePrototype"))
|
||||
, m_address(address)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ class WebAssemblyTablePrototype final : public JS::Object {
|
|||
|
||||
public:
|
||||
explicit WebAssemblyTablePrototype(JS::Realm& realm)
|
||||
: JS::Object(*realm.intrinsics().object_prototype())
|
||||
: JS::Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().object_prototype())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue