1
use crate::ast::ReturnType;
2
use polyquine::Quine;
3
use serde::{Deserialize, Serialize};
4
use std::fmt::{Debug, Display};
5
use std::hash::Hash;
6
use uniplate::derive_unplateable;
7

            
8
derive_unplateable!(Metadata);
9

            
10
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize, Default, Quine)]
11
#[path_prefix(conjure_cp::ast)]
12
pub struct Metadata {
13
    pub clean: bool,
14
    pub etype: Option<ReturnType>,
15
}
16

            
17
impl Metadata {
18
1016
    pub fn new() -> Metadata {
19
1016
        Metadata {
20
1016
            clean: false,
21
1016
            etype: None,
22
1016
        }
23
1016
    }
24

            
25
    pub fn clone_dirty(&self) -> Metadata {
26
        Metadata {
27
            clean: false,
28
            ..self.clone()
29
        }
30
    }
31
}
32

            
33
impl Display for Metadata {
34
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
35
        write!(f, "Metadata")
36
    }
37
}
38

            
39
impl Hash for Metadata {
40
    fn hash<H: std::hash::Hasher>(&self, _state: &mut H) {
41
        // Dummy method - Metadata is ignored when hashing an Expression
42
    }
43
}