refactor(furvm): move bad access exceptions to exceptions.hpp
Refs: #12
This commit is contained in:
@@ -1,49 +1,13 @@
|
|||||||
#ifndef FURVM_CONSTANT_HPP
|
#ifndef FURVM_CONSTANT_HPP
|
||||||
#define FURVM_CONSTANT_HPP
|
#define FURVM_CONSTANT_HPP
|
||||||
|
|
||||||
|
#include "furvm/exceptions.hpp"
|
||||||
#include "furvm/fwd.hpp"
|
#include "furvm/fwd.hpp"
|
||||||
|
|
||||||
#include <exception>
|
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
|
||||||
namespace furvm {
|
namespace furvm {
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Bad constant access exception.
|
|
||||||
*/
|
|
||||||
class bad_constant_access : public std::exception {
|
|
||||||
public:
|
|
||||||
bad_constant_access() = default;
|
|
||||||
~bad_constant_access() override = default;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Move constructor.
|
|
||||||
*/
|
|
||||||
bad_constant_access(bad_constant_access&&) noexcept = default;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Move constructor.
|
|
||||||
*/
|
|
||||||
bad_constant_access& operator=(bad_constant_access&&) noexcept = default;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Copy constructor.
|
|
||||||
*/
|
|
||||||
bad_constant_access(const bad_constant_access&) = default;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Copy constructor.
|
|
||||||
*/
|
|
||||||
bad_constant_access& operator=(const bad_constant_access&) = default;
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* @brief Returns a C-style string describing the cause of the error.
|
|
||||||
*
|
|
||||||
* @return The cause of the error.
|
|
||||||
*/
|
|
||||||
const char* what() const noexcept override { return "bad constant access"; }
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class constant_t : std::uint8_t {
|
enum class constant_t : std::uint8_t {
|
||||||
String, /**< String constant. */
|
String, /**< String constant. */
|
||||||
};
|
};
|
||||||
@@ -109,4 +73,4 @@ private:
|
|||||||
|
|
||||||
} // namespace furvm
|
} // namespace furvm
|
||||||
|
|
||||||
#endif // FURVM_CONSTANT_HPP
|
#endif // FURVM_CONSTANT_HPP
|
||||||
|
|||||||
@@ -5,6 +5,75 @@
|
|||||||
|
|
||||||
namespace furvm {
|
namespace furvm {
|
||||||
|
|
||||||
|
class bad_thing_access : public std::exception {
|
||||||
|
public:
|
||||||
|
bad_thing_access() = default;
|
||||||
|
~bad_thing_access() override = default;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Move constructor.
|
||||||
|
*/
|
||||||
|
bad_thing_access(bad_thing_access&&) noexcept = default;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Move constructor.
|
||||||
|
*/
|
||||||
|
bad_thing_access& operator=(bad_thing_access&&) noexcept = default;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Copy constructor.
|
||||||
|
*/
|
||||||
|
bad_thing_access(const bad_thing_access&) = default;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Copy constructor.
|
||||||
|
*/
|
||||||
|
bad_thing_access& operator=(const bad_thing_access&) = default;
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Returns a C-style string describing the cause of the error.
|
||||||
|
*
|
||||||
|
* @return The cause of the error.
|
||||||
|
*/
|
||||||
|
const char* what() const noexcept override { return "bad thing access"; }
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Bad constant access exception.
|
||||||
|
*/
|
||||||
|
class bad_constant_access : public std::exception {
|
||||||
|
public:
|
||||||
|
bad_constant_access() = default;
|
||||||
|
~bad_constant_access() override = default;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Move constructor.
|
||||||
|
*/
|
||||||
|
bad_constant_access(bad_constant_access&&) noexcept = default;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Move constructor.
|
||||||
|
*/
|
||||||
|
bad_constant_access& operator=(bad_constant_access&&) noexcept = default;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Copy constructor.
|
||||||
|
*/
|
||||||
|
bad_constant_access(const bad_constant_access&) = default;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Copy constructor.
|
||||||
|
*/
|
||||||
|
bad_constant_access& operator=(const bad_constant_access&) = default;
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Returns a C-style string describing the cause of the error.
|
||||||
|
*
|
||||||
|
* @return The cause of the error.
|
||||||
|
*/
|
||||||
|
const char* what() const noexcept override { return "bad constant access"; }
|
||||||
|
};
|
||||||
|
|
||||||
class stack_underflow : public std::exception {
|
class stack_underflow : public std::exception {
|
||||||
public:
|
public:
|
||||||
stack_underflow() = default;
|
stack_underflow() = default;
|
||||||
@@ -40,4 +109,4 @@ public:
|
|||||||
|
|
||||||
} // namespace furvm
|
} // namespace furvm
|
||||||
|
|
||||||
#endif // FURVM_EXCEPTIONS_HPP
|
#endif // FURVM_EXCEPTIONS_HPP
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#define FURVM_THING_HPP
|
#define FURVM_THING_HPP
|
||||||
|
|
||||||
#include "furlang/arena.hpp"
|
#include "furlang/arena.hpp"
|
||||||
|
#include "furvm/exceptions.hpp"
|
||||||
#include "furvm/fwd.hpp"
|
#include "furvm/fwd.hpp"
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
@@ -30,39 +31,6 @@ static inline std::size_t thing_type_size(thing_t type) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class bad_thing_access : public std::exception {
|
|
||||||
public:
|
|
||||||
bad_thing_access() = default;
|
|
||||||
~bad_thing_access() override = default;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Move constructor.
|
|
||||||
*/
|
|
||||||
bad_thing_access(bad_thing_access&&) noexcept = default;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Move constructor.
|
|
||||||
*/
|
|
||||||
bad_thing_access& operator=(bad_thing_access&&) noexcept = default;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Copy constructor.
|
|
||||||
*/
|
|
||||||
bad_thing_access(const bad_thing_access&) = default;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Copy constructor.
|
|
||||||
*/
|
|
||||||
bad_thing_access& operator=(const bad_thing_access&) = default;
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* @brief Returns a C-style string describing the cause of the error.
|
|
||||||
*
|
|
||||||
* @return The cause of the error.
|
|
||||||
*/
|
|
||||||
const char* what() const noexcept override { return "bad thing access"; }
|
|
||||||
};
|
|
||||||
|
|
||||||
template <template <typename> typename Allocator>
|
template <template <typename> typename Allocator>
|
||||||
class thing final {
|
class thing final {
|
||||||
friend class executor;
|
friend class executor;
|
||||||
|
|||||||
Reference in New Issue
Block a user