#if !defined(BOOST_SPIRIT_CALC8_VM_HPP)
#define BOOST_SPIRIT_CALC8_VM_HPP
#include <vector>
namespace client
{
enum byte_code
{
op_neg, op_add, op_sub, op_mul, op_div,
op_not, op_eq, op_neq, op_lt, op_lte, op_gt, op_gte,
op_and, op_or,
op_load, op_store,
op_int, op_true, op_false,
op_jump_if, op_jump,
op_stk_adj, op_call, op_return };
class vmachine
{
public:
vmachine(unsigned stackSize = 4096)
: stack(stackSize)
{
}
int execute(
std::vector<int> const& code , std::vector<int>::const_iterator pc , std::vector<int>::iterator frame_ptr );
int execute(std::vector<int> const& code)
{
return execute(code, code.begin(), stack.begin());
};
std::vector<int> stack;
};
}
#endif