12#ifndef ARK_VM_STATE_HPP
13#define ARK_VM_STATE_HPP
17#include <unordered_map>
39 explicit State(
const std::vector<std::filesystem::path>& libenv = {})
noexcept;
48 bool feed(
const std::string& bytecode_filename);
67 bool doFile(
const std::string& file, uint16_t features =
DefaultFeatures);
77 bool doString(
const std::string& code, uint16_t features =
DefaultFeatures);
85 void loadFunction(
const std::string& name,
Value::ProcType function)
noexcept;
92 void setArgs(
const std::vector<std::string>& args)
noexcept;
99 void setDebug(
unsigned level)
noexcept;
106 void setLibDirs(
const std::vector<std::filesystem::path>& libenv)
noexcept;
112 void reset()
noexcept;
135 bool compile(
const std::string& file,
const std::string& output, uint16_t features)
const;
139 throw Error(
"StateError: " + message);
Common code for the compiler.
Constants used by ArkScript.
ArkScript homemade exceptions.
This class is just a helper to.
Ark state to handle the dirty job of loading and compiling ArkScript code.
std::vector< std::filesystem::path > m_libenv
std::vector< Value > m_constants
static void throwStateError(const std::string &message)
std::unordered_map< std::string, Value > m_binded
std::vector< std::string > m_symbols
std::vector< bytecode_t > m_pages
The ArkScript virtual machine, executing ArkScript bytecode.
Value(*)(std::vector< Value > &, VM *) ProcType
constexpr uint16_t DefaultFeatures
std::vector< uint8_t > bytecode_t