#[derive(Clone, Copy)]
pub enum Type<'a> {
Boolean,
Byte,
Char,
Short,
Int,
Long,
Float,
Double,
Void,
Object(&'a str),
Array(&'a Type<'a>),
}
impl<'a> Type<'a> {
pub fn to_string(&self) -> String {
let result = match self {
Type::Boolean => String::from("Z"),
Type::Byte => String::from("B"),
Type::Char => String::from("C"),
Type::Short => String::from("S"),
Type::Int => String::from("I"),
Type::Long => String::from("J"),
Type::Float => String::from("F"),
Type::Double => String::from("D"),
Type::Void => String::from("V"),
Type::Object(s) => format!("L{};", s),
Type::Array(t) => format!("[{}", t.to_string()),
};
result
}
}