@@ -0,0 +1,25 @@
|
||||
#ifndef FURVM_DETAIL_SERIALIZATION_HPP
|
||||
#define FURVM_DETAIL_SERIALIZATION_HPP
|
||||
|
||||
#include <cstdint>
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
|
||||
namespace furvm {
|
||||
namespace detail {
|
||||
|
||||
std::ostream& serialize(std::ostream& os, std::int8_t value);
|
||||
std::ostream& serialize(std::ostream& os, std::int16_t value);
|
||||
std::ostream& serialize(std::ostream& os, std::int32_t value);
|
||||
std::ostream& serialize(std::ostream& os, std::int64_t value);
|
||||
std::ostream& serialize(std::ostream& os, std::uint8_t value);
|
||||
std::ostream& serialize(std::ostream& os, std::uint16_t value);
|
||||
std::ostream& serialize(std::ostream& os, std::uint32_t value);
|
||||
std::ostream& serialize(std::ostream& os, std::uint64_t value);
|
||||
|
||||
std::ostream& serialize(std::ostream& os, const std::string& value);
|
||||
|
||||
} // namespace detail
|
||||
} // namespace furvm
|
||||
|
||||
#endif // FURVM_DETAIL_SERIALIZATION_HPP
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "furvm/fwd.hpp"
|
||||
#include "furvm/handle.hpp"
|
||||
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
@@ -17,6 +18,8 @@ class mod {
|
||||
friend class serializer;
|
||||
public:
|
||||
using bytecode_t = std::vector<byte>; /**< An alias to a vector of bytes. */
|
||||
|
||||
static constexpr char MAGIC[4] = { 'F', 'u', 'r', 'M' }; /** Furvm module file magic. */
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a new module.
|
||||
@@ -91,6 +94,8 @@ public:
|
||||
}
|
||||
|
||||
void erase_function(function_id id) { m_functions.erase(id); }
|
||||
public:
|
||||
std::ostream& serialize(std::ostream& os) const;
|
||||
private:
|
||||
bytecode_t m_bytecode;
|
||||
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
#ifndef FURVM_SERIALIZER_HPP
|
||||
#define FURVM_SERIALIZER_HPP
|
||||
|
||||
#include "furvm/fwd.hpp"
|
||||
|
||||
#include <ostream>
|
||||
|
||||
namespace furvm {
|
||||
|
||||
class serializer {
|
||||
public:
|
||||
static constexpr byte MODULE_MAGIC[4] = { 'F', 'u', 'r', 'M' };
|
||||
static constexpr std::uint32_t VERSION = 0;
|
||||
public:
|
||||
static bool serialize_module(std::ostream& os, const mod_p& mod);
|
||||
};
|
||||
|
||||
} // namespace furvm
|
||||
|
||||
#endif // FURVM_SERIALIZER_HPP
|
||||
Reference in New Issue
Block a user