diff options
author | Ali Mohammad Pur <ali.mpfard@gmail.com> | 2021-06-11 01:38:30 +0430 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-06-11 00:30:09 +0200 |
commit | 3234697ecacb41e15e230a450f2759f404c8b047 (patch) | |
tree | 54b9b4de011c95644a4ceb3ce694b79bdcf0ce49 /Userland/Libraries/LibJS/Bytecode/Interpreter.h | |
parent | c53a86a3fe530d6adaa095944a59a8a0333be3c6 (diff) | |
download | serenity-3234697ecacb41e15e230a450f2759f404c8b047.zip |
LibJS: Implement generator functions (only in bytecode mode)
Diffstat (limited to 'Userland/Libraries/LibJS/Bytecode/Interpreter.h')
-rw-r--r-- | Userland/Libraries/LibJS/Bytecode/Interpreter.h | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/Userland/Libraries/LibJS/Bytecode/Interpreter.h b/Userland/Libraries/LibJS/Bytecode/Interpreter.h index 2e2c3f8109..26b2dc9078 100644 --- a/Userland/Libraries/LibJS/Bytecode/Interpreter.h +++ b/Userland/Libraries/LibJS/Bytecode/Interpreter.h @@ -30,10 +30,23 @@ public: GlobalObject& global_object() { return m_global_object; } VM& vm() { return m_vm; } - Value run(Bytecode::Executable const&); + Value run(Bytecode::Executable const&, Bytecode::BasicBlock const* entry_point = nullptr); ALWAYS_INLINE Value& accumulator() { return reg(Register::accumulator()); } Value& reg(Register const& r) { return registers()[r.index()]; } + [[nodiscard]] RegisterWindow snapshot_frame() const { return m_register_windows.last(); } + + void enter_frame(RegisterWindow const& frame) + { + ++m_manually_entered_frames; + m_register_windows.append(make<RegisterWindow>(frame)); + } + void leave_frame() + { + VERIFY(m_manually_entered_frames); + --m_manually_entered_frames; + m_register_windows.take_last(); + } void jump(Label const& label) { @@ -55,6 +68,7 @@ private: NonnullOwnPtrVector<RegisterWindow> m_register_windows; Optional<BasicBlock const*> m_pending_jump; Value m_return_value; + size_t m_manually_entered_frames { 0 }; Executable const* m_current_executable { nullptr }; Vector<UnwindInfo> m_unwind_contexts; Handle<Exception> m_saved_exception; |