pclass_parser/classfile/
signature.rs1use crate::BytesRef;
2use std::fmt::Formatter;
3
4#[derive(Clone, PartialEq)]
5pub enum Type {
6 Byte,
7 Char,
8 Double,
9 Float,
10 Int,
11 Long,
12 Object(BytesRef, Option<Vec<Type>>, Option<u8>),
20 Short,
21 Boolean,
22 Array(BytesRef),
23 Void,
24}
25
26impl std::fmt::Debug for Type {
27 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
28 match self {
29 Type::Byte => write!(f, "B"),
30 Type::Char => write!(f, "C"),
31 Type::Double => write!(f, "D"),
32 Type::Float => write!(f, "F"),
33 Type::Int => write!(f, "I"),
34 Type::Long => write!(f, "J"),
35 Type::Object(container, args, prefix) => {
36 write!(f, "Object(");
37 write!(f, "\"{}\",", String::from_utf8_lossy(container.as_slice()));
38 write!(f, "{:?},", args);
39 write!(f, "{:?}", prefix);
40 write!(f, ")")
41 }
42 Type::Short => write!(f, "S"),
43 Type::Boolean => write!(f, "Z"),
44 Type::Array(desc) => write!(f, "Array({})", String::from_utf8_lossy(desc.as_slice())),
45 Type::Void => write!(f, "V"),
46 }
47 }
48}