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
use crate::helpers::{IntoWasm, WasmName};
use std::{
    fmt::{Debug, Display, Formatter},
    sync::Arc,
};
use wast::{
    component::ComponentExternName,
    token::{Id, Index},
};

mod codegen;
mod convert;
mod display;

#[derive(Clone)]
pub struct WasmSymbol {
    inner: Arc<str>,
}

#[derive(Clone, Default)]
pub struct WasmExportName {
    inner: Option<Arc<str>>,
}

impl WasmSymbol {
    pub fn new(name: &str) -> Self {
        Self { inner: Arc::from(name) }
    }
}
impl WasmExportName {
    pub fn create<S: Into<WasmSymbol>>(name: S) -> Self {
        Self { inner: Some(name.into().inner) }
    }
    pub fn create_by(symbol: &WasmSymbol, export: bool) -> Self {
        match export {
            true => WasmExportName { inner: Some(symbol.inner.clone()) },
            false => WasmExportName::default(),
        }
    }
    pub fn clear(&mut self) {
        self.inner = None;
    }
}