Line | Branch | Exec | Source |
---|---|---|---|
1 | #include "ast/ops.h" | ||
2 | #include "ast/visitor.h" | ||
3 | #include "logging/logging.h" | ||
4 | |||
5 | namespace lython { | ||
6 | |||
7 | // Equality Visitor | ||
8 | struct Equality { | ||
9 | using Return_t = bool; | ||
10 | |||
11 | template <typename T> | ||
12 | bool exec(T const& a, T const& b, int depth) { | ||
13 | 2000 | return a == b; | |
14 | } | ||
15 | |||
16 | bool exec(MatchCase const& a, MatchCase const& b, int depth) { | ||
17 | kwtrace(depth, "MatchCase"); | ||
18 |
2/4✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
|
18 | return exec(a.pattern, b.pattern, depth) && exec(a.guard, b.guard, depth) && |
19 |
1/2✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
|
18 | exec(a.body, b.body, depth); |
20 | } | ||
21 | |||
22 | bool exec(ExceptHandler const& a, ExceptHandler const& b, int depth) { | ||
23 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
2 | return exec(a.type, b.type, depth) && exec(a.name, b.name, depth) && |
24 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | exec(a.body, b.body, depth); |
25 | } | ||
26 | |||
27 | bool exec(JoinedStr const& a, JoinedStr const& b, int depth) { | ||
28 | return exec(a.values, b.values, depth); | ||
29 | } | ||
30 | |||
31 | bool exec(WithItem const& a, WithItem const& b, int depth) { | ||
32 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
8 | return exec(a.context_expr, b.context_expr, depth) && |
33 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
8 | exec(a.optional_vars, b.optional_vars, depth); |
34 | } | ||
35 | |||
36 | bool exec(Comprehension const& a, Comprehension const& b, int depth) { | ||
37 |
2/4✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
|
8 | return exec(a.target, b.target, depth) && exec(a.iter, b.iter, depth) && |
38 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
8 | exec(a.ifs, b.ifs, depth); |
39 | } | ||
40 | |||
41 | bool exec(Alias const& a, Alias const& b, int depth) { | ||
42 |
2/4✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
|
10 | return a.asname == b.asname && a.name == b.name; |
43 | } | ||
44 | |||
45 | bool exec(Arg const& a, Arg const& b, int depth) { | ||
46 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | return a.arg == b.arg && exec(a.annotation, b.annotation, depth); |
47 | } | ||
48 | |||
49 | bool exec(Keyword const& a, Keyword const& b, int depth) { | ||
50 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | return a.arg == b.arg && exec(a.value, b.value, depth); |
51 | } | ||
52 | |||
53 | bool exec(Arguments const& a, Arguments const& b, int depth) { | ||
54 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
2 | return exec(a.posonlyargs, b.posonlyargs, depth) && exec(a.args, b.args, depth) && |
55 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | exec(a.vararg, b.vararg, depth) && exec(a.kwonlyargs, b.kwonlyargs, depth) && |
56 |
3/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
|
3 | exec(a.kw_defaults, b.kw_defaults, depth) && exec(a.kwarg, b.kwarg, depth) && |
57 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | exec(a.defaults, b.defaults, depth); |
58 | } | ||
59 | |||
60 | template <typename T> | ||
61 | bool exec(Optional<T> const& a, Optional<T> const& b, int depth) { | ||
62 |
1/2✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
|
116 | if (a.has_value() == b.has_value()) { |
63 |
2/2✓ Branch 1 taken 39 times.
✓ Branch 2 taken 19 times.
|
116 | if (a.has_value()) { |
64 | 78 | return exec(a.value(), b.value(), depth); | |
65 | } | ||
66 | 38 | return true; | |
67 | } | ||
68 | |||
69 | ✗ | return false; | |
70 | } | ||
71 | |||
72 | template <typename T> | ||
73 | bool exec(Array<T> const& a, Array<T> const& b, int depth) { | ||
74 |
1/2✗ Branch 2 not taken.
✓ Branch 3 taken 221 times.
|
442 | if (a.size() != b.size()) { |
75 | ✗ | return false; | |
76 | } | ||
77 |
2/2✓ Branch 1 taken 288 times.
✓ Branch 2 taken 220 times.
|
1016 | for (int i = 0; i < a.size(); i++) { |
78 |
2/2✓ Branch 3 taken 1 times.
✓ Branch 4 taken 287 times.
|
576 | if (!exec(a[i], b[i], depth)) { |
79 | 2 | return false; | |
80 | } | ||
81 | } | ||
82 | 440 | return true; | |
83 | } | ||
84 | |||
85 | bool exec(Node* a, Node* b) { | ||
86 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 572 times.
|
573 | if (a->kind != b->kind) { |
87 | 1 | return false; | |
88 | } | ||
89 | // clang-format off | ||
90 |
2/5✗ Branch 1 not taken.
✓ Branch 2 taken 112 times.
✓ Branch 3 taken 460 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
572 | switch (a->family()) { |
91 | ✗ | case NodeFamily::Module: | |
92 | ✗ | return exec(reinterpret_cast<ModNode *>(a), reinterpret_cast<ModNode *>(b), 0); | |
93 | 112 | case NodeFamily::Statement: | |
94 | 112 | return exec(reinterpret_cast<StmtNode *>(a), reinterpret_cast<StmtNode *>(b), 0); | |
95 | 460 | case NodeFamily::Expression: | |
96 | 460 | return exec(reinterpret_cast<ExprNode *>(a), reinterpret_cast<ExprNode *>(b), 0); | |
97 | ✗ | case NodeFamily::Pattern: | |
98 | ✗ | return exec(reinterpret_cast<Pattern *>(a), reinterpret_cast<Pattern *>(b), 0); | |
99 | } | ||
100 | // clang-format on | ||
101 | ✗ | return false; | |
102 | } | ||
103 | |||
104 | bool exec(ModNode* a, ModNode* b, int depth) { | ||
105 | kwtrace(depth, "{}", str(a->kind)); | ||
106 | |||
107 | ✗ | if (a->kind != b->kind) { | |
108 | ✗ | return false; | |
109 | } | ||
110 | // clang-format off | ||
111 | ✗ | switch (a->kind) { | |
112 | #define X(name, _) | ||
113 | #define PASS(_a, _b) | ||
114 | #define SECTION(_) | ||
115 | #define MOD(name, fun)\ | ||
116 | case NodeKind::name: {\ | ||
117 | name* aa = reinterpret_cast<name*>(a);\ | ||
118 | name* bb = reinterpret_cast<name*>(b);\ | ||
119 | return fun(aa, bb, depth + 1);\ | ||
120 | } | ||
121 | |||
122 | ✗ | NODEKIND_ENUM(X, SECTION, PASS, PASS, MOD, PASS) | |
123 | |||
124 | #undef X | ||
125 | #undef PASS | ||
126 | #undef SECTION | ||
127 | #undef MOD | ||
128 | |||
129 | ✗ | default: | |
130 | ✗ | return false; | |
131 | |||
132 | } | ||
133 | // clang-format on | ||
134 | return false; | ||
135 | } | ||
136 | |||
137 | bool exec(Pattern* a, Pattern* b, int depth) { | ||
138 | kwtrace(depth, "{}", str(a->kind)); | ||
139 | |||
140 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
|
20 | if (a->kind != b->kind) { |
141 | ✗ | return false; | |
142 | } | ||
143 | // clang-format off | ||
144 |
8/9✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
|
20 | switch (a->kind) { |
145 | #define X(name, _) | ||
146 | #define PASS(_a, _b) | ||
147 | #define SECTION(_) | ||
148 | #define MATCH(name, fun)\ | ||
149 | case NodeKind::name: {\ | ||
150 | name* aa = reinterpret_cast<name*>(a);\ | ||
151 | name* bb = reinterpret_cast<name*>(b);\ | ||
152 | return fun(aa, bb, depth + 1);\ | ||
153 | } | ||
154 | |||
155 | 20 | NODEKIND_ENUM(X, SECTION, PASS, PASS, PASS, MATCH) | |
156 | |||
157 | #undef X | ||
158 | #undef PASS | ||
159 | #undef SECTION | ||
160 | #undef MATCH | ||
161 | |||
162 | ✗ | default: | |
163 | ✗ | return false; | |
164 | } | ||
165 | // clang-format on | ||
166 | return false; | ||
167 | } | ||
168 | |||
169 | bool exec(ExprNode* a, ExprNode* b, int depth) { | ||
170 |
3/4✓ Branch 0 taken 23 times.
✓ Branch 1 taken 939 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
|
962 | if (a == nullptr && b == nullptr) { |
171 | 23 | return true; | |
172 | } | ||
173 |
2/4✓ Branch 0 taken 939 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 939 times.
|
939 | if (a == nullptr || b == nullptr) { |
174 | ✗ | return false; | |
175 | } | ||
176 | kwtrace(depth, "{}", str(a->kind)); | ||
177 | |||
178 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 939 times.
|
939 | if (a->kind != b->kind) { |
179 | ✗ | return false; | |
180 | } | ||
181 | // clang-format off | ||
182 |
29/36✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 11 taken 1 times.
✓ Branch 12 taken 1 times.
✓ Branch 13 taken 3 times.
✓ Branch 14 taken 1 times.
✓ Branch 15 taken 9 times.
✓ Branch 16 taken 1 times.
✓ Branch 17 taken 3 times.
✓ Branch 18 taken 3 times.
✓ Branch 19 taken 59 times.
✓ Branch 20 taken 3 times.
✓ Branch 21 taken 2 times.
✓ Branch 22 taken 1 times.
✓ Branch 23 taken 483 times.
✓ Branch 24 taken 4 times.
✓ Branch 25 taken 11 times.
✓ Branch 26 taken 2 times.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✓ Branch 30 taken 79 times.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 240 times.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
|
939 | switch (a->kind) { |
183 | #define X(name, _) | ||
184 | #define PASS(_a, _b) | ||
185 | #define SECTION(_) | ||
186 | #define EXPR(name, fun)\ | ||
187 | case NodeKind::name: {\ | ||
188 | name* aa = reinterpret_cast<name*>(a);\ | ||
189 | name* bb = reinterpret_cast<name*>(b);\ | ||
190 | return fun(aa, bb, depth + 1);\ | ||
191 | } | ||
192 | |||
193 | 939 | NODEKIND_ENUM(X, SECTION, EXPR, PASS, PASS, PASS) | |
194 | |||
195 | #undef X | ||
196 | #undef PASS | ||
197 | #undef SECTION | ||
198 | #undef EXPR | ||
199 | |||
200 | ✗ | default: | |
201 | ✗ | return false; | |
202 | } | ||
203 | // clang-format on | ||
204 | return false; | ||
205 | } | ||
206 | |||
207 | bool exec(StmtNode* a, StmtNode* b, int depth) { | ||
208 | kwtrace(depth, "{}", str(a->kind)); | ||
209 | |||
210 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
|
142 | if (a->kind != b->kind) { |
211 | ✗ | return false; | |
212 | } | ||
213 | // clang-format off | ||
214 |
24/26✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 28 times.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 5 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 11 taken 2 times.
✓ Branch 12 taken 2 times.
✓ Branch 13 taken 1 times.
✓ Branch 14 taken 2 times.
✓ Branch 15 taken 2 times.
✓ Branch 16 taken 2 times.
✓ Branch 17 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 19 taken 50 times.
✓ Branch 20 taken 18 times.
✓ Branch 21 taken 1 times.
✓ Branch 22 taken 1 times.
✓ Branch 23 taken 3 times.
✓ Branch 24 taken 1 times.
✗ Branch 25 not taken.
|
142 | switch (a->kind) { |
215 | #define X(name, _) | ||
216 | #define PASS(_a, _b) | ||
217 | #define SECTION(_) | ||
218 | #define STMT(name, fun)\ | ||
219 | case NodeKind::name: {\ | ||
220 | name* aa = reinterpret_cast<name*>(a);\ | ||
221 | name* bb = reinterpret_cast<name*>(b);\ | ||
222 | return this->fun(aa, bb, depth + 1);\ | ||
223 | } | ||
224 | |||
225 | 142 | NODEKIND_ENUM(X, SECTION, PASS, STMT, PASS, PASS) | |
226 | |||
227 | #undef X | ||
228 | #undef PASS | ||
229 | #undef SECTION | ||
230 | #undef STMT | ||
231 | |||
232 | ✗ | default: | |
233 | ✗ | return false; | |
234 | } | ||
235 | // clang-format on | ||
236 | return false; | ||
237 | } | ||
238 | |||
239 | // >>>>>>>>>>>> Types | ||
240 | bool functiontype(FunctionType* a, FunctionType* b, int depth) { | ||
241 | ✗ | if (a->argtypes.size() != b->argtypes.size()) { | |
242 | ✗ | return false; | |
243 | } | ||
244 | |||
245 | ✗ | for (int i = 0; i < a->argtypes.size(); i++) { | |
246 | ✗ | auto a_arg = a->argtypes[i]; | |
247 | ✗ | auto b_arg = b->argtypes[i]; | |
248 | |||
249 | ✗ | if (!exec(a_arg, b_arg, depth)) { | |
250 | ✗ | return false; | |
251 | } | ||
252 | } | ||
253 | |||
254 | ✗ | return exec(a->returns, b->returns, depth); | |
255 | } | ||
256 | |||
257 | bool comment(Comment* a, Comment* b, int depth) { return true; } | ||
258 | |||
259 | bool dicttype(DictType* a, DictType* b, int depth) { | ||
260 | ✗ | return exec(a->key, b->key, depth) && exec(a->value, b->value, depth); | |
261 | } | ||
262 | bool arraytype(ArrayType* a, ArrayType* b, int depth) { | ||
263 | ✗ | return exec(a->value, b->value, depth); | |
264 | } | ||
265 | bool settype(SetType* a, SetType* b, int depth) { return exec(a->value, b->value, depth); } | ||
266 | bool tupletype(TupleType* a, TupleType* b, int depth) { | ||
267 | ✗ | return exec(a->types, b->types, depth); | |
268 | } | ||
269 | |||
270 | bool arrow(Arrow* a, Arrow* b, int depth) { | ||
271 |
3/4✓ Branch 1 taken 78 times.
✓ Branch 2 taken 1 times.
✓ Branch 4 taken 78 times.
✗ Branch 5 not taken.
|
79 | return exec(a->args, b->args, depth) && exec(a->returns, b->returns, depth); |
272 | } | ||
273 | |||
274 | bool builtintype(BuiltinType* a, BuiltinType* b, int depth) { | ||
275 | kwdebug("{} {} {}", a->name, b->name, exec(a->name, b->name, depth)); | ||
276 | 240 | return exec(a->name, b->name, depth); | |
277 | } | ||
278 | bool functiondef(FunctionDef* a, FunctionDef* b, int depth) { | ||
279 | // TODO check full module path | ||
280 | 4 | return exec(a->name, b->name, depth); | |
281 | } | ||
282 | bool classdef(ClassDef* a, ClassDef* b, int depth) { | ||
283 | // TODO check full module path | ||
284 | 3 | return exec(a->name, b->name, depth); | |
285 | } | ||
286 | |||
287 | bool classtype(ClassType* a, ClassType* b, int depth) { return bool(); } | ||
288 | // Types <<<<<<<<<<<<<<<<<<<< | ||
289 | |||
290 | bool module(Module* a, Module* b, int depth) { return exec(a->body, b->body, depth); } | ||
291 | bool interactive(Interactive* a, Interactive* b, int depth) { | ||
292 | ✗ | return exec(a->body, b->body, depth); | |
293 | } | ||
294 | bool expression(Expression* a, Expression* b, int depth) { | ||
295 | ✗ | return exec(a->body, b->body, depth); | |
296 | } | ||
297 | |||
298 | bool pass(Pass* a, Pass* b, int depth) { return true; } | ||
299 | bool breakstmt(Break* a, Break* b, int depth) { return true; } | ||
300 | bool continuestmt(Continue* a, Continue* b, int depth) { return true; } | ||
301 | |||
302 | bool invalidstmt(InvalidStatement* a, InvalidStatement* b, int depth) { return false; } | ||
303 | |||
304 | bool constant(Constant* a, Constant* b, int depth) { return a->value == b->value; } | ||
305 | bool exprstmt(Expr* a, Expr* b, int depth) { return exec(a->value, b->value, depth); } | ||
306 | bool returnstmt(Return* a, Return* b, int depth) { return exec(a->value, b->value, depth); } | ||
307 | bool await(Await* a, Await* b, int depth) { return exec(a->value, b->value, depth); } | ||
308 | bool yield(Yield* a, Yield* b, int depth) { return exec(a->value, b->value, depth); } | ||
309 | bool yieldfrom(YieldFrom* a, YieldFrom* b, int depth) { | ||
310 | 1 | return exec(a->value, b->value, depth); | |
311 | } | ||
312 | |||
313 | bool boolop(BoolOp* a, BoolOp* b, int depth) { | ||
314 |
2/4✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
|
3 | return a->op == b->op && exec(a->values, b->values, depth); |
315 | } | ||
316 | bool namedexpr(NamedExpr* a, NamedExpr* b, int depth) { | ||
317 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | return exec(a->target, b->target, depth) && exec(a->value, b->value, depth); |
318 | } | ||
319 | bool binop(BinOp* a, BinOp* b, int depth) { | ||
320 |
3/6✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 12 times.
✗ Branch 7 not taken.
|
12 | return a->op == b->op && exec(a->left, b->left, depth) && exec(a->right, b->right, depth); |
321 | } | ||
322 | bool unaryop(UnaryOp* a, UnaryOp* b, int depth) { | ||
323 |
2/4✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
|
4 | return a->op == b->op && exec(a->operand, b->operand, depth); |
324 | } | ||
325 | bool lambda(Lambda* a, Lambda* b, int depth) { | ||
326 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | return exec(a->args, b->args, depth) && exec(a->body, b->body, depth); |
327 | } | ||
328 | bool ifexp(IfExp* a, IfExp* b, int depth) { | ||
329 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
2 | return exec(a->test, b->test, depth) && exec(a->body, b->body, depth) && |
330 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | exec(a->orelse, b->orelse, depth); |
331 | } | ||
332 | bool dictexpr(DictExpr* a, DictExpr* b, int depth) { | ||
333 |
2/4✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
|
4 | return exec(a->keys, b->keys, depth) && exec(a->values, b->values, depth); |
334 | } | ||
335 | bool setexpr(SetExpr* a, SetExpr* b, int depth) { return exec(a->elts, b->elts, depth); } | ||
336 | bool listcomp(ListComp* a, ListComp* b, int depth) { | ||
337 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | return exec(a->elt, b->elt, depth) && exec(a->generators, b->generators, depth); |
338 | } | ||
339 | bool generateexpr(GeneratorExp* a, GeneratorExp* b, int depth) { | ||
340 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | return exec(a->elt, b->elt, depth) && exec(a->generators, b->generators, depth); |
341 | } | ||
342 | bool setcomp(SetComp* a, SetComp* b, int depth) { | ||
343 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | return exec(a->elt, b->elt, depth) && exec(a->generators, b->generators, depth); |
344 | } | ||
345 | bool dictcomp(DictComp* a, DictComp* b, int depth) { | ||
346 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
2 | return exec(a->key, b->key, depth) && exec(a->value, b->value, depth) && |
347 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | exec(a->generators, b->generators, depth); |
348 | } | ||
349 | |||
350 | bool compare(Compare* a, Compare* b, int depth) { | ||
351 |
2/4✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
|
18 | return exec(a->left, b->left, depth) && exec(a->ops, b->ops, depth) && |
352 |
1/2✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
|
18 | exec(a->comparators, b->comparators, depth); |
353 | } | ||
354 | bool call(Call* a, Call* b, int depth) { | ||
355 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
2 | return exec(a->func, b->func, depth) && exec(a->args, b->args, depth) && |
356 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | exec(a->keywords, b->keywords, depth); |
357 | } | ||
358 | bool joinedstr(JoinedStr* a, JoinedStr* b, int depth) { | ||
359 | 3 | return exec(a->values, b->values, depth); | |
360 | } | ||
361 | bool formattedvalue(FormattedValue* a, FormattedValue* b, int depth) { | ||
362 | return true // | ||
363 | 3 | && exec(a->value, b->value, depth) // | |
364 |
1/2✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
|
3 | && exec(a->conversion, b->conversion, depth) // |
365 |
2/4✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
|
6 | && exec(a->format_spec->values, b->format_spec->values, depth); // |
366 | } | ||
367 | bool attribute(Attribute* a, Attribute* b, int depth) { | ||
368 |
2/4✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
|
3 | return exec(a->value, b->value, depth) && exec(a->attr, b->attr, depth) /* && |
369 | exec(a->ctx, b->ctx, depth) */ | ||
370 | ; | ||
371 | } | ||
372 | bool subscript(Subscript* a, Subscript* b, int depth) { | ||
373 | |||
374 |
2/4✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
|
2 | return exec(a->value, b->value, depth) && exec(a->slice, b->slice, depth); /*&& |
375 | exec(a->ctx, b->ctx, depth) */ | ||
376 | ; | ||
377 | } | ||
378 | bool starred(Starred* a, Starred* b, int depth) { | ||
379 | 1 | return exec(a->value, b->value, depth) /*&& exec(a->ctx, b->ctx, depth) */; | |
380 | } | ||
381 | bool name(Name* a, Name* b, int depth) { return exec(a->id, b->id, depth); } | ||
382 | bool listexpr(ListExpr* a, ListExpr* b, int depth) { return exec(a->elts, b->elts, depth); } | ||
383 | bool tupleexpr(TupleExpr* a, TupleExpr* b, int depth) { return exec(a->elts, b->elts, depth); } | ||
384 | bool slice(Slice* a, Slice* b, int depth) { | ||
385 |
2/4✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
|
4 | return exec(a->lower, b->lower, depth) && exec(a->upper, b->upper, depth) && |
386 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
4 | exec(a->step, b->step, depth); |
387 | } | ||
388 | bool deletestmt(Delete* a, Delete* b, int depth) { return exec(a->targets, b->targets, depth); } | ||
389 | bool assign(Assign* a, Assign* b, int depth) { | ||
390 |
2/4✓ Branch 1 taken 28 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 28 times.
✗ Branch 5 not taken.
|
28 | return exec(a->targets, b->targets, depth) && exec(a->value, b->value, depth); |
391 | } | ||
392 | bool augassign(AugAssign* a, AugAssign* b, int depth) { | ||
393 |
2/4✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
|
2 | return exec(a->target, b->target, depth) && exec(a->value, b->value, depth); |
394 | } | ||
395 | bool annassign(AnnAssign* a, AnnAssign* b, int depth) { | ||
396 |
2/4✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
|
10 | return exec(a->target, b->target, depth) && exec(a->value, b->value, depth) && |
397 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
10 | exec(a->annotation, b->annotation, depth); |
398 | } | ||
399 | bool forstmt(For* a, For* b, int depth) { | ||
400 |
1/2✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
4 | return exec(a->target, b->target, depth) && exec(a->iter, b->iter, depth) && |
401 |
3/6✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
|
4 | exec(a->body, b->body, depth) && exec(a->orelse, b->orelse, depth); |
402 | } | ||
403 | bool whilestmt(While* a, While* b, int depth) { | ||
404 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
2 | return exec(a->test, b->test, depth) && exec(a->body, b->body, depth) && |
405 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | exec(a->orelse, b->orelse, depth); |
406 | } | ||
407 | bool ifstmt(If* a, If* b, int depth) { | ||
408 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
2 | return exec(a->test, b->test, depth) && exec(a->body, b->body, depth) && |
409 |
3/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
|
3 | exec(a->orelse, b->orelse, depth) && exec(a->tests, b->tests, depth) && |
410 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | exec(a->bodies, b->bodies, depth); |
411 | } | ||
412 | bool with(With* a, With* b, int depth) { | ||
413 |
3/6✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
|
4 | return exec(a->items, b->items, depth) && exec(a->body, b->body, depth) && |
414 | 4 | exec(a->async, b->async, depth); | |
415 | } | ||
416 | bool raise(Raise* a, Raise* b, int depth) { | ||
417 |
2/4✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
|
2 | return exec(a->exc, b->exc, depth) && exec(a->cause, b->cause, depth); |
418 | } | ||
419 | bool trystmt(Try* a, Try* b, int depth) { | ||
420 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
2 | return exec(a->body, b->body, depth) && exec(a->handlers, b->handlers, depth) && |
421 |
3/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
|
2 | exec(a->orelse, b->orelse, depth) && exec(a->finalbody, b->finalbody, depth); |
422 | } | ||
423 | bool assertstmt(Assert* a, Assert* b, int depth) { | ||
424 |
2/4✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
|
2 | return exec(a->test, b->test, depth) && exec(a->msg, b->msg, depth); |
425 | } | ||
426 | bool import(Import* a, Import* b, int depth) { return exec(a->names, b->names, depth); } | ||
427 | bool importfrom(ImportFrom* a, ImportFrom* b, int depth) { | ||
428 |
2/4✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
|
4 | return exec(a->module, b->module, depth) && exec(a->names, b->names, depth) && |
429 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
4 | exec(a->level, b->level, depth); |
430 | } | ||
431 | |||
432 | bool global(Global* a, Global* b, int depth) { return exec(a->names, b->names, depth); } | ||
433 | bool nonlocal(Nonlocal* a, Nonlocal* b, int depth) { return exec(a->names, b->names, depth); } | ||
434 | bool inlinestmt(Inline* a, Inline* b, int depth) { return exec(a->body, b->body, depth); } | ||
435 | |||
436 | // Patterns | ||
437 | bool match(Match* a, Match* b, int depth) { | ||
438 |
2/4✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
|
3 | return exec(a->subject, b->subject, depth) && exec(a->cases, b->cases, depth); |
439 | } | ||
440 | bool matchvalue(MatchValue* a, MatchValue* b, int depth) { | ||
441 | 9 | return exec(a->value, b->value, depth); | |
442 | } | ||
443 | bool matchsingleton(MatchSingleton* a, MatchSingleton* b, int depth) { | ||
444 | 2 | return exec(a->value, b->value, depth); | |
445 | } | ||
446 | bool matchsequence(MatchSequence* a, MatchSequence* b, int depth) { | ||
447 | 3 | return exec(a->patterns, b->patterns, depth); | |
448 | } | ||
449 | bool matchmapping(MatchMapping* a, MatchMapping* b, int depth) { | ||
450 |
1/2✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
|
2 | if (a->patterns.size() != b->patterns.size()) { |
451 | ✗ | return false; | |
452 | } | ||
453 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 2 taken 2 times.
|
3 | for (int i = 0; i < a->patterns.size(); i++) { |
454 |
1/2✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
|
1 | if (!exec(a->patterns[i], b->patterns[i], depth)) { |
455 | ✗ | return false; | |
456 | } | ||
457 |
1/2✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
|
1 | if (!exec(a->keys[i], b->keys[i], depth)) { |
458 | ✗ | return false; | |
459 | } | ||
460 | } | ||
461 | 2 | return exec(a->rest, b->rest, depth); | |
462 | } | ||
463 | bool matchclass(MatchClass* a, MatchClass* b, int depth) { | ||
464 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | if (!exec(a->cls, b->cls, depth)) { |
465 | ✗ | return false; | |
466 | } | ||
467 | // patterns | ||
468 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | if (!exec(a->patterns, b->patterns, depth)) { |
469 | ✗ | return false; | |
470 | } | ||
471 | |||
472 | // kwd_attrs | ||
473 |
1/2✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | if (a->kwd_attrs.size() != b->kwd_attrs.size()) { |
474 | ✗ | return false; | |
475 | } | ||
476 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
|
2 | for (int i = 0; i < a->kwd_attrs.size(); i++) { |
477 |
1/2✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
|
1 | if (!exec(a->kwd_attrs[i], b->kwd_attrs[i], depth)) { |
478 | ✗ | return false; | |
479 | } | ||
480 |
1/2✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
|
1 | if (!exec(a->kwd_patterns[i], b->kwd_patterns[i], depth)) { |
481 | ✗ | return false; | |
482 | } | ||
483 | } | ||
484 | |||
485 | 1 | return true; | |
486 | } | ||
487 | bool matchstar(MatchStar* a, MatchStar* b, int depth) { return exec(a->name, b->name, depth); } | ||
488 | bool matchas(MatchAs* a, MatchAs* b, int depth) { | ||
489 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | return exec(a->pattern, b->pattern, depth) && exec(a->name, b->name, depth); |
490 | } | ||
491 | bool matchor(MatchOr* a, MatchOr* b, int depth) { | ||
492 | 1 | return exec(a->patterns, b->patterns, depth); | |
493 | } | ||
494 | }; | ||
495 | |||
496 | bool equal(Node* a, Node* b) { | ||
497 | ✗ | int n = (a == nullptr) + (b == nullptr); | |
498 | ✗ | if (n > 0) { | |
499 | ✗ | return n == 2; | |
500 | } | ||
501 | Equality eq; | ||
502 | ✗ | return eq.exec(a, b); | |
503 | } | ||
504 | |||
505 | bool equal(ExprNode* a, ExprNode* b) { | ||
506 | 497 | int n = (a == nullptr) + (b == nullptr); | |
507 |
2/2✓ Branch 0 taken 37 times.
✓ Branch 1 taken 460 times.
|
497 | if (n > 0) { |
508 | 37 | return n == 2; | |
509 | } | ||
510 | Equality eq; | ||
511 |
1/1✓ Branch 1 taken 460 times.
|
460 | return eq.exec(a, b); |
512 | } | ||
513 | |||
514 | bool equal(Pattern* a, Pattern* b) { | ||
515 | ✗ | int n = (a == nullptr) + (b == nullptr); | |
516 | ✗ | if (n > 0) { | |
517 | ✗ | return n == 2; | |
518 | } | ||
519 | Equality eq; | ||
520 | ✗ | return eq.exec(a, b); | |
521 | } | ||
522 | |||
523 | bool equal(StmtNode* a, StmtNode* b) { | ||
524 | 113 | int n = (a == nullptr) + (b == nullptr); | |
525 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
|
113 | if (n > 0) { |
526 | ✗ | return n == 2; | |
527 | } | ||
528 | Equality eq; | ||
529 |
1/1✓ Branch 1 taken 113 times.
|
113 | return eq.exec(a, b); |
530 | } | ||
531 | |||
532 | bool equal(ModNode* a, ModNode* b) { | ||
533 | ✗ | int n = (a == nullptr) + (b == nullptr); | |
534 | ✗ | if (n > 0) { | |
535 | ✗ | return n == 2; | |
536 | } | ||
537 | Equality eq; | ||
538 | ✗ | return eq.exec(a, b); | |
539 | } | ||
540 | |||
541 | } // namespace lython | ||
542 |