forked from KPGPMC/furlang
refactor: add bytecode to module
This commit is contained in:
@@ -1,11 +1,25 @@
|
||||
#ifndef FURVM_MODULE_HPP
|
||||
#define FURVM_MODULE_HPP
|
||||
|
||||
#include "furvm/fwd.hpp"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace furvm {
|
||||
|
||||
class mod {
|
||||
public:
|
||||
mod() = default;
|
||||
using bytecode_t = std::vector<byte>; /**< An alias to a vector of bytes. */
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a new module.
|
||||
*
|
||||
* @param args Arguments to forward to bytecode's constructor.
|
||||
*/
|
||||
template <typename... Args, typename = std::enable_if_t<std::is_constructible_v<bytecode_t, Args...>>>
|
||||
mod(Args&&... args)
|
||||
: m_bytecode(std::forward<Args>(args)...) {}
|
||||
|
||||
~mod() = default;
|
||||
|
||||
/**
|
||||
@@ -21,6 +35,7 @@ public:
|
||||
mod(const mod&) = delete;
|
||||
mod& operator=(const mod&) = delete;
|
||||
private:
|
||||
bytecode_t m_bytecode;
|
||||
};
|
||||
|
||||
} // namespace furvm
|
||||
|
||||
+9
-1
@@ -1,11 +1,19 @@
|
||||
#ifndef LIBFURVM
|
||||
|
||||
#include "furvm/context.hpp"
|
||||
#include "furvm/instruction.hpp"
|
||||
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
|
||||
static constexpr std::array<furvm::byte, 1> s_bytecode = {
|
||||
furvm::byte(furvm::instruction_t::NoOperation),
|
||||
};
|
||||
|
||||
int main(void) {
|
||||
furvm::context context;
|
||||
|
||||
auto mainModule = context.emplace();
|
||||
auto mainModule = context.emplace(s_bytecode.begin(), s_bytecode.end());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user