38 lines
536 B
C++
38 lines
536 B
C++
|
#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
|