microcad_lang/syntax/call/
mod.rs1mod argument;
7mod argument_list;
8mod method_call;
9
10pub use argument::*;
11pub use argument_list::*;
12pub use method_call::*;
13
14use crate::{model::*, src_ref::*, syntax::*, value::*};
15
16pub enum CallResult {
18 Models(Vec<Model>),
20 Value(Value),
22 None,
24}
25
26#[derive(Clone, Default)]
28pub struct Call {
29 pub name: QualifiedName,
31 pub argument_list: ArgumentList,
33 pub src_ref: SrcRef,
35}
36
37impl SrcReferrer for Call {
38 fn src_ref(&self) -> SrcRef {
39 self.src_ref.clone()
40 }
41}
42
43impl std::fmt::Display for Call {
44 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
45 write!(f, "{}({})", self.name, self.argument_list)
46 }
47}
48
49impl std::fmt::Debug for Call {
50 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
51 write!(f, "{:?}({:?})", self.name, self.argument_list)
52 }
53}
54
55impl TreeDisplay for Call {
56 fn tree_print(&self, f: &mut std::fmt::Formatter, mut depth: TreeState) -> std::fmt::Result {
57 writeln!(f, "{:depth$}Call '{}':", "", self.name)?;
58 depth.indent();
59 self.argument_list
60 .iter()
61 .try_for_each(|a| a.tree_print(f, depth))
62 }
63}