@@ -10,7 +10,7 @@ use core::ops::Deref;
1010use wasmtime_environ:: PanicOnOom as _;
1111use wasmtime_environ:: component:: {
1212 ComponentTypes , Export , InterfaceType , ResourceIndex , TypeComponentIndex ,
13- TypeComponentInstanceIndex , TypeDef , TypeEnumIndex , TypeFlagsIndex , TypeFuncIndex ,
13+ TypeComponentInstanceIndex , TypeDef , TypeEnumIndex , TypeFixedSizeListIndex , TypeFlagsIndex , TypeFuncIndex ,
1414 TypeFutureIndex , TypeFutureTableIndex , TypeListIndex , TypeMapIndex , TypeModuleIndex ,
1515 TypeOptionIndex , TypeRecordIndex , TypeResourceTable , TypeResourceTableIndex , TypeResultIndex ,
1616 TypeStreamIndex , TypeStreamTableIndex , TypeTupleIndex , TypeVariantIndex , alternate_lookup_key,
@@ -165,7 +165,10 @@ impl TypeChecker<'_> {
165165 ( InterfaceType :: Stream ( _) , _) => false ,
166166 ( InterfaceType :: ErrorContext ( _) , InterfaceType :: ErrorContext ( _) ) => true ,
167167 ( InterfaceType :: ErrorContext ( _) , _) => false ,
168- ( InterfaceType :: FixedLengthList ( _) , _) => todo ! ( ) , // FIXME(#12279)
168+ ( InterfaceType :: FixedLengthList ( t1) , InterfaceType :: FixedSizeList ( t2) ) => {
169+ self . fixed_length_lists_equal ( t1, t2)
170+ }
171+ ( InterfaceType :: FixedSizeList ( _) , _) => false ,
169172 }
170173 }
171174
@@ -181,6 +184,19 @@ impl TypeChecker<'_> {
181184 self . interface_types_equal ( a. key , b. key ) && self . interface_types_equal ( a. value , b. value )
182185 }
183186
187+ fn fixed_length_lists_equal (
188+ & self ,
189+ l1 : wasmtime_environ:: component:: TypeFixedLengthListIndex ,
190+ l2 : wasmtime_environ:: component:: TypeFixedLengthListIndex ,
191+ ) -> bool {
192+ let a = & self . a_types [ l1] ;
193+ let b = & self . b_types [ l2] ;
194+ if a. size != b. size {
195+ return false ;
196+ }
197+ self . interface_types_equal ( a. element , b. element )
198+ }
199+
184200 fn resources_equal ( & self , o1 : TypeResourceTableIndex , o2 : TypeResourceTableIndex ) -> bool {
185201 match ( & self . a_types [ o1] , & self . b_types [ o2] ) {
186202 // Concrete resource types are the same if they map back to the
@@ -365,6 +381,34 @@ impl Map {
365381 Type :: from ( & self . 0 . types [ self . 0 . index ] . value , & self . 0 . instance ( ) )
366382 }
367383}
384+ /// A `list` interface type
385+ #[ derive( Clone , Debug ) ]
386+ pub struct FixedLengthList ( Handle < TypeFixedLengthListIndex > ) ;
387+
388+ impl PartialEq for FixedLengthList {
389+ fn eq ( & self , other : & Self ) -> bool {
390+ self . 0
391+ . equivalent ( & other. 0 , TypeChecker :: fixed_size_lists_equal)
392+ }
393+ }
394+
395+ impl Eq for FixedLengthList { }
396+
397+ impl FixedLengthList {
398+ pub ( crate ) fn from ( index : TypeFixedLengthListIndex , ty : & InstanceType < ' _ > ) -> Self {
399+ FixedLengthList ( Handle :: new ( index, ty) )
400+ }
401+
402+ /// Retrieve the element type of this `list`.
403+ pub fn ty ( & self ) -> Type {
404+ Type :: from ( & self . 0 . types [ self . 0 . index ] . element , & self . 0 . instance ( ) )
405+ }
406+
407+ /// Retrieve the size of this `list`.
408+ pub fn size ( & self ) -> u32 {
409+ self . 0 . types [ self . 0 . index ] . size
410+ }
411+ }
368412
369413/// A field declaration belonging to a `record`
370414#[ derive( Debug ) ]
@@ -738,6 +782,7 @@ pub enum Type {
738782 Future ( FutureType ) ,
739783 Stream ( StreamType ) ,
740784 ErrorContext ,
785+ FixedSizeList ( FixedSizeList ) ,
741786}
742787
743788impl Type {
@@ -899,7 +944,9 @@ impl Type {
899944 InterfaceType :: Future ( index) => Type :: Future ( instance. future_type ( * index) ) ,
900945 InterfaceType :: Stream ( index) => Type :: Stream ( instance. stream_type ( * index) ) ,
901946 InterfaceType :: ErrorContext ( _) => Type :: ErrorContext ,
902- InterfaceType :: FixedLengthList ( _) => todo ! ( ) , // FIXME(#12279)
947+ InterfaceType :: FixedLengthList ( index) => {
948+ Type :: FixedLengthList ( FixedSizeList :: from ( * index, instance) )
949+ }
903950 }
904951 }
905952
@@ -932,6 +979,7 @@ impl Type {
932979 Type :: Future ( _) => "future" ,
933980 Type :: Stream ( _) => "stream" ,
934981 Type :: ErrorContext => "error-context" ,
982+ Type :: FixedSizeList ( _) => "list<_, N>" ,
935983 }
936984 }
937985}
0 commit comments