microcad_lang/value/
argument_value.rs1use crate::{src_ref::*, syntax::*, ty::*, value::*};
7
8#[derive(Clone)]
10pub struct ArgumentValue {
11 pub value: Value,
13 pub inline_id: Option<Identifier>,
15 src_ref: SrcRef,
17}
18
19impl SrcReferrer for ArgumentValue {
20 fn src_ref(&self) -> SrcRef {
21 self.src_ref.clone()
22 }
23}
24
25impl std::fmt::Display for ArgumentValue {
26 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
27 write!(f, "{val}", val = self.value,)
28 }
29}
30
31impl std::fmt::Debug for ArgumentValue {
32 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
33 write!(f, "{val:?}", val = self.value)
34 }
35}
36
37impl Ty for ArgumentValue {
38 fn ty(&self) -> Type {
39 self.value.ty()
40 }
41}
42
43impl ArgumentValue {
44 pub fn new(value: Value, inline_id: Option<Identifier>, src_ref: SrcRef) -> Self {
46 Self {
47 value,
48 inline_id,
49 src_ref,
50 }
51 }
52
53 pub fn ty_inner(&self) -> Type {
55 if let Type::Array(ty) = self.ty() {
56 ty.as_ref().clone()
57 } else {
58 Type::Invalid
59 }
60 }
61}