1 /*=============================================================================
2 Copyright (c) 2001-2014 Joel de Guzman
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 =============================================================================*/
7 #if !defined(BOOST_SPIRIT_X3_CALC8_VM_HPP)
8 #define BOOST_SPIRIT_X3_CALC8_VM_HPP
14 ////////////////////////////////////////////////////////////////////////////
15 // The Virtual Machine
16 ////////////////////////////////////////////////////////////////////////////
19 op_neg, // negate the top stack entry
20 op_add, // add top two stack entries
21 op_sub, // subtract top two stack entries
22 op_mul, // multiply top two stack entries
23 op_div, // divide top two stack entries
25 op_load, // load a variable
26 op_store, // store a variable
27 op_int, // push constant integer into the stack
28 op_stk_adj // adjust the stack for local variables
35 vmachine(unsigned stackSize = 4096)
37 , stack_ptr(stack.begin())
41 void execute(std::vector<int> const& code);
42 std::vector<int> const& get_stack() const { return stack; };
46 std::vector<int> stack;
47 std::vector<int>::iterator stack_ptr;