@@ -12,7 +12,7 @@ use rustc_codegen_ssa::{traits::CodegenBackend, CodegenResults};
12
12
use rustc_metadata:: EncodedMetadata ;
13
13
use rustc_middle:: {
14
14
dep_graph:: { WorkProduct , WorkProductId } ,
15
- ty:: { Ty , TyCtxt , TyKind , IntTy } ,
15
+ ty:: { Ty , TyCtxt , TyKind , IntTy , UintTy } ,
16
16
} ;
17
17
use rustc_span:: ErrorGuaranteed ;
18
18
use std:: any:: Any ;
@@ -31,7 +31,9 @@ pub type IString = Box<str>;
31
31
struct MyBackend ;
32
32
#[ derive( Clone , Debug ) ]
33
33
enum VariableType {
34
- I32 ,
34
+ I8 , I16 , I32 , I64 , I128 , ISize ,
35
+ U8 , U16 , U32 , U64 , U128 , USize ,
36
+ Bool ,
35
37
}
36
38
#[ derive( Debug ) ]
37
39
struct FunctionSignature {
@@ -54,13 +56,37 @@ impl FunctionSignature{
54
56
impl VariableType {
55
57
fn from_ty ( ty : Ty ) ->Self {
56
58
match ty. kind ( ) {
59
+ TyKind :: Int ( IntTy :: I8 ) => VariableType :: I8 ,
60
+ TyKind :: Int ( IntTy :: I16 ) => VariableType :: I16 ,
57
61
TyKind :: Int ( IntTy :: I32 ) => VariableType :: I32 ,
62
+ TyKind :: Int ( IntTy :: I64 ) => VariableType :: I64 ,
63
+ TyKind :: Int ( IntTy :: I128 ) => VariableType :: I128 ,
64
+ TyKind :: Int ( IntTy :: Isize ) => VariableType :: ISize ,
65
+ TyKind :: Uint ( UintTy :: U8 ) => VariableType :: U8 ,
66
+ TyKind :: Uint ( UintTy :: U16 ) => VariableType :: U16 ,
67
+ TyKind :: Uint ( UintTy :: U32 ) => VariableType :: U32 ,
68
+ TyKind :: Uint ( UintTy :: U64 ) => VariableType :: U64 ,
69
+ TyKind :: Uint ( UintTy :: U128 ) => VariableType :: U128 ,
70
+ TyKind :: Uint ( UintTy :: Usize ) => VariableType :: USize ,
71
+ TyKind :: Bool =>VariableType :: Bool ,
58
72
_ => todo ! ( "Unhandled type kind {:?}" , ty. kind( ) ) ,
59
73
}
60
74
}
61
75
pub ( crate ) fn il_name ( & self ) ->IString {
62
76
match self {
63
- Self :: I32 =>"int32"
77
+ Self :: I8 =>"int8" ,
78
+ Self :: I16 =>"int16" ,
79
+ Self :: I32 =>"int32" ,
80
+ Self :: I64 =>"int64" ,
81
+ Self :: I128 =>"[System.Runtime]System.Int128" ,
82
+ Self :: ISize => "native int" ,
83
+ Self :: U8 =>"uint8" ,
84
+ Self :: U16 =>"uint16" ,
85
+ Self :: U32 =>"uint32" ,
86
+ Self :: U64 =>"uint64" ,
87
+ Self :: U128 =>"[System.Runtime]System.UInt128" ,
88
+ Self :: USize =>"native uint" ,
89
+ Self :: Bool =>"bool" ,
64
90
} . into ( )
65
91
}
66
92
}
0 commit comments