@@ -10,10 +10,10 @@ use core::ops::Deref;
1010use wasmtime_environ:: PrimaryMap ;
1111use wasmtime_environ:: component:: {
1212 ComponentTypes , Export , InterfaceType , ResourceIndex , TypeComponentIndex ,
13- TypeComponentInstanceIndex , TypeDef , TypeEnumIndex , TypeFlagsIndex , TypeFuncIndex ,
14- TypeFutureIndex , TypeFutureTableIndex , TypeListIndex , TypeModuleIndex , TypeOptionIndex ,
15- TypeRecordIndex , TypeResourceTable , TypeResourceTableIndex , TypeResultIndex , TypeStreamIndex ,
16- TypeStreamTableIndex , TypeTupleIndex , TypeVariantIndex ,
13+ TypeComponentInstanceIndex , TypeDef , TypeEnumIndex , TypeFixedSizeListIndex , TypeFlagsIndex ,
14+ TypeFuncIndex , TypeFutureIndex , TypeFutureTableIndex , TypeListIndex , TypeModuleIndex ,
15+ TypeOptionIndex , TypeRecordIndex , TypeResourceTable , TypeResourceTableIndex , TypeResultIndex ,
16+ TypeStreamIndex , TypeStreamTableIndex , TypeTupleIndex , TypeVariantIndex ,
1717} ;
1818
1919pub use crate :: component:: resources:: ResourceType ;
@@ -158,7 +158,10 @@ impl TypeChecker<'_> {
158158 ( InterfaceType :: Stream ( _) , _) => false ,
159159 ( InterfaceType :: ErrorContext ( _) , InterfaceType :: ErrorContext ( _) ) => true ,
160160 ( InterfaceType :: ErrorContext ( _) , _) => false ,
161- ( InterfaceType :: FixedSizeList ( _) , _) => todo ! ( ) , // FIXME(#12279)
161+ ( InterfaceType :: FixedSizeList ( t1) , InterfaceType :: FixedSizeList ( t2) ) => {
162+ self . fixed_size_lists_equal ( t1, t2)
163+ }
164+ ( InterfaceType :: FixedSizeList ( _) , _) => false ,
162165 }
163166 }
164167
@@ -168,6 +171,19 @@ impl TypeChecker<'_> {
168171 self . interface_types_equal ( a. element , b. element )
169172 }
170173
174+ fn fixed_size_lists_equal (
175+ & self ,
176+ l1 : wasmtime_environ:: component:: TypeFixedSizeListIndex ,
177+ l2 : wasmtime_environ:: component:: TypeFixedSizeListIndex ,
178+ ) -> bool {
179+ let a = & self . a_types [ l1] ;
180+ let b = & self . b_types [ l2] ;
181+ if a. size != b. size {
182+ return false ;
183+ }
184+ self . interface_types_equal ( a. element , b. element )
185+ }
186+
171187 fn resources_equal ( & self , o1 : TypeResourceTableIndex , o2 : TypeResourceTableIndex ) -> bool {
172188 match ( & self . a_types [ o1] , & self . b_types [ o2] ) {
173189 // Concrete resource types are the same if they map back to the
@@ -325,6 +341,35 @@ impl List {
325341 }
326342}
327343
344+ /// A `list` interface type
345+ #[ derive( Clone , Debug ) ]
346+ pub struct FixedSizeList ( Handle < TypeFixedSizeListIndex > ) ;
347+
348+ impl PartialEq for FixedSizeList {
349+ fn eq ( & self , other : & Self ) -> bool {
350+ self . 0
351+ . equivalent ( & other. 0 , TypeChecker :: fixed_size_lists_equal)
352+ }
353+ }
354+
355+ impl Eq for FixedSizeList { }
356+
357+ impl FixedSizeList {
358+ pub ( crate ) fn from ( index : TypeFixedSizeListIndex , ty : & InstanceType < ' _ > ) -> Self {
359+ FixedSizeList ( Handle :: new ( index, ty) )
360+ }
361+
362+ /// Retrieve the element type of this `list`.
363+ pub fn ty ( & self ) -> Type {
364+ Type :: from ( & self . 0 . types [ self . 0 . index ] . element , & self . 0 . instance ( ) )
365+ }
366+
367+ /// Retrieve the size of this `list`.
368+ pub fn size ( & self ) -> u32 {
369+ self . 0 . types [ self . 0 . index ] . size
370+ }
371+ }
372+
328373/// A field declaration belonging to a `record`
329374#[ derive( Debug ) ]
330375pub struct Field < ' a > {
@@ -696,6 +741,7 @@ pub enum Type {
696741 Future ( FutureType ) ,
697742 Stream ( StreamType ) ,
698743 ErrorContext ,
744+ FixedSizeList ( FixedSizeList ) ,
699745}
700746
701747impl Type {
@@ -856,7 +902,9 @@ impl Type {
856902 InterfaceType :: Future ( index) => Type :: Future ( instance. future_type ( * index) ) ,
857903 InterfaceType :: Stream ( index) => Type :: Stream ( instance. stream_type ( * index) ) ,
858904 InterfaceType :: ErrorContext ( _) => Type :: ErrorContext ,
859- InterfaceType :: FixedSizeList ( _) => todo ! ( ) , // FIXME(#12279)
905+ InterfaceType :: FixedSizeList ( index) => {
906+ Type :: FixedSizeList ( FixedSizeList :: from ( * index, instance) )
907+ }
860908 }
861909 }
862910
@@ -888,6 +936,7 @@ impl Type {
888936 Type :: Future ( _) => "future" ,
889937 Type :: Stream ( _) => "stream" ,
890938 Type :: ErrorContext => "error-context" ,
939+ Type :: FixedSizeList ( _) => "list<_, N>" ,
891940 }
892941 }
893942}
0 commit comments