GCC Code Coverage Report


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