11use crate :: {
22 hir,
33 mir:: {
4- Expr , FuncD ,
4+ Expr , FuncD , FuncK ,
55 builder:: { Builder , InitVar } ,
66 } ,
77 shared:: { ApiCheck , NumberKind , Range } ,
@@ -118,6 +118,7 @@ impl Serdes for hir::Type {
118118 ) -> impl Fn ( & mut Builder , Expr ) + use < ' ty , ' ser > + ' ty {
119119 #[ allow( clippy:: type_complexity) ]
120120 let cb: Box < dyn Fn ( & mut Builder , Expr ) > = match self {
121+ hir:: Type :: Boolean ( ty) => Box :: new ( ty. ser ( b, ser) ) ,
121122 hir:: Type :: Number ( ty) => Box :: new ( ty. ser ( b, ser) ) ,
122123 hir:: Type :: Vector ( ty) => Box :: new ( ty. ser ( b, ser) ) ,
123124 hir:: Type :: BinaryString ( ty) => Box :: new ( ty. ser ( b, ser) ) ,
@@ -140,6 +141,7 @@ impl Serdes for hir::Type {
140141 des : & ' des Des ,
141142 ) -> impl Fn ( & mut Builder ) -> InitVar + use < ' ty , ' des > + ' ty {
142143 let cb: Box < dyn Fn ( & mut Builder ) -> InitVar > = match self {
144+ hir:: Type :: Boolean ( ty) => Box :: new ( ty. des ( b, des) ) ,
143145 hir:: Type :: Number ( ty) => Box :: new ( ty. des ( b, des) ) ,
144146 hir:: Type :: Vector ( ty) => Box :: new ( ty. des ( b, des) ) ,
145147 hir:: Type :: BinaryString ( ty) => Box :: new ( ty. des ( b, des) ) ,
@@ -155,6 +157,32 @@ impl Serdes for hir::Type {
155157 }
156158}
157159
160+ impl Serdes for hir:: BooleanType {
161+ fn ser < ' ty , ' b , ' ser : ' ty > (
162+ & ' ty self ,
163+ _: & ' b mut Builder ,
164+ ser : & ' ser Ser ,
165+ ) -> impl Fn ( & mut Builder , Expr ) + use < ' ty , ' ser > + ' ty {
166+ move |b : & mut Builder , from : Expr | {
167+ apicheck_full ! ( ser, check_type( b, from. clone( ) , "boolean" ) ) ;
168+
169+ b. alloc_k ( 1 ) ;
170+ b. write_k ( FuncK :: U8 , from. bit ( ) ) ;
171+ }
172+ }
173+
174+ fn des < ' ty , ' b , ' des : ' ty > (
175+ & ' ty self ,
176+ _: & ' b mut Builder ,
177+ _: & ' des Des ,
178+ ) -> impl Fn ( & mut Builder ) -> InitVar + use < ' ty , ' des > + ' ty {
179+ move |b : & mut Builder | {
180+ let value = b. read_k ( FuncK :: U8 ) ;
181+ b. expr ( value. expr ( ) . eq ( 1 ) )
182+ }
183+ }
184+ }
185+
158186impl Serdes for hir:: NumberType {
159187 fn ser < ' ty , ' b , ' ser : ' ty > (
160188 & ' ty self ,
0 commit comments