1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use super::*;
use wast::component::{ComponentDefinedType, List};

impl<'a, 'i> IntoWasm<'a, Type<'i>> for ArrayType
where
    'a: 'i,
{
    fn as_wast(&'a self) -> Type<'i> {
        Type {
            span: Span::from_offset(0),
            id: WasmName::id(self.symbol.as_ref()),
            name: Some(NameAnnotation { name: self.symbol.as_ref() }),
            def: TypeDef::Array(self.as_wast()),
            parent: None,
            final_type: Some(true),
        }
    }
}
impl<'a, 'i> IntoWasm<'a, wast::core::ArrayType<'i>> for ArrayType
where
    'a: 'i,
{
    fn as_wast(&'a self) -> wast::core::ArrayType<'i> {
        wast::core::ArrayType { mutable: self.mutable, ty: self.item_type.as_wast() }
    }
}

impl<'a, 'i> IntoWasm<'a, ComponentDefinedType<'i>> for ArrayType
where
    'a: 'i,
{
    fn as_wast(&'a self) -> ComponentDefinedType<'i> {
        ComponentDefinedType::List(self.as_wast())
    }
}

impl<'a, 'i> IntoWasm<'a, List<'i>> for ArrayType
where
    'a: 'i,
{
    fn as_wast(&'a self) -> List<'i> {
        List { element: Box::new(self.item_type.as_wast()) }
    }
}