2021-09-28 23:09:38 +00:00
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub enum ErrorType {
|
|
|
|
Emulator,
|
|
|
|
Processor,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub struct Error {
|
|
|
|
pub err: ErrorType,
|
|
|
|
pub native: u32,
|
|
|
|
pub msg: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Error {
|
|
|
|
pub fn new(msg: &str) -> Error {
|
|
|
|
Error {
|
|
|
|
err: ErrorType::Emulator,
|
|
|
|
native: 0,
|
|
|
|
msg: msg.to_string(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn processor(native: u32) -> Error {
|
|
|
|
Error {
|
|
|
|
err: ErrorType::Processor,
|
|
|
|
native,
|
|
|
|
msg: "".to_string(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-15 04:16:31 +00:00
|
|
|
static mut DEBUG_ENABLE: bool = true;
|
|
|
|
|
|
|
|
pub fn debug_enabled() -> bool {
|
|
|
|
unsafe { DEBUG_ENABLE }
|
|
|
|
}
|
|
|
|
|
2021-09-28 23:09:38 +00:00
|
|
|
macro_rules! debug {
|
|
|
|
($($arg:tt)*) => ({
|
2021-10-15 04:16:31 +00:00
|
|
|
if crate::error::debug_enabled() {
|
|
|
|
println!($($arg)*);
|
|
|
|
}
|
2021-09-28 23:09:38 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|