GCC Code Coverage Report


Directory: ../
File: src/ast/ASTNodes.h
Date: 2025-03-05 01:50:32
Exec Total Coverage
Lines: 358 387 92.5%
Functions: 314 341 92.1%
Branches: 447 728 61.4%

Line Branch Exec Source
1 // Copyright (c) 2021-2025 ChilliBits. All rights reserved.
2
3 #pragma once
4
5 #include <queue>
6 #include <utility>
7 #include <vector>
8
9 #include <ast/ASTVisitor.h>
10 #include <ast/ParallelizableASTVisitor.h>
11 #include <exception/CompilerError.h>
12 #include <model/Function.h>
13 #include <model/Struct.h>
14 #include <symboltablebuilder/Scope.h>
15 #include <symboltablebuilder/TypeQualifiers.h>
16 #include <typechecker/ExprResult.h>
17 #include <util/CodeLoc.h>
18 #include <util/CommonUtil.h>
19
20 namespace spice::compiler {
21
22 // Forward declarations
23 class TopLevelDefNode;
24
25 // Macros
26 #define GET_CHILDREN(...) \
27 std::vector<ASTNode *> getChildren() const override { return collectChildren(__VA_ARGS__); }
28
29 // Operator overload function names
30 constexpr const char *const OP_FCT_PREFIX = "op.";
31 constexpr const char *const OP_FCT_PLUS = "op.plus";
32 constexpr const char *const OP_FCT_MINUS = "op.minus";
33 constexpr const char *const OP_FCT_MUL = "op.mul";
34 constexpr const char *const OP_FCT_DIV = "op.div";
35 constexpr const char *const OP_FCT_EQUAL = "op.equal";
36 constexpr const char *const OP_FCT_NOT_EQUAL = "op.notequal";
37 constexpr const char *const OP_FCT_SHL = "op.shl";
38 constexpr const char *const OP_FCT_SHR = "op.shr";
39 constexpr const char *const OP_FCT_PLUS_EQUAL = "op.plusequal";
40 constexpr const char *const OP_FCT_MINUS_EQUAL = "op.minusequal";
41 constexpr const char *const OP_FCT_MUL_EQUAL = "op.mulequal";
42 constexpr const char *const OP_FCT_DIV_EQUAL = "op.divequal";
43 constexpr const char *const OP_FCT_POSTFIX_PLUS_PLUS = "op.plusplus.post";
44 constexpr const char *const OP_FCT_POSTFIX_MINUS_MINUS = "op.minusminus.post";
45 constexpr const char *const OP_FCT_SUBSCRIPT = "op.subscript";
46
47 /**
48 * Saves a constant value for an AST node to realize features like array-out-of-bounds checks
49 */
50 union CompileTimeValue {
51 double_t doubleValue;
52 int32_t intValue;
53 int16_t shortValue;
54 int64_t longValue;
55 int8_t charValue;
56 bool boolValue;
57 size_t stringValueOffset = 0; // Offset into vector of strings in GlobalResourceManager
58 };
59
60 // Make sure we have no unexpected increases in memory consumption
61 static_assert(sizeof(CompileTimeValue) == 8);
62
63 // =========================================================== AstNode ===========================================================
64
65 class ASTNode {
66 public:
67 // Constructors
68 1506123 explicit ASTNode(const CodeLoc &codeLoc) : codeLoc(codeLoc) {}
69 1506123 virtual ~ASTNode() = default;
70 ASTNode(const ASTNode &) = delete;
71
72 // Virtual methods
73 virtual std::any accept(AbstractASTVisitor *visitor) = 0;
74 virtual std::any accept(ParallelizableASTVisitor *visitor) const = 0;
75
76 7366334 template <typename... Args> [[nodiscard]] ALWAYS_INLINE std::vector<ASTNode *> collectChildren(Args &&...args) const {
77 7366334 std::vector<ASTNode *> children;
78
79 // Lambda to handle each argument
80 9671757 [[maybe_unused]] const auto addChild = [&children]<typename T>(T &&arg) ALWAYS_INLINE {
81 using TDecayed = std::decay_t<T>;
82 if constexpr (std::is_pointer_v<TDecayed>) {
83
209/260
✓ Branch 0 (3→4) taken 51 times.
✓ Branch 1 (3→6) taken 171 times.
✓ Branch 2 (9→10) taken 123 times.
✓ Branch 3 (9→12) taken 99 times.
✓ Branch 4 (3→4) taken 7666 times.
✓ Branch 5 (3→6) taken 51226 times.
✓ Branch 6 (3→4) taken 58892 times.
✓ Branch 7 (3→6) taken 93431 times.
✓ Branch 8 (9→10) taken 222 times.
✓ Branch 9 (9→12) taken 152101 times.
✓ Branch 10 (3→4) taken 65395 times.
✓ Branch 11 (3→6) taken 86937 times.
✓ Branch 12 (9→10) taken 152332 times.
✗ Branch 13 (9→12) not taken.
✓ Branch 14 (3→4) taken 2 times.
✗ Branch 15 (3→6) not taken.
✓ Branch 16 (9→10) taken 2 times.
✗ Branch 17 (9→12) not taken.
✓ Branch 18 (3→4) taken 14 times.
✓ Branch 19 (3→6) taken 43 times.
✓ Branch 20 (9→10) taken 57 times.
✗ Branch 21 (9→12) not taken.
✓ Branch 22 (15→16) taken 34 times.
✓ Branch 23 (15→18) taken 23 times.
✓ Branch 24 (3→4) taken 24 times.
✗ Branch 25 (3→6) not taken.
✓ Branch 26 (9→10) taken 16 times.
✓ Branch 27 (9→12) taken 8 times.
✓ Branch 28 (15→16) taken 24 times.
✗ Branch 29 (15→18) not taken.
✗ Branch 30 (21→22) not taken.
✓ Branch 31 (21→24) taken 24 times.
✓ Branch 32 (3→4) taken 71 times.
✓ Branch 33 (3→6) taken 865 times.
✓ Branch 34 (9→10) taken 884 times.
✓ Branch 35 (9→12) taken 52 times.
✓ Branch 36 (3→4) taken 217 times.
✓ Branch 37 (3→6) taken 3 times.
✓ Branch 38 (3→4) taken 2201 times.
✓ Branch 39 (3→6) taken 70203 times.
✓ Branch 40 (9→10) taken 56179 times.
✓ Branch 41 (9→12) taken 16225 times.
✓ Branch 42 (3→4) taken 83869 times.
✓ Branch 43 (3→6) taken 5831 times.
✓ Branch 44 (9→10) taken 220 times.
✓ Branch 45 (9→12) taken 89480 times.
✓ Branch 46 (15→16) taken 937 times.
✓ Branch 47 (15→18) taken 88763 times.
✓ Branch 48 (21→22) taken 36 times.
✓ Branch 49 (21→24) taken 89664 times.
✓ Branch 50 (27→28) taken 94 times.
✓ Branch 51 (27→30) taken 89606 times.
✓ Branch 52 (33→34) taken 3 times.
✓ Branch 53 (33→36) taken 89697 times.
✓ Branch 54 (39→40) taken 4541 times.
✓ Branch 55 (39→42) taken 85159 times.
✓ Branch 56 (3→4) taken 71351 times.
✓ Branch 57 (3→6) taken 354722 times.
✓ Branch 58 (9→10) taken 91990 times.
✓ Branch 59 (9→12) taken 334083 times.
✓ Branch 60 (15→16) taken 3572 times.
✓ Branch 61 (15→18) taken 422501 times.
✓ Branch 62 (21→22) taken 9642 times.
✓ Branch 63 (21→24) taken 416431 times.
✓ Branch 64 (3→4) taken 448869 times.
✓ Branch 65 (3→6) taken 115954 times.
✓ Branch 66 (9→10) taken 115954 times.
✓ Branch 67 (9→12) taken 448869 times.
✓ Branch 68 (15→16) taken 20724 times.
✓ Branch 69 (15→18) taken 544099 times.
✓ Branch 70 (3→4) taken 5331 times.
✓ Branch 71 (3→6) taken 437628 times.
✓ Branch 72 (9→10) taken 437628 times.
✓ Branch 73 (9→12) taken 5331 times.
✓ Branch 74 (3→4) taken 402080 times.
✓ Branch 75 (3→6) taken 10108 times.
✓ Branch 76 (9→10) taken 10108 times.
✓ Branch 77 (9→12) taken 402080 times.
✓ Branch 78 (15→16) taken 10108 times.
✓ Branch 79 (15→18) taken 402080 times.
✓ Branch 80 (3→4) taken 308848 times.
✗ Branch 81 (3→6) not taken.
✓ Branch 82 (9→10) taken 1738 times.
✓ Branch 83 (9→12) taken 307110 times.
✓ Branch 84 (15→16) taken 1744 times.
✓ Branch 85 (15→18) taken 307104 times.
✓ Branch 86 (3→4) taken 33418 times.
✓ Branch 87 (3→6) taken 310158 times.
✓ Branch 88 (9→10) taken 33418 times.
✓ Branch 89 (9→12) taken 310158 times.
✓ Branch 90 (15→16) taken 310158 times.
✓ Branch 91 (15→18) taken 33418 times.
✓ Branch 92 (3→4) taken 3962 times.
✗ Branch 93 (3→6) not taken.
✓ Branch 94 (3→4) taken 622 times.
✗ Branch 95 (3→6) not taken.
✓ Branch 96 (3→4) taken 44 times.
✗ Branch 97 (3→6) not taken.
✓ Branch 98 (9→10) taken 44 times.
✗ Branch 99 (9→12) not taken.
✓ Branch 100 (3→4) taken 917 times.
✗ Branch 101 (3→6) not taken.
✓ Branch 102 (9→10) taken 917 times.
✗ Branch 103 (9→12) not taken.
✓ Branch 104 (3→4) taken 3244 times.
✓ Branch 105 (3→6) taken 6398 times.
✓ Branch 106 (9→10) taken 935 times.
✓ Branch 107 (9→12) taken 8707 times.
✓ Branch 108 (15→16) taken 44 times.
✓ Branch 109 (15→18) taken 9598 times.
✓ Branch 110 (21→22) taken 658 times.
✓ Branch 111 (21→24) taken 8984 times.
✓ Branch 112 (27→28) taken 4757 times.
✓ Branch 113 (27→30) taken 4885 times.
✓ Branch 114 (33→34) taken 4 times.
✓ Branch 115 (33→36) taken 9638 times.
✓ Branch 116 (3→4) taken 2129 times.
✗ Branch 117 (3→6) not taken.
✓ Branch 118 (3→4) taken 39530 times.
✓ Branch 119 (3→6) taken 1018 times.
✓ Branch 120 (3→4) taken 36 times.
✓ Branch 121 (3→6) taken 200 times.
✓ Branch 122 (3→4) taken 3389 times.
✓ Branch 123 (3→6) taken 1360 times.
✓ Branch 124 (3→4) taken 34 times.
✗ Branch 125 (3→6) not taken.
✓ Branch 126 (3→4) taken 2061 times.
✗ Branch 127 (3→6) not taken.
✓ Branch 128 (3→4) taken 1674 times.
✗ Branch 129 (3→6) not taken.
✓ Branch 130 (3→4) taken 91170 times.
✗ Branch 131 (3→6) not taken.
✓ Branch 132 (3→4) taken 76373 times.
✗ Branch 133 (3→6) not taken.
✓ Branch 134 (9→10) taken 31772 times.
✓ Branch 135 (9→12) taken 44601 times.
✓ Branch 136 (3→4) taken 24 times.
✓ Branch 137 (3→6) taken 346 times.
✓ Branch 138 (9→10) taken 291 times.
✓ Branch 139 (9→12) taken 79 times.
✓ Branch 140 (15→16) taken 190 times.
✓ Branch 141 (15→18) taken 180 times.
✓ Branch 142 (21→22) taken 11 times.
✓ Branch 143 (21→24) taken 359 times.
✓ Branch 144 (3→4) taken 4708 times.
✗ Branch 145 (3→6) not taken.
✓ Branch 146 (9→10) taken 695 times.
✓ Branch 147 (9→12) taken 4013 times.
✓ Branch 148 (3→4) taken 81 times.
✗ Branch 149 (3→6) not taken.
✓ Branch 150 (3→4) taken 18 times.
✗ Branch 151 (3→6) not taken.
✓ Branch 152 (12→13) taken 168 times.
✗ Branch 153 (12→15) not taken.
✓ Branch 154 (3→4) taken 57 times.
✗ Branch 155 (3→6) not taken.
✓ Branch 156 (18→19) taken 30 times.
✓ Branch 157 (18→21) taken 27 times.
✓ Branch 158 (3→4) taken 209 times.
✓ Branch 159 (3→6) taken 514 times.
✓ Branch 160 (9→10) taken 514 times.
✓ Branch 161 (9→12) taken 209 times.
✓ Branch 162 (3→4) taken 15845 times.
✗ Branch 163 (3→6) not taken.
✓ Branch 164 (9→10) taken 15845 times.
✗ Branch 165 (9→12) not taken.
✓ Branch 166 (15→16) taken 723 times.
✓ Branch 167 (15→18) taken 15122 times.
✓ Branch 168 (3→4) taken 24 times.
✗ Branch 169 (3→6) not taken.
✓ Branch 170 (9→10) taken 24 times.
✗ Branch 171 (9→12) not taken.
✓ Branch 172 (3→4) taken 3093 times.
✗ Branch 173 (3→6) not taken.
✓ Branch 174 (9→10) taken 3093 times.
✗ Branch 175 (9→12) not taken.
✓ Branch 176 (3→4) taken 18 times.
✓ Branch 177 (3→6) taken 394 times.
✓ Branch 178 (9→10) taken 412 times.
✗ Branch 179 (9→12) not taken.
✓ Branch 180 (15→16) taken 412 times.
✗ Branch 181 (15→18) not taken.
✓ Branch 182 (21→22) taken 412 times.
✗ Branch 183 (21→24) not taken.
✓ Branch 184 (3→4) taken 5641 times.
✗ Branch 185 (3→6) not taken.
✓ Branch 186 (9→10) taken 5641 times.
✗ Branch 187 (9→12) not taken.
✓ Branch 188 (15→16) taken 5641 times.
✗ Branch 189 (15→18) not taken.
✓ Branch 190 (21→22) taken 5641 times.
✗ Branch 191 (21→24) not taken.
✓ Branch 192 (3→4) taken 12938 times.
✗ Branch 193 (3→6) not taken.
✓ Branch 194 (3→4) taken 1 times.
✓ Branch 195 (3→6) taken 1726 times.
✓ Branch 196 (9→10) taken 1121 times.
✓ Branch 197 (9→12) taken 606 times.
✓ Branch 198 (15→16) taken 1649 times.
✓ Branch 199 (15→18) taken 78 times.
✓ Branch 200 (3→4) taken 2269 times.
✗ Branch 201 (3→6) not taken.
✓ Branch 202 (9→10) taken 2267 times.
✓ Branch 203 (9→12) taken 2 times.
✓ Branch 204 (3→4) taken 16 times.
✓ Branch 205 (3→6) taken 83 times.
✓ Branch 206 (9→10) taken 99 times.
✗ Branch 207 (9→12) not taken.
✓ Branch 208 (3→4) taken 1583 times.
✗ Branch 209 (3→6) not taken.
✓ Branch 210 (3→4) taken 104 times.
✓ Branch 211 (3→6) taken 16 times.
✓ Branch 212 (9→10) taken 120 times.
✗ Branch 213 (9→12) not taken.
✓ Branch 214 (3→4) taken 118 times.
✓ Branch 215 (3→6) taken 35 times.
✓ Branch 216 (9→10) taken 138 times.
✓ Branch 217 (9→12) taken 15 times.
✓ Branch 218 (15→16) taken 121 times.
✓ Branch 219 (15→18) taken 32 times.
✓ Branch 220 (3→4) taken 209 times.
✓ Branch 221 (3→6) taken 2472 times.
✓ Branch 222 (9→10) taken 2183 times.
✓ Branch 223 (9→12) taken 498 times.
✓ Branch 224 (15→16) taken 930 times.
✓ Branch 225 (15→18) taken 1751 times.
✓ Branch 226 (21→22) taken 501 times.
✓ Branch 227 (21→24) taken 2180 times.
✗ Branch 228 (3→4) not taken.
✓ Branch 229 (3→6) taken 13890 times.
✓ Branch 230 (9→10) taken 12267 times.
✓ Branch 231 (9→12) taken 1623 times.
✓ Branch 232 (15→16) taken 13890 times.
✗ Branch 233 (15→18) not taken.
✓ Branch 234 (21→22) taken 4136 times.
✓ Branch 235 (21→24) taken 9754 times.
✓ Branch 236 (27→28) taken 10425 times.
✓ Branch 237 (27→30) taken 3465 times.
✓ Branch 238 (33→34) taken 13890 times.
✗ Branch 239 (33→36) not taken.
✓ Branch 240 (3→4) taken 1320 times.
✓ Branch 241 (3→6) taken 24065 times.
✓ Branch 242 (9→10) taken 24931 times.
✓ Branch 243 (9→12) taken 454 times.
✓ Branch 244 (15→16) taken 25385 times.
✗ Branch 245 (15→18) not taken.
✓ Branch 246 (21→22) taken 25385 times.
✗ Branch 247 (21→24) not taken.
✓ Branch 248 (27→28) taken 3336 times.
✓ Branch 249 (27→30) taken 22049 times.
✓ Branch 250 (33→34) taken 19375 times.
✓ Branch 251 (33→36) taken 6010 times.
✓ Branch 252 (39→40) taken 25385 times.
✗ Branch 253 (39→42) not taken.
✗ Branch 254 (3→4) not taken.
✓ Branch 255 (3→6) taken 740 times.
✓ Branch 256 (9→10) taken 8 times.
✓ Branch 257 (9→12) taken 732 times.
✓ Branch 258 (15→16) taken 740 times.
✗ Branch 259 (15→18) not taken.
9671757 if (arg != nullptr)
84
127/260
✓ Branch 0 (4→5) taken 51 times.
✗ Branch 1 (4→7) not taken.
✓ Branch 2 (10→11) taken 123 times.
✗ Branch 3 (10→13) not taken.
✓ Branch 4 (4→5) taken 7666 times.
✗ Branch 5 (4→7) not taken.
✓ Branch 6 (4→5) taken 58892 times.
✗ Branch 7 (4→7) not taken.
✓ Branch 8 (10→11) taken 222 times.
✗ Branch 9 (10→13) not taken.
✓ Branch 10 (4→5) taken 65395 times.
✗ Branch 11 (4→7) not taken.
✓ Branch 12 (10→11) taken 152332 times.
✗ Branch 13 (10→13) not taken.
✓ Branch 14 (4→5) taken 2 times.
✗ Branch 15 (4→7) not taken.
✓ Branch 16 (10→11) taken 2 times.
✗ Branch 17 (10→13) not taken.
✓ Branch 18 (4→5) taken 14 times.
✗ Branch 19 (4→7) not taken.
✓ Branch 20 (10→11) taken 57 times.
✗ Branch 21 (10→13) not taken.
✓ Branch 22 (16→17) taken 34 times.
✗ Branch 23 (16→19) not taken.
✓ Branch 24 (4→5) taken 24 times.
✗ Branch 25 (4→7) not taken.
✓ Branch 26 (10→11) taken 16 times.
✗ Branch 27 (10→13) not taken.
✓ Branch 28 (16→17) taken 24 times.
✗ Branch 29 (16→19) not taken.
✗ Branch 30 (22→23) not taken.
✗ Branch 31 (22→25) not taken.
✓ Branch 32 (4→5) taken 71 times.
✗ Branch 33 (4→7) not taken.
✓ Branch 34 (10→11) taken 884 times.
✗ Branch 35 (10→13) not taken.
✓ Branch 36 (4→5) taken 217 times.
✗ Branch 37 (4→7) not taken.
✓ Branch 38 (4→5) taken 2201 times.
✗ Branch 39 (4→7) not taken.
✓ Branch 40 (10→11) taken 56179 times.
✗ Branch 41 (10→13) not taken.
✓ Branch 42 (4→5) taken 83869 times.
✗ Branch 43 (4→7) not taken.
✓ Branch 44 (10→11) taken 220 times.
✗ Branch 45 (10→13) not taken.
✓ Branch 46 (16→17) taken 937 times.
✗ Branch 47 (16→19) not taken.
✓ Branch 48 (22→23) taken 36 times.
✗ Branch 49 (22→25) not taken.
✓ Branch 50 (28→29) taken 94 times.
✗ Branch 51 (28→31) not taken.
✓ Branch 52 (34→35) taken 3 times.
✗ Branch 53 (34→37) not taken.
✓ Branch 54 (40→41) taken 4541 times.
✗ Branch 55 (40→43) not taken.
✓ Branch 56 (4→5) taken 71351 times.
✗ Branch 57 (4→7) not taken.
✓ Branch 58 (10→11) taken 91990 times.
✗ Branch 59 (10→13) not taken.
✓ Branch 60 (16→17) taken 3572 times.
✗ Branch 61 (16→19) not taken.
✓ Branch 62 (22→23) taken 9642 times.
✗ Branch 63 (22→25) not taken.
✓ Branch 64 (4→5) taken 448869 times.
✗ Branch 65 (4→7) not taken.
✓ Branch 66 (10→11) taken 115954 times.
✗ Branch 67 (10→13) not taken.
✓ Branch 68 (16→17) taken 20724 times.
✗ Branch 69 (16→19) not taken.
✓ Branch 70 (4→5) taken 5331 times.
✗ Branch 71 (4→7) not taken.
✓ Branch 72 (10→11) taken 437628 times.
✗ Branch 73 (10→13) not taken.
✓ Branch 74 (4→5) taken 402080 times.
✗ Branch 75 (4→7) not taken.
✓ Branch 76 (10→11) taken 10108 times.
✗ Branch 77 (10→13) not taken.
✓ Branch 78 (16→17) taken 10108 times.
✗ Branch 79 (16→19) not taken.
✓ Branch 80 (4→5) taken 308848 times.
✗ Branch 81 (4→7) not taken.
✓ Branch 82 (10→11) taken 1738 times.
✗ Branch 83 (10→13) not taken.
✓ Branch 84 (16→17) taken 1744 times.
✗ Branch 85 (16→19) not taken.
✓ Branch 86 (4→5) taken 33418 times.
✗ Branch 87 (4→7) not taken.
✓ Branch 88 (10→11) taken 33418 times.
✗ Branch 89 (10→13) not taken.
✓ Branch 90 (16→17) taken 310158 times.
✗ Branch 91 (16→19) not taken.
✓ Branch 92 (4→5) taken 3962 times.
✗ Branch 93 (4→7) not taken.
✓ Branch 94 (4→5) taken 622 times.
✗ Branch 95 (4→7) not taken.
✓ Branch 96 (4→5) taken 44 times.
✗ Branch 97 (4→7) not taken.
✓ Branch 98 (10→11) taken 44 times.
✗ Branch 99 (10→13) not taken.
✓ Branch 100 (4→5) taken 917 times.
✗ Branch 101 (4→7) not taken.
✓ Branch 102 (10→11) taken 917 times.
✗ Branch 103 (10→13) not taken.
✓ Branch 104 (4→5) taken 3244 times.
✗ Branch 105 (4→7) not taken.
✓ Branch 106 (10→11) taken 935 times.
✗ Branch 107 (10→13) not taken.
✓ Branch 108 (16→17) taken 44 times.
✗ Branch 109 (16→19) not taken.
✓ Branch 110 (22→23) taken 658 times.
✗ Branch 111 (22→25) not taken.
✓ Branch 112 (28→29) taken 4757 times.
✗ Branch 113 (28→31) not taken.
✓ Branch 114 (34→35) taken 4 times.
✗ Branch 115 (34→37) not taken.
✓ Branch 116 (4→5) taken 2129 times.
✗ Branch 117 (4→7) not taken.
✓ Branch 118 (4→5) taken 39530 times.
✗ Branch 119 (4→7) not taken.
✓ Branch 120 (4→5) taken 36 times.
✗ Branch 121 (4→7) not taken.
✓ Branch 122 (4→5) taken 3389 times.
✗ Branch 123 (4→7) not taken.
✓ Branch 124 (4→5) taken 34 times.
✗ Branch 125 (4→7) not taken.
✓ Branch 126 (4→5) taken 2061 times.
✗ Branch 127 (4→7) not taken.
✓ Branch 128 (4→5) taken 1674 times.
✗ Branch 129 (4→7) not taken.
✓ Branch 130 (4→5) taken 91170 times.
✗ Branch 131 (4→7) not taken.
✓ Branch 132 (4→5) taken 76373 times.
✗ Branch 133 (4→7) not taken.
✓ Branch 134 (10→11) taken 31772 times.
✗ Branch 135 (10→13) not taken.
✓ Branch 136 (4→5) taken 24 times.
✗ Branch 137 (4→7) not taken.
✓ Branch 138 (10→11) taken 291 times.
✗ Branch 139 (10→13) not taken.
✓ Branch 140 (16→17) taken 190 times.
✗ Branch 141 (16→19) not taken.
✓ Branch 142 (22→23) taken 11 times.
✗ Branch 143 (22→25) not taken.
✓ Branch 144 (4→5) taken 4708 times.
✗ Branch 145 (4→7) not taken.
✓ Branch 146 (10→11) taken 695 times.
✗ Branch 147 (10→13) not taken.
✓ Branch 148 (4→5) taken 81 times.
✗ Branch 149 (4→7) not taken.
✓ Branch 150 (4→5) taken 18 times.
✗ Branch 151 (4→7) not taken.
✓ Branch 152 (13→14) taken 168 times.
✗ Branch 153 (13→16) not taken.
✓ Branch 154 (4→5) taken 57 times.
✗ Branch 155 (4→7) not taken.
✓ Branch 156 (19→20) taken 30 times.
✗ Branch 157 (19→22) not taken.
✓ Branch 158 (4→5) taken 209 times.
✗ Branch 159 (4→7) not taken.
✓ Branch 160 (10→11) taken 514 times.
✗ Branch 161 (10→13) not taken.
✓ Branch 162 (4→5) taken 15845 times.
✗ Branch 163 (4→7) not taken.
✓ Branch 164 (10→11) taken 15845 times.
✗ Branch 165 (10→13) not taken.
✓ Branch 166 (16→17) taken 723 times.
✗ Branch 167 (16→19) not taken.
✓ Branch 168 (4→5) taken 24 times.
✗ Branch 169 (4→7) not taken.
✓ Branch 170 (10→11) taken 24 times.
✗ Branch 171 (10→13) not taken.
✓ Branch 172 (4→5) taken 3093 times.
✗ Branch 173 (4→7) not taken.
✓ Branch 174 (10→11) taken 3093 times.
✗ Branch 175 (10→13) not taken.
✓ Branch 176 (4→5) taken 18 times.
✗ Branch 177 (4→7) not taken.
✓ Branch 178 (10→11) taken 412 times.
✗ Branch 179 (10→13) not taken.
✓ Branch 180 (16→17) taken 412 times.
✗ Branch 181 (16→19) not taken.
✓ Branch 182 (22→23) taken 412 times.
✗ Branch 183 (22→25) not taken.
✓ Branch 184 (4→5) taken 5641 times.
✗ Branch 185 (4→7) not taken.
✓ Branch 186 (10→11) taken 5641 times.
✗ Branch 187 (10→13) not taken.
✓ Branch 188 (16→17) taken 5641 times.
✗ Branch 189 (16→19) not taken.
✓ Branch 190 (22→23) taken 5641 times.
✗ Branch 191 (22→25) not taken.
✓ Branch 192 (4→5) taken 12938 times.
✗ Branch 193 (4→7) not taken.
✓ Branch 194 (4→5) taken 1 times.
✗ Branch 195 (4→7) not taken.
✓ Branch 196 (10→11) taken 1121 times.
✗ Branch 197 (10→13) not taken.
✓ Branch 198 (16→17) taken 1649 times.
✗ Branch 199 (16→19) not taken.
✓ Branch 200 (4→5) taken 2269 times.
✗ Branch 201 (4→7) not taken.
✓ Branch 202 (10→11) taken 2267 times.
✗ Branch 203 (10→13) not taken.
✓ Branch 204 (4→5) taken 16 times.
✗ Branch 205 (4→7) not taken.
✓ Branch 206 (10→11) taken 99 times.
✗ Branch 207 (10→13) not taken.
✓ Branch 208 (4→5) taken 1583 times.
✗ Branch 209 (4→7) not taken.
✓ Branch 210 (4→5) taken 104 times.
✗ Branch 211 (4→7) not taken.
✓ Branch 212 (10→11) taken 120 times.
✗ Branch 213 (10→13) not taken.
✓ Branch 214 (4→5) taken 118 times.
✗ Branch 215 (4→7) not taken.
✓ Branch 216 (10→11) taken 138 times.
✗ Branch 217 (10→13) not taken.
✓ Branch 218 (16→17) taken 121 times.
✗ Branch 219 (16→19) not taken.
✓ Branch 220 (4→5) taken 209 times.
✗ Branch 221 (4→7) not taken.
✓ Branch 222 (10→11) taken 2183 times.
✗ Branch 223 (10→13) not taken.
✓ Branch 224 (16→17) taken 930 times.
✗ Branch 225 (16→19) not taken.
✓ Branch 226 (22→23) taken 501 times.
✗ Branch 227 (22→25) not taken.
✗ Branch 228 (4→5) not taken.
✗ Branch 229 (4→7) not taken.
✓ Branch 230 (10→11) taken 12267 times.
✗ Branch 231 (10→13) not taken.
✓ Branch 232 (16→17) taken 13890 times.
✗ Branch 233 (16→19) not taken.
✓ Branch 234 (22→23) taken 4136 times.
✗ Branch 235 (22→25) not taken.
✓ Branch 236 (28→29) taken 10425 times.
✗ Branch 237 (28→31) not taken.
✓ Branch 238 (34→35) taken 13890 times.
✗ Branch 239 (34→37) not taken.
✓ Branch 240 (4→5) taken 1320 times.
✗ Branch 241 (4→7) not taken.
✓ Branch 242 (10→11) taken 24931 times.
✗ Branch 243 (10→13) not taken.
✓ Branch 244 (16→17) taken 25385 times.
✗ Branch 245 (16→19) not taken.
✓ Branch 246 (22→23) taken 25385 times.
✗ Branch 247 (22→25) not taken.
✓ Branch 248 (28→29) taken 3336 times.
✗ Branch 249 (28→31) not taken.
✓ Branch 250 (34→35) taken 19375 times.
✗ Branch 251 (34→37) not taken.
✓ Branch 252 (40→41) taken 25385 times.
✗ Branch 253 (40→43) not taken.
✗ Branch 254 (4→5) not taken.
✗ Branch 255 (4→7) not taken.
✓ Branch 256 (10→11) taken 8 times.
✗ Branch 257 (10→13) not taken.
✓ Branch 258 (16→17) taken 740 times.
✗ Branch 259 (16→19) not taken.
3291404 children.push_back(arg);
85 } else if constexpr (is_vector_of_derived_from_v<TDecayed, ASTNode>) {
86
27/54
✓ Branch 0 (7→8) taken 404684 times.
✗ Branch 1 (7→9) not taken.
✓ Branch 2 (7→8) taken 377803 times.
✗ Branch 3 (7→9) not taken.
✓ Branch 4 (7→8) taken 377810 times.
✗ Branch 5 (7→9) not taken.
✓ Branch 6 (7→8) taken 353923 times.
✗ Branch 7 (7→9) not taken.
✓ Branch 8 (7→8) taken 323228 times.
✗ Branch 9 (7→9) not taken.
✓ Branch 10 (7→8) taken 323393 times.
✗ Branch 11 (7→9) not taken.
✓ Branch 12 (7→8) taken 323380 times.
✗ Branch 13 (7→9) not taken.
✓ Branch 14 (7→8) taken 322991 times.
✗ Branch 15 (7→9) not taken.
✓ Branch 16 (7→8) taken 321562 times.
✗ Branch 17 (7→9) not taken.
✓ Branch 18 (7→8) taken 313976 times.
✗ Branch 19 (7→9) not taken.
✓ Branch 20 (7→8) taken 5 times.
✗ Branch 21 (7→9) not taken.
✓ Branch 22 (7→8) taken 3244 times.
✗ Branch 23 (7→9) not taken.
✓ Branch 24 (7→8) taken 3769 times.
✗ Branch 25 (7→9) not taken.
✓ Branch 26 (7→8) taken 105049 times.
✗ Branch 27 (7→9) not taken.
✓ Branch 28 (7→8) taken 185 times.
✗ Branch 29 (7→9) not taken.
✓ Branch 30 (7→8) taken 57262 times.
✗ Branch 31 (7→9) not taken.
✓ Branch 32 (7→8) taken 37112 times.
✗ Branch 33 (7→9) not taken.
✓ Branch 34 (7→8) taken 1583 times.
✗ Branch 35 (7→9) not taken.
✓ Branch 36 (7→8) taken 20917 times.
✗ Branch 37 (7→9) not taken.
✓ Branch 38 (7→8) taken 94919 times.
✗ Branch 39 (7→9) not taken.
✓ Branch 40 (7→8) taken 168 times.
✗ Branch 41 (7→9) not taken.
✓ Branch 42 (13→14) taken 57 times.
✗ Branch 43 (13→15) not taken.
✓ Branch 44 (25→26) taken 153 times.
✗ Branch 45 (25→27) not taken.
✓ Branch 46 (31→32) taken 2681 times.
✗ Branch 47 (31→33) not taken.
✓ Branch 48 (7→8) taken 5937 times.
✗ Branch 49 (7→9) not taken.
✓ Branch 50 (16→17) taken 5937 times.
✗ Branch 51 (16→18) not taken.
✓ Branch 52 (25→26) taken 5937 times.
✗ Branch 53 (25→27) not taken.
3787665 children.insert(children.end(), arg.begin(), arg.end());
87 } else {
88 static_assert(false, "Unsupported type");
89 }
90 };
91
92 6334225 (addChild(std::forward<Args>(args)), ...);
93 7125197 return children;
94 }
95
96 [[nodiscard]] virtual std::vector<ASTNode *> getChildren() const = 0;
97
98 4415642 virtual void resizeToNumberOfManifestations(size_t manifestationCount){ // NOLINT(misc-no-recursion)
99 // Resize children
100
3/4
✓ Branch 0 (2→3) taken 4415642 times.
✗ Branch 1 (2→17) not taken.
✓ Branch 2 (11→5) taken 4393048 times.
✓ Branch 3 (11→12) taken 4415642 times.
8808690 for (ASTNode *child : getChildren()) {
101
1/2
✗ Branch 0 (6→7) not taken.
✓ Branch 1 (6→8) taken 4393048 times.
4393048 assert(child != nullptr);
102
1/2
✓ Branch 0 (8→9) taken 4393048 times.
✗ Branch 1 (8→15) not taken.
4393048 child->resizeToNumberOfManifestations(manifestationCount);
103 4415642 }
104 // Do custom work
105 4415642 customItemsInitialization(manifestationCount);
106 4415642 }
107
108 virtual std::vector<std::vector<const Function *>> *getOpFctPointers() { // LCOV_EXCL_LINE
109 assert_fail("The given node does not overload the getOpFctPointers function"); // LCOV_EXCL_LINE
110 return nullptr; // LCOV_EXCL_LINE
111 } // LCOV_EXCL_LINE
112 [[nodiscard]] virtual const std::vector<std::vector<const Function *>> *getOpFctPointers() const { // LCOV_EXCL_LINE
113 assert_fail("The given node does not overload the getOpFctPointers function"); // LCOV_EXCL_LINE
114 return nullptr; // LCOV_EXCL_LINE
115 } // LCOV_EXCL_LINE
116
117 2572202 virtual void customItemsInitialization(size_t) {} // Noop
118
119 16503 [[nodiscard]] virtual bool hasCompileTimeValue() const { // NOLINT(misc-no-recursion)
120
1/2
✓ Branch 0 (2→3) taken 16503 times.
✗ Branch 1 (2→14) not taken.
16503 const std::vector<ASTNode *> children = getChildren();
121
2/2
✓ Branch 0 (4→5) taken 5472 times.
✓ Branch 1 (4→6) taken 11031 times.
16503 if (children.size() != 1)
122 5472 return false;
123
1/2
✓ Branch 0 (7→8) taken 11031 times.
✗ Branch 1 (7→12) not taken.
11031 return children.front()->hasCompileTimeValue();
124 16503 }
125
126 174 [[nodiscard]] virtual CompileTimeValue getCompileTimeValue() const { // NOLINT(misc-no-recursion)
127
1/2
✓ Branch 0 (2→3) taken 174 times.
✗ Branch 1 (2→14) not taken.
174 const std::vector<ASTNode *> children = getChildren();
128
1/2
✗ Branch 0 (4→5) not taken.
✓ Branch 1 (4→6) taken 174 times.
174 if (children.size() != 1)
129 return {};
130
1/2
✓ Branch 0 (7→8) taken 174 times.
✗ Branch 1 (7→12) not taken.
174 return children.front()->getCompileTimeValue();
131 174 }
132
133 [[nodiscard]] std::string getErrorMessage() const;
134
135 131782 [[nodiscard]] virtual bool returnsOnAllControlPaths(bool *doSetPredecessorsUnreachable) const { // NOLINT(misc-no-recursion)
136
1/2
✓ Branch 0 (2→3) taken 131782 times.
✗ Branch 1 (2→16) not taken.
131782 const std::vector<ASTNode *> children = getChildren();
137
5/6
✓ Branch 0 (4→5) taken 123133 times.
✓ Branch 1 (4→9) taken 8649 times.
✓ Branch 2 (6→7) taken 123133 times.
✗ Branch 3 (6→14) not taken.
✓ Branch 4 (7→8) taken 14271 times.
✓ Branch 5 (7→9) taken 108862 times.
263564 return children.size() == 1 && children.front()->returnsOnAllControlPaths(doSetPredecessorsUnreachable);
138 131782 }
139
140 [[nodiscard]] virtual std::vector<Function *> *getFctManifestations(const std::string &) { // LCOV_EXCL_LINE
141 assert_fail("Must be called on a FctDefNode, ProcDefNode, ExtDeclNode, StructDefNode or SignatureNode"); // LCOV_EXCL_LINE
142 return nullptr; // LCOV_EXCL_LINE
143 } // LCOV_EXCL_LINE
144
145 [[nodiscard]] virtual std::vector<Struct *> *getStructManifestations() { // LCOV_EXCL_LINE
146 assert_fail("Must be called on a StructDefNode"); // LCOV_EXCL_LINE
147 return nullptr; // LCOV_EXCL_LINE
148 } // LCOV_EXCL_LINE
149
150 [[nodiscard]] virtual std::vector<Interface *> *getInterfaceManifestations() { // LCOV_EXCL_LINE
151 assert_fail("Must be called on a InterfaceDefNode"); // LCOV_EXCL_LINE
152 return nullptr; // LCOV_EXCL_LINE
153 } // LCOV_EXCL_LINE
154
155 [[nodiscard]] const StmtLstNode *getNextOuterStmtLst() const;
156
157 153886 [[nodiscard]] virtual bool isFctOrProcDef() const { return false; }
158 127324 [[nodiscard]] virtual bool isStructDef() const { return false; }
159 12 [[nodiscard]] virtual bool isParam() const { return false; }
160 11096 [[nodiscard]] virtual bool isStmtLst() const { return false; }
161 133296 [[nodiscard]] virtual bool isAssignExpr() const { return false; }
162 6483 [[nodiscard]] virtual bool isExprStmt() const { return false; }
163
164 // Public members
165 ASTNode *parent = nullptr;
166 const CodeLoc codeLoc;
167 };
168
169 // Make sure we have no unexpected increases in memory consumption
170 // Note: If this is adjusted, please run UnitBlockAllocator, which depends on the ASTNode size
171 static_assert(sizeof(ASTNode) == 48);
172
173 // ========================================================== EntryNode ==========================================================
174
175 class EntryNode final : public ASTNode {
176 public:
177 // Constructors
178 using ASTNode::ASTNode;
179
180 // Visitor methods
181 5141 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitEntry(this); }
182 822 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitEntry(this); }
183
184 // Other methods
185 5937 GET_CHILDREN(modAttrs, importDefs, topLevelDefs);
186
187 // Public members
188 std::vector<ModAttrNode *> modAttrs;
189 std::vector<ImportDefNode *> importDefs;
190 std::vector<TopLevelDefNode *> topLevelDefs;
191 };
192
193 // ======================================================= TopLevelDefNode =======================================================
194
195 class TopLevelDefNode : public ASTNode {
196 public:
197 // Constructors
198 using ASTNode::ASTNode;
199
200 // Visitor methods
201 std::any accept(AbstractASTVisitor *visitor) override = 0;
202 std::any accept(ParallelizableASTVisitor *visitor) const override = 0;
203 };
204
205 // =========================================================== StmtNode ==========================================================
206
207 class StmtNode : public ASTNode {
208 public:
209 // Constructors
210 using ASTNode::ASTNode;
211
212 // Visitor methods
213 std::any accept(AbstractASTVisitor *visitor) override = 0;
214 std::any accept(ParallelizableASTVisitor *visitor) const override = 0;
215
216 // Public members
217 bool unreachable = false;
218 };
219
220 // Make sure we have no unexpected increases in memory consumption
221 static_assert(sizeof(StmtNode) == 56);
222
223 // ========================================================== ExprNode ===========================================================
224
225 class ExprNode : public ASTNode {
226 public:
227 // Constructors
228 using ASTNode::ASTNode;
229
230 // Visitor methods
231 std::any accept(AbstractASTVisitor *visitor) override = 0;
232 std::any accept(ParallelizableASTVisitor *visitor) const override = 0;
233
234 // Other methods
235 3888887 void resizeToNumberOfManifestations(size_t manifestationCount) override {
236 // Reserve this node
237
2/4
✓ Branch 0 (2→3) taken 3888887 times.
✗ Branch 1 (2→6) not taken.
✓ Branch 2 (3→4) taken 3888887 times.
✗ Branch 3 (3→6) not taken.
3888887 symbolTypes.resize(manifestationCount, QualType(TY_INVALID));
238 // Call parent
239 3888887 ASTNode::resizeToNumberOfManifestations(manifestationCount);
240 3888887 }
241
242 299054 QualType setEvaluatedSymbolType(const QualType &symbolType, const size_t idx) {
243
1/2
✗ Branch 0 (3→4) not taken.
✓ Branch 1 (3→5) taken 299054 times.
299054 assert(symbolTypes.size() > idx);
244 299054 symbolTypes.at(idx) = symbolType;
245 299054 return symbolType;
246 }
247
248 321034 [[nodiscard]] const QualType &getEvaluatedSymbolType(const size_t idx) const { // NOLINT(misc-no-recursion)
249
7/10
✓ Branch 0 (3→4) taken 321034 times.
✗ Branch 1 (3→8) not taken.
✓ Branch 2 (4→5) taken 321034 times.
✗ Branch 3 (4→47) not taken.
✓ Branch 4 (5→6) taken 321034 times.
✗ Branch 5 (5→47) not taken.
✓ Branch 6 (6→7) taken 131958 times.
✓ Branch 7 (6→8) taken 189076 times.
✓ Branch 8 (9→10) taken 131958 times.
✓ Branch 9 (9→12) taken 189076 times.
321034 if (!symbolTypes.empty() && !symbolTypes.at(idx).is(TY_INVALID))
250
1/2
✓ Branch 0 (10→11) taken 131958 times.
✗ Branch 1 (10→47) not taken.
131958 return symbolTypes.at(idx);
251
1/2
✓ Branch 0 (12→13) taken 189076 times.
✗ Branch 1 (12→47) not taken.
189076 const std::vector<ASTNode *> children = getChildren();
252
1/2
✗ Branch 0 (14→15) not taken.
✓ Branch 1 (14→23) taken 189076 times.
189076 if (children.size() != 1)
253 throw CompilerError(INTERNAL_ERROR, "Cannot deduce evaluated symbol type");
254
1/2
✓ Branch 0 (24→25) taken 189076 times.
✗ Branch 1 (24→26) not taken.
189076 const auto expr = spice_pointer_cast<ExprNode *>(children.front());
255
1/2
✓ Branch 0 (31→32) taken 189076 times.
✗ Branch 1 (31→45) not taken.
189076 return expr->getEvaluatedSymbolType(idx);
256 189076 }
257
258 private:
259 // Private members
260 QualTypeList symbolTypes;
261 };
262
263 // Make sure we have no unexpected increases in memory consumption
264 static_assert(sizeof(ExprNode) == 72);
265
266 // ======================================================== MainFctDefNode =======================================================
267
268 class MainFctDefNode final : public TopLevelDefNode {
269 public:
270 // Constructors
271 using TopLevelDefNode::TopLevelDefNode;
272
273 // Visitor methods
274 1147 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitMainFctDef(this); }
275 227 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitMainFctDef(this); }
276
277 // Other methods
278 740 GET_CHILDREN(attrs, paramLst, body);
279
1/2
✓ Branch 0 (4→5) taken 376 times.
✗ Branch 1 (4→8) not taken.
1128 [[nodiscard]] static std::string getScopeId() { return "fct:main"; }
280 bool returnsOnAllControlPaths(bool *doSetPredecessorsUnreachable) const override;
281 [[nodiscard]] bool isFctOrProcDef() const override { return true; }
282
283 // Public members
284 TopLevelDefinitionAttrNode *attrs = nullptr;
285 ParamLstNode *paramLst = nullptr;
286 StmtLstNode *body = nullptr;
287 bool takesArgs = false;
288 SymbolTableEntry *entry = nullptr;
289 Scope *bodyScope = nullptr;
290 };
291
292 // ========================================================== FctNameNode =======================================================
293
294 class FctNameNode final : public ASTNode {
295 public:
296 // Constructors
297 using ASTNode::ASTNode;
298
299 // Visitor methods
300 9415 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitFctName(this); }
301 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitFctName(this); }
302
303 // Other methods
304 39275 GET_CHILDREN();
305 [[nodiscard]] constexpr bool isOperatorOverload() const { return name.starts_with(OP_FCT_PREFIX); }
306 [[nodiscard]] bool supportsInverseOperator() const { return name == OP_FCT_EQUAL || name == OP_FCT_NOT_EQUAL; }
307
308 // Public members
309 std::string name;
310 std::string structName;
311 std::string fqName;
312 std::vector<std::string> nameFragments;
313 };
314
315 // ======================================================== FctDefBaseNode =======================================================
316
317 class FctDefBaseNode : public TopLevelDefNode {
318 public:
319 // Constructors
320 using TopLevelDefNode::TopLevelDefNode;
321
322 // Other methods
323 19246 [[nodiscard]] std::string getSymbolTableEntryName() const { return Function::getSymbolTableEntryName(name->name, codeLoc); }
324 1723 std::vector<Function *> *getFctManifestations(const std::string &) override { return &manifestations; }
325 599272 [[nodiscard]] bool isFctOrProcDef() const override { return true; }
326 bool returnsOnAllControlPaths(bool *doSetPredecessorsUnreachable) const override;
327
328 // Public members
329 TopLevelDefinitionAttrNode *attrs = nullptr;
330 QualifierLstNode *qualifierLst = nullptr;
331 FctNameNode *name;
332 TypeLstNode *templateTypeLst = nullptr;
333 ParamLstNode *paramLst = nullptr;
334 StmtLstNode *body = nullptr;
335 bool isMethod = false;
336 bool hasTemplateTypes = false;
337 bool hasParams = false;
338 TypeQualifiers qualifiers = TypeQualifiers::of(TY_FUNCTION);
339 SymbolTableEntry *entry = nullptr;
340 Scope *structScope = nullptr;
341 Scope *scope = nullptr;
342 std::vector<Function *> manifestations;
343 };
344
345 // ========================================================== FctDefNode =========================================================
346
347 class FctDefNode final : public FctDefBaseNode {
348 public:
349 // Constructors
350 using FctDefBaseNode::FctDefBaseNode;
351
352 // Visitor methods
353 31612 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitFctDef(this); }
354 5762 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitFctDef(this); }
355
356 // Other methods
357 25385 GET_CHILDREN(attrs, qualifierLst, returnType, name, templateTypeLst, paramLst, body);
358
2/4
✓ Branch 0 (2→3) taken 13062 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 13062 times.
✗ Branch 3 (3→8) not taken.
13062 [[nodiscard]] std::string getScopeId() const { return "fct:" + codeLoc.toString(); }
359
360 // Public members
361 DataTypeNode *returnType = nullptr;
362 };
363
364 // ========================================================== ProcDefNode ========================================================
365
366 class ProcDefNode final : public FctDefBaseNode {
367 public:
368 // Constructors
369 using FctDefBaseNode::FctDefBaseNode;
370
371 // Visitor methods
372 17292 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitProcDef(this); }
373 3139 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitProcDef(this); }
374
375 // Other methods
376 13890 GET_CHILDREN(attrs, qualifierLst, name, templateTypeLst, paramLst, body);
377
2/4
✓ Branch 0 (2→3) taken 6946 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 6946 times.
✗ Branch 3 (3→8) not taken.
6946 [[nodiscard]] std::string getScopeId() const { return "proc:" + codeLoc.toString(); }
378
379 // Public members
380 bool isCtor = false;
381 };
382
383 // ========================================================= StructDefNode =======================================================
384
385 class StructDefNode final : public TopLevelDefNode {
386 public:
387 // Constructors
388 using TopLevelDefNode::TopLevelDefNode;
389
390 // Visitor methods
391 2682 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitStructDef(this); }
392 518 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitStructDef(this); }
393
394 // Other methods
395 2681 GET_CHILDREN(attrs, qualifierLst, templateTypeLst, interfaceTypeLst, fields);
396 25021 std::vector<Struct *> *getStructManifestations() override { return &structManifestations; }
397 406 std::vector<Function *> *getFctManifestations(const std::string &fctName) override {
398
2/2
✓ Branch 0 (3→4) taken 286 times.
✓ Branch 1 (3→10) taken 120 times.
406 if (!defaultFctManifestations.contains(fctName))
399
2/4
✓ Branch 0 (5→6) taken 286 times.
✗ Branch 1 (5→15) not taken.
✓ Branch 2 (6→7) taken 286 times.
✗ Branch 3 (6→13) not taken.
286 defaultFctManifestations.insert({fctName, {}});
400 406 return &defaultFctManifestations.at(fctName);
401 }
402 28008 [[nodiscard]] bool isStructDef() const override { return true; }
403
404 // Public members
405 TopLevelDefinitionAttrNode *attrs = nullptr;
406 QualifierLstNode *qualifierLst = nullptr;
407 TypeLstNode *templateTypeLst = nullptr;
408 TypeLstNode *interfaceTypeLst = nullptr;
409 std::vector<FieldNode *> fields;
410 bool hasTemplateTypes = false;
411 bool hasInterfaces = false;
412 bool emitVTable = false;
413 TypeQualifiers qualifiers = TypeQualifiers::of(TY_STRUCT);
414 std::string structName;
415 uint64_t typeId;
416 SymbolTableEntry *entry = nullptr;
417 std::vector<Struct *> structManifestations;
418 std::map<const std::string, std::vector<Function *>> defaultFctManifestations;
419 Scope *structScope = nullptr;
420 };
421
422 // ======================================================= InterfaceDefNode ======================================================
423
424 class InterfaceDefNode final : public TopLevelDefNode {
425 public:
426 // Constructors
427 using TopLevelDefNode::TopLevelDefNode;
428
429 // Visitor methods
430 327 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitInterfaceDef(this); }
431 69 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitInterfaceDef(this); }
432
433 // Other methods
434 153 GET_CHILDREN(attrs, qualifierLst, templateTypeLst, signatures);
435 119 std::vector<Interface *> *getInterfaceManifestations() override { return &interfaceManifestations; }
436
437 // Public members
438 TopLevelDefinitionAttrNode *attrs = nullptr;
439 QualifierLstNode *qualifierLst = nullptr;
440 TypeLstNode *templateTypeLst = nullptr;
441 std::vector<SignatureNode *> signatures;
442 bool hasTemplateTypes = false;
443 TypeQualifiers qualifiers = TypeQualifiers::of(TY_INTERFACE);
444 std::string interfaceName;
445 uint64_t typeId;
446 SymbolTableEntry *entry = nullptr;
447 std::vector<Interface *> interfaceManifestations;
448 Scope *interfaceScope = nullptr;
449 };
450
451 // ========================================================== EnumDefNode ========================================================
452
453 class EnumDefNode final : public TopLevelDefNode {
454 public:
455 // Constructors
456 using TopLevelDefNode::TopLevelDefNode;
457
458 // Visitor methods
459 307 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitEnumDef(this); }
460 62 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitEnumDef(this); }
461
462 // Other methods
463 120 GET_CHILDREN(qualifierLst, itemLst);
464
465 // Public members
466 QualifierLstNode *qualifierLst = nullptr;
467 EnumItemLstNode *itemLst = nullptr;
468 TypeQualifiers qualifiers = TypeQualifiers::of(TY_ENUM);
469 std::string enumName;
470 uint64_t typeId;
471 SymbolTableEntry *entry = nullptr;
472 Scope *enumScope;
473 };
474
475 // ====================================================== GenericTypeDefNode =====================================================
476
477 class GenericTypeDefNode final : public TopLevelDefNode {
478 public:
479 // Constructors
480 using TopLevelDefNode::TopLevelDefNode;
481
482 // Visitor methods
483 4112 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitGenericTypeDef(this); }
484 735 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitGenericTypeDef(this); }
485
486 // Other methods
487 1583 GET_CHILDREN(typeAltsLst);
488
489 // Public members
490 TypeAltsLstNode *typeAltsLst = nullptr;
491 std::string typeName;
492 SymbolTableEntry *entry = nullptr;
493 };
494
495 // ========================================================= AliasDefNode ========================================================
496
497 class AliasDefNode final : public TopLevelDefNode {
498 public:
499 // Constructors
500 using TopLevelDefNode::TopLevelDefNode;
501
502 // Visitor methods
503 243 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitAliasDef(this); }
504 52 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitAliasDef(this); }
505
506 // Other methods
507 99 GET_CHILDREN(qualifierLst, dataType);
508
509 // Public members
510 QualifierLstNode *qualifierLst = nullptr;
511 DataTypeNode *dataType = nullptr;
512 TypeQualifiers qualifiers = TypeQualifiers::of(TY_ALIAS);
513 std::string aliasName;
514 std::string dataTypeString;
515 uint64_t typeId;
516 SymbolTableEntry *entry = nullptr;
517 SymbolTableEntry *aliasedTypeContainerEntry = nullptr;
518 };
519
520 // ======================================================= GlobalVarDefNode ======================================================
521
522 class GlobalVarDefNode final : public TopLevelDefNode {
523 public:
524 // Constructors
525 using TopLevelDefNode::TopLevelDefNode;
526
527 // Visitor methods
528 4918 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitGlobalVarDef(this); }
529 1119 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitGlobalVarDef(this); }
530
531 // Other methods
532 [[nodiscard]] bool hasCompileTimeValue() const override { return true; }
533 [[nodiscard]] CompileTimeValue getCompileTimeValue() const override;
534
535 // Other methods
536 2269 GET_CHILDREN(dataType, constant);
537
538 // Public members
539 DataTypeNode *dataType = nullptr;
540 ConstantNode *constant = nullptr;
541 bool hasValue = false;
542 std::string varName;
543 SymbolTableEntry *entry = nullptr;
544 };
545
546 // ========================================================== ExtDeclNode ========================================================
547
548 class ExtDeclNode final : public TopLevelDefNode {
549 public:
550 // Constructors
551 using TopLevelDefNode::TopLevelDefNode;
552
553 // Visitor methods
554 4277 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitExtDecl(this); }
555 834 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitExtDecl(this); }
556
557 // Other methods
558 1727 GET_CHILDREN(attrs, returnType, argTypeLst);
559 2 std::vector<Function *> *getFctManifestations(const std::string &) override { return &extFunctionManifestations; }
560 1736 [[nodiscard]] std::string getScopeId() const {
561
1/2
✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 1736 times.
1736 const char *prefix = hasReturnType ? "func:" : "proc:";
562
2/4
✓ Branch 0 (5→6) taken 1736 times.
✗ Branch 1 (5→13) not taken.
✓ Branch 2 (6→7) taken 1736 times.
✗ Branch 3 (6→11) not taken.
1736 return prefix + codeLoc.toString();
563 }
564
565 // Public members
566 TopLevelDefinitionAttrNode *attrs = nullptr;
567 DataTypeNode *returnType = nullptr;
568 TypeLstNode *argTypeLst = nullptr;
569 bool hasArgs = false;
570 bool isVarArg = false;
571 bool hasReturnType = false;
572 std::string extFunctionName;
573 SymbolTableEntry *entry = nullptr;
574 Function *extFunction = nullptr;
575 std::vector<Function *> extFunctionManifestations;
576 };
577
578 // ======================================================== ImportDefNode ========================================================
579
580 class ImportDefNode final : public TopLevelDefNode {
581 public:
582 // Constructors
583 using TopLevelDefNode::TopLevelDefNode;
584
585 // Visitor methods
586 2829 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitImportDef(this); }
587 479 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitImportDef(this); }
588
589 // Other methods
590 1887 GET_CHILDREN();
591
592 // Public members
593 std::string importPath;
594 std::string importName;
595 SymbolTableEntry *entry = nullptr;
596 };
597
598 // ======================================================== UnsafeBlockNode ======================================================
599
600 class UnsafeBlockNode final : public StmtNode {
601 public:
602 // Constructors
603 using StmtNode::StmtNode;
604
605 // Visitor methods
606 6877 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitUnsafeBlock(this); }
607 1946 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitUnsafeBlockDef(this); }
608
609 // Other methods
610 12938 GET_CHILDREN(body);
611
2/4
✓ Branch 0 (2→3) taken 6441 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 6441 times.
✗ Branch 3 (3→8) not taken.
6441 [[nodiscard]] std::string getScopeId() const { return "unsafe:" + codeLoc.toString(); }
612
613 // Public members
614 StmtLstNode *body = nullptr;
615 Scope *bodyScope = nullptr;
616 };
617
618 // ========================================================== ForLoopNode ========================================================
619
620 class ForLoopNode final : public StmtNode {
621 public:
622 // Constructors
623 using StmtNode::StmtNode;
624
625 // Visitor methods
626 3646 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitForLoop(this); }
627 1113 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitForLoop(this); }
628
629 // Other methods
630 5641 GET_CHILDREN(initDecl, condAssign, incAssign, body);
631
2/4
✓ Branch 0 (2→3) taken 3567 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 3567 times.
✗ Branch 3 (3→8) not taken.
3567 [[nodiscard]] std::string getScopeId() const { return "for:" + codeLoc.toString(); }
632 [[nodiscard]] bool returnsOnAllControlPaths(bool *doSetPredecessorsUnreachable) const override;
633
634 // Public members
635 DeclStmtNode *initDecl = nullptr;
636 AssignExprNode *condAssign = nullptr;
637 AssignExprNode *incAssign = nullptr;
638 StmtLstNode *body = nullptr;
639 Scope *bodyScope = nullptr;
640 };
641
642 // ======================================================== ForeachLoopNode ======================================================
643
644 class ForeachLoopNode final : public StmtNode {
645 public:
646 // Constructors
647 using StmtNode::StmtNode;
648
649 // Visitor methods
650 267 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitForeachLoop(this); }
651 100 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitForeachLoop(this); }
652
653 // Other methods
654 412 GET_CHILDREN(idxVarDecl, itemVarDecl, iteratorAssign, body);
655
2/4
✓ Branch 0 (2→3) taken 304 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 304 times.
✗ Branch 3 (3→8) not taken.
304 [[nodiscard]] std::string getScopeId() const { return "foreach:" + codeLoc.toString(); }
656
657 // Public members
658 DeclStmtNode *idxVarDecl = nullptr;
659 DeclStmtNode *itemVarDecl = nullptr;
660 AssignExprNode *iteratorAssign = nullptr;
661 StmtLstNode *body = nullptr;
662 Scope *bodyScope = nullptr;
663 Function *getIteratorFct = nullptr;
664 Function *getFct = nullptr;
665 Function *getIdxFct = nullptr;
666 Function *isValidFct = nullptr;
667 Function *nextFct = nullptr;
668 };
669
670 // ========================================================= WhileLoopNode =======================================================
671
672 class WhileLoopNode final : public StmtNode {
673 public:
674 // Constructors
675 using StmtNode::StmtNode;
676
677 // Visitor methods
678 2028 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitWhileLoop(this); }
679 616 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitWhileLoop(this); }
680
681 // Other methods
682 3093 GET_CHILDREN(condition, body);
683
2/4
✓ Branch 0 (2→3) taken 1977 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 1977 times.
✗ Branch 3 (3→8) not taken.
1977 [[nodiscard]] std::string getScopeId() const { return "while:" + codeLoc.toString(); }
684 [[nodiscard]] bool returnsOnAllControlPaths(bool *doSetPredecessorsUnreachable) const override;
685
686 // Public members
687 AssignExprNode *condition = nullptr;
688 StmtLstNode *body = nullptr;
689 Scope *bodyScope = nullptr;
690 };
691
692 // ======================================================== DoWhileLoopNode ======================================================
693
694 class DoWhileLoopNode final : public StmtNode {
695 public:
696 // Constructors
697 using StmtNode::StmtNode;
698
699 // Visitor methods
700 21 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitDoWhileLoop(this); }
701 8 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitDoWhileLoop(this); }
702
703 // Other methods
704 24 GET_CHILDREN(body, condition);
705
2/4
✓ Branch 0 (2→3) taken 26 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 26 times.
✗ Branch 3 (3→8) not taken.
26 [[nodiscard]] std::string getScopeId() const { return "dowhile:" + codeLoc.toString(); }
706 [[nodiscard]] bool returnsOnAllControlPaths(bool *doSetPredecessorsUnreachable) const override;
707
708 // Public members
709 StmtLstNode *body = nullptr;
710 AssignExprNode *condition = nullptr;
711 Scope *bodyScope = nullptr;
712 };
713
714 // ========================================================== IfStmtNode =========================================================
715
716 class IfStmtNode final : public StmtNode {
717 public:
718 // Constructors
719 using StmtNode::StmtNode;
720
721 // Visitor methods
722 11092 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitIfStmt(this); }
723 3663 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitIfStmt(this); }
724
725 // Other methods
726 15845 GET_CHILDREN(condition, thenBody, elseStmt);
727
2/4
✓ Branch 0 (2→3) taken 11199 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 11199 times.
✗ Branch 3 (3→8) not taken.
11199 [[nodiscard]] std::string getScopeId() const { return "if:" + codeLoc.toString(); }
728 [[nodiscard]] bool returnsOnAllControlPaths(bool *doSetPredecessorsUnreachable) const override;
729
730 // Public members
731 AssignExprNode *condition = nullptr;
732 StmtLstNode *thenBody = nullptr;
733 ElseStmtNode *elseStmt = nullptr;
734 Scope *thenBodyScope = nullptr;
735 };
736
737 // ========================================================= ElseStmtNode ========================================================
738
739 class ElseStmtNode final : public StmtNode {
740 public:
741 // Constructors
742 using StmtNode::StmtNode;
743
744 // Visitor methods
745 486 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitElseStmt(this); }
746 146 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitElseStmt(this); }
747
748 // Other methods
749 723 GET_CHILDREN(ifStmt, body);
750
2/4
✓ Branch 0 (2→3) taken 330 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 330 times.
✗ Branch 3 (3→8) not taken.
330 [[nodiscard]] std::string getScopeId() const { return "if:" + codeLoc.toString(); }
751 [[nodiscard]] bool returnsOnAllControlPaths(bool *doSetPredecessorsUnreachable) const override;
752
753 // Public members
754 bool isElseIf = false;
755 IfStmtNode *ifStmt = nullptr;
756 StmtLstNode *body = nullptr;
757 Scope *elseBodyScope = nullptr;
758 };
759
760 // ======================================================== SwitchStmtNode =======================================================
761
762 class SwitchStmtNode final : public StmtNode {
763 public:
764 // Constructors
765 using StmtNode::StmtNode;
766
767 // Visitor methods
768 29 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitSwitchStmt(this); }
769 8 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitSwitchStmt(this); }
770
771 // Other methods
772 57 GET_CHILDREN(assignExpr, caseBranches, defaultBranch);
773 [[nodiscard]] bool returnsOnAllControlPaths(bool *doSetPredecessorsUnreachable) const override;
774
775 // Public members
776 AssignExprNode *assignExpr = nullptr;
777 std::vector<CaseBranchNode *> caseBranches;
778 DefaultBranchNode *defaultBranch = nullptr;
779 bool hasDefaultBranch = false;
780 };
781
782 // ======================================================== CaseBranchNode =======================================================
783
784 class CaseBranchNode final : public ASTNode {
785 public:
786 // Constructors
787 using ASTNode::ASTNode;
788
789 // Visitor methods
790 137 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitCaseBranch(this); }
791 49 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitCaseBranch(this); }
792
793 // Other methods
794 168 GET_CHILDREN(caseConstants, body);
795
2/4
✓ Branch 0 (2→3) taken 155 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 155 times.
✗ Branch 3 (3→8) not taken.
155 [[nodiscard]] std::string getScopeId() const { return "case:" + codeLoc.toString(); }
796 [[nodiscard]] bool returnsOnAllControlPaths(bool *doSetPredecessorsUnreachable) const override;
797
798 // Public members
799 std::vector<CaseConstantNode *> caseConstants;
800 StmtLstNode *body = nullptr;
801 Scope *bodyScope = nullptr;
802 };
803
804 // ======================================================= DefaultBranchNode =====================================================
805
806 class DefaultBranchNode final : public ASTNode {
807 public:
808 // Constructors
809 using ASTNode::ASTNode;
810
811 // Visitor methods
812 15 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitDefaultBranch(this); }
813 4 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitDefaultBranch(this); }
814
815 // Other methods
816 18 GET_CHILDREN(body);
817
2/4
✓ Branch 0 (2→3) taken 16 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 16 times.
✗ Branch 3 (3→8) not taken.
16 [[nodiscard]] std::string getScopeId() const { return "default:" + codeLoc.toString(); }
818 [[nodiscard]] bool returnsOnAllControlPaths(bool *doSetPredecessorsUnreachable) const override;
819
820 // Public members
821 StmtLstNode *body = nullptr;
822 Scope *bodyScope = nullptr;
823 };
824
825 // ==================================================== AnonymousBlockStmtNode ===================================================
826
827 class AnonymousBlockStmtNode final : public StmtNode {
828 public:
829 // Constructors
830 using StmtNode::StmtNode;
831
832 // Visitor methods
833 54 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitAnonymousBlockStmt(this); }
834 27 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitAnonymousBlockStmt(this); }
835
836 // Other methods
837 81 GET_CHILDREN(body);
838
2/4
✓ Branch 0 (2→3) taken 81 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 81 times.
✗ Branch 3 (3→8) not taken.
81 [[nodiscard]] std::string getScopeId() const { return "anon:" + codeLoc.toString(); }
839
840 // Public members
841 StmtLstNode *body = nullptr;
842 Scope *bodyScope = nullptr;
843 };
844
845 // ========================================================= StmtLstNode =========================================================
846
847 class StmtLstNode final : public ASTNode {
848 public:
849 // Structs
850 struct ResourcesForManifestationToCleanup {
851 std::vector<std::pair<SymbolTableEntry *, Function *>> dtorFunctionsToCall;
852 std::vector<SymbolTableEntry *> heapVarsToFree;
853 };
854
855 // Constructors
856 using ASTNode::ASTNode;
857
858 // Visitor methods
859 52990 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitStmtLst(this); }
860 16048 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitStmtLst(this); }
861
862 // Other methods
863 94919 GET_CHILDREN(statements);
864 [[nodiscard]] bool returnsOnAllControlPaths(bool *doSetPredecessorsUnreachable) const override;
865 59184 void customItemsInitialization(const size_t manifestationCount) override { resourcesToCleanup.resize(manifestationCount); }
866 16632 [[nodiscard]] bool isStmtLst() const override { return true; }
867
868 // Public members
869 std::vector<StmtNode *> statements;
870 size_t complexity = 0;
871 std::vector<ResourcesForManifestationToCleanup> resourcesToCleanup;
872 CodeLoc closingBraceCodeLoc = CodeLoc(1, 0);
873 };
874
875 // ========================================================= TypeLstNode =========================================================
876
877 class TypeLstNode final : public ASTNode {
878 public:
879 // Constructors
880 using ASTNode::ASTNode;
881
882 // Visitor methods
883 6343 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitTypeLst(this); }
884 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitTypeLst(this); }
885
886 // Other methods
887 20917 GET_CHILDREN(dataTypes);
888
889 // Public members
890 std::vector<DataTypeNode *> dataTypes;
891 };
892
893 // ======================================================= TypeAltsLstNode =======================================================
894
895 class TypeAltsLstNode final : public ASTNode {
896 public:
897 // Constructors
898 using ASTNode::ASTNode;
899
900 // Visitor methods
901 773 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitTypeAltsLst(this); }
902 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitTypeAltsLst(this); }
903
904 // Other methods
905 1583 GET_CHILDREN(dataTypes);
906
907 // Public members
908 std::vector<DataTypeNode *> dataTypes;
909 };
910
911 // ======================================================== ParamLstNode =========================================================
912
913 class ParamLstNode final : public ASTNode {
914 public:
915 // Constructors
916 using ASTNode::ASTNode;
917
918 // Visitor methods
919 28166 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitParamLst(this); }
920 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitParamLst(this); }
921
922 // Other methods
923 37112 GET_CHILDREN(params);
924
925 // Public members
926 std::vector<DeclStmtNode *> params;
927 };
928
929 // ========================================================== ArgLstNode =========================================================
930
931 class ArgLstNode final : public ASTNode {
932 public:
933 // Structs
934 struct ArgInfo {
935 Function *copyCtor = nullptr;
936 };
937
938 // Constructors
939 using ASTNode::ASTNode;
940
941 // Visitor methods
942 20802 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitArgLst(this); }
943 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitArgLst(this); }
944
945 // Other methods
946 57262 GET_CHILDREN(args);
947
948 // Public members
949 std::vector<AssignExprNode *> args;
950 std::vector<ArgInfo> argInfos;
951 };
952
953 // ======================================================== EnumItemLstNode ======================================================
954
955 class EnumItemLstNode final : public ASTNode {
956 public:
957 // Constructors
958 using ASTNode::ASTNode;
959
960 // Visitor methods
961 122 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitEnumItemLst(this); }
962 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitEnumItemLst(this); }
963
964 // Other methods
965 185 GET_CHILDREN(items);
966
967 // Public members
968 std::vector<EnumItemNode *> items;
969 };
970
971 // ========================================================= EnumItemNode ========================================================
972
973 class EnumItemNode final : public ASTNode {
974 public:
975 // Constructors
976 using ASTNode::ASTNode;
977
978 // Visitor methods
979 1448 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitEnumItem(this); }
980 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitEnumItem(this); }
981
982 // Other methods
983 1442 GET_CHILDREN();
984 37 [[nodiscard]] CompileTimeValue getCompileTimeValue() const override { return {.intValue = static_cast<int32_t>(itemValue)}; }
985
986 // Public members
987 bool hasValue = false;
988 uint32_t itemValue;
989 std::string itemName;
990 SymbolTableEntry *entry = nullptr;
991 EnumDefNode *enumDef = nullptr;
992 };
993
994 // ========================================================== FieldNode ==========================================================
995
996 class FieldNode final : public ASTNode {
997 public:
998 // Constructors
999 using ASTNode::ASTNode;
1000
1001 // Visitor methods
1002 3707 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitField(this); }
1003 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitField(this); }
1004
1005 // Other methods
1006 4708 GET_CHILDREN(dataType, defaultValue);
1007
1008 // Public members
1009 DataTypeNode *dataType = nullptr;
1010 TernaryExprNode *defaultValue = nullptr;
1011 std::string fieldName;
1012 SymbolTableEntry *entry = nullptr;
1013 };
1014
1015 // ======================================================== SignatureNode ========================================================
1016
1017 class SignatureNode final : public ASTNode {
1018 public:
1019 // Enums
1020 enum class SignatureType : uint8_t {
1021 TYPE_NONE,
1022 TYPE_FUNCTION,
1023 TYPE_PROCEDURE,
1024 };
1025
1026 // Constructors
1027 using ASTNode::ASTNode;
1028
1029 // Visitor methods
1030 563 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitSignature(this); }
1031 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitSignature(this); }
1032
1033 // Other methods
1034 370 GET_CHILDREN(qualifierLst, returnType, templateTypeLst, paramTypeLst);
1035 std::vector<Function *> *getFctManifestations(const std::string &) override { return &signatureManifestations; }
1036
1037 // Public members
1038 QualifierLstNode *qualifierLst = nullptr;
1039 DataTypeNode *returnType = nullptr;
1040 TypeLstNode *templateTypeLst = nullptr;
1041 TypeLstNode *paramTypeLst = nullptr;
1042 bool hasReturnType = false;
1043 bool hasTemplateTypes = false;
1044 bool hasParams = false;
1045 SignatureType signatureType = SignatureType::TYPE_NONE;
1046 TypeQualifiers signatureQualifiers;
1047 std::string methodName;
1048 SymbolTableEntry *entry = nullptr;
1049 std::vector<Function *> signatureManifestations;
1050 };
1051
1052 // ========================================================= DeclStmtNode ========================================================
1053
1054 class DeclStmtNode final : public StmtNode {
1055 public:
1056 // Constructors
1057 using StmtNode::StmtNode;
1058
1059 // Visitor methods
1060 61872 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitDeclStmt(this); }
1061 6883 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitDeclStmt(this); }
1062
1063 // Other methods
1064 76373 GET_CHILDREN(dataType, assignExpr);
1065 55525 void customItemsInitialization(const size_t manifestationCount) override { entries.resize(manifestationCount); }
1066 697 [[nodiscard]] bool isParam() const override { return isFctParam; }
1067
1068 // Public members
1069 DataTypeNode *dataType = nullptr;
1070 AssignExprNode *assignExpr = nullptr;
1071 bool hasAssignment = false;
1072 bool isFctParam = false;
1073 bool isForEachItem = false;
1074 bool isCtorCallRequired = false; // For struct, in case there are reference fields, we need to call a user-defined ctor
1075 std::string varName;
1076 std::vector<SymbolTableEntry *> entries;
1077 Function *calledInitCtor = nullptr;
1078 Function *calledCopyCtor = nullptr;
1079 };
1080
1081 // ========================================================= ExprStmtNode ========================================================
1082
1083 class ExprStmtNode final : public StmtNode {
1084 public:
1085 // Constructors
1086 using StmtNode::StmtNode;
1087
1088 // Visitor methods
1089 33261 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitExprStmt(this); }
1090 9749 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitExprStmt(this); }
1091
1092 // Other methods
1093 91170 GET_CHILDREN(expr);
1094 148 [[nodiscard]] bool isExprStmt() const override { return true; }
1095
1096 // Public members
1097 AssignExprNode *expr = nullptr;
1098 };
1099
1100 // ======================================================= QualifierLstNode ======================================================
1101
1102 class QualifierLstNode final : public ASTNode {
1103 public:
1104 // Constructors
1105 using ASTNode::ASTNode;
1106
1107 // Visitor methods
1108 28016 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitQualifierLst(this); }
1109 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitQualifierLst(this); }
1110
1111 // Other methods
1112 105049 GET_CHILDREN(qualifiers);
1113
1114 // Public members
1115 std::vector<QualifierNode *> qualifiers;
1116 };
1117
1118 // ========================================================= QualifierNode =======================================================
1119
1120 class QualifierNode final : public ASTNode {
1121 public:
1122 // Enums
1123 enum class QualifierType : uint8_t {
1124 TY_NONE,
1125 TY_CONST,
1126 TY_SIGNED,
1127 TY_UNSIGNED,
1128 TY_INLINE,
1129 TY_PUBLIC,
1130 TY_HEAP,
1131 TY_COMPOSITION,
1132 };
1133
1134 // Constructors
1135 using ASTNode::ASTNode;
1136
1137 // Visitor methods
1138 33672 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitQualifier(this); }
1139 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitQualifier(this); }
1140
1141 // Other methods
1142 126045 GET_CHILDREN();
1143
1144 // Public members
1145 QualifierType type = QualifierType::TY_NONE;
1146 };
1147
1148 // ========================================================== ModAttrNode ========================================================
1149
1150 class ModAttrNode final : public ASTNode {
1151 public:
1152 // Constructors
1153 using ASTNode::ASTNode;
1154
1155 // Visitor methods
1156 1675 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitModAttr(this); }
1157 270 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitModAttr(this); }
1158
1159 // Other methods
1160 1674 GET_CHILDREN(attrLst);
1161
1162 // Public members
1163 AttrLstNode *attrLst = nullptr;
1164 };
1165
1166 // =================================================== TopLevelDefinitionAttrNode ================================================
1167
1168 class TopLevelDefinitionAttrNode final : public ASTNode {
1169 public:
1170 // Constructors
1171 using ASTNode::ASTNode;
1172
1173 // Visitor methods
1174 866 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitTopLevelDefinitionAttr(this); }
1175 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitTopLevelDefinitionAttr(this); }
1176
1177 // Other methods
1178 2061 GET_CHILDREN(attrLst);
1179
1180 // Public members
1181 AttrLstNode *attrLst = nullptr;
1182 };
1183
1184 // ========================================================= LambdaAttrNode ======================================================
1185
1186 class LambdaAttrNode final : public ASTNode {
1187 public:
1188 // Constructors
1189 using ASTNode::ASTNode;
1190
1191 // Visitor methods
1192 1 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitLambdaAttr(this); }
1193 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitLambdaAttr(this); }
1194
1195 // Other methods
1196 34 GET_CHILDREN(attrLst);
1197
1198 // Public members
1199 AttrLstNode *attrLst = nullptr;
1200 };
1201
1202 // ========================================================== AttrLstNode ========================================================
1203
1204 class AttrLstNode final : public ASTNode {
1205 public:
1206 // Constructors
1207 using ASTNode::ASTNode;
1208
1209 // Visitor methods
1210 2241 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitAttrLst(this); }
1211 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitAttrLst(this); }
1212
1213 // Other methods
1214 3769 GET_CHILDREN(attributes);
1215 [[nodiscard]] std::vector<const CompileTimeValue *> getAttrValuesByName(const std::string &key) const;
1216 [[nodiscard]] const CompileTimeValue *getAttrValueByName(const std::string &key) const;
1217 [[nodiscard]] bool hasAttr(const std::string &key) const;
1218
1219 // Public members
1220 std::vector<AttrNode *> attributes;
1221 };
1222
1223 // ============================================================ AttrNode =========================================================
1224
1225 class AttrNode final : public ASTNode {
1226 public:
1227 // Enums
1228 enum AttrTarget : uint8_t {
1229 TARGET_INVALID = 0,
1230 TARGET_MODULE = 1 << 0,
1231 TARGET_STRUCT = 1 << 1,
1232 TARGET_INTERFACE = 1 << 2,
1233 TARGET_FCT_PROC = 1 << 3,
1234 TARGET_EXT_DECL = 1 << 4,
1235 TARGET_LAMBDA = 1 << 5,
1236 };
1237
1238 enum class AttrType : uint8_t {
1239 ATTR_TYPE_INVALID,
1240 TYPE_STRING,
1241 TYPE_BOOL,
1242 TYPE_INT,
1243 };
1244
1245 // Constructors
1246 using ASTNode::ASTNode;
1247
1248 // Visitor methods
1249 3983 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitAttr(this); }
1250 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitAttr(this); }
1251
1252 // Other methods
1253 4749 GET_CHILDREN(value);
1254 [[nodiscard]] const CompileTimeValue *getValue() const;
1255
1256 // Public members
1257 ConstantNode *value = nullptr;
1258 AttrType type = AttrType::ATTR_TYPE_INVALID;
1259 AttrTarget target = TARGET_INVALID;
1260 std::string key;
1261 };
1262
1263 // ======================================================== CaseConstantNode =====================================================
1264
1265 class CaseConstantNode final : public ExprNode {
1266 public:
1267 // Constructors
1268 using ExprNode::ExprNode;
1269
1270 // Visitor methods
1271 188 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitCaseConstant(this); }
1272 66 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitCaseConstant(this); }
1273
1274 // Other methods
1275 236 GET_CHILDREN(constant);
1276
1277 // Public members
1278 ConstantNode *constant = nullptr;
1279 std::vector<std::string> identifierFragments;
1280 std::string fqIdentifier;
1281 const SymbolTableEntry *entry = nullptr;
1282 };
1283
1284 // ======================================================== ReturnStmtNode =======================================================
1285
1286 class ReturnStmtNode final : public StmtNode {
1287 public:
1288 // Constructors
1289 using StmtNode::StmtNode;
1290
1291 // Visitor methods
1292 23655 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitReturnStmt(this); }
1293 7608 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitReturnStmt(this); }
1294
1295 // Other methods
1296 40548 GET_CHILDREN(assignExpr);
1297 7459 [[nodiscard]] bool returnsOnAllControlPaths(bool *) const override { return true; }
1298
1/2
✓ Branch 0 (2→3) taken 7608 times.
✗ Branch 1 (2→4) not taken.
15216 [[nodiscard]] StmtLstNode *getParentScopeNode() const { return spice_pointer_cast<StmtLstNode *>(parent); }
1299
1300 // Public members
1301 AssignExprNode *assignExpr = nullptr;
1302 QualType returnType;
1303 Function *calledCopyCtor = nullptr;
1304 bool hasReturnValue = false;
1305 };
1306
1307 // ======================================================== BreakStmtNode ========================================================
1308
1309 class BreakStmtNode final : public StmtNode {
1310 public:
1311 // Constructors
1312 using StmtNode::StmtNode;
1313
1314 // Visitor methods
1315 309 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitBreakStmt(this); }
1316 97 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitBreakStmt(this); }
1317
1318 // Other methods
1319 558 GET_CHILDREN();
1320
1321 // Public members
1322 int breakTimes = 1;
1323 };
1324
1325 // ======================================================= ContinueStmtNode ======================================================
1326
1327 class ContinueStmtNode final : public StmtNode {
1328 public:
1329 // Constructors
1330 using StmtNode::StmtNode;
1331
1332 // Visitor methods
1333 718 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitContinueStmt(this); }
1334 325 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitContinueStmt(this); }
1335
1336 // Other methods
1337 1019 GET_CHILDREN();
1338
1339 // Public members
1340 int continueTimes = 1;
1341 };
1342
1343 // ====================================================== FallthroughStmtNode ====================================================
1344
1345 class FallthroughStmtNode final : public StmtNode {
1346 public:
1347 // Constructors
1348 using StmtNode::StmtNode;
1349
1350 // Visitor methods
1351 12 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitFallthroughStmt(this); }
1352 4 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitFallthroughStmt(this); }
1353
1354 // Other methods
1355 21 GET_CHILDREN();
1356 };
1357
1358 // ======================================================== AssertStmtNode =======================================================
1359
1360 class AssertStmtNode final : public StmtNode {
1361 public:
1362 // Constructors
1363 using StmtNode::StmtNode;
1364
1365 // Visitor methods
1366 1453 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitAssertStmt(this); }
1367 705 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitAssertStmt(this); }
1368
1369 // Other methods
1370 2129 GET_CHILDREN(assignExpr);
1371 [[nodiscard]] bool returnsOnAllControlPaths(bool *doSetPredecessorsUnreachable) const override;
1372
1373 // Public members
1374 AssignExprNode *assignExpr = nullptr;
1375 std::string expressionString;
1376 };
1377
1378 // ======================================================== BuiltinCallNode ======================================================
1379
1380 class BuiltinCallNode final : public ExprNode {
1381 public:
1382 // Constructors
1383 using ExprNode::ExprNode;
1384
1385 // Visitor methods
1386 4759 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitBuiltinCall(this); }
1387 1481 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitBuiltinCall(this); }
1388
1389 // Other methods
1390 9642 GET_CHILDREN(printfCall, sizeofCall, alignofCall, lenCall, panicCall, sysCall);
1391
1392 // Public members
1393 PrintfCallNode *printfCall = nullptr;
1394 SizeofCallNode *sizeofCall = nullptr;
1395 AlignofCallNode *alignofCall = nullptr;
1396 LenCallNode *lenCall = nullptr;
1397 PanicCallNode *panicCall = nullptr;
1398 SysCallNode *sysCall = nullptr;
1399 };
1400
1401 // ======================================================== PrintfCallNode =======================================================
1402
1403 class PrintfCallNode final : public ExprNode {
1404 public:
1405 // Constructors
1406 using ExprNode::ExprNode;
1407
1408 // Visitor methods
1409 952 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitPrintfCall(this); }
1410 709 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitPrintfCall(this); }
1411
1412 // Other methods
1413 3244 GET_CHILDREN(args);
1414 [[nodiscard]] bool hasCompileTimeValue() const override { return false; }
1415
1416 // Public members
1417 std::vector<AssignExprNode *> args;
1418 std::string templatedString;
1419 };
1420
1421 // ======================================================== SizeofCallNode =======================================================
1422
1423 class SizeofCallNode final : public ExprNode {
1424 public:
1425 // Constructors
1426 using ExprNode::ExprNode;
1427
1428 // Visitor methods
1429 401 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitSizeofCall(this); }
1430 127 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitSizeofCall(this); }
1431
1432 // Other methods
1433 917 GET_CHILDREN(assignExpr, dataType);
1434 8 [[nodiscard]] bool hasCompileTimeValue() const override { return false; }
1435
1436 // Public members
1437 union {
1438 AssignExprNode *assignExpr = nullptr;
1439 DataTypeNode *dataType;
1440 };
1441 bool isType = false;
1442 };
1443
1444 // ======================================================== AlignofCallNode ======================================================
1445
1446 class AlignofCallNode final : public ExprNode {
1447 public:
1448 // Constructors
1449 using ExprNode::ExprNode;
1450
1451 // Visitor methods
1452 11 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitAlignofCall(this); }
1453 11 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitAlignofCall(this); }
1454
1455 // Other methods
1456 44 GET_CHILDREN(assignExpr, dataType);
1457 [[nodiscard]] bool hasCompileTimeValue() const override { return false; }
1458
1459 // Public members
1460 union {
1461 AssignExprNode *assignExpr = nullptr;
1462 DataTypeNode *dataType;
1463 };
1464 bool isType = false;
1465 };
1466
1467 // ========================================================= LenCallNode =========================================================
1468
1469 class LenCallNode final : public ExprNode {
1470 public:
1471 // Constructors
1472 using ExprNode::ExprNode;
1473
1474 // Visitor methods
1475 219 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitLenCall(this); }
1476 49 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitLenCall(this); }
1477
1478 // Other methods
1479 7 [[nodiscard]] bool hasCompileTimeValue() const override { return false; }
1480
1481 // Other methods
1482 622 GET_CHILDREN(assignExpr);
1483
1484 // Public members
1485 AssignExprNode *assignExpr = nullptr;
1486 };
1487
1488 // ======================================================== PanicCallNode ========================================================
1489
1490 class PanicCallNode final : public ExprNode {
1491 public:
1492 // Constructors
1493 using ExprNode::ExprNode;
1494
1495 // Visitor methods
1496 1595 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitPanicCall(this); }
1497 584 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitPanicCall(this); }
1498
1499 // Other methods
1500 3962 GET_CHILDREN(assignExpr);
1501 [[nodiscard]] bool hasCompileTimeValue() const override { return false; }
1502 795 [[nodiscard]] bool returnsOnAllControlPaths(bool *) const override { return true; }
1503
1504 // Public members
1505 AssignExprNode *assignExpr = nullptr;
1506 };
1507
1508 // ========================================================= SysCallNode =========================================================
1509
1510 class SysCallNode final : public ExprNode {
1511 public:
1512 // Constructors
1513 using ExprNode::ExprNode;
1514
1515 // Visitor methods
1516 1 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitSysCall(this); }
1517 1 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitSysCall(this); }
1518
1519 // Other methods
1520 5 GET_CHILDREN(args);
1521
1522 // Public members
1523 std::vector<AssignExprNode *> args;
1524 };
1525
1526 // ======================================================= AssignExprNode ========================================================
1527
1528 class AssignExprNode final : public ExprNode {
1529 public:
1530 // Enums
1531 enum class AssignOp : uint8_t {
1532 OP_NONE,
1533 OP_ASSIGN,
1534 OP_PLUS_EQUAL,
1535 OP_MINUS_EQUAL,
1536 OP_MUL_EQUAL,
1537 OP_DIV_EQUAL,
1538 OP_REM_EQUAL,
1539 OP_SHL_EQUAL,
1540 OP_SHR_EQUAL,
1541 OP_AND_EQUAL,
1542 OP_OR_EQUAL,
1543 OP_XOR_EQUAL
1544 };
1545
1546 // Constructors
1547 using ExprNode::ExprNode;
1548
1549 // Visitor methods
1550 185134 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitAssignExpr(this); }
1551 58611 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitAssignExpr(this); }
1552
1553 // Other methods
1554 343576 GET_CHILDREN(lhs, rhs, ternaryExpr);
1555 [[nodiscard]] bool returnsOnAllControlPaths(bool *doSetPredecessorsUnreachable) const override;
1556 6631 [[nodiscard]] bool isAssignExpr() const override { return true; }
1557 268 [[nodiscard]] std::vector<std::vector<const Function *>> *getOpFctPointers() override { return &opFct; }
1558 778 [[nodiscard]] const std::vector<std::vector<const Function *>> *getOpFctPointers() const override { return &opFct; }
1559
2/4
✓ Branch 0 (4→5) taken 206719 times.
✗ Branch 1 (4→11) not taken.
✓ Branch 2 (5→6) taken 206719 times.
✗ Branch 3 (5→9) not taken.
620157 void customItemsInitialization(const size_t manifestationCount) override { opFct.resize(manifestationCount, {nullptr}); }
1560
1561 // Public members
1562 PrefixUnaryExprNode *lhs = nullptr;
1563 AssignExprNode *rhs = nullptr;
1564 TernaryExprNode *ternaryExpr = nullptr;
1565 AssignOp op = AssignOp::OP_NONE;
1566 std::vector<std::vector<const Function *>> opFct; // Operator overloading functions
1567 };
1568
1569 // ======================================================= TernaryExprNode =======================================================
1570
1571 class TernaryExprNode final : public ExprNode {
1572 public:
1573 // Constructors
1574 using ExprNode::ExprNode;
1575
1576 // Visitor methods
1577 167851 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitTernaryExpr(this); }
1578 53673 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitTernaryExpr(this); }
1579
1580 // Other methods
1581 308848 GET_CHILDREN(condition, trueExpr, falseExpr);
1582 [[nodiscard]] bool hasCompileTimeValue() const override;
1583 [[nodiscard]] CompileTimeValue getCompileTimeValue() const override;
1584
1585 // Public members
1586 LogicalOrExprNode *condition = nullptr;
1587 LogicalOrExprNode *trueExpr = nullptr;
1588 LogicalOrExprNode *falseExpr = nullptr;
1589 Function *calledCopyCtor = nullptr;
1590 bool trueSideCallsCopyCtor = false;
1591 bool falseSideCallsCopyCtor = false;
1592 bool isShortened = false;
1593 };
1594
1595 // ===================================================== LogicalOrExprNode =======================================================
1596
1597 class LogicalOrExprNode final : public ExprNode {
1598 public:
1599 // Constructors
1600 using ExprNode::ExprNode;
1601
1602 // Visitor methods
1603 169819 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitLogicalOrExpr(this); }
1604 54365 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitLogicalOrExpr(this); }
1605
1606 // Other methods
1607 313976 GET_CHILDREN(operands);
1608
1609 // Public members
1610 std::vector<LogicalAndExprNode *> operands;
1611 [[nodiscard]] bool hasCompileTimeValue() const override;
1612 [[nodiscard]] CompileTimeValue getCompileTimeValue() const override;
1613 };
1614
1615 // ===================================================== LogicalAndExprNode ======================================================
1616
1617 class LogicalAndExprNode final : public ExprNode {
1618 public:
1619 // Constructors
1620 using ExprNode::ExprNode;
1621
1622 // Visitor methods
1623 173169 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitLogicalAndExpr(this); }
1624 55424 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitLogicalAndExpr(this); }
1625
1626 // Other methods
1627 321562 GET_CHILDREN(operands);
1628
1629 // Public members
1630 std::vector<BitwiseOrExprNode *> operands;
1631 [[nodiscard]] bool hasCompileTimeValue() const override;
1632 [[nodiscard]] CompileTimeValue getCompileTimeValue() const override;
1633 };
1634
1635 // ===================================================== BitwiseOrExprNode =======================================================
1636
1637 class BitwiseOrExprNode final : public ExprNode {
1638 public:
1639 // Constructors
1640 using ExprNode::ExprNode;
1641
1642 // Visitor methods
1643 173805 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitBitwiseOrExpr(this); }
1644 55600 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitBitwiseOrExpr(this); }
1645
1646 // Other methods
1647 322991 GET_CHILDREN(operands);
1648
1649 // Public members
1650 std::vector<BitwiseXorExprNode *> operands;
1651 [[nodiscard]] bool hasCompileTimeValue() const override;
1652 [[nodiscard]] CompileTimeValue getCompileTimeValue() const override;
1653 };
1654
1655 // ==================================================== BitwiseXorExprNode =======================================================
1656
1657 class BitwiseXorExprNode final : public ExprNode {
1658 public:
1659 // Constructors
1660 using ExprNode::ExprNode;
1661
1662 // Visitor methods
1663 174000 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitBitwiseXorExpr(this); }
1664 55665 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitBitwiseXorExpr(this); }
1665
1666 // Other methods
1667 323380 GET_CHILDREN(operands);
1668
1669 // Public members
1670 std::vector<BitwiseAndExprNode *> operands;
1671 [[nodiscard]] bool hasCompileTimeValue() const override;
1672 [[nodiscard]] CompileTimeValue getCompileTimeValue() const override;
1673 };
1674
1675 // ==================================================== BitwiseAndExprNode =======================================================
1676
1677 class BitwiseAndExprNode final : public ExprNode {
1678 public:
1679 // Constructors
1680 using ExprNode::ExprNode;
1681
1682 // Visitor methods
1683 174009 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitBitwiseAndExpr(this); }
1684 55668 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitBitwiseAndExpr(this); }
1685
1686 // Other methods
1687 323393 GET_CHILDREN(operands);
1688
1689 // Public members
1690 std::vector<EqualityExprNode *> operands;
1691 [[nodiscard]] bool hasCompileTimeValue() const override;
1692 [[nodiscard]] CompileTimeValue getCompileTimeValue() const override;
1693 };
1694
1695 // ===================================================== EqualityExprNode ========================================================
1696
1697 class EqualityExprNode final : public ExprNode {
1698 public:
1699 // Enums
1700 enum class EqualityOp : uint8_t {
1701 OP_NONE,
1702 OP_EQUAL,
1703 OP_NOT_EQUAL,
1704 };
1705
1706 // Constructors
1707 using ExprNode::ExprNode;
1708
1709 // Visitor methods
1710 174090 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitEqualityExpr(this); }
1711 55699 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitEqualityExpr(this); }
1712
1713 // Other methods
1714 323228 GET_CHILDREN(operands);
1715 [[nodiscard]] bool hasCompileTimeValue() const override;
1716 [[nodiscard]] CompileTimeValue getCompileTimeValue() const override;
1717 818 [[nodiscard]] std::vector<std::vector<const Function *>> *getOpFctPointers() override { return &opFct; }
1718 9221 [[nodiscard]] const std::vector<std::vector<const Function *>> *getOpFctPointers() const override { return &opFct; }
1719
2/4
✓ Branch 0 (4→5) taken 192549 times.
✗ Branch 1 (4→11) not taken.
✓ Branch 2 (5→6) taken 192549 times.
✗ Branch 3 (5→9) not taken.
577647 void customItemsInitialization(const size_t manifestationCount) override { opFct.resize(manifestationCount, {nullptr}); }
1720
1721 // Public members
1722 std::vector<RelationalExprNode *> operands;
1723 EqualityOp op = EqualityOp::OP_NONE;
1724 std::vector<std::vector<const Function *>> opFct; // Operator overloading functions
1725 };
1726
1727 // ==================================================== RelationalExprNode =======================================================
1728
1729 class RelationalExprNode final : public ExprNode {
1730 public:
1731 // Enums
1732 enum class RelationalOp : uint8_t {
1733 OP_NONE,
1734 OP_LESS,
1735 OP_GREATER,
1736 OP_LESS_EQUAL,
1737 OP_GREATER_EQUAL,
1738 };
1739
1740 // Constructors
1741 using ExprNode::ExprNode;
1742
1743 // Visitor methods
1744 187311 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitRelationalExpr(this); }
1745 60121 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitRelationalExpr(this); }
1746
1747 // Other methods
1748 353923 GET_CHILDREN(operands);
1749 [[nodiscard]] bool hasCompileTimeValue() const override;
1750 [[nodiscard]] CompileTimeValue getCompileTimeValue() const override;
1751
1752 // Public members
1753 std::vector<ShiftExprNode *> operands;
1754 RelationalOp op = RelationalOp::OP_NONE;
1755 };
1756
1757 // ====================================================== ShiftExprNode ==========================================================
1758
1759 class ShiftExprNode final : public ExprNode {
1760 public:
1761 // Enums
1762 enum class ShiftOp : uint8_t {
1763 OP_NONE,
1764 OP_SHIFT_LEFT,
1765 OP_SHIFT_RIGHT,
1766 };
1767
1768 // Typedefs
1769 using OpQueue = std::queue<std::pair<ShiftOp, QualType>>;
1770
1771 // Constructors
1772 using ExprNode::ExprNode;
1773
1774 // Visitor methods
1775 196241 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitShiftExpr(this); }
1776 63266 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitShiftExpr(this); }
1777
1778 // Other methods
1779 377810 GET_CHILDREN(operands);
1780 [[nodiscard]] bool hasCompileTimeValue() const override;
1781 [[nodiscard]] CompileTimeValue getCompileTimeValue() const override;
1782 172 [[nodiscard]] std::vector<std::vector<const Function *>> *getOpFctPointers() override { return &opFct; }
1783 286 [[nodiscard]] const std::vector<std::vector<const Function *>> *getOpFctPointers() const override { return &opFct; }
1784
2/4
✓ Branch 0 (4→5) taken 218357 times.
✗ Branch 1 (4→11) not taken.
✓ Branch 2 (5→6) taken 218357 times.
✗ Branch 3 (5→9) not taken.
655071 void customItemsInitialization(const size_t manifestationCount) override { opFct.resize(manifestationCount, {nullptr}); }
1785
1786 // Public members
1787 std::vector<AdditiveExprNode *> operands;
1788 OpQueue opQueue;
1789 std::vector<std::vector<const Function *>> opFct; // Operator overloading functions
1790 };
1791
1792 // ==================================================== AdditiveExprNode =========================================================
1793
1794 class AdditiveExprNode final : public ExprNode {
1795 public:
1796 // Enums
1797 enum class AdditiveOp : uint8_t {
1798 OP_PLUS,
1799 OP_MINUS,
1800 };
1801
1802 // Typedefs
1803 using OpQueue = std::queue<std::pair<AdditiveOp, QualType>>;
1804
1805 // Constructors
1806 using ExprNode::ExprNode;
1807
1808 // Visitor methods
1809 196478 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitAdditiveExpr(this); }
1810 63366 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitAdditiveExpr(this); }
1811
1812 // Other methods
1813 377803 GET_CHILDREN(operands);
1814 [[nodiscard]] bool hasCompileTimeValue() const override;
1815 [[nodiscard]] CompileTimeValue getCompileTimeValue() const override;
1816 110 [[nodiscard]] std::vector<std::vector<const Function *>> *getOpFctPointers() override { return &opFct; }
1817 7997 [[nodiscard]] const std::vector<std::vector<const Function *>> *getOpFctPointers() const override { return &opFct; }
1818
2/4
✓ Branch 0 (4→5) taken 218541 times.
✗ Branch 1 (4→11) not taken.
✓ Branch 2 (5→6) taken 218541 times.
✗ Branch 3 (5→9) not taken.
655623 void customItemsInitialization(const size_t manifestationCount) override { opFct.resize(manifestationCount, {nullptr}); }
1819
1820 // Public members
1821 std::vector<MultiplicativeExprNode *> operands;
1822 OpQueue opQueue;
1823 std::vector<std::vector<const Function *>> opFct; // Operator overloading functions
1824 };
1825
1826 // ================================================== MultiplicativeExprNode =====================================================
1827
1828 class MultiplicativeExprNode final : public ExprNode {
1829 public:
1830 // Enums
1831 enum class MultiplicativeOp : uint8_t {
1832 OP_MUL,
1833 OP_DIV,
1834 OP_REM,
1835 };
1836
1837 // Typedefs
1838 using OpQueue = std::queue<std::pair<MultiplicativeOp, QualType>>;
1839
1840 // Constructors
1841 using ExprNode::ExprNode;
1842
1843 // Visitor methods
1844 207682 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitMultiplicativeExpr(this); }
1845 67337 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitMultiplicativeExpr(this); }
1846
1847 // Other methods
1848 404684 GET_CHILDREN(operands);
1849 [[nodiscard]] bool hasCompileTimeValue() const override;
1850 [[nodiscard]] CompileTimeValue getCompileTimeValue() const override;
1851 24 [[nodiscard]] std::vector<std::vector<const Function *>> *getOpFctPointers() override { return &opFct; }
1852 1550 [[nodiscard]] const std::vector<std::vector<const Function *>> *getOpFctPointers() const override { return &opFct; }
1853
2/4
✓ Branch 0 (4→5) taken 231325 times.
✗ Branch 1 (4→11) not taken.
✓ Branch 2 (5→6) taken 231325 times.
✗ Branch 3 (5→9) not taken.
693975 void customItemsInitialization(const size_t manifestationCount) override { opFct.resize(manifestationCount, {nullptr}); }
1854
1855 // Public members
1856 std::vector<CastExprNode *> operands;
1857 OpQueue opQueue;
1858 std::vector<std::vector<const Function *>> opFct; // Operator overloading functions
1859 };
1860
1861 // ======================================================= CastExprNode ==========================================================
1862
1863 class CastExprNode final : public ExprNode {
1864 public:
1865 // Constructors
1866 using ExprNode::ExprNode;
1867
1868 // Visitor methods
1869 210808 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitCastExpr(this); }
1870 68116 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitCastExpr(this); }
1871
1872 // Other methods
1873 412188 GET_CHILDREN(prefixUnaryExpr, dataType, assignExpr);
1874 [[nodiscard]] bool hasCompileTimeValue() const override;
1875 [[nodiscard]] CompileTimeValue getCompileTimeValue() const override;
1876
1877 // Public members
1878 PrefixUnaryExprNode *prefixUnaryExpr = nullptr;
1879 DataTypeNode *dataType = nullptr;
1880 AssignExprNode *assignExpr = nullptr;
1881 bool isCast = false;
1882 };
1883
1884 // ==================================================== PrefixUnaryExprNode ======================================================
1885
1886 class PrefixUnaryExprNode final : public ExprNode {
1887 public:
1888 // Enums
1889 enum class PrefixUnaryOp : uint8_t {
1890 OP_NONE,
1891 OP_MINUS,
1892 OP_PLUS_PLUS,
1893 OP_MINUS_MINUS,
1894 OP_NOT,
1895 OP_BITWISE_NOT,
1896 OP_DEREFERENCE,
1897 OP_ADDRESS_OF,
1898 };
1899
1900 // Constructors
1901 using ExprNode::ExprNode;
1902
1903 // Visitor methods
1904 226199 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitPrefixUnaryExpr(this); }
1905 72508 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitPrefixUnaryExpr(this); }
1906
1907 // Other methods
1908 442959 GET_CHILDREN(prefixUnaryExpr, postfixUnaryExpr);
1909 [[nodiscard]] bool hasCompileTimeValue() const override;
1910 [[nodiscard]] CompileTimeValue getCompileTimeValue() const override;
1911
1912 // Public members
1913 PrefixUnaryExprNode *prefixUnaryExpr = nullptr;
1914 PostfixUnaryExprNode *postfixUnaryExpr = nullptr;
1915 PrefixUnaryOp op = PrefixUnaryOp::OP_NONE;
1916 };
1917
1918 // =================================================== PostfixUnaryExprNode ======================================================
1919
1920 class PostfixUnaryExprNode final : public ExprNode {
1921 public:
1922 // Enums
1923 enum class PostfixUnaryOp : uint8_t {
1924 OP_NONE,
1925 OP_SUBSCRIPT,
1926 OP_MEMBER_ACCESS,
1927 OP_PLUS_PLUS,
1928 OP_MINUS_MINUS,
1929 };
1930
1931 // Constructors
1932 using ExprNode::ExprNode;
1933
1934 // Visitor methods
1935 283795 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitPostfixUnaryExpr(this); }
1936 89814 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitPostfixUnaryExpr(this); }
1937
1938 // Other methods
1939 564823 GET_CHILDREN(atomicExpr, postfixUnaryExpr, subscriptIndexExpr);
1940 [[nodiscard]] bool hasCompileTimeValue() const override;
1941 [[nodiscard]] CompileTimeValue getCompileTimeValue() const override;
1942 252 [[nodiscard]] std::vector<std::vector<const Function *>> *getOpFctPointers() override { return &opFct; }
1943 13176 [[nodiscard]] const std::vector<std::vector<const Function *>> *getOpFctPointers() const override { return &opFct; }
1944
2/4
✓ Branch 0 (4→5) taken 324377 times.
✗ Branch 1 (4→11) not taken.
✓ Branch 2 (5→6) taken 324377 times.
✗ Branch 3 (5→9) not taken.
973131 void customItemsInitialization(const size_t manifestationCount) override { opFct.resize(manifestationCount, {nullptr}); }
1945
1946 // Public members
1947 AtomicExprNode *atomicExpr = nullptr;
1948 PostfixUnaryExprNode *postfixUnaryExpr = nullptr;
1949 AssignExprNode *subscriptIndexExpr = nullptr;
1950 PostfixUnaryOp op = PostfixUnaryOp::OP_NONE;
1951 std::vector<std::vector<const Function *>> opFct; // Operator overloading functions
1952 std::string identifier; // Only set when operator is member access
1953 };
1954
1955 // ====================================================== AtomicExprNode =========================================================
1956
1957 class AtomicExprNode final : public ExprNode {
1958 public:
1959 // Structs
1960 struct VarAccessData {
1961 SymbolTableEntry *entry = nullptr;
1962 Scope *accessScope = nullptr;
1963 Capture *capture = nullptr;
1964 };
1965
1966 // Constructors
1967 using ExprNode::ExprNode;
1968
1969 // Visitor methods
1970 223269 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitAtomicExpr(this); }
1971 71624 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitAtomicExpr(this); }
1972
1973 // Other methods
1974 426073 GET_CHILDREN(constant, value, assignExpr, builtinCall);
1975 250319 void customItemsInitialization(const size_t manifestationCount) override { data.resize(manifestationCount); }
1976
1977 // Public members
1978 ConstantNode *constant = nullptr;
1979 ValueNode *value = nullptr;
1980 AssignExprNode *assignExpr = nullptr;
1981 BuiltinCallNode *builtinCall = nullptr;
1982 std::vector<std::string> identifierFragments;
1983 std::string fqIdentifier;
1984 std::vector<VarAccessData> data; // Only set if identifier is set as well
1985 };
1986
1987 // ======================================================== ValueNode ============================================================
1988
1989 class ValueNode final : public ExprNode {
1990 public:
1991 // Constructors
1992 using ExprNode::ExprNode;
1993
1994 // Visitor methods
1995 43521 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitValue(this); }
1996 14238 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitValue(this); }
1997
1998 // Other methods
1999 89700 GET_CHILDREN(fctCall, arrayInitialization, structInstantiation, lambdaFunc, lambdaProc, lambdaExpr, nilType);
2000 1386 [[nodiscard]] bool hasCompileTimeValue() const override { return isNil; }
2001
2002 // Public members
2003 FctCallNode *fctCall = nullptr;
2004 ArrayInitializationNode *arrayInitialization = nullptr;
2005 StructInstantiationNode *structInstantiation = nullptr;
2006 LambdaFuncNode *lambdaFunc = nullptr;
2007 LambdaProcNode *lambdaProc = nullptr;
2008 LambdaExprNode *lambdaExpr = nullptr;
2009 DataTypeNode *nilType = nullptr;
2010 bool isNil = false;
2011 };
2012
2013 // ====================================================== ConstantNode ===========================================================
2014
2015 class ConstantNode final : public ExprNode {
2016 public:
2017 // Enum
2018 enum class PrimitiveValueType : uint8_t {
2019 TYPE_NONE,
2020 TYPE_DOUBLE,
2021 TYPE_INT,
2022 TYPE_SHORT,
2023 TYPE_LONG,
2024 TYPE_BYTE,
2025 TYPE_CHAR,
2026 TYPE_STRING,
2027 TYPE_BOOL
2028 };
2029
2030 // Constructors
2031 using ExprNode::ExprNode;
2032
2033 // Visitor methods
2034 44596 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitConstant(this); }
2035 13754 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitConstant(this); }
2036
2037 // Other methods
2038 70890 GET_CHILDREN();
2039 13885 [[nodiscard]] CompileTimeValue getCompileTimeValue() const override { return compileTimeValue; }
2040 300 [[nodiscard]] bool hasCompileTimeValue() const override { return true; }
2041
2042 // Public members
2043 PrimitiveValueType type = PrimitiveValueType::TYPE_NONE;
2044 CompileTimeValue compileTimeValue;
2045 };
2046
2047 // ====================================================== FctCallNode ============================================================
2048
2049 class FctCallNode final : public ExprNode {
2050 public:
2051 // Enums
2052 enum class FctCallType : uint8_t {
2053 TYPE_ORDINARY,
2054 TYPE_METHOD,
2055 TYPE_CTOR,
2056 TYPE_FCT_PTR,
2057 };
2058
2059 // Structs
2060 struct FctCallData {
2061 // Members
2062 FctCallType callType = FctCallType::TYPE_ORDINARY;
2063 bool isImported = false;
2064 QualTypeList templateTypes;
2065 QualType thisType = QualType(TY_DYN); // Is filled if method or ctor call
2066 ArgList args;
2067 Function *callee = nullptr;
2068 Scope *calleeParentScope = nullptr;
2069
2070 // Methods
2071 16098 [[nodiscard]] bool isOrdinaryCall() const { return callType == FctCallType::TYPE_ORDINARY; }
2072 64421 [[nodiscard]] bool isMethodCall() const { return callType == FctCallType::TYPE_METHOD; }
2073
4/4
✓ Branch 0 (3→4) taken 6190 times.
✓ Branch 1 (3→7) taken 14747 times.
✓ Branch 2 (5→6) taken 30 times.
✓ Branch 3 (5→7) taken 6160 times.
20937 [[nodiscard]] bool isVirtualMethodCall() const { return isMethodCall() && thisType.isBase(TY_INTERFACE); }
2074 66565 [[nodiscard]] bool isCtorCall() const { return callType == FctCallType::TYPE_CTOR; }
2075 125211 [[nodiscard]] bool isFctPtrCall() const { return callType == FctCallType::TYPE_FCT_PTR; }
2076 };
2077
2078 // Constructors
2079 using ExprNode::ExprNode;
2080
2081 // Visitor methods
2082 39614 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitFctCall(this); }
2083 12840 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitFctCall(this); }
2084
2085 // Other methods
2086 72404 GET_CHILDREN(templateTypeLst, argLst);
2087 [[nodiscard]] bool hasCompileTimeValue() const override { return false; }
2088 42937 void customItemsInitialization(const size_t manifestationCount) override { data.resize(manifestationCount); }
2089 [[nodiscard]] bool hasReturnValueReceiver() const;
2090
2091 // Public members
2092 TypeLstNode *templateTypeLst = nullptr;
2093 ArgLstNode *argLst = nullptr;
2094 bool hasArgs = false;
2095 bool hasTemplateTypes = false;
2096 std::string fqFunctionName;
2097 std::vector<std::string> functionNameFragments;
2098 std::vector<FctCallData> data;
2099 };
2100
2101 // ================================================= ArrayInitializationNode =====================================================
2102
2103 class ArrayInitializationNode final : public ExprNode {
2104 public:
2105 // Constructors
2106 using ExprNode::ExprNode;
2107
2108 // Visitor methods
2109 149 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitArrayInitialization(this); }
2110 54 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitArrayInitialization(this); }
2111
2112 // Other methods
2113 220 GET_CHILDREN(itemLst);
2114
2115 // Public members
2116 ArgLstNode *itemLst = nullptr;
2117 size_t actualSize = 0z;
2118 };
2119
2120 // ================================================= StructInstantiationNode =====================================================
2121
2122 class StructInstantiationNode final : public ExprNode {
2123 public:
2124 // Constructors
2125 using ExprNode::ExprNode;
2126
2127 // Visitor methods
2128 652 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitStructInstantiation(this); }
2129 269 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitStructInstantiation(this); }
2130
2131 // Other methods
2132 936 GET_CHILDREN(templateTypeLst, fieldLst);
2133 563 void customItemsInitialization(const size_t manifestationCount) override { instantiatedStructs.resize(manifestationCount); }
2134
2135 // Public members
2136 TypeLstNode *templateTypeLst = nullptr;
2137 ArgLstNode *fieldLst = nullptr;
2138 bool hasTemplateTypes = false;
2139 std::string fqStructName;
2140 std::vector<std::string> structNameFragments;
2141 std::vector<Struct *> instantiatedStructs;
2142 };
2143
2144 // ====================================================== LambdaBaseNode =========================================================
2145
2146 class LambdaBaseNode : public ExprNode {
2147 public:
2148 // Constructors
2149 using ExprNode::ExprNode;
2150
2151 // Other methods
2152
2/4
✓ Branch 0 (2→3) taken 115 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 115 times.
✗ Branch 3 (3→8) not taken.
115 [[nodiscard]] std::string getScopeId() const { return "lambda:" + codeLoc.toString(); }
2153 [[nodiscard]] bool hasCompileTimeValue() const override { return false; }
2154 81 void customItemsInitialization(const size_t manifestationCount) override { manifestations.resize(manifestationCount); }
2155
2156 // Public members
2157 ParamLstNode *paramLst = nullptr;
2158 bool hasParams = false;
2159 Scope *bodyScope = nullptr;
2160 std::vector<Function> manifestations;
2161 };
2162
2163 // ====================================================== LambdaFuncNode =========================================================
2164
2165 class LambdaFuncNode final : public LambdaBaseNode {
2166 public:
2167 // Constructors
2168 using LambdaBaseNode::LambdaBaseNode;
2169
2170 // Visit methods
2171 24 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitLambdaFunc(this); }
2172 8 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitLambdaFunc(this); }
2173
2174 // Other methods
2175 24 GET_CHILDREN(returnType, paramLst, body, lambdaAttr);
2176 [[nodiscard]] bool returnsOnAllControlPaths(bool *overrideUnreachable) const override;
2177
2178 // Public members
2179 DataTypeNode *returnType = nullptr;
2180 StmtLstNode *body = nullptr;
2181 LambdaAttrNode *lambdaAttr = nullptr;
2182 };
2183
2184 // ====================================================== LambdaProcNode =========================================================
2185
2186 class LambdaProcNode final : public LambdaBaseNode {
2187 public:
2188 // Constructors
2189 using LambdaBaseNode::LambdaBaseNode;
2190
2191 // Visit methods
2192 57 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitLambdaProc(this); }
2193 26 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitLambdaProc(this); }
2194
2195 // Other methods
2196 57 GET_CHILDREN(paramLst, body, lambdaAttr);
2197 bool returnsOnAllControlPaths(bool *overrideUnreachable) const override;
2198
2199 // Public members
2200 StmtLstNode *body = nullptr;
2201 LambdaAttrNode *lambdaAttr = nullptr;
2202 };
2203
2204 // ====================================================== LambdaExprNode =========================================================
2205
2206 class LambdaExprNode final : public LambdaBaseNode {
2207 public:
2208 // Constructors
2209 using LambdaBaseNode::LambdaBaseNode;
2210
2211 // Visit methods
2212 2 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitLambdaExpr(this); }
2213 1 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitLambdaExpr(this); }
2214
2215 // Other methods
2216 2 GET_CHILDREN(paramLst, lambdaExpr);
2217
2218 // Public members
2219 AssignExprNode *lambdaExpr = nullptr;
2220 };
2221
2222 // ======================================================= DataTypeNode ==========================================================
2223
2224 class DataTypeNode final : public ExprNode {
2225 public:
2226 // Enums
2227 enum class TypeModifierType : uint8_t {
2228 TYPE_PTR,
2229 TYPE_REF,
2230 TYPE_ARRAY,
2231 };
2232
2233 // Structs
2234 struct TypeModifier {
2235 TypeModifierType modifierType = TypeModifierType::TYPE_PTR;
2236 bool hasSize = false;
2237 unsigned int hardcodedSize = 0;
2238 std::string sizeVarName;
2239 };
2240
2241 // Constructors
2242 using ExprNode::ExprNode;
2243
2244 // Visitor methods
2245 91805 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitDataType(this); }
2246 2279 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitDataType(this); }
2247
2248 // Other methods
2249 152332 GET_CHILDREN(qualifierLst, baseDataType);
2250 void setFieldTypeRecursive();
2251
2252 // Public members
2253 QualifierLstNode *qualifierLst = nullptr;
2254 BaseDataTypeNode *baseDataType = nullptr;
2255 bool isParamType = false;
2256 bool isGlobalType = false;
2257 bool isFieldType = false;
2258 bool isReturnType = false;
2259 std::queue<TypeModifier> tmQueue;
2260 };
2261
2262 // ==================================================== BaseDataTypeNode =========================================================
2263
2264 class BaseDataTypeNode final : public ExprNode {
2265 public:
2266 // Enums
2267 enum class Type : uint8_t {
2268 TYPE_NONE,
2269 TYPE_DOUBLE,
2270 TYPE_INT,
2271 TYPE_SHORT,
2272 TYPE_LONG,
2273 TYPE_BYTE,
2274 TYPE_CHAR,
2275 TYPE_STRING,
2276 TYPE_BOOL,
2277 TYPE_DYN,
2278 TYPE_CUSTOM,
2279 TYPE_FUNCTION
2280 };
2281
2282 // Constructors
2283 using ExprNode::ExprNode;
2284
2285 // Visitor methods
2286 91805 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitBaseDataType(this); }
2287 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitBaseDataType(this); }
2288
2289 // Other methods
2290 152323 GET_CHILDREN(customDataType, functionDataType);
2291
2292 // Public members
2293 CustomDataTypeNode *customDataType = nullptr;
2294 FunctionDataTypeNode *functionDataType = nullptr;
2295 Type type = Type::TYPE_NONE;
2296 };
2297
2298 // ==================================================== CustomDataTypeNode =======================================================
2299
2300 class CustomDataTypeNode final : public ExprNode {
2301 public:
2302 // Constructors
2303 using ExprNode::ExprNode;
2304
2305 // Visitor methods
2306 33521 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitCustomDataType(this); }
2307 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitCustomDataType(this); }
2308
2309 // Other methods
2310 58892 GET_CHILDREN(templateTypeLst);
2311 42788 void customItemsInitialization(const size_t manifestationCount) override { customTypes.resize(manifestationCount); }
2312
2313 // Public members
2314 TypeLstNode *templateTypeLst = nullptr;
2315 std::string fqTypeName;
2316 std::vector<std::string> typeNameFragments;
2317 std::vector<SymbolTableEntry *> customTypes;
2318 };
2319
2320 // =================================================== FunctionDataTypeNode ======================================================
2321
2322 class FunctionDataTypeNode final : public ExprNode {
2323 public:
2324 // Constructors
2325 using ExprNode::ExprNode;
2326
2327 // Visitor methods
2328 159 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitFunctionDataType(this); }
2329 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitFunctionDataType(this); }
2330
2331 // Other methods
2332 222 GET_CHILDREN(returnType, paramTypeLst);
2333 175 void customItemsInitialization(const size_t manifestationCount) override { customTypes.resize(manifestationCount); }
2334
2335 // Public members
2336 DataTypeNode *returnType = nullptr;
2337 TypeLstNode *paramTypeLst = nullptr;
2338 bool isFunction = false; // Function or procedure
2339 std::vector<SymbolTableEntry *> customTypes;
2340 };
2341
2342 } // namespace spice::compiler
2343