1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 15:58:11 +00:00

LibJS: Track which Identifier nodes refer to function arguments

This patch adds an "argument index" field to Identifier AST nodes.
If the Identifier refers to a function parameter in the currently
open function scope, we stash the index of the parameter here.

This will allow us to implement much faster direct access to function
argument variables.
This commit is contained in:
Andreas Kling 2021-06-14 09:30:43 +02:00
parent ae8b55a80a
commit 481cef59b6
4 changed files with 39 additions and 5 deletions

View file

@ -1313,7 +1313,10 @@ Value Identifier::execute(Interpreter& interpreter, GlobalObject& global_object)
void Identifier::dump(int indent) const
{
print_indent(indent);
outln("Identifier \"{}\"", m_string);
if (m_argument_index.has_value())
outln("Identifier \"{}\" (argument #{})", m_string, m_argument_index.value());
else
outln("Identifier \"{}\"", m_string);
}
void SpreadExpression::dump(int indent) const