feat: add core module to context

Closes: #45
This commit is contained in:
2026-07-05 13:31:15 +02:00
parent f89f643870
commit 9690ac3617
2 changed files with 17 additions and 2 deletions
+15 -1
View File
@@ -1,10 +1,24 @@
#include "furvm/context.hpp" #include "furvm/context.hpp"
#include "furvm/thing.hpp" // IWYU pragma: keep #include "furvm/thing.hpp" // IWYU pragma: keep
#include "furvm/type.hpp"
#include <cstdint>
#include <memory>
namespace furvm { namespace furvm {
context::context() context::context()
: m_thingAllocator(m_thingArena) {} : m_thingAllocator(m_thingArena) {
mod core;
core.emplace_type(std::make_shared<type>(byteType));
core.emplace_type(std::make_shared<type>(shortType));
core.emplace_type(std::make_shared<type>(intType));
core.emplace_type(std::make_shared<type>(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 } // namespace furvm
+2 -1
View File
@@ -91,7 +91,8 @@ void executor::step() {
switch (instr) { switch (instr) {
case instruction_t::NoOperation: break; case instruction_t::NoOperation: break;
case instruction_t::PushB2I: { case instruction_t::PushB2I: {
push_thing({ intType, m_context, m_context->thing_alloc() })->get<int_t>() = frame.mod->byte(frame.position++); push_thing({ *m_context->at("core")->type_at(2), m_context, m_context->thing_alloc() })->get<int_t>() =
frame.mod->byte(frame.position++);
} break; } break;
case instruction_t::Drop: { case instruction_t::Drop: {
pop_thing(); pop_thing();