mirror of
https://github.com/TomHarte/CLK.git
synced 2025-01-01 17:31:18 +00:00
Adds safety asserts.
This commit is contained in:
parent
6805acd74f
commit
a491650c8b
@ -8,6 +8,8 @@
|
|||||||
|
|
||||||
#include "../6502.hpp"
|
#include "../6502.hpp"
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
using namespace CPU::MOS6502;
|
using namespace CPU::MOS6502;
|
||||||
|
|
||||||
const uint8_t CPU::MOS6502::JamOpcode = 0xf2;
|
const uint8_t CPU::MOS6502::JamOpcode = 0xf2;
|
||||||
@ -80,6 +82,7 @@ ProcessorBase::State ProcessorBase::get_state() {
|
|||||||
|
|
||||||
state.execution_state.micro_program = int(micro_offset / list_length);
|
state.execution_state.micro_program = int(micro_offset / list_length);
|
||||||
state.execution_state.micro_program_offset = int(micro_offset % list_length);
|
state.execution_state.micro_program_offset = int(micro_offset % list_length);
|
||||||
|
assert(&operations_[state.execution_state.micro_program][state.execution_state.micro_program_offset] == scheduled_program_counter_);
|
||||||
|
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#ifndef Struct_hpp
|
#ifndef Struct_hpp
|
||||||
#define Struct_hpp
|
#define Struct_hpp
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
#include <cstdarg>
|
#include <cstdarg>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -113,6 +114,15 @@ struct Serialisable {
|
|||||||
|
|
||||||
template <typename Owner> class StructImpl: public Struct {
|
template <typename Owner> class StructImpl: public Struct {
|
||||||
public:
|
public:
|
||||||
|
#ifndef NDEBUG
|
||||||
|
StructImpl() {
|
||||||
|
// Protect against declarations that nominate the wrong Owner; this isn't
|
||||||
|
// a static assert because that wouldn't catch all invalid cases.
|
||||||
|
const auto owner = static_cast<Owner *>(this);
|
||||||
|
assert(owner != nullptr);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@returns the value of type @c Type that is loaded from the offset registered for the field @c name.
|
@returns the value of type @c Type that is loaded from the offset registered for the field @c name.
|
||||||
It is the caller's responsibility to provide an appropriate type of data.
|
It is the caller's responsibility to provide an appropriate type of data.
|
||||||
|
Loading…
Reference in New Issue
Block a user