diff options
Diffstat (limited to 'Userland/Libraries/LibJS/Bytecode/Op.cpp')
-rw-r--r-- | Userland/Libraries/LibJS/Bytecode/Op.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/Userland/Libraries/LibJS/Bytecode/Op.cpp b/Userland/Libraries/LibJS/Bytecode/Op.cpp index f97fd1b538..2d080627c1 100644 --- a/Userland/Libraries/LibJS/Bytecode/Op.cpp +++ b/Userland/Libraries/LibJS/Bytecode/Op.cpp @@ -218,8 +218,7 @@ void Call::execute(Bytecode::Interpreter& interpreter) const void NewFunction::execute(Bytecode::Interpreter& interpreter) const { auto& vm = interpreter.vm(); - auto& global_object = interpreter.global_object(); - interpreter.accumulator() = ScriptFunction::create(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_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()); } void Return::execute(Bytecode::Interpreter& interpreter) const @@ -280,6 +279,18 @@ void PushLexicalEnvironment::execute(Bytecode::Interpreter& interpreter) const interpreter.vm().call_frame().scope = block_lexical_environment; } +void Yield::execute(Bytecode::Interpreter& interpreter) const +{ + auto yielded_value = interpreter.accumulator().value_or(js_undefined()); + auto object = JS::Object::create_empty(interpreter.global_object()); + object->put("result", yielded_value); + if (m_continuation_label.has_value()) + object->put("continuation", Value(static_cast<double>(reinterpret_cast<u64>(&m_continuation_label->block())))); + else + object->put("continuation", Value(0)); + interpreter.do_return(object); +} + String Load::to_string(Bytecode::Executable const&) const { return String::formatted("Load {}", m_src); @@ -445,4 +456,11 @@ String PushLexicalEnvironment::to_string(const Bytecode::Executable& executable) return builder.to_string(); } +String Yield::to_string(Bytecode::Executable const&) const +{ + if (m_continuation_label.has_value()) + return String::formatted("Yield continuation:@{}", m_continuation_label->block().name()); + return String::formatted("Yield return"); +} + } |