1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 14:28:12 +00:00

LibJS/Bytecode: Simplify creating/leaving lexical environment

Since we no longer need to create or leave var environments directly
in bytecode, we can streamline the two instructions by making them
always operate on the lexical environment.
This commit is contained in:
Andreas Kling 2023-06-16 16:43:24 +02:00
parent 12ce0789da
commit dbfe1311ef
6 changed files with 25 additions and 45 deletions

View file

@ -383,11 +383,10 @@ enum class EnvironmentMode {
Var,
};
class CreateEnvironment final : public Instruction {
class CreateLexicalEnvironment final : public Instruction {
public:
explicit CreateEnvironment(EnvironmentMode mode)
: Instruction(Type::CreateEnvironment)
, m_mode(mode)
explicit CreateLexicalEnvironment()
: Instruction(Type::CreateLexicalEnvironment)
{
}
@ -395,9 +394,6 @@ public:
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
void replace_references_impl(Register, Register) { }
private:
EnvironmentMode m_mode { EnvironmentMode::Lexical };
};
class EnterObjectEnvironment final : public Instruction {
@ -955,11 +951,10 @@ private:
Label m_target;
};
class LeaveEnvironment final : public Instruction {
class LeaveLexicalEnvironment final : public Instruction {
public:
LeaveEnvironment(EnvironmentMode mode)
: Instruction(Type::LeaveEnvironment)
, m_mode(mode)
LeaveLexicalEnvironment()
: Instruction(Type::LeaveLexicalEnvironment)
{
}
@ -967,9 +962,6 @@ public:
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
void replace_references_impl(Register, Register) { }
private:
EnvironmentMode m_mode { EnvironmentMode::Lexical };
};
class LeaveUnwindContext final : public Instruction {