microcad_lang/syntax/module/
module_definition.rs1use crate::{rc::*, src_ref::*, syntax::*};
7
8#[derive(Debug, Clone)]
10pub struct ModuleDefinition {
11 pub visibility: Visibility,
13 pub id: Identifier,
15 pub body: Body,
17 pub src_ref: SrcRef,
19}
20
21impl ModuleDefinition {
22 pub fn new(visibility: Visibility, id: Identifier) -> Rc<Self> {
24 Rc::new(Self {
25 visibility,
26 id,
27 body: Body::default(),
28 src_ref: SrcRef(None),
29 })
30 }
31}
32
33impl SrcReferrer for ModuleDefinition {
34 fn src_ref(&self) -> SrcRef {
35 self.src_ref.clone()
36 }
37}
38
39impl TreeDisplay for ModuleDefinition {
40 fn tree_print(&self, f: &mut std::fmt::Formatter, mut depth: TreeState) -> std::fmt::Result {
41 writeln!(f, "{:depth$}ModuleDefinition '{}':", "", self.id)?;
42 depth.indent();
43 self.body.tree_print(f, depth)
44 }
45}