feat(furvm): introduce executor

This commit is contained in:
2026-06-06 21:05:17 +02:00
parent 16b6b9549c
commit a869f71f3a
6 changed files with 145 additions and 5 deletions
+5 -1
View File
@@ -1,3 +1,7 @@
#include "furvm/context.hpp"
namespace furvm {}
namespace furvm {
context::context() {}
} // namespace furvm
+20
View File
@@ -0,0 +1,20 @@
#include "furvm/executor.hpp"
#include "furvm/context.hpp"
namespace furvm {
executor::executor(egzekutor, executor_handle id, const std::shared_ptr<context>& context)
: m_id(id), m_context(context) {}
executor::~executor() {
m_context->m_executors[m_id] = nullptr;
}
std::shared_ptr<executor> executor::create(const std::shared_ptr<context>& context) {
auto ex = std::make_shared<executor>(egzekutor{}, context->m_executors.size(), context);
context->m_executors.push_back(ex);
return std::move(ex);
}
} // namespace furvm
+6 -2
View File
@@ -1,10 +1,12 @@
#ifndef LIBFURVM
#include "furvm/context.hpp"
#include "furvm/executor.hpp"
#include "furvm/instruction.hpp"
#include <array>
#include <cstddef>
#include <memory>
static constexpr std::array<furvm::byte, 3> s_bytecode = {
furvm::byte(furvm::instruction_t::PushB2I),
@@ -13,9 +15,11 @@ static constexpr std::array<furvm::byte, 3> s_bytecode = {
};
int main(void) {
furvm::context context;
auto context = std::make_shared<furvm::context>();
const auto& mainModule = context.emplace(s_bytecode.begin(), s_bytecode.end());
const auto& mainModule = context->emplace(s_bytecode.begin(), s_bytecode.end());
auto executor = furvm::executor::create(context);
return 0;
}