@@ -50,6 +50,7 @@ pub struct ComponentTypesBuilder {
5050 future_tables : HashMap < TypeFutureTable , TypeFutureTableIndex > ,
5151 stream_tables : HashMap < TypeStreamTable , TypeStreamTableIndex > ,
5252 error_context_tables : HashMap < TypeErrorContextTable , TypeComponentLocalErrorContextTableIndex > ,
53+ fixed_size_lists : HashMap < TypeFixedSizeList , TypeFixedSizeListIndex > ,
5354
5455 component_types : ComponentTypes ,
5556 module_types : ModuleTypesBuilder ,
@@ -111,6 +112,7 @@ impl ComponentTypesBuilder {
111112 component_types : ComponentTypes :: default ( ) ,
112113 type_info : TypeInformationCache :: default ( ) ,
113114 resources : ResourcesBuilder :: default ( ) ,
115+ fixed_size_lists : HashMap :: default ( ) ,
114116 }
115117 }
116118
@@ -418,6 +420,9 @@ impl ComponentTypesBuilder {
418420 ComponentDefinedType :: Stream ( ty) => {
419421 InterfaceType :: Stream ( self . stream_table_type ( types, ty) ?)
420422 }
423+ ComponentDefinedType :: FixedSizeList ( ty, size) => {
424+ InterfaceType :: FixedSizeList ( self . fixed_size_list_type ( types, ty, * size) ?)
425+ }
421426 } ;
422427 let info = self . type_information ( & ret) ;
423428 if info. depth > MAX_TYPE_DEPTH {
@@ -531,6 +536,19 @@ impl ComponentTypesBuilder {
531536 self . add_tuple_type ( TypeTuple { types, abi } )
532537 }
533538
539+ fn fixed_size_list_type ( & mut self , types : TypesRef < ' _ > , ty : & ComponentValType , size : u32 ) -> Result < TypeFixedSizeListIndex > {
540+ assert_eq ! ( types. id( ) , self . module_types. validator_id( ) ) ;
541+ let element = self . valtype ( types, ty) ?;
542+ Ok ( self . new_fixed_size_list_type ( element, size) )
543+ }
544+
545+ pub ( crate ) fn new_fixed_size_list_type ( & mut self , element : InterfaceType , size : u32 ) -> TypeFixedSizeListIndex {
546+ let element_abi = self . component_types . canonical_abi ( & element) ;
547+ let abi = CanonicalAbiInfo :: record (
548+ ( 0 ..size) . into_iter ( ) . map ( |_| element_abi) ) ;
549+ self . add_fixed_size_list_type ( TypeFixedSizeList { element, size, abi } )
550+ }
551+
534552 fn flags_type ( & mut self , flags : & IndexSet < KebabString > ) -> TypeFlagsIndex {
535553 let flags = TypeFlags {
536554 names : flags. iter ( ) . map ( |s| s. to_string ( ) ) . collect ( ) ,
@@ -647,6 +665,11 @@ impl ComponentTypesBuilder {
647665 intern_and_fill_flat_types ! ( self , tuples, ty)
648666 }
649667
668+ /// Interns a new tuple type within this type information.
669+ pub fn add_fixed_size_list_type ( & mut self , ty : TypeFixedSizeList ) -> TypeFixedSizeListIndex {
670+ intern_and_fill_flat_types ! ( self , fixed_size_lists, ty)
671+ }
672+
650673 /// Interns a new variant type within this type information.
651674 pub fn add_variant_type ( & mut self , ty : TypeVariant ) -> TypeVariantIndex {
652675 intern_and_fill_flat_types ! ( self , variants, ty)
@@ -782,6 +805,7 @@ impl ComponentTypesBuilder {
782805 InterfaceType :: Enum ( i) => & self . type_info . enums [ * i] ,
783806 InterfaceType :: Option ( i) => & self . type_info . options [ * i] ,
784807 InterfaceType :: Result ( i) => & self . type_info . results [ * i] ,
808+ InterfaceType :: FixedSizeList ( i) => & self . type_info . fixed_size_lists [ * i] ,
785809 }
786810 }
787811}
@@ -891,6 +915,7 @@ struct TypeInformationCache {
891915 options : PrimaryMap < TypeOptionIndex , TypeInformation > ,
892916 results : PrimaryMap < TypeResultIndex , TypeInformation > ,
893917 lists : PrimaryMap < TypeListIndex , TypeInformation > ,
918+ fixed_size_lists : PrimaryMap < TypeFixedSizeListIndex , TypeInformation > ,
894919}
895920
896921struct TypeInformation {
@@ -1040,6 +1065,10 @@ impl TypeInformation {
10401065 self . build_record ( ty. types . iter ( ) . map ( |t| types. type_information ( t) ) ) ;
10411066 }
10421067
1068+ fn fixed_size_lists ( & mut self , types : & ComponentTypesBuilder , ty : & TypeFixedSizeList ) {
1069+ self . build_record ( ( 0 ..ty. size ) . into_iter ( ) . map ( |_| types. type_information ( & ty. element ) ) ) ;
1070+ }
1071+
10431072 fn enums ( & mut self , _types : & ComponentTypesBuilder , _ty : & TypeEnum ) {
10441073 self . depth = 1 ;
10451074 self . flat . push ( FlatType :: I32 , FlatType :: I32 ) ;
0 commit comments