This repository has been archived on 2023-09-09. You can view files and clone it, but cannot push or open issues/pull-requests.
skemla/lib/VM.hpp

38 lines
536 B
C++
Raw Normal View History

2023-09-08 11:13:47 +00:00
#ifndef sk_VM_HPP
#define sk_VM_HPP
#include "commons.hpp"
#include "Program.hpp"
namespace sk
{
struct Frame {
std::shared_ptr<Program> program;
};
class VM
{
public:
explicit VM();
virtual ~VM();
std::string string() const;
void exec(std::shared_ptr<Program> program);
private:
std::vector<Frame> m_frames;
std::vector<param_t> m_stack;
size_t m_pc = 0;
void exec();
std::shared_ptr<Program> program() const;
void push(param_t param);
param_t pop();
};
}
#endif