mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 00:17:46 +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:
parent
1082e99e08
commit
8a3c9d9851
9 changed files with 4 additions and 79 deletions
|
@ -267,10 +267,7 @@ void RegExpLiteral::generate_bytecode(Bytecode::Generator& generator) const
|
|||
|
||||
void Identifier::generate_bytecode(Bytecode::Generator& generator) const
|
||||
{
|
||||
if (m_argument_index.has_value())
|
||||
generator.emit<Bytecode::Op::LoadArgument>(m_argument_index.value());
|
||||
else
|
||||
generator.emit<Bytecode::Op::GetVariable>(generator.intern_string(m_string));
|
||||
generator.emit<Bytecode::Op::GetVariable>(generator.intern_string(m_string));
|
||||
}
|
||||
|
||||
void AssignmentExpression::generate_bytecode(Bytecode::Generator& generator) const
|
||||
|
|
|
@ -65,7 +65,6 @@
|
|||
O(Decrement) \
|
||||
O(Throw) \
|
||||
O(PushDeclarativeEnvironmentRecord) \
|
||||
O(LoadArgument) \
|
||||
O(EnterUnwindContext) \
|
||||
O(LeaveUnwindContext) \
|
||||
O(ContinuePendingUnwind) \
|
||||
|
|
|
@ -429,11 +429,6 @@ void PutByValue::execute_impl(Bytecode::Interpreter& interpreter) const
|
|||
}
|
||||
}
|
||||
|
||||
void LoadArgument::execute_impl(Bytecode::Interpreter& interpreter) const
|
||||
{
|
||||
interpreter.accumulator() = interpreter.vm().argument(m_index);
|
||||
}
|
||||
|
||||
void GetIterator::execute_impl(Bytecode::Interpreter& interpreter) const
|
||||
{
|
||||
interpreter.accumulator() = get_iterator(interpreter.global_object(), interpreter.accumulator());
|
||||
|
@ -672,11 +667,6 @@ String PutByValue::to_string_impl(const Bytecode::Executable&) const
|
|||
return String::formatted("PutByValue base:{}, property:{}", m_base, m_property);
|
||||
}
|
||||
|
||||
String LoadArgument::to_string_impl(const Bytecode::Executable&) const
|
||||
{
|
||||
return String::formatted("LoadArgument {}", m_index);
|
||||
}
|
||||
|
||||
String GetIterator::to_string_impl(Executable const&) const
|
||||
{
|
||||
return "GetIterator";
|
||||
|
|
|
@ -651,22 +651,6 @@ private:
|
|||
HashMap<u32, Variable> m_variables;
|
||||
};
|
||||
|
||||
class LoadArgument final : public Instruction {
|
||||
public:
|
||||
explicit LoadArgument(size_t index)
|
||||
: Instruction(Type::LoadArgument)
|
||||
, m_index(index)
|
||||
{
|
||||
}
|
||||
|
||||
void execute_impl(Bytecode::Interpreter&) const;
|
||||
String to_string_impl(Bytecode::Executable const&) const;
|
||||
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
|
||||
|
||||
private:
|
||||
size_t m_index { 0 };
|
||||
};
|
||||
|
||||
class GetIterator final : public Instruction {
|
||||
public:
|
||||
GetIterator()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue