From 464b24eeed0a75cb802ea7e7125185579ffb3898 Mon Sep 17 00:00:00 2001 From: CHatingPython Date: Sun, 7 Jun 2026 11:43:38 +0200 Subject: [PATCH] feat(furvm): implement return value instruction --- furvm/src/executor.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/furvm/src/executor.cpp b/furvm/src/executor.cpp index 6fe69ba..9101fb2 100644 --- a/furvm/src/executor.cpp +++ b/furvm/src/executor.cpp @@ -59,10 +59,6 @@ void executor::step() { instruction_t instr = static_cast(frame.mod->byte(frame.position++)); switch (instr) { case instruction_t::NoOperation: break; - case instruction_t::Return: { - pop_frame(); - if (m_frames.empty()) m_flags = m_flags | executor_flags::Done; - } break; case instruction_t::PushB2I: { auto thing = thing::create(m_context, thing_t::Int32); thing->int32() = frame.mod->byte(frame.position++); @@ -71,9 +67,17 @@ void executor::step() { case instruction_t::Drop: { m_stack.pop(); } break; - case instruction_t::PushConstant: - case instruction_t::Duplicate: + case instruction_t::Return: { + pop_frame(); + if (m_frames.empty()) m_flags = m_flags | executor_flags::Done; + } break; case instruction_t::ReturnValue: { + auto value = pop_thing(); + pop_frame(); + m_stack.push(std::move(value)); + } break; + case instruction_t::PushConstant: + case instruction_t::Duplicate: { throw std::runtime_error("unimplemented"); } }