use crate::ir::Type;
pub trait TypeFormatter {
type Return;
fn type_int(&self, bits: u16) -> Self::Return;
fn type_uint(&self, bits: u16) -> Self::Return;
fn type_bool(&self) -> Self::Return;
fn type_string(&self) -> Self::Return;
fn type_float32(&self) -> Self::Return;
fn type_float64(&self) -> Self::Return;
fn type_option(&self, inner: Type) -> Self::Return;
fn type_tuple(&self, inner: Vec<Type>) -> Self::Return;
fn type_fixed(&self, bits: u16) -> Self::Return;
fn type_ufixed(&self, bits: u16) -> Self::Return;
fn type_bytes(&self) -> Self::Return;
fn ty(&self, ty: Type) -> Self::Return {
match ty {
Type::Int(b) => self.type_int(b),
Type::UInt(b) => self.type_uint(b),
Type::Bool => self.type_bool(),
Type::String => self.type_string(),
Type::Float32 => self.type_float32(),
Type::Float64 => self.type_float64(),
Type::Option(inner) => self.type_option(*inner),
Type::Tuple(items) => self.type_tuple(items),
Type::Fixed(b) => self.type_fixed(b),
Type::UFixed(b) => self.type_ufixed(b),
Type::Bytes => self.type_bytes(),
}
}
}