mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:17:44 +00:00
LibJS: Make Environment::has_binding() optionally return binding index
If the caller wants to use the binding index for anything, if there is such a thing, it can now be obtained via an optional out-parameter.
This commit is contained in:
parent
6ef5464015
commit
cb696eff08
7 changed files with 13 additions and 8 deletions
|
@ -35,9 +35,14 @@ void DeclarativeEnvironment::visit_edges(Visitor& visitor)
|
|||
}
|
||||
|
||||
// 9.1.1.1.1 HasBinding ( N ), https://tc39.es/ecma262/#sec-declarative-environment-records-hasbinding-n
|
||||
bool DeclarativeEnvironment::has_binding(FlyString const& name) const
|
||||
bool DeclarativeEnvironment::has_binding(FlyString const& name, Optional<size_t>* out_index) const
|
||||
{
|
||||
return m_names.contains(name);
|
||||
auto it = m_names.find(name);
|
||||
if (it == m_names.end())
|
||||
return false;
|
||||
if (out_index)
|
||||
*out_index = it->value;
|
||||
return true;
|
||||
}
|
||||
|
||||
// 9.1.1.1.2 CreateMutableBinding ( N, D ), https://tc39.es/ecma262/#sec-declarative-environment-records-createmutablebinding-n-d
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue