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

LibJS: Convert set_mutable_binding() to ThrowCompletionOr

Also add spec step comments to it while we're here.
This commit is contained in:
Linus Groh 2021-10-09 19:34:54 +01:00
parent ae397541fb
commit 7652138ce0
11 changed files with 68 additions and 52 deletions

View file

@ -92,14 +92,18 @@ ThrowCompletionOr<void> GlobalEnvironment::initialize_binding(GlobalObject& glob
}
// 9.1.1.4.5 SetMutableBinding ( N, V, S ), https://tc39.es/ecma262/#sec-global-environment-records-setmutablebinding-n-v-s
void GlobalEnvironment::set_mutable_binding(GlobalObject& global_object, FlyString const& name, Value value, bool strict)
ThrowCompletionOr<void> GlobalEnvironment::set_mutable_binding(GlobalObject& global_object, FlyString const& name, Value value, bool strict)
{
// 1. Let DclRec be envRec.[[DeclarativeRecord]].
// 2. If DclRec.HasBinding(N) is true, then
if (MUST(m_declarative_record->has_binding(name))) {
m_declarative_record->set_mutable_binding(global_object, name, value, strict);
return;
// a. Return DclRec.SetMutableBinding(N, V, S).
return m_declarative_record->set_mutable_binding(global_object, name, value, strict);
}
m_object_record->set_mutable_binding(global_object, name, value, strict);
// 3. Let ObjRec be envRec.[[ObjectRecord]].
// 4. Return ? ObjRec.SetMutableBinding(N, V, S).
return m_object_record->set_mutable_binding(global_object, name, value, strict);
}
// 9.1.1.4.6 GetBindingValue ( N, S ), https://tc39.es/ecma262/#sec-global-environment-records-getbindingvalue-n-s