@@ -3,9 +3,9 @@ use indexmap::IndexMap;
33use petgraph:: graph:: NodeIndex ;
44use std:: collections:: HashMap ;
55use wac_types:: {
6- CoreExtern , DefinedType , DefinedTypeId , Enum , Flags , FuncResult , FuncTypeId , InterfaceId ,
7- ItemKind , ModuleTypeId , PrimitiveType , Record , ResourceId , Type , Types , UsedType , ValueType ,
8- Variant , WorldId ,
6+ CoreExtern , DefinedType , DefinedTypeId , Enum , Flags , FuncTypeId , InterfaceId , ItemKind ,
7+ ModuleTypeId , PrimitiveType , Record , ResourceId , Type , Types , UsedType , ValueType , Variant ,
8+ WorldId ,
99} ;
1010use wasm_encoder:: {
1111 Alias , ComponentBuilder , ComponentCoreTypeEncoder , ComponentExportKind ,
@@ -227,27 +227,11 @@ impl<'a> TypeEncoder<'a> {
227227 . map ( |( n, ty) | ( n. as_str ( ) , self . value_type ( state, * ty) ) )
228228 . collect :: < Vec < _ > > ( ) ;
229229
230- let results = match & ty. results {
231- Some ( FuncResult :: Scalar ( ty) ) => vec ! [ ( "" , self . value_type( state, * ty) ) ] ,
232- Some ( FuncResult :: List ( results) ) => results
233- . iter ( )
234- . map ( |( n, ty) | ( n. as_str ( ) , self . value_type ( state, * ty) ) )
235- . collect ( ) ,
236- None => Vec :: new ( ) ,
237- } ;
238-
230+ let result = ty. result . map ( |ty| self . value_type ( state, ty) ) ;
239231 let index = state. current . encodable . type_count ( ) ;
240232 let mut encoder = state. current . encodable . ty ( ) . function ( ) ;
241233 encoder. params ( params) ;
242-
243- match & ty. results {
244- Some ( FuncResult :: Scalar ( _) ) => {
245- encoder. result ( results[ 0 ] . 1 ) ;
246- }
247- _ => {
248- encoder. results ( results) ;
249- }
250- }
234+ encoder. result ( result) ;
251235
252236 log:: debug!( "function type encoded to type index {index}" ) ;
253237 index
@@ -271,7 +255,6 @@ impl<'a> TypeEncoder<'a> {
271255 DefinedType :: Alias ( ValueType :: Defined ( id) ) => self . defined ( state, * id) ,
272256 DefinedType :: Stream ( ty) => self . stream ( state, * ty) ,
273257 DefinedType :: Future ( ty) => self . future ( state, * ty) ,
274- DefinedType :: ErrorContext => self . error_context ( state) ,
275258 } ;
276259
277260 log:: debug!( "defined type encoded to type index {index}" ) ;
@@ -583,12 +566,6 @@ impl<'a> TypeEncoder<'a> {
583566 index
584567 }
585568
586- fn error_context ( & self , state : & mut State ) -> u32 {
587- let index = state. current . encodable . type_count ( ) ;
588- state. current . encodable . ty ( ) . defined_type ( ) . error_context ( ) ;
589- index
590- }
591-
592569 fn option ( & self , state : & mut State , ty : ValueType ) -> u32 {
593570 let ty = self . value_type ( state, ty) ;
594571 let index = state. current . encodable . type_count ( ) ;
0 commit comments