@@ -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 ,
@@ -118,6 +119,7 @@ impl ComponentTypesBuilder {
118119 type_info : TypeInformationCache :: default ( ) ,
119120 resources : ResourcesBuilder :: default ( ) ,
120121 abstract_resources : 0 ,
122+ fixed_size_lists : HashMap :: default ( ) ,
121123 }
122124 }
123125
@@ -456,8 +458,8 @@ impl ComponentTypesBuilder {
456458 ComponentDefinedType :: Stream ( ty) => {
457459 InterfaceType :: Stream ( self . stream_table_type ( types, ty) ?)
458460 }
459- ComponentDefinedType :: FixedSizeList ( .. ) => {
460- bail ! ( "support not implemented for fixed- size-lists" ) ;
461+ ComponentDefinedType :: FixedSizeList ( ty , size ) => {
462+ InterfaceType :: FixedSizeList ( self . fixed_size_list_type ( types , ty , * size) ? )
461463 }
462464 ComponentDefinedType :: Map ( ..) => {
463465 bail ! ( "support not implemented for map type" ) ;
@@ -575,6 +577,19 @@ impl ComponentTypesBuilder {
575577 self . add_tuple_type ( TypeTuple { types, abi } )
576578 }
577579
580+ fn fixed_size_list_type ( & mut self , types : TypesRef < ' _ > , ty : & ComponentValType , size : u32 ) -> Result < TypeFixedSizeListIndex > {
581+ assert_eq ! ( types. id( ) , self . module_types. validator_id( ) ) ;
582+ let element = self . valtype ( types, ty) ?;
583+ Ok ( self . new_fixed_size_list_type ( element, size) )
584+ }
585+
586+ pub ( crate ) fn new_fixed_size_list_type ( & mut self , element : InterfaceType , size : u32 ) -> TypeFixedSizeListIndex {
587+ let element_abi = self . component_types . canonical_abi ( & element) ;
588+ let abi = CanonicalAbiInfo :: record (
589+ ( 0 ..size) . into_iter ( ) . map ( |_| element_abi) ) ;
590+ self . add_fixed_size_list_type ( TypeFixedSizeList { element, size, abi } )
591+ }
592+
578593 fn flags_type ( & mut self , flags : & IndexSet < KebabString > ) -> TypeFlagsIndex {
579594 let flags = TypeFlags {
580595 names : flags. iter ( ) . map ( |s| s. to_string ( ) ) . collect ( ) ,
@@ -691,6 +706,11 @@ impl ComponentTypesBuilder {
691706 intern_and_fill_flat_types ! ( self , tuples, ty)
692707 }
693708
709+ /// Interns a new tuple type within this type information.
710+ pub fn add_fixed_size_list_type ( & mut self , ty : TypeFixedSizeList ) -> TypeFixedSizeListIndex {
711+ intern_and_fill_flat_types ! ( self , fixed_size_lists, ty)
712+ }
713+
694714 /// Interns a new variant type within this type information.
695715 pub fn add_variant_type ( & mut self , ty : TypeVariant ) -> TypeVariantIndex {
696716 intern_and_fill_flat_types ! ( self , variants, ty)
@@ -826,6 +846,7 @@ impl ComponentTypesBuilder {
826846 InterfaceType :: Enum ( i) => & self . type_info . enums [ * i] ,
827847 InterfaceType :: Option ( i) => & self . type_info . options [ * i] ,
828848 InterfaceType :: Result ( i) => & self . type_info . results [ * i] ,
849+ InterfaceType :: FixedSizeList ( i) => & self . type_info . fixed_size_lists [ * i] ,
829850 }
830851 }
831852}
@@ -935,6 +956,7 @@ struct TypeInformationCache {
935956 options : PrimaryMap < TypeOptionIndex , TypeInformation > ,
936957 results : PrimaryMap < TypeResultIndex , TypeInformation > ,
937958 lists : PrimaryMap < TypeListIndex , TypeInformation > ,
959+ fixed_size_lists : PrimaryMap < TypeFixedSizeListIndex , TypeInformation > ,
938960}
939961
940962struct TypeInformation {
@@ -1084,6 +1106,10 @@ impl TypeInformation {
10841106 self . build_record ( ty. types . iter ( ) . map ( |t| types. type_information ( t) ) ) ;
10851107 }
10861108
1109+ fn fixed_size_lists ( & mut self , types : & ComponentTypesBuilder , ty : & TypeFixedSizeList ) {
1110+ self . build_record ( ( 0 ..ty. size ) . into_iter ( ) . map ( |_| types. type_information ( & ty. element ) ) ) ;
1111+ }
1112+
10871113 fn enums ( & mut self , _types : & ComponentTypesBuilder , _ty : & TypeEnum ) {
10881114 self . depth = 1 ;
10891115 self . flat . push ( FlatType :: I32 , FlatType :: I32 ) ;
0 commit comments