3#include "libmicroemu/exception_type.h"
4#include "libmicroemu/types.h"
9using ExceptionFlagsSet = u8;
11enum class ExceptionFlags : ExceptionFlagsSet {
16static constexpr i16 kLowestExceptionPriority = 255U;
20struct SingleExceptionState {
21 explicit constexpr SingleExceptionState(u8 number) : number_{number}, priority_{0}, flags_{0U} {}
32 return (flags_ &
static_cast<ExceptionFlagsSet
>(ExceptionFlags::kPending)) != 0U;
38 flags_ &= ~static_cast<ExceptionFlagsSet>(ExceptionFlags::kPending);
44 flags_ |=
static_cast<ExceptionFlagsSet
>(ExceptionFlags::kPending);
52 return (flags_ &
static_cast<ExceptionFlagsSet
>(ExceptionFlags::kActive)) != 0U;
58 flags_ &= ~static_cast<ExceptionFlagsSet>(ExceptionFlags::kActive);
64 flags_ |=
static_cast<ExceptionFlagsSet
>(ExceptionFlags::kActive);
77 inline void SetPriority(i16 priority)
noexcept { priority_ = priority; }
83 inline u8
GetNumber() const noexcept {
return number_; }
88 ExceptionFlagsSet flags_;
91template <std::size_t... Indices>
92constexpr auto MakeExceptionArray(std::index_sequence<Indices...>) {
93 return std::array<SingleExceptionState,
sizeof...(Indices)>{
94 SingleExceptionState(
static_cast<u8
>(Indices))...};
97struct ExceptionStates {
99 : exception{MakeExceptionArray(std::make_index_sequence<CountExceptions()>())} {}
101 u32 pending_exceptions{0U};
The libmicroemu namespace contains all classes and functions of the libmicroemu which are public.
Definition bkpt_flags.h:6
Represents the state of a single exception.
Definition exception_states.h:20
i16 GetPriority() const noexcept
Gets the priority of the exception.
Definition exception_states.h:71
u8 GetNumber() const noexcept
Gets the number of the exception.
Definition exception_states.h:83
void SetActive() noexcept
Sets the active flag of the exception.
Definition exception_states.h:63
void SetPriority(i16 priority) noexcept
Sets the priority of the exception.
Definition exception_states.h:77
void ClearFlags() noexcept
Clears all flags of the exception.
Definition exception_states.h:25
bool IsActive() const noexcept
Checks if the exception is active.
Definition exception_states.h:51
void ClearPending() noexcept
Clears the pending flag of the exception.
Definition exception_states.h:37
void SetPending() noexcept
Sets the pending flag of the exception.
Definition exception_states.h:43
bool IsPending() const noexcept
Checks if the exception is pending.
Definition exception_states.h:31
void ClearActive() noexcept
Clears the active flag of the exception.
Definition exception_states.h:57