#pragma once #include "arch.hpp" #include "value.hpp" #include #include #include namespace sliger { class VM { public: VM(const std::vector& program) : program(program.data()) , program_size(program.size()) { } void run(); inline void step() { this->pc += 1; } inline auto eat_as_op() -> Op { auto value = curr_as_op(); step(); return value; } inline auto curr_as_op() const -> Op { return static_cast(this->program[this->pc]); } inline auto done() const -> bool { return this->pc >= this->program_size; } private: uint32_t pc = 0; const Op* program; size_t program_size; std::vector stack; std::vector pool_heap; }; }