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::*;
13use microcad_lang_base::{SrcRef, SrcReferrer, TreeDisplay, TreeState};
14
15use crate::{model::*, syntax::*, value::*};
16
17pub enum CallResult {
19 Models(Vec<Model>),
21 Value(Value),
23 None,
25}
26
27#[derive(Clone, Default)]
29pub struct Call {
30 pub name: QualifiedName,
32 pub argument_list: ArgumentList,
34 pub src_ref: SrcRef,
36}
37
38impl SrcReferrer for Call {
39 fn src_ref(&self) -> SrcRef {
40 self.src_ref.clone()
41 }
42}
43
44impl std::fmt::Display for Call {
45 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
46 write!(f, "{}({})", self.name, self.argument_list)
47 }
48}
49
50impl std::fmt::Debug for Call {
51 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
52 write!(f, "{:?}({:?})", self.name, self.argument_list)
53 }
54}
55
56impl TreeDisplay for Call {
57 fn tree_print(&self, f: &mut std::fmt::Formatter, mut depth: TreeState) -> std::fmt::Result {
58 writeln!(f, "{:depth$}Call '{}':", "", self.name)?;
59 depth.indent();
60 self.argument_list
61 .iter()
62 .try_for_each(|a| a.tree_print(f, depth))
63 }
64}