@@ -27,7 +27,7 @@ pub enum Type {
2727 Bool ,
2828 /// `typ x : width`. e.g. `unsigned int x: 3`.
2929 CBitField { typ : Box < Type > , width : u64 } ,
30- /// Machine dependent integers: `bool`, `char`, `int`, `size_t`, etc.
30+ /// Machine dependent integers: `bool`, `char`, `int`, `long int`, ` size_t`, etc.
3131 CInteger ( CIntType ) ,
3232 /// `return_type x(parameters)`
3333 Code { parameters : Vec < Parameter > , return_type : Box < Type > } ,
@@ -83,6 +83,8 @@ pub enum CIntType {
8383 Char ,
8484 /// `int`
8585 Int ,
86+ /// `long int`
87+ LongInt ,
8688 /// `size_t`
8789 SizeT ,
8890 /// `ssize_t`
@@ -232,6 +234,7 @@ impl CIntType {
232234 CIntType :: Bool => st. machine_model ( ) . bool_width ,
233235 CIntType :: Char => st. machine_model ( ) . char_width ,
234236 CIntType :: Int => st. machine_model ( ) . int_width ,
237+ CIntType :: LongInt => st. machine_model ( ) . long_int_width ,
235238 CIntType :: SizeT => st. machine_model ( ) . pointer_width ,
236239 CIntType :: SSizeT => st. machine_model ( ) . pointer_width ,
237240 }
@@ -287,6 +290,7 @@ impl Type {
287290 CInteger ( CIntType :: Bool ) => Some ( mm. bool_width ) ,
288291 CInteger ( CIntType :: Char ) => Some ( mm. char_width ) ,
289292 CInteger ( CIntType :: Int ) => Some ( mm. int_width ) ,
293+ CInteger ( CIntType :: LongInt ) => Some ( mm. long_int_width ) ,
290294 Signedbv { width } | Unsignedbv { width } => Some ( * width) ,
291295 _ => None ,
292296 }
@@ -450,6 +454,14 @@ impl Type {
450454 }
451455 }
452456
457+ pub fn is_long_int ( & self ) -> bool {
458+ let concrete = self . unwrap_typedef ( ) ;
459+ match concrete {
460+ Type :: CInteger ( CIntType :: LongInt ) => true ,
461+ _ => false ,
462+ }
463+ }
464+
453465 pub fn is_c_size_t ( & self ) -> bool {
454466 let concrete = self . unwrap_typedef ( ) ;
455467 match concrete {
@@ -637,7 +649,10 @@ impl Type {
637649 pub fn is_signed ( & self , mm : & MachineModel ) -> bool {
638650 let concrete = self . unwrap_typedef ( ) ;
639651 match concrete {
640- CInteger ( CIntType :: Int ) | CInteger ( CIntType :: SSizeT ) | Signedbv { .. } => true ,
652+ CInteger ( CIntType :: Int )
653+ | CInteger ( CIntType :: LongInt )
654+ | CInteger ( CIntType :: SSizeT )
655+ | Signedbv { .. } => true ,
641656 CInteger ( CIntType :: Char ) => !mm. char_is_unsigned ,
642657 _ => false ,
643658 }
@@ -963,6 +978,10 @@ impl Type {
963978 CInteger ( CIntType :: Int )
964979 }
965980
981+ pub fn c_long_int ( ) -> Self {
982+ CInteger ( CIntType :: LongInt )
983+ }
984+
966985 pub fn c_size_t ( ) -> Self {
967986 CInteger ( CIntType :: SizeT )
968987 }
@@ -1471,6 +1490,7 @@ mod type_tests {
14711490 assert_eq ! ( type_def. is_empty( ) , src_type. is_empty( ) ) ;
14721491 assert_eq ! ( type_def. is_double( ) , src_type. is_double( ) ) ;
14731492 assert_eq ! ( type_def. is_bool( ) , src_type. is_bool( ) ) ;
1493+ assert_eq ! ( type_def. is_long_int( ) , src_type. is_long_int( ) ) ;
14741494 assert_eq ! ( type_def. is_array( ) , src_type. is_array( ) ) ;
14751495 assert_eq ! ( type_def. is_array_like( ) , src_type. is_array_like( ) ) ;
14761496 assert_eq ! ( type_def. is_union( ) , src_type. is_union( ) ) ;
0 commit comments