midenc_frontend_wasm/
config.rs

1use alloc::borrow::Cow;
2
3/// Configuration for the WASM translation.
4#[derive(Clone)]
5pub struct WasmTranslationConfig {
6    /// The source file name.
7    /// This is used as a fallback for module/component name if it's not parsed from the Wasm
8    /// binary, and an override name is not specified
9    pub source_name: Cow<'static, str>,
10
11    /// If specified, overrides the module/component name with the one specified
12    pub override_name: Option<Cow<'static, str>>,
13
14    /// The HIR world in which to translate any components/modules
15    pub world: Option<midenc_hir::dialects::builtin::WorldRef>,
16
17    /// Whether or not to generate native DWARF debug information.
18    pub generate_native_debuginfo: bool,
19
20    /// Whether or not to retain DWARF sections in compiled modules.
21    pub parse_wasm_debuginfo: bool,
22}
23
24impl core::fmt::Debug for WasmTranslationConfig {
25    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
26        let world = if self.world.is_some() { "Some" } else { "None" };
27        f.debug_struct("WasmTranslationConfig")
28            .field("source_name", &self.source_name)
29            .field("override_name", &self.override_name)
30            .field("world", &world)
31            .field("generate_native_debuginfo", &self.generate_native_debuginfo)
32            .field("parse_wasm_debuginfo", &self.parse_wasm_debuginfo)
33            .finish()
34    }
35}
36
37impl Default for WasmTranslationConfig {
38    fn default() -> Self {
39        Self {
40            source_name: Cow::Borrowed("noname"),
41            override_name: None,
42            world: None,
43            generate_native_debuginfo: false,
44            parse_wasm_debuginfo: true,
45        }
46    }
47}