rajac_types/
primitive_type.rs1#[derive(Debug, Clone, PartialEq)]
2pub enum PrimitiveType {
3 Boolean,
4 Byte,
5 Char,
6 Short,
7 Int,
8 Long,
9 Float,
10 Double,
11 Void,
12}
13
14impl PrimitiveType {
15 pub fn descriptor(&self) -> char {
16 match self {
17 PrimitiveType::Boolean => 'Z',
18 PrimitiveType::Byte => 'B',
19 PrimitiveType::Char => 'C',
20 PrimitiveType::Short => 'S',
21 PrimitiveType::Int => 'I',
22 PrimitiveType::Long => 'J',
23 PrimitiveType::Float => 'F',
24 PrimitiveType::Double => 'D',
25 PrimitiveType::Void => 'V',
26 }
27 }
28
29 pub fn is_integral(&self) -> bool {
30 matches!(
31 self,
32 PrimitiveType::Boolean
33 | PrimitiveType::Byte
34 | PrimitiveType::Char
35 | PrimitiveType::Short
36 | PrimitiveType::Int
37 | PrimitiveType::Long
38 )
39 }
40
41 pub fn is_numeric(&self) -> bool {
42 matches!(
43 self,
44 PrimitiveType::Byte
45 | PrimitiveType::Char
46 | PrimitiveType::Short
47 | PrimitiveType::Int
48 | PrimitiveType::Long
49 | PrimitiveType::Float
50 | PrimitiveType::Double
51 )
52 }
53}