feat(furvm): add call instruction
This commit is contained in:
@@ -14,7 +14,7 @@ enum class function_t : std::uint8_t {
|
||||
Native, /**< A native function implemented through furvm API. */
|
||||
};
|
||||
|
||||
using native_function = std::function<void(const executor_p&)>;
|
||||
using native_function = std::function<void(executor&)>;
|
||||
|
||||
class function {
|
||||
private:
|
||||
|
||||
@@ -65,6 +65,13 @@ enum class instruction_t : byte {
|
||||
*/
|
||||
Mod,
|
||||
|
||||
/**
|
||||
* @brief Calls a function.
|
||||
*
|
||||
* Calls a function denoted by next two bytes in little-endian from current frame's module.
|
||||
*/
|
||||
Call,
|
||||
|
||||
/**
|
||||
* @brief Pops the current call frame.
|
||||
*/
|
||||
|
||||
@@ -51,6 +51,14 @@ public:
|
||||
* @return The byte.
|
||||
*/
|
||||
constexpr byte byte(std::size_t offset) const { return m_bytecode.at(offset); }
|
||||
public:
|
||||
/**
|
||||
* @brief Returns a function from this module.
|
||||
*
|
||||
* @param id Id of the function.
|
||||
* @return The function.
|
||||
*/
|
||||
constexpr const function_p& function_at(function_handle id) const { return m_functions.at(id); }
|
||||
private:
|
||||
module_handle m_id;
|
||||
bytecode_t m_bytecode;
|
||||
|
||||
Reference in New Issue
Block a user