50 lines
1.8 KiB
C++
50 lines
1.8 KiB
C++
#include <execute/error.hpp>
|
|
|
|
namespace Execute
|
|
{
|
|
std::string const & RuntimeError::GetMessage() const { return message; }
|
|
|
|
RuntimeError::RuntimeError() : message("Undocumented runtime error") { }
|
|
|
|
RuntimeError::RuntimeError(std::string const & what, std::size_t const _byteLocation)
|
|
: message(what), byteLocation(_byteLocation)
|
|
{ }
|
|
|
|
InterruptIndexOutOfRange::InterruptIndexOutOfRange(std::size_t const location, int const index)
|
|
: RuntimeError("", location)
|
|
{
|
|
message = "Interrupt at byte ";
|
|
message += std::to_string(location);
|
|
message += " with index ";
|
|
message += std::to_string(index);
|
|
message += " is out of range";
|
|
}
|
|
|
|
AttemptedWriteToImmediate::AttemptedWriteToImmediate(std::size_t const location) : RuntimeError("", location)
|
|
{
|
|
message = "Instruction at ";
|
|
message += std::to_string(location);
|
|
message += " attempted to write to an immediate value";
|
|
}
|
|
|
|
NonExecutableInstruction::NonExecutableInstruction(std::size_t const location) : RuntimeError("", location)
|
|
{
|
|
message = "Attempted to execute byte at ";
|
|
message += std::to_string(location);
|
|
message += " which is not an instruction byte";
|
|
}
|
|
|
|
NonArgumentByte::NonArgumentByte(std::size_t const location) : RuntimeError("", location)
|
|
{
|
|
message = "Expected an argument byte (immediate, register or memory location) at ";
|
|
message += std::to_string(location);
|
|
}
|
|
|
|
OutOfMemory::OutOfMemory(std::size_t const requiredMemorySize, std::size_t const actualMemorySize)
|
|
{
|
|
message = "Not enough memory to fit code. Actual size is ";
|
|
message += std::to_string(actualMemorySize);
|
|
message += ". Minimal required size is ";
|
|
message += std::to_string(requiredMemorySize);
|
|
}
|
|
} |