From 42e71080a22e5c84ac4bc5a30abb141f518d7474 Mon Sep 17 00:00:00 2001 From: CHatingPython Date: Tue, 14 Jul 2026 12:40:47 +0200 Subject: [PATCH] feat(furvm): introduce set instruction Closes: #57 --- furvm/include/furvm/instruction.hpp | 5 +++++ furvm/src/executor.cpp | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/furvm/include/furvm/instruction.hpp b/furvm/include/furvm/instruction.hpp index c1ece78..958af29 100644 --- a/furvm/include/furvm/instruction.hpp +++ b/furvm/include/furvm/instruction.hpp @@ -38,6 +38,11 @@ enum class instruction_t : byte { */ Get, + /** + * @brief Sets an array element. + */ + Set, + /** * @brief Pops top element from the stack. */ diff --git a/furvm/src/executor.cpp b/furvm/src/executor.cpp index a86c766..f58d4d1 100644 --- a/furvm/src/executor.cpp +++ b/furvm/src/executor.cpp @@ -161,6 +161,12 @@ void executor::step() { auto array = pop_thing(); push_thing(array->at(index->integer())); } break; + case instruction_t::Set: { + auto index = pop_thing(); + auto array = pop_thing(); + auto element = pop_thing(); + array->at(index->integer()) = std::move(element->clone()); + } break; case instruction_t::Drop: { pop_thing(); } break;