Skip to main content

litex/fact/
fact_inside_forall.rs

1use crate::prelude::*;
2use std::fmt;
3
4#[derive(Clone)]
5pub enum ExistOrAndChainAtomicFact {
6    AtomicFact(AtomicFact),
7    AndFact(AndFact),
8    ChainFact(ChainFact),
9    OrFact(OrFact),
10    ExistFact(ExistFactEnum),
11}
12
13impl fmt::Display for ExistOrAndChainAtomicFact {
14    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
15        match self {
16            ExistOrAndChainAtomicFact::AtomicFact(atomic_fact) => write!(f, "{}", atomic_fact),
17            ExistOrAndChainAtomicFact::AndFact(and_fact) => write!(f, "{}", and_fact),
18            ExistOrAndChainAtomicFact::ChainFact(chain_fact) => write!(f, "{}", chain_fact),
19            ExistOrAndChainAtomicFact::OrFact(or_fact) => write!(f, "{}", or_fact),
20            ExistOrAndChainAtomicFact::ExistFact(exist_fact) => write!(f, "{}", exist_fact),
21        }
22    }
23}
24
25impl ExistOrAndChainAtomicFact {
26    pub fn to_fact(self) -> Fact {
27        match self {
28            ExistOrAndChainAtomicFact::AtomicFact(atomic_fact) => Fact::AtomicFact(atomic_fact),
29            ExistOrAndChainAtomicFact::AndFact(and_fact) => Fact::AndFact(and_fact),
30            ExistOrAndChainAtomicFact::ChainFact(chain_fact) => Fact::ChainFact(chain_fact),
31            ExistOrAndChainAtomicFact::OrFact(or_fact) => Fact::OrFact(or_fact),
32            ExistOrAndChainAtomicFact::ExistFact(exist_fact) => Fact::ExistFact(exist_fact),
33        }
34    }
35
36    pub fn line_file(&self) -> LineFile {
37        match self {
38            ExistOrAndChainAtomicFact::AtomicFact(atomic_fact) => atomic_fact.line_file(),
39            ExistOrAndChainAtomicFact::AndFact(and_fact) => and_fact.line_file(),
40            ExistOrAndChainAtomicFact::ChainFact(chain_fact) => chain_fact.line_file(),
41            ExistOrAndChainAtomicFact::OrFact(or_fact) => or_fact.line_file.clone(),
42            ExistOrAndChainAtomicFact::ExistFact(exist_fact) => exist_fact.line_file(),
43        }
44    }
45}
46
47impl From<AtomicFact> for ExistOrAndChainAtomicFact {
48    fn from(atomic_fact: AtomicFact) -> Self {
49        ExistOrAndChainAtomicFact::AtomicFact(atomic_fact)
50    }
51}
52
53impl From<GreaterEqualFact> for ExistOrAndChainAtomicFact {
54    fn from(f: GreaterEqualFact) -> Self {
55        AtomicFact::from(f).into()
56    }
57}
58
59impl From<IsNonemptySetFact> for ExistOrAndChainAtomicFact {
60    fn from(f: IsNonemptySetFact) -> Self {
61        AtomicFact::from(f).into()
62    }
63}
64
65impl From<EqualFact> for ExistOrAndChainAtomicFact {
66    fn from(f: EqualFact) -> Self {
67        AtomicFact::from(f).into()
68    }
69}
70
71impl From<InFact> for ExistOrAndChainAtomicFact {
72    fn from(f: InFact) -> Self {
73        ExistOrAndChainAtomicFact::AtomicFact(f.into())
74    }
75}
76
77impl From<OrAndChainAtomicFact> for ExistOrAndChainAtomicFact {
78    fn from(f: OrAndChainAtomicFact) -> Self {
79        match f {
80            OrAndChainAtomicFact::AtomicFact(a) => ExistOrAndChainAtomicFact::AtomicFact(a),
81            OrAndChainAtomicFact::AndFact(a) => ExistOrAndChainAtomicFact::AndFact(a),
82            OrAndChainAtomicFact::ChainFact(c) => ExistOrAndChainAtomicFact::ChainFact(c),
83            OrAndChainAtomicFact::OrFact(o) => ExistOrAndChainAtomicFact::OrFact(o),
84        }
85    }
86}
87
88impl From<ExistFactEnum> for ExistOrAndChainAtomicFact {
89    fn from(exist_fact: ExistFactEnum) -> Self {
90        ExistOrAndChainAtomicFact::ExistFact(exist_fact)
91    }
92}
93
94impl From<AndFact> for ExistOrAndChainAtomicFact {
95    fn from(a: AndFact) -> Self {
96        ExistOrAndChainAtomicFact::AndFact(a)
97    }
98}
99
100impl From<ChainFact> for ExistOrAndChainAtomicFact {
101    fn from(c: ChainFact) -> Self {
102        ExistOrAndChainAtomicFact::ChainFact(c)
103    }
104}
105
106impl From<OrFact> for ExistOrAndChainAtomicFact {
107    fn from(o: OrFact) -> Self {
108        ExistOrAndChainAtomicFact::OrFact(o)
109    }
110}