1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 06:48:12 +00:00

LibJS: Add spec links to a bunch of the environment record methods

This commit is contained in:
Andreas Kling 2021-06-23 13:25:57 +02:00
parent cf34313fad
commit 15faa13c95
3 changed files with 26 additions and 0 deletions

View file

@ -52,6 +52,7 @@ bool ObjectEnvironmentRecord::has_binding(FlyString const& name) const
return true;
}
// 9.1.1.2.2 CreateMutableBinding ( N, D ), https://tc39.es/ecma262/#sec-object-environment-records-createmutablebinding-n-d
void ObjectEnvironmentRecord::create_mutable_binding(GlobalObject&, FlyString const& name, bool can_be_deleted)
{
PropertyAttributes attributes;
@ -65,16 +66,20 @@ void ObjectEnvironmentRecord::create_mutable_binding(GlobalObject&, FlyString co
m_object.define_property(name, js_undefined(), attributes, true);
}
// 9.1.1.2.3 CreateImmutableBinding ( N, S ), https://tc39.es/ecma262/#sec-object-environment-records-createimmutablebinding-n-s
void ObjectEnvironmentRecord::create_immutable_binding(GlobalObject&, FlyString const&, bool)
{
// "The CreateImmutableBinding concrete method of an object Environment Record is never used within this specification."
VERIFY_NOT_REACHED();
}
// 9.1.1.2.4 InitializeBinding ( N, V ), https://tc39.es/ecma262/#sec-object-environment-records-initializebinding-n-v
void ObjectEnvironmentRecord::initialize_binding(GlobalObject& global_object, FlyString const& name, Value value)
{
set_mutable_binding(global_object, name, value, false);
}
// 9.1.1.2.5 SetMutableBinding ( N, V, S ), https://tc39.es/ecma262/#sec-object-environment-records-setmutablebinding-n-v-s
void ObjectEnvironmentRecord::set_mutable_binding(GlobalObject& global_object, FlyString const& name, Value value, bool strict)
{
bool still_exists = m_object.has_property(name);
@ -87,6 +92,7 @@ void ObjectEnvironmentRecord::set_mutable_binding(GlobalObject& global_object, F
m_object.put(name, value);
}
// 9.1.1.2.6 GetBindingValue ( N, S ), https://tc39.es/ecma262/#sec-object-environment-records-getbindingvalue-n-s
Value ObjectEnvironmentRecord::get_binding_value(GlobalObject& global_object, FlyString const& name, bool strict)
{
if (!m_object.has_property(name)) {
@ -100,6 +106,7 @@ Value ObjectEnvironmentRecord::get_binding_value(GlobalObject& global_object, Fl
return m_object.get(name);
}
// 9.1.1.2.7 DeleteBinding ( N ), https://tc39.es/ecma262/#sec-object-environment-records-deletebinding-n
bool ObjectEnvironmentRecord::delete_binding(GlobalObject&, FlyString const& name)
{
return m_object.delete_property(name);