mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:57:45 +00:00
LibJS: Add the Symbol.species getter to the appropriate built-ins
This commit is contained in:
parent
39c3aefe5d
commit
aefb7995f1
10 changed files with 45 additions and 0 deletions
|
@ -25,6 +25,8 @@ void ArrayBufferConstructor::initialize(GlobalObject& global_object)
|
|||
define_property(vm.names.prototype, global_object.array_buffer_prototype(), 0);
|
||||
define_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
define_native_function(vm.names.isView, is_view, 1, attr);
|
||||
|
||||
define_native_property(vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable);
|
||||
}
|
||||
|
||||
ArrayBufferConstructor::~ArrayBufferConstructor()
|
||||
|
@ -62,4 +64,9 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayBufferConstructor::is_view)
|
|||
return Value(false);
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_GETTER(ArrayBufferConstructor::symbol_species_getter)
|
||||
{
|
||||
return vm.this_value(global_object);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@ private:
|
|||
virtual bool has_constructor() const override { return true; }
|
||||
|
||||
JS_DECLARE_NATIVE_FUNCTION(is_view);
|
||||
|
||||
JS_DECLARE_NATIVE_GETTER(symbol_species_getter);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -37,6 +37,8 @@ void ArrayConstructor::initialize(GlobalObject& global_object)
|
|||
define_native_function(vm.names.from, from, 1, attr);
|
||||
define_native_function(vm.names.isArray, is_array, 1, attr);
|
||||
define_native_function(vm.names.of, of, 0, attr);
|
||||
|
||||
define_native_property(vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable);
|
||||
}
|
||||
|
||||
Value ArrayConstructor::call()
|
||||
|
@ -151,4 +153,9 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayConstructor::of)
|
|||
return array;
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_GETTER(ArrayConstructor::symbol_species_getter)
|
||||
{
|
||||
return vm.this_value(global_object);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,6 +27,8 @@ private:
|
|||
JS_DECLARE_NATIVE_FUNCTION(from);
|
||||
JS_DECLARE_NATIVE_FUNCTION(is_array);
|
||||
JS_DECLARE_NATIVE_FUNCTION(of);
|
||||
|
||||
JS_DECLARE_NATIVE_GETTER(symbol_species_getter);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -35,6 +35,8 @@ void PromiseConstructor::initialize(GlobalObject& global_object)
|
|||
// define_native_function(vm.names.race, race, 1, attr);
|
||||
define_native_function(vm.names.reject, reject, 1, attr);
|
||||
define_native_function(vm.names.resolve, resolve, 1, attr);
|
||||
|
||||
define_native_property(vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable);
|
||||
}
|
||||
|
||||
Value PromiseConstructor::call()
|
||||
|
@ -113,4 +115,9 @@ JS_DEFINE_NATIVE_FUNCTION(PromiseConstructor::resolve)
|
|||
return promise_resolve(global_object, *constructor, value);
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_GETTER(PromiseConstructor::symbol_species_getter)
|
||||
{
|
||||
return vm.this_value(global_object);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -30,6 +30,8 @@ private:
|
|||
JS_DECLARE_NATIVE_FUNCTION(race);
|
||||
JS_DECLARE_NATIVE_FUNCTION(reject);
|
||||
JS_DECLARE_NATIVE_FUNCTION(resolve);
|
||||
|
||||
JS_DECLARE_NATIVE_GETTER(symbol_species_getter);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -22,6 +22,8 @@ void RegExpConstructor::initialize(GlobalObject& global_object)
|
|||
NativeFunction::initialize(global_object);
|
||||
define_property(vm.names.prototype, global_object.regexp_prototype(), 0);
|
||||
define_property(vm.names.length, Value(2), Attribute::Configurable);
|
||||
|
||||
define_native_property(vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable);
|
||||
}
|
||||
|
||||
RegExpConstructor::~RegExpConstructor()
|
||||
|
@ -51,4 +53,9 @@ Value RegExpConstructor::construct(Function&)
|
|||
return RegExpObject::create(global_object(), pattern, flags);
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_GETTER(RegExpConstructor::symbol_species_getter)
|
||||
{
|
||||
return vm.this_value(global_object);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,6 +23,8 @@ public:
|
|||
|
||||
private:
|
||||
virtual bool has_constructor() const override { return true; }
|
||||
|
||||
JS_DECLARE_NATIVE_GETTER(symbol_species_getter);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@ void TypedArrayConstructor::initialize(GlobalObject& global_object)
|
|||
NativeFunction::initialize(global_object);
|
||||
define_property(vm.names.prototype, global_object.typed_array_prototype(), 0);
|
||||
define_property(vm.names.length, Value(0), Attribute::Configurable);
|
||||
|
||||
define_native_property(vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable);
|
||||
}
|
||||
|
||||
TypedArrayConstructor::~TypedArrayConstructor()
|
||||
|
@ -42,4 +44,9 @@ Value TypedArrayConstructor::construct(Function&)
|
|||
return {};
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_GETTER(TypedArrayConstructor::symbol_species_getter)
|
||||
{
|
||||
return vm.this_value(global_object);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,6 +24,8 @@ public:
|
|||
|
||||
private:
|
||||
virtual bool has_constructor() const override { return true; }
|
||||
|
||||
JS_DECLARE_NATIVE_GETTER(symbol_species_getter);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue