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;