99 once_cell:: sync:: Lazy ,
1010 std:: collections:: HashMap ,
1111 wasm_encoder:: { BlockType , Instruction as Ins , MemArg , ValType } ,
12- wit_parser:: { Handle , Resolve , Results , Type , TypeDefKind , TypeId } ,
12+ wit_parser:: { Handle , Resolve , Type , TypeDefKind , TypeId } ,
1313} ;
1414
1515// Assume Wasm32
@@ -184,7 +184,7 @@ pub struct FunctionBindgen<'a> {
184184 stack_pointer : u32 ,
185185 types : & ' a IndexSet < TypeId > ,
186186 params : & ' a [ ( String , Type ) ] ,
187- results : & ' a Results ,
187+ result : & ' a Option < Type > ,
188188 params_abi : Abi ,
189189 results_abi : Abi ,
190190 local_stack : Vec < bool > ,
@@ -204,9 +204,9 @@ impl<'a> FunctionBindgen<'a> {
204204 stack_pointer,
205205 types : & summary. types ,
206206 params : function. params ,
207- results : function. results ,
207+ result : function. result ,
208208 params_abi : abi:: record_abi ( summary. resolve , function. params . types ( ) ) ,
209- results_abi : abi:: record_abi ( summary. resolve , function. results . types ( ) ) ,
209+ results_abi : abi:: record_abi ( summary. resolve , function. result . types ( ) ) ,
210210 local_types : Vec :: new ( ) ,
211211 local_stack : Vec :: new ( ) ,
212212 instructions : Vec :: new ( ) ,
@@ -332,7 +332,7 @@ impl<'a> FunctionBindgen<'a> {
332332 } )
333333 . collect :: < Vec < _ > > ( ) ;
334334
335- self . from_canon_record ( self . results . types ( ) , context, & locals, output) ;
335+ self . from_canon_record ( self . result . types ( ) , context, & locals, output) ;
336336
337337 for ( local, ty) in locals. iter ( ) . zip ( & self . results_abi . flattened . clone ( ) ) . rev ( ) {
338338 self . pop_local ( * local, * ty) ;
@@ -343,7 +343,7 @@ impl<'a> FunctionBindgen<'a> {
343343 self . get_stack ( ) ;
344344 self . push ( Ins :: LocalSet ( source) ) ;
345345
346- self . load_record ( self . results . types ( ) , context, source, output) ;
346+ self . load_record ( self . result . types ( ) , context, source, output) ;
347347
348348 self . pop_local ( source, ValType :: I32 ) ;
349349 self . pop_stack ( self . results_abi . size ) ;
@@ -369,7 +369,7 @@ impl<'a> FunctionBindgen<'a> {
369369 }
370370
371371 pub fn compile_export ( & mut self , index : i32 , from_canon : i32 , to_canon : i32 ) {
372- let return_style = match self . results . types ( ) . collect :: < Vec < _ > > ( ) . as_slice ( ) {
372+ let return_style = match self . result . types ( ) . collect :: < Vec < _ > > ( ) . as_slice ( ) {
373373 [ Type :: Id ( id) ] if matches ! ( & self . resolve. types[ * id] . kind, TypeDefKind :: Result ( _) ) => {
374374 ReturnStyle :: Result
375375 }
@@ -429,7 +429,7 @@ impl<'a> FunctionBindgen<'a> {
429429 self . get_stack ( ) ;
430430 self . push ( Ins :: LocalSet ( source) ) ;
431431
432- self . load_copy_record ( self . results . types ( ) , source) ;
432+ self . load_copy_record ( self . result . types ( ) , source) ;
433433
434434 self . pop_local ( source, ValType :: I32 ) ;
435435
@@ -462,7 +462,7 @@ impl<'a> FunctionBindgen<'a> {
462462
463463 let mut store_offset = 0 ;
464464 let mut load_offset = 0 ;
465- for ty in self . results . types ( ) {
465+ for ty in self . result . types ( ) {
466466 let abi = abi:: abi ( self . resolve , ty) ;
467467 store_offset = abi:: align ( store_offset, abi. align ) ;
468468
@@ -496,7 +496,7 @@ impl<'a> FunctionBindgen<'a> {
496496 // Arg 0: *mut MyResults
497497 let value = 0 ;
498498
499- self . free_stored_record ( self . results . types ( ) , value) ;
499+ self . free_stored_record ( self . result . types ( ) , value) ;
500500
501501 self . push ( Ins :: LocalGet ( value) ) ;
502502 self . push ( Ins :: I32Const ( self . results_abi . size . try_into ( ) . unwrap ( ) ) ) ;
@@ -619,7 +619,7 @@ impl<'a> FunctionBindgen<'a> {
619619 * IMPORTS . get ( "componentize-py#ToCanonI32" ) . unwrap ( ) ,
620620 ) ) ;
621621 }
622- Type :: U8 | Type :: U16 | Type :: U32 => {
622+ Type :: U8 | Type :: U16 | Type :: U32 | Type :: ErrorContext => {
623623 self . push ( Ins :: LocalGet ( context) ) ;
624624 self . push ( Ins :: LocalGet ( value) ) ;
625625 self . push ( Ins :: Call (
@@ -920,7 +920,7 @@ impl<'a> FunctionBindgen<'a> {
920920 self . to_canon ( ty, context, value) ;
921921 self . push ( Ins :: I32Store16 ( mem_arg ( 0 , 1 ) ) ) ;
922922 }
923- Type :: U32 | Type :: S32 => {
923+ Type :: U32 | Type :: S32 | Type :: ErrorContext => {
924924 self . push ( Ins :: LocalGet ( destination) ) ;
925925 self . to_canon ( ty, context, value) ;
926926 self . push ( Ins :: I32Store ( mem_arg ( 0 , 2 ) ) ) ;
@@ -1212,7 +1212,7 @@ impl<'a> FunctionBindgen<'a> {
12121212 self . push ( Ins :: LocalGet ( source[ 0 ] ) ) ;
12131213 self . push ( Ins :: I32Store16 ( mem_arg ( 0 , 1 ) ) ) ;
12141214 }
1215- Type :: U32 | Type :: S32 | Type :: Char => {
1215+ Type :: U32 | Type :: S32 | Type :: Char | Type :: ErrorContext => {
12161216 self . push ( Ins :: LocalGet ( destination) ) ;
12171217 self . push ( Ins :: LocalGet ( source[ 0 ] ) ) ;
12181218 self . push ( Ins :: I32Store ( mem_arg ( 0 , 2 ) ) ) ;
@@ -1458,7 +1458,7 @@ impl<'a> FunctionBindgen<'a> {
14581458 * IMPORTS . get ( "componentize-py#FromCanonI32" ) . unwrap ( ) ,
14591459 ) ) ;
14601460 }
1461- Type :: U8 | Type :: U16 | Type :: U32 => {
1461+ Type :: U8 | Type :: U16 | Type :: U32 | Type :: ErrorContext => {
14621462 self . push ( Ins :: LocalGet ( context) ) ;
14631463 self . push ( Ins :: LocalGet ( value[ 0 ] ) ) ;
14641464 self . push ( Ins :: Call (
@@ -1793,7 +1793,7 @@ impl<'a> FunctionBindgen<'a> {
17931793 self . from_canon ( ty, context, & [ value] ) ;
17941794 self . pop_local ( value, ValType :: I32 ) ;
17951795 }
1796- Type :: U32 | Type :: S32 | Type :: Char => {
1796+ Type :: U32 | Type :: S32 | Type :: Char | Type :: ErrorContext => {
17971797 let value = self . push_local ( ValType :: I32 ) ;
17981798 self . push ( Ins :: LocalGet ( source) ) ;
17991799 self . push ( Ins :: I32Load ( mem_arg ( 0 , 2 ) ) ) ;
@@ -2091,7 +2091,7 @@ impl<'a> FunctionBindgen<'a> {
20912091 self . push ( Ins :: LocalGet ( source) ) ;
20922092 self . push ( Ins :: I32Load16S ( mem_arg ( 0 , 1 ) ) ) ;
20932093 }
2094- Type :: U32 | Type :: S32 | Type :: Char => {
2094+ Type :: U32 | Type :: S32 | Type :: Char | Type :: ErrorContext => {
20952095 self . push ( Ins :: LocalGet ( source) ) ;
20962096 self . push ( Ins :: I32Load ( mem_arg ( 0 , 2 ) ) ) ;
20972097 }
@@ -2307,7 +2307,8 @@ impl<'a> FunctionBindgen<'a> {
23072307 | Type :: U64
23082308 | Type :: S64
23092309 | Type :: F32
2310- | Type :: F64 => { }
2310+ | Type :: F64
2311+ | Type :: ErrorContext => { }
23112312
23122313 Type :: String => {
23132314 self . push ( Ins :: LocalGet ( value[ 0 ] ) ) ;
@@ -2466,7 +2467,8 @@ impl<'a> FunctionBindgen<'a> {
24662467 | Type :: U64
24672468 | Type :: S64
24682469 | Type :: F32
2469- | Type :: F64 => { }
2470+ | Type :: F64
2471+ | Type :: ErrorContext => { }
24702472
24712473 Type :: String => {
24722474 self . push ( Ins :: LocalGet ( value) ) ;
0 commit comments