1
- use crate :: { data_units:: BitUnits , target:: Target } ;
1
+ use crate :: { ast :: CInteger , data_units:: BitUnits , target:: Target } ;
2
2
use derive_more:: IsVariant ;
3
3
use std:: cmp:: Ordering ;
4
4
5
5
#[ derive( Copy , Clone , Debug ) ]
6
6
pub enum IntegerRank {
7
7
Bool ,
8
- Char ,
9
- Short ,
10
- Int ,
11
- Long ,
12
- LongLong ,
8
+ Flexible ( CInteger ) ,
13
9
Size ,
14
- FixedInt ( BitUnits ) ,
10
+ Fixed ( BitUnits ) ,
15
11
}
16
12
17
13
impl IntegerRank {
@@ -22,19 +18,27 @@ impl IntegerRank {
22
18
pub fn precision ( & self , target : & Target ) -> IntegerPrecision {
23
19
match self {
24
20
IntegerRank :: Bool => IntegerPrecision :: boolean ( ) ,
25
- IntegerRank :: Char => IntegerPrecision :: flexible ( target. char_layout ( ) . width . to_bits ( ) ) ,
26
- IntegerRank :: Short => IntegerPrecision :: flexible ( target. short_layout ( ) . width . to_bits ( ) ) ,
27
- IntegerRank :: Int => IntegerPrecision :: flexible ( target. int_layout ( ) . width . to_bits ( ) ) ,
28
- IntegerRank :: Long => IntegerPrecision :: flexible ( target. long_layout ( ) . width . to_bits ( ) ) ,
29
- IntegerRank :: LongLong => {
21
+ IntegerRank :: Flexible ( CInteger :: Char ) => {
22
+ IntegerPrecision :: flexible ( target. char_layout ( ) . width . to_bits ( ) )
23
+ }
24
+ IntegerRank :: Flexible ( CInteger :: Short ) => {
25
+ IntegerPrecision :: flexible ( target. short_layout ( ) . width . to_bits ( ) )
26
+ }
27
+ IntegerRank :: Flexible ( CInteger :: Int ) => {
28
+ IntegerPrecision :: flexible ( target. int_layout ( ) . width . to_bits ( ) )
29
+ }
30
+ IntegerRank :: Flexible ( CInteger :: Long ) => {
31
+ IntegerPrecision :: flexible ( target. long_layout ( ) . width . to_bits ( ) )
32
+ }
33
+ IntegerRank :: Flexible ( CInteger :: LongLong ) => {
30
34
IntegerPrecision :: flexible ( target. longlong_layout ( ) . width . to_bits ( ) )
31
35
}
32
36
IntegerRank :: Size => {
33
37
// This means that size types have the same effective rank as the type they would
34
38
// be in C for this target.
35
39
IntegerPrecision :: flexible ( target. size_layout ( ) . width . to_bits ( ) )
36
40
}
37
- IntegerRank :: FixedInt ( bits) => IntegerPrecision :: fixed ( * bits) ,
41
+ IntegerRank :: Fixed ( bits) => IntegerPrecision :: fixed ( * bits) ,
38
42
}
39
43
}
40
44
}
0 commit comments