1use crate::prelude::*;
2
3impl Runtime {
4 pub fn equal_literally(&self, left: &Obj, right: &Obj) -> bool {
5 match left {
6 Obj::Atom(AtomObj::Identifier(a)) => match right {
7 Obj::Atom(AtomObj::Identifier(b)) => a.to_string() == b.to_string(),
8 _ => false,
9 },
10 Obj::Atom(AtomObj::IdentifierWithMod(a)) => match right {
11 Obj::Atom(AtomObj::IdentifierWithMod(b)) => {
12 if a.mod_name == b.mod_name {
13 a.to_string() == b.to_string()
14 } else {
15 match (
16 self.module_manager
17 .module_name_and_path_map
18 .get(&a.mod_name),
19 self.module_manager
20 .module_name_and_path_map
21 .get(&b.mod_name),
22 ) {
23 (Some(p1), Some(p2)) => p1 == p2 && a.name == b.name,
24 _ => false,
25 }
26 }
27 }
28 _ => false,
29 },
30 Obj::FnObj(f) => match right {
31 Obj::FnObj(g) => f.to_string() == g.to_string(),
32 _ => false,
33 },
34 Obj::Number(n) => match right {
35 Obj::Number(m) => n.to_string() == m.to_string(),
36 _ => false,
37 },
38 Obj::Add(a) => match right {
39 Obj::Add(b) => a.to_string() == b.to_string(),
40 _ => false,
41 },
42 Obj::Sub(a) => match right {
43 Obj::Sub(b) => a.to_string() == b.to_string(),
44 _ => false,
45 },
46 Obj::Mul(a) => match right {
47 Obj::Mul(b) => a.to_string() == b.to_string(),
48 _ => false,
49 },
50 Obj::Div(a) => match right {
51 Obj::Div(b) => a.to_string() == b.to_string(),
52 _ => false,
53 },
54 Obj::Mod(a) => match right {
55 Obj::Mod(b) => a.to_string() == b.to_string(),
56 _ => false,
57 },
58 Obj::Pow(a) => match right {
59 Obj::Pow(b) => a.to_string() == b.to_string(),
60 _ => false,
61 },
62 Obj::MatrixAdd(a) => match right {
63 Obj::MatrixAdd(b) => a.to_string() == b.to_string(),
64 _ => false,
65 },
66 Obj::MatrixSub(a) => match right {
67 Obj::MatrixSub(b) => a.to_string() == b.to_string(),
68 _ => false,
69 },
70 Obj::MatrixMul(a) => match right {
71 Obj::MatrixMul(b) => a.to_string() == b.to_string(),
72 _ => false,
73 },
74 Obj::MatrixScalarMul(a) => match right {
75 Obj::MatrixScalarMul(b) => a.to_string() == b.to_string(),
76 _ => false,
77 },
78 Obj::MatrixPow(a) => match right {
79 Obj::MatrixPow(b) => a.to_string() == b.to_string(),
80 _ => false,
81 },
82 Obj::Abs(a) => match right {
83 Obj::Abs(b) => a.to_string() == b.to_string(),
84 _ => false,
85 },
86 Obj::Log(a) => match right {
87 Obj::Log(b) => a.to_string() == b.to_string(),
88 _ => false,
89 },
90 Obj::Max(a) => match right {
91 Obj::Max(b) => a.to_string() == b.to_string(),
92 _ => false,
93 },
94 Obj::Min(a) => match right {
95 Obj::Min(b) => a.to_string() == b.to_string(),
96 _ => false,
97 },
98 Obj::Union(a) => match right {
99 Obj::Union(b) => a.to_string() == b.to_string(),
100 _ => false,
101 },
102 Obj::Intersect(a) => match right {
103 Obj::Intersect(b) => a.to_string() == b.to_string(),
104 _ => false,
105 },
106 Obj::SetMinus(a) => match right {
107 Obj::SetMinus(b) => a.to_string() == b.to_string(),
108 _ => false,
109 },
110 Obj::SetDiff(a) => match right {
111 Obj::SetDiff(b) => a.to_string() == b.to_string(),
112 _ => false,
113 },
114 Obj::Cup(a) => match right {
115 Obj::Cup(b) => a.to_string() == b.to_string(),
116 _ => false,
117 },
118 Obj::Cap(a) => match right {
119 Obj::Cap(b) => a.to_string() == b.to_string(),
120 _ => false,
121 },
122 Obj::ListSet(a) => match right {
123 Obj::ListSet(b) => a.to_string() == b.to_string(),
124 _ => false,
125 },
126 Obj::SetBuilder(a) => match right {
127 Obj::SetBuilder(b) => a.to_string() == b.to_string(),
128 _ => false,
129 },
130 Obj::FnSet(a) => match right {
131 Obj::FnSet(b) => a.to_string() == b.to_string(),
132 _ => false,
133 },
134 Obj::AnonymousFn(a) => match right {
135 Obj::AnonymousFn(b) => a.to_string() == b.to_string(),
136 _ => false,
137 },
138 Obj::StandardSet(StandardSet::NPos) => match right {
139 Obj::StandardSet(StandardSet::NPos) => true,
140 _ => false,
141 },
142 Obj::StandardSet(StandardSet::N) => match right {
143 Obj::StandardSet(StandardSet::N) => true,
144 _ => false,
145 },
146 Obj::StandardSet(StandardSet::Q) => match right {
147 Obj::StandardSet(StandardSet::Q) => true,
148 _ => false,
149 },
150 Obj::StandardSet(StandardSet::Z) => match right {
151 Obj::StandardSet(StandardSet::Z) => true,
152 _ => false,
153 },
154 Obj::StandardSet(StandardSet::R) => match right {
155 Obj::StandardSet(StandardSet::R) => true,
156 _ => false,
157 },
158 Obj::Cart(a) => match right {
159 Obj::Cart(b) => a.to_string() == b.to_string(),
160 _ => false,
161 },
162 Obj::CartDim(a) => match right {
163 Obj::CartDim(b) => a.to_string() == b.to_string(),
164 _ => false,
165 },
166 Obj::Proj(a) => match right {
167 Obj::Proj(b) => a.to_string() == b.to_string(),
168 _ => false,
169 },
170 Obj::TupleDim(a) => match right {
171 Obj::TupleDim(b) => a.to_string() == b.to_string(),
172 _ => false,
173 },
174 Obj::Tuple(a) => match right {
175 Obj::Tuple(b) => a.to_string() == b.to_string(),
176 _ => false,
177 },
178 Obj::Count(a) => match right {
179 Obj::Count(b) => a.to_string() == b.to_string(),
180 _ => false,
181 },
182 Obj::Sum(a) => match right {
183 Obj::Sum(b) => a.to_string() == b.to_string(),
184 _ => false,
185 },
186 Obj::Product(a) => match right {
187 Obj::Product(b) => a.to_string() == b.to_string(),
188 _ => false,
189 },
190 Obj::Range(a) => match right {
191 Obj::Range(b) => a.to_string() == b.to_string(),
192 _ => false,
193 },
194 Obj::ClosedRange(a) => match right {
195 Obj::ClosedRange(b) => a.to_string() == b.to_string(),
196 _ => false,
197 },
198 Obj::FnRange(a) => match right {
199 Obj::FnRange(b) => a.to_string() == b.to_string(),
200 _ => false,
201 },
202 Obj::FnDom(a) => match right {
203 Obj::FnDom(b) => a.to_string() == b.to_string(),
204 _ => false,
205 },
206 Obj::FiniteSeqSet(a) => match right {
207 Obj::FiniteSeqSet(b) => a.to_string() == b.to_string(),
208 _ => false,
209 },
210 Obj::SeqSet(a) => match right {
211 Obj::SeqSet(b) => a.to_string() == b.to_string(),
212 _ => false,
213 },
214 Obj::FiniteSeqListObj(a) => match right {
215 Obj::FiniteSeqListObj(b) => a.to_string() == b.to_string(),
216 _ => false,
217 },
218 Obj::MatrixSet(a) => match right {
219 Obj::MatrixSet(b) => a.to_string() == b.to_string(),
220 _ => false,
221 },
222 Obj::MatrixListObj(a) => match right {
223 Obj::MatrixListObj(b) => a.to_string() == b.to_string(),
224 _ => false,
225 },
226 Obj::PowerSet(a) => match right {
227 Obj::PowerSet(b) => a.to_string() == b.to_string(),
228 _ => false,
229 },
230 Obj::Choose(a) => match right {
231 Obj::Choose(b) => a.to_string() == b.to_string(),
232 _ => false,
233 },
234 Obj::ObjAtIndex(a) => match right {
235 Obj::ObjAtIndex(b) => a.to_string() == b.to_string(),
236 _ => false,
237 },
238 Obj::StandardSet(StandardSet::QPos) => match right {
239 Obj::StandardSet(StandardSet::QPos) => true,
240 _ => false,
241 },
242 Obj::StandardSet(StandardSet::RPos) => match right {
243 Obj::StandardSet(StandardSet::RPos) => true,
244 _ => false,
245 },
246 Obj::StandardSet(StandardSet::QNeg) => match right {
247 Obj::StandardSet(StandardSet::QNeg) => true,
248 _ => false,
249 },
250 Obj::StandardSet(StandardSet::ZNeg) => match right {
251 Obj::StandardSet(StandardSet::ZNeg) => true,
252 _ => false,
253 },
254 Obj::StandardSet(StandardSet::RNeg) => match right {
255 Obj::StandardSet(StandardSet::RNeg) => true,
256 _ => false,
257 },
258 Obj::StandardSet(StandardSet::QNz) => match right {
259 Obj::StandardSet(StandardSet::QNz) => true,
260 _ => false,
261 },
262 Obj::StandardSet(StandardSet::ZNz) => match right {
263 Obj::StandardSet(StandardSet::ZNz) => true,
264 _ => false,
265 },
266 Obj::StandardSet(StandardSet::RNz) => match right {
267 Obj::StandardSet(StandardSet::RNz) => true,
268 _ => false,
269 },
270 Obj::FamilyObj(a) => match right {
271 Obj::FamilyObj(b) => a.to_string() == b.to_string(),
272 _ => false,
273 },
274 Obj::StructObj(a) => match right {
275 Obj::StructObj(b) => a.to_string() == b.to_string(),
276 _ => false,
277 },
278 Obj::ObjAsStructInstanceWithFieldAccess(a) => match right {
279 Obj::ObjAsStructInstanceWithFieldAccess(b) => a.to_string() == b.to_string(),
280 _ => false,
281 },
282 Obj::Atom(AtomObj::Forall(a)) => {
284 matches!(right, Obj::Atom(AtomObj::Forall(b)) if a.to_string() == b.to_string())
285 }
286 Obj::Atom(AtomObj::Def(a)) => {
287 matches!(right, Obj::Atom(AtomObj::Def(b)) if a.to_string() == b.to_string())
288 }
289 Obj::Atom(AtomObj::Exist(a)) => {
290 matches!(right, Obj::Atom(AtomObj::Exist(b)) if a.to_string() == b.to_string())
291 }
292 Obj::Atom(AtomObj::SetBuilder(a)) => {
293 matches!(right, Obj::Atom(AtomObj::SetBuilder(b)) if a.to_string() == b.to_string())
294 }
295 Obj::Atom(AtomObj::FnSet(a)) => {
296 matches!(right, Obj::Atom(AtomObj::FnSet(b)) if a.to_string() == b.to_string())
297 }
298 Obj::Atom(AtomObj::Induc(a)) => {
299 matches!(right, Obj::Atom(AtomObj::Induc(b)) if a.to_string() == b.to_string())
300 }
301 Obj::Atom(AtomObj::DefAlgo(a)) => {
302 matches!(right, Obj::Atom(AtomObj::DefAlgo(b)) if a.to_string() == b.to_string())
303 }
304 Obj::Atom(AtomObj::DefStructField(a)) => {
305 matches!(right, Obj::Atom(AtomObj::DefStructField(b)) if a.to_string() == b.to_string())
306 }
307 }
308 }
309}