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

LibJS: Remove direct argument loading since it was buggy

The parser doesn't always track lexical scopes correctly, so let's not
rely on that for direct argument loading.

This reverts the LoadArguments bytecode instruction as well. We can
bring these things back when the parser can reliably tell us that
a given Identifier is indeed a function argument.
This commit is contained in:
Andreas Kling 2021-06-22 22:20:17 +02:00
parent 1082e99e08
commit 8a3c9d9851
9 changed files with 4 additions and 79 deletions

View file

@ -665,8 +665,6 @@ Reference Expression::to_reference(Interpreter&, GlobalObject&) const
Reference Identifier::to_reference(Interpreter& interpreter, GlobalObject&) const
{
if (m_argument_index.has_value())
return Reference(Reference::CallFrameArgument, m_argument_index.value(), string());
return interpreter.vm().get_reference(string());
}
@ -1315,9 +1313,6 @@ Value Identifier::execute(Interpreter& interpreter, GlobalObject& global_object)
{
InterpreterNodeScope node_scope { interpreter, *this };
if (m_argument_index.has_value())
return interpreter.vm().argument(m_argument_index.value());
auto value = interpreter.vm().get_variable(string(), global_object);
if (value.is_empty()) {
if (!interpreter.exception())
@ -1330,10 +1325,7 @@ Value Identifier::execute(Interpreter& interpreter, GlobalObject& global_object)
void Identifier::dump(int indent) const
{
print_indent(indent);
if (m_argument_index.has_value())
outln("Identifier \"{}\" (argument #{})", m_string, m_argument_index.value());
else
outln("Identifier \"{}\"", m_string);
outln("Identifier \"{}\"", m_string);
}
void SpreadExpression::dump(int indent) const