1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 19:17:35 +00:00

LibJS: Make Reference aware of DeclarativeEnvironment indices

VM::resolve_binding() can now return a Reference that knows the exact
binding index if it's pointing into a DeclarativeEnvironment.

Reading/writing through the Reference will now use direct environment
access when possible.
This commit is contained in:
Andreas Kling 2021-10-07 00:16:37 +02:00
parent 540ce075b6
commit 4444bcabde
3 changed files with 14 additions and 4 deletions

View file

@ -44,11 +44,12 @@ public:
}
}
Reference(Environment& base, FlyString referenced_name, bool strict = false)
Reference(Environment& base, FlyString referenced_name, bool strict = false, Optional<size_t> index_in_declarative_environment = {})
: m_base_type(BaseType::Environment)
, m_base_environment(&base)
, m_name(move(referenced_name))
, m_strict(strict)
, m_index_in_declarative_environment(move(index_in_declarative_environment))
{
}
@ -129,6 +130,7 @@ private:
PropertyName m_name;
Value m_this_value;
bool m_strict { false };
Optional<size_t> m_index_in_declarative_environment;
};
}