sway_core/language/lexed/
mod.rs

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
mod program;

use crate::language::ModName;
pub use program::LexedProgram;
use sway_ast::Module;

use super::{HasModule, HasSubmodules};

/// A module and its submodules in the form of a tree.
#[derive(Debug, Clone)]
pub struct LexedModule {
    /// The content of this module in the form of a [Module].
    pub tree: Module,
    /// Submodules introduced within this module using the `dep` syntax in order of declaration.
    pub submodules: Vec<(ModName, LexedSubmodule)>,
}

/// A library module that was declared as a `mod` of another module.
///
/// Only submodules are guaranteed to be a `library`.
#[derive(Debug, Clone)]
pub struct LexedSubmodule {
    pub module: LexedModule,
}

impl HasModule<LexedModule> for LexedSubmodule {
    fn module(&self) -> &LexedModule {
        &self.module
    }
}

impl HasSubmodules<LexedSubmodule> for LexedModule {
    fn submodules(&self) -> &[(ModName, LexedSubmodule)] {
        &self.submodules
    }
}