ArkScript
A small, fast, functional and scripting language for video games
ExecutionContext.hpp
Go to the documentation of this file.
1 /**
2  * @file ExecutionContext.hpp
3  * @author Alexandre Plateau (lexplt.dev@gmail.com)
4  * @brief Keeping track of the internal data needed by the VM
5  * @version 0.1
6  * @date 2021-11-15
7  *
8  * @copyright Copyright (c) 2021
9  *
10  */
11 
12 #ifndef ARK_VM_EXECUTIONCONTEXT_HPP
13 #define ARK_VM_EXECUTIONCONTEXT_HPP
14 
15 #include <array>
16 #include <limits>
17 #include <optional>
18 #include <cinttypes>
19 
20 #include <Ark/Constants.hpp>
21 #include <Ark/VM/Value.hpp>
22 #include <Ark/VM/Scope.hpp>
23 
24 #ifdef max
25 # undef max
26 #endif
27 
28 namespace Ark::internal
29 {
31  {
32  static inline unsigned Count = 0;
33 
34  const bool primary; ///< Tells if the current ExecutionContext is the primary one or not
35  int ip = 0; ///< Instruction pointer
36  std::size_t pp = 0; ///< Page pointer
37  uint16_t sp = 0; ///< Stack pointer
38  uint16_t fc = 0; ///< Frame count
39  uint16_t last_symbol = std::numeric_limits<uint16_t>::max();
40 
41  std::array<Value, VMStackSize> stack;
42  std::vector<uint8_t> scope_count_to_delete;
43  std::optional<Scope_t> saved_scope;
44  std::vector<Scope_t> locals;
45 
46  ExecutionContext() noexcept :
48  {
50  }
51  };
52 }
53 
54 #endif
Constants used by ArkScript.
The virtual machine scope system.
std::array< Value, VMStackSize > stack
std::size_t pp
Page pointer.
const bool primary
Tells if the current ExecutionContext is the primary one or not.
std::optional< Scope_t > saved_scope
std::vector< uint8_t > scope_count_to_delete