Skip to main content

miden_assembly_syntax/ast/item/
mod.rs

1mod index;
2mod items;
3mod resolver;
4
5use miden_debug_types::Spanned;
6
7pub use self::{
8    index::{GlobalItemIndex, ItemIndex, ModuleIndex},
9    items::Item,
10    resolver::{
11        LocalSymbol, LocalSymbolResolver, SymbolResolution, SymbolResolutionError, SymbolTable,
12    },
13};
14use super::{Ident, Import, Visibility};
15
16#[derive(Debug, Copy, Clone)]
17pub enum Declaration<'a> {
18    Item(&'a Item),
19    Import(&'a Import),
20    Submodule(&'a SubmoduleDecl),
21}
22
23impl Spanned for Declaration<'_> {
24    fn span(&self) -> miden_debug_types::SourceSpan {
25        match self {
26            Self::Item(item) => item.span(),
27            Self::Import(import) => import.local_name().span(),
28            Self::Submodule(decl) => decl.name.span(),
29        }
30    }
31}
32
33/// Represents a submodule declaration in a [super::Module], i.e. `mod foo` or `pub mod foo`
34#[derive(Debug, Clone, PartialEq, Eq)]
35pub struct SubmoduleDecl {
36    /// The visibility of the submodule outside the containing namespace.
37    ///
38    /// A private submodule is visible only to:
39    ///
40    /// * It's parent
41    /// * It's siblings and their descendants
42    ///
43    /// A public submodule is visible to everyone.
44    pub visibility: Visibility,
45    /// The name of the submodule
46    ///
47    /// The full path of the submodule is derived from the path of its parent module
48    pub name: Ident,
49}