1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:47:45 +00:00

LibJS: Make Identifier::execute() actually use the lookup cache

If we have cached environment coordinates for an Identifier, we have
to call to_reference() to actually make use of them. :^)
This commit is contained in:
Andreas Kling 2022-11-10 20:59:44 +01:00 committed by Linus Groh
parent d7e5a2058d
commit 6ff9931dde

View file

@ -2543,7 +2543,8 @@ Completion Identifier::execute(Interpreter& interpreter) const
auto& vm = interpreter.vm();
// 1. Return ? ResolveBinding(StringValue of Identifier).
auto reference = TRY(vm.resolve_binding(m_string));
// OPTIMIZATION: We call Identifier::to_reference() here, which acts as a caching layer around ResolveBinding.
auto reference = TRY(to_reference(interpreter));
// NOTE: The spec wants us to return the reference directly; this is not possible with ASTNode::execute() (short of letting it return a variant).
// So, instead of calling GetValue at the call site, we do it here.