mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-05 06:32:30 +02: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:
committed by
Andreas Kling
parent
0daff637e2
commit
ae3a7fd4b8
Notes:
sideshowbarker
2024-07-16 20:21:48 +09:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/SerenityOS/serenity/commit/ae3a7fd4b8 Pull-request: https://github.com/SerenityOS/serenity/pull/19719 Reviewed-by: https://github.com/awesomekling
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user