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
68
69
70
use crate::{
    helpers::{IndexedIterator, IntoWasm},
    ArrayType, EnumerateType, ExternalType, FlagType, VariantType,
};
use indexmap::IndexMap;
use wast::{component::CoreType, token::Span};

use crate::structures::StructureType;
use wast::{
    component::{ComponentDefinedType, ComponentValType, PrimitiveValType},
    core::{HeapType, RefType, StorageType, ValType},
};

pub mod array;
pub mod external;

mod codegen;

#[derive(Clone, Debug)]
pub enum WasmType {
    Bool,
    U8,
    U16,
    U32,
    U64,
    I8,
    I16,
    I32,
    I64,
    F32,
    F64,
    Unicode,
    UTF8Text,
    Any { nullable: bool },
    Flag(FlagType),
    Enumerate(EnumerateType),
    Structure(StructureType),
    Variant(Box<VariantType>),
    Array(Box<ArrayType>),
}

impl WasmType {
    pub fn set_nullable(&mut self, null: bool) {
        match self {
            Self::Bool => {}
            Self::U8 => {}
            Self::U16 => {}
            Self::U32 => {}
            Self::U64 => {}
            Self::I8 => {}
            Self::I16 => {}
            Self::I32 => {}
            Self::I64 => {}
            Self::F32 => {}
            Self::F64 => {}
            Self::Unicode => {}
            Self::UTF8Text => {}
            Self::Any { .. } => {}
            Self::Flag(_) => {}
            Self::Enumerate(_) => {}
            Self::Structure(v) => v.nullable = null,
            Self::Variant(_) => {}
            Self::Array(_) => {}
        }
    }
    pub fn with_nullable(mut self, null: bool) -> Self {
        self.set_nullable(null);
        self
    }
}