|
| VM (State &state) noexcept |
| Construct a new vm t object. More...
|
|
| VM (State *state) noexcept |
|
int | run () noexcept |
| Run the bytecode held in the state. More...
|
|
Value & | operator[] (const std::string &name) noexcept |
| Retrieve a value from the virtual machine, given its symbol name. More...
|
|
template<typename... Args> |
Value | call (const std::string &name, Args &&... args) |
| Call a function from ArkScript, by giving it arguments. More...
|
|
template<typename... Args> |
Value | resolve (const Value *val, Args &&... args) |
| Resolving a function call (called by plugins) More...
|
|
void | exit (int code) noexcept |
| Ask the VM to exit with a given exit code. More...
|
|
void | setUserPointer (void *ptr) noexcept |
| Set the User Pointer object. More...
|
|
void * | getUserPointer () noexcept |
| Retrieves the stored pointer. More...
|
|
|
int | safeRun (internal::ExecutionContext &context, std::size_t untilFrameCount=0) |
| Run ArkScript bytecode inside a try catch to retrieve all the exceptions and display a stack trace if needed. More...
|
|
void | init () noexcept |
| Initialize the VM according to the parameters. More...
|
|
uint16_t | readNumber (internal::ExecutionContext &context) |
| Read a 2 bytes number from the current bytecode page, starting at the current instruction. More...
|
|
Value * | pop (internal::ExecutionContext &context) |
| Pop a value from the stack. More...
|
|
void | push (const Value &val, internal::ExecutionContext &context) |
| Push a value on the stack. More...
|
|
void | push (Value &&val, internal::ExecutionContext &context) |
| Push a value on the stack. More...
|
|
void | push (Value *valptr, internal::ExecutionContext &context) |
| Push a value on the stack as a reference. More...
|
|
Value * | popAndResolveAsPtr (internal::ExecutionContext &context) |
| Pop a value from the stack and resolve it if possible, then return it. More...
|
|
void | swapStackForFunCall (uint16_t argc, internal::ExecutionContext &context) |
| Move stack values around and invert them. More...
|
|
void | createNewScope (internal::ExecutionContext &context) noexcept |
|
Value * | findNearestVariable (uint16_t id, internal::ExecutionContext &context) noexcept |
| Find the nearest variable of a given id. More...
|
|
void | returnFromFuncCall (internal::ExecutionContext &context) |
| Destroy the current frame and get back to the previous one, resuming execution. More...
|
|
void | loadPlugin (uint16_t id, internal::ExecutionContext &context) |
| Load a plugin from a constant id. More...
|
|
uint16_t | findNearestVariableIdWithValue (const Value &value, internal::ExecutionContext &context) const noexcept |
| Find the nearest variable id with a given value. More...
|
|
void | throwVMError (const std::string &message) |
| Throw a VM error message. More...
|
|
void | backtrace (internal::ExecutionContext &context) noexcept |
| Display a backtrace when the VM encounter an exception. More...
|
|
void | call (internal::ExecutionContext &context, int16_t argc_=-1) |
| Function called when the CALL instruction is met in the bytecode. More...
|
|
The ArkScript virtual machine, executing ArkScript bytecode.
Definition at line 45 of file VM.hpp.
Run ArkScript bytecode inside a try catch to retrieve all the exceptions and display a stack trace if needed.
- Parameters
-
context | |
untilFrameCount | the frame count we need to reach before stopping the VM |
- Returns
- int the exit code
Definition at line 211 of file VM.cpp.
References Ark::internal::ADD, Ark::internal::AND_, Ark::Any, Ark::internal::APPEND, Ark::internal::APPEND_IN_PLACE, Ark::internal::ASSERT, Ark::internal::AT, backtrace(), Ark::internal::BUILTIN, Ark::internal::Builtins::builtins, Ark::internal::CALL, call(), Ark::internal::CAPTURE, Ark::Closure, Ark::internal::CONCAT, Ark::internal::CONCAT_IN_PLACE, Ark::Value::constList(), COZ_PROGRESS_NAMED, Ark::internal::DEL, Ark::internal::DIV, Ark::internal::EMPTY, Ark::internal::EQ, Ark::internal::Builtins::falseSym, findNearestVariable(), Ark::internal::GE, Ark::types::generateError(), Ark::internal::GET_FIELD, Ark::internal::GT, Ark::internal::HALT, Ark::internal::HASFIELD, Ark::internal::HEAD, Ark::InstPtr, Ark::internal::ExecutionContext::ip, Ark::Value::isConst(), Ark::Utils::isDouble(), Ark::internal::ISNIL, Ark::internal::JUMP, Ark::internal::ExecutionContext::last_symbol, Ark::internal::LE, Ark::internal::LEN, Ark::internal::LET, Ark::internal::LIST, Ark::List, Ark::Value::list(), Ark::internal::LOAD_CONST, Ark::internal::LOAD_SYMBOL, loadPlugin(), Ark::internal::ExecutionContext::locals, Ark::internal::LT, Ark::State::m_constants, Ark::State::m_debug_level, m_exit_code, m_fc, Ark::State::m_pages, m_running, m_state, Ark::State::m_symbols, m_until_frame_count, Ark::internal::MOD, Ark::internal::MUL, Ark::internal::MUT, Ark::internal::NEQ, Ark::internal::Builtins::nil, Ark::Nil, Ark::internal::NOT, Ark::Number, Ark::Value::number(), Ark::internal::OR_, Ark::PageAddr, Ark::Value::pageAddr(), Ark::internal::PLUGIN, Ark::internal::POP, pop(), Ark::internal::POP_JUMP_IF_FALSE, Ark::internal::POP_JUMP_IF_TRUE, Ark::internal::POP_LIST, Ark::internal::POP_LIST_IN_PLACE, popAndResolveAsPtr(), Ark::internal::ExecutionContext::pp, push(), Ark::Value::push_back(), readNumber(), Ark::Value::refClosure(), Ark::Reference, Ark::Value::reference(), Ark::internal::RET, returnFromFuncCall(), Ark::internal::SAVE_ENV, Ark::internal::ExecutionContext::saved_scope, Ark::internal::Closure::scope(), Ark::internal::ExecutionContext::scope_count_to_delete, Ark::Value::setConst(), Ark::internal::ExecutionContext::sp, Ark::internal::STORE, Ark::String, Ark::Value::string(), Ark::Value::stringRef(), Ark::internal::SUB, Ark::internal::TAIL, throwVMError(), Ark::internal::TO_NUM, Ark::internal::TO_STR, Ark::internal::Builtins::trueSym, Ark::internal::TYPE, Ark::types_to_str, Ark::User, Value, Ark::Value::valueType(), and Ark::VMStackSize.
Referenced by Ark::Repl::run(), and run().
Move stack values around and invert them.
values: 1, 2, 3, _, _ wanted: pp, ip, 3, 2, 1 positions: 0, 1, 2, 3, 4
- Parameters
-
argc | number of arguments to swap around |
context | |