use std::fmt;
#[derive(Debug)]
pub enum FromIRError {
InvalidIR,
UnsupportedType,
UnsupportedInstruction,
MissingEntryBlock,
UnknownVariable,
PrintStringLiteralUnsupported,
}
impl fmt::Display for FromIRError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
FromIRError::InvalidIR => write!(f, "Invalid IR structure detected during conversion"),
FromIRError::UnsupportedType => {
write!(
f,
"IR type cannot be converted to MIR (composite types not yet supported)"
)
}
FromIRError::UnsupportedInstruction => {
write!(f, "IR instruction is not supported in MIR")
}
FromIRError::MissingEntryBlock => {
write!(f, "Function is missing its entry block")
}
FromIRError::UnknownVariable => {
write!(
f,
"Variable reference cannot be resolved in current context"
)
}
FromIRError::PrintStringLiteralUnsupported => write!(
f,
"print with string literal is not supported. Use writebyte in a loop for portable output. See docs/OUTPUT_SEMANTICS.md"
),
}
}
}