Skip to main content

microcad_lang/eval/call/
argument_value.rs

1// Copyright © 2024-2026 The µcad authors <info@microcad.xyz>
2// SPDX-License-Identifier: AGPL-3.0-or-later
3
4//! Argument value evaluation entity
5
6use microcad_lang_base::{Identifier, SrcRef};
7use microcad_lang_proc_macros::SrcReferrer;
8
9use crate::{ty::*, value::*};
10
11/// Argument value.
12#[derive(Clone, Debug, SrcReferrer)]
13pub struct ArgumentValue {
14    /// *value* of the argument.
15    pub value: Value,
16    /// If expression of value is a single identifier, this item catches it.
17    pub inline_id: Option<Identifier>,
18    /// Source code reference.
19    src_ref: SrcRef,
20}
21
22impl std::fmt::Display for ArgumentValue {
23    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
24        write!(f, "{val}", val = self.value,)
25    }
26}
27
28impl Ty for ArgumentValue {
29    fn ty(&self) -> Type {
30        self.value.ty()
31    }
32}
33
34impl ArgumentValue {
35    /// Create new argument value
36    pub fn new(value: Value, inline_id: Option<Identifier>, src_ref: SrcRef) -> Self {
37        Self {
38            value,
39            inline_id,
40            src_ref,
41        }
42    }
43}