From 9690ac3617c2801278c30c347b5eef353d0d6ae6 Mon Sep 17 00:00:00 2001 From: CHatingPython Date: Sun, 5 Jul 2026 13:31:15 +0200 Subject: [PATCH] feat: add core module to context Closes: #45 --- furvm/src/context.cpp | 16 +++++++++++++++- furvm/src/executor.cpp | 3 ++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/furvm/src/context.cpp b/furvm/src/context.cpp index b4ffb57..e5cfd51 100644 --- a/furvm/src/context.cpp +++ b/furvm/src/context.cpp @@ -1,10 +1,24 @@ #include "furvm/context.hpp" #include "furvm/thing.hpp" // IWYU pragma: keep +#include "furvm/type.hpp" + +#include +#include namespace furvm { context::context() - : m_thingAllocator(m_thingArena) {} + : m_thingAllocator(m_thingArena) { + mod core; + core.emplace_type(std::make_shared(byteType)); + core.emplace_type(std::make_shared(shortType)); + core.emplace_type(std::make_shared(intType)); + core.emplace_type(std::make_shared(longType)); + static_assert(sizeof(std::uintptr_t) == 8, "Unsupported platform"); + core.emplace_type(*core.type_at(3)); + + emplace("core", std::move(core)).dispatch(); +} } // namespace furvm diff --git a/furvm/src/executor.cpp b/furvm/src/executor.cpp index 75ee38f..68cca56 100644 --- a/furvm/src/executor.cpp +++ b/furvm/src/executor.cpp @@ -91,7 +91,8 @@ void executor::step() { switch (instr) { case instruction_t::NoOperation: break; case instruction_t::PushB2I: { - push_thing({ intType, m_context, m_context->thing_alloc() })->get() = frame.mod->byte(frame.position++); + push_thing({ *m_context->at("core")->type_at(2), m_context, m_context->thing_alloc() })->get() = + frame.mod->byte(frame.position++); } break; case instruction_t::Drop: { pop_thing();