refactor: add bytecode to module
This commit is contained in:
@@ -1,11 +1,25 @@
|
|||||||
#ifndef FURVM_MODULE_HPP
|
#ifndef FURVM_MODULE_HPP
|
||||||
#define FURVM_MODULE_HPP
|
#define FURVM_MODULE_HPP
|
||||||
|
|
||||||
|
#include "furvm/fwd.hpp"
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace furvm {
|
namespace furvm {
|
||||||
|
|
||||||
class mod {
|
class mod {
|
||||||
public:
|
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;
|
~mod() = default;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -21,6 +35,7 @@ public:
|
|||||||
mod(const mod&) = delete;
|
mod(const mod&) = delete;
|
||||||
mod& operator=(const mod&) = delete;
|
mod& operator=(const mod&) = delete;
|
||||||
private:
|
private:
|
||||||
|
bytecode_t m_bytecode;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace furvm
|
} // namespace furvm
|
||||||
|
|||||||
+9
-1
@@ -1,11 +1,19 @@
|
|||||||
#ifndef LIBFURVM
|
#ifndef LIBFURVM
|
||||||
|
|
||||||
#include "furvm/context.hpp"
|
#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) {
|
int main(void) {
|
||||||
furvm::context context;
|
furvm::context context;
|
||||||
|
|
||||||
auto mainModule = context.emplace();
|
auto mainModule = context.emplace(s_bytecode.begin(), s_bytecode.end());
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user