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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
use super::*;
use wast::component::Flags;

impl<'a, 'i> IntoWasm<'a, wast::component::Type<'i>> for FlagType
where
    'a: 'i,
{
    fn as_wast(&'a self) -> wast::component::Type<'i> {
        wast::component::Type {
            span: Span::from_offset(0),
            id: WasmName::id(self.symbol.as_ref()),
            name: None,
            exports: Default::default(),
            def: self.as_wast(),
        }
    }
}

impl<'a, 'i> IntoWasm<'a, wast::core::Type<'i>> for FlagType
where
    'a: 'i,
{
    fn as_wast(&'a self) -> wast::core::Type<'i> {
        wast::core::Type {
            span: Span::from_offset(0),
            id: WasmName::id(self.symbol.as_ref()),
            name: None,
            def: self.as_wast(),
            parent: None,
            final_type: None,
        }
    }
}
impl<'a, 'i> IntoWasm<'a, wast::component::TypeDef<'i>> for FlagType
where
    'a: 'i,
{
    fn as_wast(&'a self) -> wast::component::TypeDef<'i> {
        wast::component::TypeDef::Defined(self.as_wast())
    }
}

impl<'a, 'i> IntoWasm<'a, wast::core::TypeDef<'i>> for FlagType
where
    'a: 'i,
{
    fn as_wast(&'a self) -> wast::core::TypeDef<'i> {
        todo!()
    }
}
impl<'a, 'i> IntoWasm<'a, ComponentDefinedType<'i>> for FlagType
where
    'a: 'i,
{
    fn as_wast(&'a self) -> ComponentDefinedType<'i> {
        ComponentDefinedType::Flags(self.as_wast())
    }
}

impl<'a, 'i> IntoWasm<'a, Flags<'i>> for FlagType
where
    'a: 'i,
{
    fn as_wast(&'a self) -> Flags<'i> {
        Flags { names: self.fields.iter().map(|(_, v)| v.name.as_ref()).collect() }
    }
}