mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-21 02:08:12 +03:00
LibJS: Add bytecode generation for FunctionExpression :^)
This commit is contained in:
parent
749a3b9245
commit
af48a066c6
Notes:
sideshowbarker
2024-07-18 12:27:36 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/af48a066c6c
@ -308,6 +308,8 @@ public:
|
||||
bool cannot_auto_rename() const { return m_cannot_auto_rename; }
|
||||
void set_cannot_auto_rename() { m_cannot_auto_rename = true; }
|
||||
|
||||
virtual void generate_bytecode(Bytecode::Generator&) const override;
|
||||
|
||||
private:
|
||||
bool m_cannot_auto_rename { false };
|
||||
};
|
||||
|
@ -605,6 +605,11 @@ void FunctionDeclaration::generate_bytecode(Bytecode::Generator&) const
|
||||
{
|
||||
}
|
||||
|
||||
void FunctionExpression::generate_bytecode(Bytecode::Generator& generator) const
|
||||
{
|
||||
generator.emit<Bytecode::Op::NewFunction>(*this);
|
||||
}
|
||||
|
||||
void VariableDeclaration::generate_bytecode(Bytecode::Generator& generator) const
|
||||
{
|
||||
for (auto& declarator : m_declarations) {
|
||||
|
@ -218,7 +218,7 @@ void Call::execute(Bytecode::Interpreter& interpreter) const
|
||||
void NewFunction::execute(Bytecode::Interpreter& interpreter) const
|
||||
{
|
||||
auto& vm = interpreter.vm();
|
||||
interpreter.accumulator() = ScriptFunction::create(interpreter.global_object(), m_function_node.name(), m_function_node.body(), m_function_node.parameters(), m_function_node.function_length(), vm.current_scope(), m_function_node.is_generator(), m_function_node.is_strict_mode());
|
||||
interpreter.accumulator() = ScriptFunction::create(interpreter.global_object(), m_function_node.name(), m_function_node.body(), m_function_node.parameters(), m_function_node.function_length(), vm.current_scope(), m_function_node.is_generator(), m_function_node.is_strict_mode(), m_function_node.is_arrow_function());
|
||||
}
|
||||
|
||||
void Return::execute(Bytecode::Interpreter& interpreter) const
|
||||
|
Loading…
Reference in New Issue
Block a user