mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:17:35 +00:00
LibJS: Update bytecode generator to use local variables
- Update ECMAScriptFunctionObject::function_declaration_instantiation to initialize local variables - Introduce GetLocal, SetLocal, TypeofLocal that will be used to operate on local variables. - Update bytecode generator to emit instructions for local variables
This commit is contained in:
parent
0daff637e2
commit
ae3a7fd4b8
8 changed files with 170 additions and 37 deletions
|
@ -484,6 +484,25 @@ private:
|
|||
InitializationMode m_initialization_mode { InitializationMode::Set };
|
||||
};
|
||||
|
||||
class SetLocal final : public Instruction {
|
||||
public:
|
||||
explicit SetLocal(size_t index)
|
||||
: Instruction(Type::SetLocal)
|
||||
, m_index(index)
|
||||
{
|
||||
}
|
||||
|
||||
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
||||
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
|
||||
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
|
||||
void replace_references_impl(Register, Register) { }
|
||||
|
||||
size_t index() const { return m_index; }
|
||||
|
||||
private:
|
||||
size_t m_index;
|
||||
};
|
||||
|
||||
class GetVariable final : public Instruction {
|
||||
public:
|
||||
explicit GetVariable(IdentifierTableIndex identifier)
|
||||
|
@ -505,6 +524,25 @@ private:
|
|||
Optional<EnvironmentCoordinate> mutable m_cached_environment_coordinate;
|
||||
};
|
||||
|
||||
class GetLocal final : public Instruction {
|
||||
public:
|
||||
explicit GetLocal(size_t index)
|
||||
: Instruction(Type::GetLocal)
|
||||
, m_index(index)
|
||||
{
|
||||
}
|
||||
|
||||
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
||||
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
|
||||
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
|
||||
void replace_references_impl(Register, Register) { }
|
||||
|
||||
size_t index() const { return m_index; }
|
||||
|
||||
private:
|
||||
size_t m_index;
|
||||
};
|
||||
|
||||
class DeleteVariable final : public Instruction {
|
||||
public:
|
||||
explicit DeleteVariable(IdentifierTableIndex identifier)
|
||||
|
@ -1338,6 +1376,23 @@ private:
|
|||
IdentifierTableIndex m_identifier;
|
||||
};
|
||||
|
||||
class TypeofLocal final : public Instruction {
|
||||
public:
|
||||
explicit TypeofLocal(size_t index)
|
||||
: Instruction(Type::TypeofLocal)
|
||||
, m_index(index)
|
||||
{
|
||||
}
|
||||
|
||||
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
||||
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
|
||||
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
|
||||
void replace_references_impl(Register, Register) { }
|
||||
|
||||
private:
|
||||
size_t m_index;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace JS::Bytecode {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue