use ristretto_classfile::attributes::Instruction;
pub type Result<T, E = Error> = core::result::Result<T, E>;
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error(transparent)]
ClassFileError(#[from] ristretto_classfile::Error),
#[error(transparent)]
CodegenError(#[from] cranelift::codegen::CodegenError),
#[error("Internal error: {0}")]
InternalError(String),
#[error("Invalid block address: {0}")]
InvalidBlockAddress(usize),
#[error("Invalid constant; expected {expected}, found {actual}")]
InvalidConstant { expected: String, actual: String },
#[error("Invalid instant index: {0}")]
InvalidConstantIndex(u16),
#[error("Invalid local variable index: {0}")]
InvalidLocalVariableIndex(usize),
#[error("Invalid value; expected {expected}, found {actual}")]
InvalidValue { expected: i8, actual: i8 },
#[error(transparent)]
ModuleError(#[from] cranelift::module::ModuleError),
#[error(transparent)]
TryFromIntError(#[from] std::num::TryFromIntError),
#[error("Unsupported instruction: {0}")]
UnsupportedInstruction(Instruction),
#[error("Unsupported method: {0}")]
UnsupportedMethod(String),
#[error("Unsupported target ISA: {0}")]
UnsupportedTargetISA(&'static str),
#[error("Unsupported type: {0}")]
UnsupportedType(String),
}