GCC Code Coverage Report


Directory: ../
File: src/ast/ASTNodes.h
Date: 2025-08-26 18:26:32
Exec Total Coverage
Lines: 363 394 92.1%
Functions: 319 348 91.7%
Branches: 456 744 61.3%

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 1570347 explicit ASTNode(const CodeLoc &codeLoc) : codeLoc(codeLoc) {}
68 1570347 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 7690092 template <typename... Args> [[nodiscard]] ALWAYS_INLINE std::vector<ASTNode *> collectChildren(Args &&...args) const {
76 7690092 std::vector<ASTNode *> children;
77
78 // Lambda to handle each argument
79 10086568 [[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
214/268
✓ 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 7767 times.
✓ Branch 5 (3→6) taken 52012 times.
✓ Branch 6 (3→4) taken 59779 times.
✓ Branch 7 (3→6) taken 103856 times.
✓ Branch 8 (9→10) taken 222 times.
✓ Branch 9 (9→12) taken 163413 times.
✓ Branch 10 (3→4) taken 66469 times.
✓ Branch 11 (3→6) taken 97175 times.
✓ Branch 12 (9→10) taken 163644 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 869 times.
✓ Branch 34 (9→10) taken 888 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 2277 times.
✓ Branch 39 (3→6) taken 72698 times.
✓ Branch 40 (9→10) taken 58130 times.
✓ Branch 41 (9→12) taken 16845 times.
✓ Branch 42 (3→4) taken 86925 times.
✓ Branch 43 (3→6) taken 7047 times.
✓ Branch 44 (9→10) taken 220 times.
✓ Branch 45 (9→12) taken 93752 times.
✓ Branch 46 (15→16) taken 941 times.
✓ Branch 47 (15→18) taken 93031 times.
✓ Branch 48 (21→22) taken 36 times.
✓ Branch 49 (21→24) taken 93936 times.
✓ Branch 50 (27→28) taken 94 times.
✓ Branch 51 (27→30) taken 93878 times.
✓ Branch 52 (33→34) taken 3 times.
✓ Branch 53 (33→36) taken 93969 times.
✓ Branch 54 (39→40) taken 5753 times.
✓ Branch 55 (39→42) taken 88219 times.
✓ Branch 56 (3→4) taken 75702 times.
✓ Branch 57 (3→6) taken 366035 times.
✓ Branch 58 (9→10) taken 96303 times.
✓ Branch 59 (9→12) taken 345434 times.
✓ Branch 60 (15→16) taken 3631 times.
✓ Branch 61 (15→18) taken 438106 times.
✓ Branch 62 (21→22) taken 9737 times.
✓ Branch 63 (21→24) taken 432000 times.
✓ Branch 64 (3→4) taken 464950 times.
✓ Branch 65 (3→6) taken 116539 times.
✓ Branch 66 (9→10) taken 116539 times.
✓ Branch 67 (9→12) taken 464950 times.
✓ Branch 68 (15→16) taken 20726 times.
✓ Branch 69 (15→18) taken 560763 times.
✓ Branch 70 (3→4) taken 5480 times.
✓ Branch 71 (3→6) taken 453609 times.
✓ Branch 72 (9→10) taken 453609 times.
✓ Branch 73 (9→12) taken 5480 times.
✓ Branch 74 (3→4) taken 416653 times.
✓ Branch 75 (3→6) taken 12875 times.
✓ Branch 76 (9→10) taken 12875 times.
✓ Branch 77 (9→12) taken 416653 times.
✓ Branch 78 (15→16) taken 12875 times.
✓ Branch 79 (15→18) taken 416653 times.
✓ Branch 80 (3→4) taken 322924 times.
✗ Branch 81 (3→6) not taken.
✓ Branch 82 (9→10) taken 2183 times.
✓ Branch 83 (9→12) taken 320741 times.
✓ Branch 84 (15→16) taken 2189 times.
✓ Branch 85 (15→18) taken 320735 times.
✓ Branch 86 (3→4) taken 34682 times.
✓ Branch 87 (3→6) taken 324170 times.
✓ Branch 88 (9→10) taken 34682 times.
✓ Branch 89 (9→12) taken 324170 times.
✓ Branch 90 (15→16) taken 324170 times.
✓ Branch 91 (15→18) taken 34682 times.
✓ Branch 92 (3→4) taken 3989 times.
✗ Branch 93 (3→6) not taken.
✓ Branch 94 (3→4) taken 606 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 958 times.
✗ Branch 105 (3→6) not taken.
✓ Branch 106 (9→10) taken 958 times.
✗ Branch 107 (9→12) not taken.
✓ Branch 108 (3→4) taken 3276 times.
✓ Branch 109 (3→6) taken 6461 times.
✓ Branch 110 (9→10) taken 976 times.
✓ Branch 111 (9→12) taken 8761 times.
✓ Branch 112 (15→16) taken 44 times.
✓ Branch 113 (15→18) taken 9693 times.
✓ Branch 114 (21→22) taken 8 times.
✓ Branch 115 (21→24) taken 9729 times.
✓ Branch 116 (27→28) taken 638 times.
✓ Branch 117 (27→30) taken 9099 times.
✓ Branch 118 (33→34) taken 4791 times.
✓ Branch 119 (33→36) taken 4946 times.
✓ Branch 120 (39→40) taken 4 times.
✓ Branch 121 (39→42) taken 9733 times.
✓ Branch 122 (3→4) taken 2224 times.
✗ Branch 123 (3→6) not taken.
✓ Branch 124 (3→4) taken 42940 times.
✓ Branch 125 (3→6) taken 1021 times.
✓ Branch 126 (3→4) taken 36 times.
✓ Branch 127 (3→6) taken 200 times.
✓ Branch 128 (3→4) taken 3418 times.
✓ Branch 129 (3→6) taken 1357 times.
✓ Branch 130 (3→4) taken 34 times.
✗ Branch 131 (3→6) not taken.
✓ Branch 132 (3→4) taken 2058 times.
✗ Branch 133 (3→6) not taken.
✓ Branch 134 (3→4) taken 1690 times.
✗ Branch 135 (3→6) not taken.
✓ Branch 136 (3→4) taken 94198 times.
✗ Branch 137 (3→6) not taken.
✓ Branch 138 (3→4) taken 80075 times.
✗ Branch 139 (3→6) not taken.
✓ Branch 140 (9→10) taken 32338 times.
✓ Branch 141 (9→12) taken 47737 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 4739 times.
✗ Branch 151 (3→6) not taken.
✓ Branch 152 (9→10) taken 695 times.
✓ Branch 153 (9→12) taken 4044 times.
✓ Branch 154 (3→4) taken 1753 times.
✗ Branch 155 (3→6) not taken.
✓ Branch 156 (3→4) taken 84 times.
✗ Branch 157 (3→6) not taken.
✓ Branch 158 (3→4) taken 18 times.
✗ Branch 159 (3→6) not taken.
✓ Branch 160 (12→13) taken 168 times.
✗ Branch 161 (12→15) not taken.
✓ Branch 162 (3→4) taken 57 times.
✗ Branch 163 (3→6) not taken.
✓ Branch 164 (18→19) taken 30 times.
✓ Branch 165 (18→21) taken 27 times.
✓ Branch 166 (3→4) taken 209 times.
✓ Branch 167 (3→6) taken 518 times.
✓ Branch 168 (9→10) taken 518 times.
✓ Branch 169 (9→12) taken 209 times.
✓ Branch 170 (3→4) taken 15935 times.
✗ Branch 171 (3→6) not taken.
✓ Branch 172 (9→10) taken 15935 times.
✗ Branch 173 (9→12) not taken.
✓ Branch 174 (15→16) taken 727 times.
✓ Branch 175 (15→18) taken 15208 times.
✓ Branch 176 (3→4) taken 24 times.
✗ Branch 177 (3→6) not taken.
✓ Branch 178 (9→10) taken 24 times.
✗ Branch 179 (9→12) not taken.
✓ Branch 180 (3→4) taken 3112 times.
✗ Branch 181 (3→6) not taken.
✓ Branch 182 (9→10) taken 3112 times.
✗ Branch 183 (9→12) not taken.
✓ Branch 184 (3→4) taken 18 times.
✓ Branch 185 (3→6) taken 394 times.
✓ Branch 186 (9→10) taken 412 times.
✗ Branch 187 (9→12) not taken.
✓ Branch 188 (15→16) taken 412 times.
✗ Branch 189 (15→18) not taken.
✓ Branch 190 (21→22) taken 412 times.
✗ Branch 191 (21→24) not taken.
✓ Branch 192 (3→4) taken 5608 times.
✗ Branch 193 (3→6) not taken.
✓ Branch 194 (9→10) taken 5608 times.
✗ Branch 195 (9→12) not taken.
✓ Branch 196 (15→16) taken 5608 times.
✗ Branch 197 (15→18) not taken.
✓ Branch 198 (21→22) taken 5608 times.
✗ Branch 199 (21→24) not taken.
✓ Branch 200 (3→4) taken 12487 times.
✗ Branch 201 (3→6) not taken.
✓ Branch 202 (3→4) taken 1 times.
✓ Branch 203 (3→6) taken 1830 times.
✓ Branch 204 (9→10) taken 1221 times.
✓ Branch 205 (9→12) taken 610 times.
✓ Branch 206 (15→16) taken 1753 times.
✓ Branch 207 (15→18) taken 78 times.
✓ Branch 208 (3→4) taken 2293 times.
✗ Branch 209 (3→6) not taken.
✓ Branch 210 (9→10) taken 2291 times.
✓ Branch 211 (9→12) taken 2 times.
✓ Branch 212 (3→4) taken 38 times.
✓ Branch 213 (3→6) taken 85 times.
✓ Branch 214 (9→10) taken 123 times.
✗ Branch 215 (9→12) not taken.
✓ Branch 216 (3→4) taken 1589 times.
✗ Branch 217 (3→6) not taken.
✓ Branch 218 (3→4) taken 104 times.
✓ Branch 219 (3→6) taken 16 times.
✓ Branch 220 (9→10) taken 120 times.
✗ Branch 221 (9→12) not taken.
✓ Branch 222 (3→4) taken 118 times.
✓ Branch 223 (3→6) taken 35 times.
✓ Branch 224 (9→10) taken 138 times.
✓ Branch 225 (9→12) taken 15 times.
✓ Branch 226 (15→16) taken 121 times.
✓ Branch 227 (15→18) taken 32 times.
✓ Branch 228 (3→4) taken 209 times.
✓ Branch 229 (3→6) taken 2495 times.
✓ Branch 230 (9→10) taken 2206 times.
✓ Branch 231 (9→12) taken 498 times.
✓ Branch 232 (15→16) taken 940 times.
✓ Branch 233 (15→18) taken 1764 times.
✓ Branch 234 (21→22) taken 501 times.
✓ Branch 235 (21→24) taken 2203 times.
✗ Branch 236 (3→4) not taken.
✓ Branch 237 (3→6) taken 14003 times.
✓ Branch 238 (9→10) taken 12383 times.
✓ Branch 239 (9→12) taken 1620 times.
✓ Branch 240 (15→16) taken 14003 times.
✗ Branch 241 (15→18) not taken.
✓ Branch 242 (21→22) taken 4134 times.
✓ Branch 243 (21→24) taken 9869 times.
✓ Branch 244 (27→28) taken 10526 times.
✓ Branch 245 (27→30) taken 3477 times.
✓ Branch 246 (33→34) taken 14003 times.
✗ Branch 247 (33→36) not taken.
✓ Branch 248 (3→4) taken 1317 times.
✓ Branch 249 (3→6) taken 27138 times.
✓ Branch 250 (9→10) taken 28001 times.
✓ Branch 251 (9→12) taken 454 times.
✓ Branch 252 (15→16) taken 28455 times.
✗ Branch 253 (15→18) not taken.
✓ Branch 254 (21→22) taken 28455 times.
✗ Branch 255 (21→24) not taken.
✓ Branch 256 (27→28) taken 3376 times.
✓ Branch 257 (27→30) taken 25079 times.
✓ Branch 258 (33→34) taken 22332 times.
✓ Branch 259 (33→36) taken 6123 times.
✓ Branch 260 (39→40) taken 28455 times.
✗ Branch 261 (39→42) not taken.
✗ Branch 262 (3→4) not taken.
✓ Branch 263 (3→6) taken 744 times.
✓ Branch 264 (9→10) taken 8 times.
✓ Branch 265 (9→12) taken 736 times.
✓ Branch 266 (15→16) taken 744 times.
✗ Branch 267 (15→18) not taken.
10086568 if (arg != nullptr)
83
131/268
✓ 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 7767 times.
✗ Branch 5 (4→7) not taken.
✓ Branch 6 (4→5) taken 59779 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 66469 times.
✗ Branch 11 (4→7) not taken.
✓ Branch 12 (10→11) taken 163644 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 888 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 2277 times.
✗ Branch 39 (4→7) not taken.
✓ Branch 40 (10→11) taken 58130 times.
✗ Branch 41 (10→13) not taken.
✓ Branch 42 (4→5) taken 86925 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 941 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 5753 times.
✗ Branch 55 (40→43) not taken.
✓ Branch 56 (4→5) taken 75702 times.
✗ Branch 57 (4→7) not taken.
✓ Branch 58 (10→11) taken 96303 times.
✗ Branch 59 (10→13) not taken.
✓ Branch 60 (16→17) taken 3631 times.
✗ Branch 61 (16→19) not taken.
✓ Branch 62 (22→23) taken 9737 times.
✗ Branch 63 (22→25) not taken.
✓ Branch 64 (4→5) taken 464950 times.
✗ Branch 65 (4→7) not taken.
✓ Branch 66 (10→11) taken 116539 times.
✗ Branch 67 (10→13) not taken.
✓ Branch 68 (16→17) taken 20726 times.
✗ Branch 69 (16→19) not taken.
✓ Branch 70 (4→5) taken 5480 times.
✗ Branch 71 (4→7) not taken.
✓ Branch 72 (10→11) taken 453609 times.
✗ Branch 73 (10→13) not taken.
✓ Branch 74 (4→5) taken 416653 times.
✗ Branch 75 (4→7) not taken.
✓ Branch 76 (10→11) taken 12875 times.
✗ Branch 77 (10→13) not taken.
✓ Branch 78 (16→17) taken 12875 times.
✗ Branch 79 (16→19) not taken.
✓ Branch 80 (4→5) taken 322924 times.
✗ Branch 81 (4→7) not taken.
✓ Branch 82 (10→11) taken 2183 times.
✗ Branch 83 (10→13) not taken.
✓ Branch 84 (16→17) taken 2189 times.
✗ Branch 85 (16→19) not taken.
✓ Branch 86 (4→5) taken 34682 times.
✗ Branch 87 (4→7) not taken.
✓ Branch 88 (10→11) taken 34682 times.
✗ Branch 89 (10→13) not taken.
✓ Branch 90 (16→17) taken 324170 times.
✗ Branch 91 (16→19) not taken.
✓ Branch 92 (4→5) taken 3989 times.
✗ Branch 93 (4→7) not taken.
✓ Branch 94 (4→5) taken 606 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 958 times.
✗ Branch 105 (4→7) not taken.
✓ Branch 106 (10→11) taken 958 times.
✗ Branch 107 (10→13) not taken.
✓ Branch 108 (4→5) taken 3276 times.
✗ Branch 109 (4→7) not taken.
✓ Branch 110 (10→11) taken 976 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 638 times.
✗ Branch 117 (28→31) not taken.
✓ Branch 118 (34→35) taken 4791 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 2224 times.
✗ Branch 123 (4→7) not taken.
✓ Branch 124 (4→5) taken 42940 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 3418 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 2058 times.
✗ Branch 133 (4→7) not taken.
✓ Branch 134 (4→5) taken 1690 times.
✗ Branch 135 (4→7) not taken.
✓ Branch 136 (4→5) taken 94198 times.
✗ Branch 137 (4→7) not taken.
✓ Branch 138 (4→5) taken 80075 times.
✗ Branch 139 (4→7) not taken.
✓ Branch 140 (10→11) taken 32338 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 4739 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 1753 times.
✗ Branch 155 (4→7) not taken.
✓ Branch 156 (4→5) taken 84 times.
✗ Branch 157 (4→7) not taken.
✓ Branch 158 (4→5) taken 18 times.
✗ Branch 159 (4→7) not taken.
✓ Branch 160 (13→14) taken 168 times.
✗ Branch 161 (13→16) not taken.
✓ Branch 162 (4→5) taken 57 times.
✗ Branch 163 (4→7) not taken.
✓ Branch 164 (19→20) taken 30 times.
✗ Branch 165 (19→22) not taken.
✓ Branch 166 (4→5) taken 209 times.
✗ Branch 167 (4→7) not taken.
✓ Branch 168 (10→11) taken 518 times.
✗ Branch 169 (10→13) not taken.
✓ Branch 170 (4→5) taken 15935 times.
✗ Branch 171 (4→7) not taken.
✓ Branch 172 (10→11) taken 15935 times.
✗ Branch 173 (10→13) not taken.
✓ Branch 174 (16→17) taken 727 times.
✗ Branch 175 (16→19) not taken.
✓ Branch 176 (4→5) taken 24 times.
✗ Branch 177 (4→7) not taken.
✓ Branch 178 (10→11) taken 24 times.
✗ Branch 179 (10→13) not taken.
✓ Branch 180 (4→5) taken 3112 times.
✗ Branch 181 (4→7) not taken.
✓ Branch 182 (10→11) taken 3112 times.
✗ Branch 183 (10→13) not taken.
✓ Branch 184 (4→5) taken 18 times.
✗ Branch 185 (4→7) not taken.
✓ Branch 186 (10→11) taken 412 times.
✗ Branch 187 (10→13) not taken.
✓ Branch 188 (16→17) taken 412 times.
✗ Branch 189 (16→19) not taken.
✓ Branch 190 (22→23) taken 412 times.
✗ Branch 191 (22→25) not taken.
✓ Branch 192 (4→5) taken 5608 times.
✗ Branch 193 (4→7) not taken.
✓ Branch 194 (10→11) taken 5608 times.
✗ Branch 195 (10→13) not taken.
✓ Branch 196 (16→17) taken 5608 times.
✗ Branch 197 (16→19) not taken.
✓ Branch 198 (22→23) taken 5608 times.
✗ Branch 199 (22→25) not taken.
✓ Branch 200 (4→5) taken 12487 times.
✗ Branch 201 (4→7) not taken.
✓ Branch 202 (4→5) taken 1 times.
✗ Branch 203 (4→7) not taken.
✓ Branch 204 (10→11) taken 1221 times.
✗ Branch 205 (10→13) not taken.
✓ Branch 206 (16→17) taken 1753 times.
✗ Branch 207 (16→19) not taken.
✓ Branch 208 (4→5) taken 2293 times.
✗ Branch 209 (4→7) not taken.
✓ Branch 210 (10→11) taken 2291 times.
✗ Branch 211 (10→13) not taken.
✓ Branch 212 (4→5) taken 38 times.
✗ Branch 213 (4→7) not taken.
✓ Branch 214 (10→11) taken 123 times.
✗ Branch 215 (10→13) not taken.
✓ Branch 216 (4→5) taken 1589 times.
✗ Branch 217 (4→7) not taken.
✓ Branch 218 (4→5) taken 104 times.
✗ Branch 219 (4→7) not taken.
✓ Branch 220 (10→11) taken 120 times.
✗ Branch 221 (10→13) not taken.
✓ Branch 222 (4→5) taken 118 times.
✗ Branch 223 (4→7) not taken.
✓ Branch 224 (10→11) taken 138 times.
✗ Branch 225 (10→13) not taken.
✓ Branch 226 (16→17) taken 121 times.
✗ Branch 227 (16→19) not taken.
✓ Branch 228 (4→5) taken 209 times.
✗ Branch 229 (4→7) not taken.
✓ Branch 230 (10→11) taken 2206 times.
✗ Branch 231 (10→13) not taken.
✓ Branch 232 (16→17) taken 940 times.
✗ Branch 233 (16→19) not taken.
✓ Branch 234 (22→23) taken 501 times.
✗ Branch 235 (22→25) not taken.
✗ Branch 236 (4→5) not taken.
✗ Branch 237 (4→7) not taken.
✓ Branch 238 (10→11) taken 12383 times.
✗ Branch 239 (10→13) not taken.
✓ Branch 240 (16→17) taken 14003 times.
✗ Branch 241 (16→19) not taken.
✓ Branch 242 (22→23) taken 4134 times.
✗ Branch 243 (22→25) not taken.
✓ Branch 244 (28→29) taken 10526 times.
✗ Branch 245 (28→31) not taken.
✓ Branch 246 (34→35) taken 14003 times.
✗ Branch 247 (34→37) not taken.
✓ Branch 248 (4→5) taken 1317 times.
✗ Branch 249 (4→7) not taken.
✓ Branch 250 (10→11) taken 28001 times.
✗ Branch 251 (10→13) not taken.
✓ Branch 252 (16→17) taken 28455 times.
✗ Branch 253 (16→19) not taken.
✓ Branch 254 (22→23) taken 28455 times.
✗ Branch 255 (22→25) not taken.
✓ Branch 256 (28→29) taken 3376 times.
✗ Branch 257 (28→31) not taken.
✓ Branch 258 (34→35) taken 22332 times.
✗ Branch 259 (34→37) not taken.
✓ Branch 260 (40→41) taken 28455 times.
✗ Branch 261 (40→43) not taken.
✗ Branch 262 (4→5) not taken.
✗ Branch 263 (4→7) not taken.
✓ Branch 264 (10→11) taken 8 times.
✗ Branch 265 (10→13) not taken.
✓ Branch 266 (16→17) taken 744 times.
✗ Branch 267 (16→19) not taken.
3432843 children.push_back(arg);
84 } else if constexpr (is_vector_of_derived_from_v<TDecayed, ASTNode>) {
85
27/54
✓ Branch 0 (7→8) taken 422045 times.
✗ Branch 1 (7→9) not taken.
✓ Branch 2 (7→8) taken 394188 times.
✗ Branch 3 (7→9) not taken.
✓ Branch 4 (7→8) taken 393946 times.
✗ Branch 5 (7→9) not taken.
✓ Branch 6 (7→8) taken 369758 times.
✗ Branch 7 (7→9) not taken.
✓ Branch 8 (7→8) taken 338476 times.
✗ Branch 9 (7→9) not taken.
✓ Branch 10 (7→8) taken 338673 times.
✗ Branch 11 (7→9) not taken.
✓ Branch 12 (7→8) taken 338625 times.
✗ Branch 13 (7→9) not taken.
✓ Branch 14 (7→8) taken 338224 times.
✗ Branch 15 (7→9) not taken.
✓ Branch 16 (7→8) taken 336795 times.
✗ Branch 17 (7→9) not taken.
✓ Branch 18 (7→8) taken 329200 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 3276 times.
✗ Branch 23 (7→9) not taken.
✓ Branch 24 (7→8) taken 3782 times.
✗ Branch 25 (7→9) not taken.
✓ Branch 26 (7→8) taken 109354 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 59217 times.
✗ Branch 31 (7→9) not taken.
✓ Branch 32 (7→8) taken 40922 times.
✗ Branch 33 (7→9) not taken.
✓ Branch 34 (7→8) taken 1589 times.
✗ Branch 35 (7→9) not taken.
✓ Branch 36 (7→8) taken 21246 times.
✗ Branch 37 (7→9) not taken.
✓ Branch 38 (7→8) taken 98566 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 2704 times.
✗ Branch 47 (31→33) not taken.
✓ Branch 48 (7→8) taken 6007 times.
✗ Branch 49 (7→9) not taken.
✓ Branch 50 (16→17) taken 6007 times.
✗ Branch 51 (16→18) not taken.
✓ Branch 52 (25→26) taken 6007 times.
✗ Branch 53 (25→27) not taken.
3959175 children.insert(children.end(), arg.begin(), arg.end());
86 } else {
87 static_assert(false, "Unsupported type");
88 }
89 };
90
91 6608473 (addChild(std::forward<Args>(args)), ...);
92 7437270 return children;
93 }
94
95 [[nodiscard]] virtual std::vector<ASTNode *> getChildren() const = 0;
96
97 4601028 virtual void resizeToNumberOfManifestations(size_t manifestationCount){ // NOLINT(misc-no-recursion)
98 // Resize children
99
3/4
✓ Branch 0 (2→3) taken 4601028 times.
✗ Branch 1 (2→17) not taken.
✓ Branch 2 (11→5) taken 4576812 times.
✓ Branch 3 (11→12) taken 4601028 times.
9177840 for (ASTNode *child : getChildren()) {
100
1/2
✗ Branch 0 (6→7) not taken.
✓ Branch 1 (6→8) taken 4576812 times.
4576812 assert(child != nullptr);
101
1/2
✓ Branch 0 (8→9) taken 4576812 times.
✗ Branch 1 (8→15) not taken.
4576812 child->resizeToNumberOfManifestations(manifestationCount);
102 4601028 }
103 // Do custom work
104 4601028 customItemsInitialization(manifestationCount);
105 4601028 }
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 2688760 virtual void customItemsInitialization(size_t) {} // Noop
117
118 16851 [[nodiscard]] virtual bool hasCompileTimeValue() const { // NOLINT(misc-no-recursion)
119
1/2
✓ Branch 0 (2→3) taken 16851 times.
✗ Branch 1 (2→14) not taken.
16851 const std::vector<ASTNode *> children = getChildren();
120
2/2
✓ Branch 0 (4→5) taken 5524 times.
✓ Branch 1 (4→6) taken 11327 times.
16851 if (children.size() != 1)
121 5524 return false;
122
1/2
✓ Branch 0 (7→8) taken 11327 times.
✗ Branch 1 (7→12) not taken.
11327 return children.front()->hasCompileTimeValue();
123 16851 }
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 134870 [[nodiscard]] virtual bool returnsOnAllControlPaths(bool *doSetPredecessorsUnreachable) const { // NOLINT(misc-no-recursion)
135
1/2
✓ Branch 0 (2→3) taken 134870 times.
✗ Branch 1 (2→16) not taken.
134870 const std::vector<ASTNode *> children = getChildren();
136
5/6
✓ Branch 0 (4→5) taken 126020 times.
✓ Branch 1 (4→9) taken 8850 times.
✓ Branch 2 (6→7) taken 126020 times.
✗ Branch 3 (6→14) not taken.
✓ Branch 4 (7→8) taken 14525 times.
✓ Branch 5 (7→9) taken 111495 times.
269740 return children.size() == 1 && children.front()->returnsOnAllControlPaths(doSetPredecessorsUnreachable);
137 134870 }
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 155216 [[nodiscard]] virtual bool isFctOrProcDef() const { return false; }
157 128589 [[nodiscard]] virtual bool isStructDef() const { return false; }
158 12 [[nodiscard]] virtual bool isParam() const { return false; }
159 11229 [[nodiscard]] virtual bool isStmtLst() const { return false; }
160 140470 [[nodiscard]] virtual bool isAssignExpr() const { return false; }
161 6833 [[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 5202 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitEntry(this); }
181 831 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitEntry(this); }
182
183 // Other methods
184 6007 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 4050627 void resizeToNumberOfManifestations(size_t manifestationCount) override {
235 // Reserve this node
236
2/4
✓ Branch 0 (2→3) taken 4050627 times.
✗ Branch 1 (2→6) not taken.
✓ Branch 2 (3→4) taken 4050627 times.
✗ Branch 3 (3→6) not taken.
4050627 symbolTypes.resize(manifestationCount, QualType(TY_INVALID));
237 // Call parent
238 4050627 ASTNode::resizeToNumberOfManifestations(manifestationCount);
239 4050627 }
240
241 315185 QualType setEvaluatedSymbolType(const QualType &symbolType, const size_t idx) {
242
1/2
✗ Branch 0 (3→4) not taken.
✓ Branch 1 (3→5) taken 315185 times.
315185 assert(symbolTypes.size() > idx);
243 315185 symbolTypes.at(idx) = symbolType;
244 315185 return symbolType;
245 }
246
247 335741 [[nodiscard]] const QualType &getEvaluatedSymbolType(const size_t idx) const { // NOLINT(misc-no-recursion)
248
7/10
✓ Branch 0 (3→4) taken 335741 times.
✗ Branch 1 (3→8) not taken.
✓ Branch 2 (4→5) taken 335741 times.
✗ Branch 3 (4→47) not taken.
✓ Branch 4 (5→6) taken 335741 times.
✗ Branch 5 (5→47) not taken.
✓ Branch 6 (6→7) taken 138921 times.
✓ Branch 7 (6→8) taken 196820 times.
✓ Branch 8 (9→10) taken 138921 times.
✓ Branch 9 (9→12) taken 196820 times.
335741 if (!symbolTypes.empty() && !symbolTypes.at(idx).is(TY_INVALID))
249
1/2
✓ Branch 0 (10→11) taken 138921 times.
✗ Branch 1 (10→47) not taken.
138921 return symbolTypes.at(idx);
250
1/2
✓ Branch 0 (12→13) taken 196820 times.
✗ Branch 1 (12→47) not taken.
196820 const std::vector<ASTNode *> children = getChildren();
251
1/2
✗ Branch 0 (14→15) not taken.
✓ Branch 1 (14→23) taken 196820 times.
196820 if (children.size() != 1)
252 throw CompilerError(INTERNAL_ERROR, "Cannot deduce evaluated symbol type");
253
1/2
✓ Branch 0 (24→25) taken 196820 times.
✗ Branch 1 (24→26) not taken.
196820 const auto expr = spice_pointer_cast<ExprNode *>(children.front());
254
1/2
✓ Branch 0 (31→32) taken 196820 times.
✗ Branch 1 (31→45) not taken.
196820 return expr->getEvaluatedSymbolType(idx);
255 196820 }
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 1153 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitMainFctDef(this); }
274 229 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitMainFctDef(this); }
275
276 // Other methods
277 744 GET_CHILDREN(attrs, paramLst, body);
278
1/2
✓ Branch 0 (4→5) taken 378 times.
✗ Branch 1 (4→8) not taken.
1134 [[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 10205 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 42458 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 20825 [[nodiscard]] std::string getSymbolTableEntryName() const { return Function::getSymbolTableEntryName(name->name, codeLoc); }
323 1755 std::vector<Function *> *getFctManifestations(const std::string &) override { return &manifestations; }
324 608611 [[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 35436 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitFctDef(this); }
353 6516 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitFctDef(this); }
354
355 // Other methods
356 28455 GET_CHILDREN(attrs, qualifierLst, returnType, name, templateTypeLst, paramLst, body);
357
2/4
✓ Branch 0 (2→3) taken 14628 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 14628 times.
✗ Branch 3 (3→8) not taken.
14628 [[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 17441 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitProcDef(this); }
372 3175 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitProcDef(this); }
373
374 // Other methods
375 14003 GET_CHILDREN(attrs, qualifierLst, name, templateTypeLst, paramLst, body);
376
2/4
✓ Branch 0 (2→3) taken 7027 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 7027 times.
✗ Branch 3 (3→8) not taken.
7027 [[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 2705 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitStructDef(this); }
391 523 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitStructDef(this); }
392
393 // Other methods
394 2704 GET_CHILDREN(attrs, qualifierLst, templateTypeLst, interfaceTypeLst, fields);
395 25800 std::vector<Struct *> *getStructManifestations() override { return &structManifestations; }
396 408 std::vector<Function *> *getFctManifestations(const std::string &fctName) override {
397
2/2
✓ Branch 0 (3→4) taken 288 times.
✓ Branch 1 (3→10) taken 120 times.
408 if (!defaultFctManifestations.contains(fctName))
398
2/4
✓ Branch 0 (5→6) taken 288 times.
✗ Branch 1 (5→15) not taken.
✓ Branch 2 (6→7) taken 288 times.
✗ Branch 3 (6→13) not taken.
288 defaultFctManifestations.insert({fctName, {}});
399 408 return &defaultFctManifestations.at(fctName);
400 }
401 28105 [[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 4121 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitGenericTypeDef(this); }
483 738 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitGenericTypeDef(this); }
484
485 // Other methods
486 1589 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 291 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitAliasDef(this); }
503 64 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitAliasDef(this); }
504
505 // Other methods
506 123 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 4966 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitGlobalVarDef(this); }
528 1131 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 2293 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 4541 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitExtDecl(this); }
554 886 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitExtDecl(this); }
555
556 // Other methods
557 1831 GET_CHILDREN(attrs, returnType, argTypeLst);
558 77 std::vector<Function *> *getFctManifestations(const std::string &) override { return &extFunctionManifestations; }
559 1840 [[nodiscard]] std::string getScopeId() const {
560
1/2
✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 1840 times.
1840 const char *prefix = hasReturnType ? "func:" : "proc:";
561
2/4
✓ Branch 0 (5→6) taken 1840 times.
✗ Branch 1 (5→13) not taken.
✓ Branch 2 (6→7) taken 1840 times.
✗ Branch 3 (6→11) not taken.
1840 return prefix + codeLoc.toString();
562 }
563
564 // Public members
565 TopLevelDefinitionAttrNode *attrs = nullptr;
566 DataTypeNode *returnType = nullptr;
567 TypeLstWithEllipsisNode *argTypeLst = nullptr;
568 bool hasArgs = false;
569 bool hasReturnType = false;
570 std::string extFunctionName;
571 SymbolTableEntry *entry = nullptr;
572 Function *extFunction = nullptr;
573 std::vector<Function *> extFunctionManifestations;
574 };
575
576 // ======================================================== ImportDefNode ========================================================
577
578 class ImportDefNode final : public TopLevelDefNode {
579 public:
580 // Constructors
581 using TopLevelDefNode::TopLevelDefNode;
582
583 // Visitor methods
584 2866 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitImportDef(this); }
585 487 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitImportDef(this); }
586
587 // Other methods
588 1913 GET_CHILDREN();
589
590 // Public members
591 std::string importPath;
592 std::string importName;
593 SymbolTableEntry *entry = nullptr;
594 };
595
596 // ======================================================== UnsafeBlockNode ======================================================
597
598 class UnsafeBlockNode final : public StmtNode {
599 public:
600 // Constructors
601 using StmtNode::StmtNode;
602
603 // Visitor methods
604 6661 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitUnsafeBlock(this); }
605 1884 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitUnsafeBlockDef(this); }
606
607 // Other methods
608 12487 GET_CHILDREN(body);
609
2/4
✓ Branch 0 (2→3) taken 6236 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 6236 times.
✗ Branch 3 (3→8) not taken.
6236 [[nodiscard]] std::string getScopeId() const { return "unsafe:" + codeLoc.toString(); }
610
611 // Public members
612 StmtLstNode *body = nullptr;
613 Scope *bodyScope = nullptr;
614 };
615
616 // ========================================================== ForLoopNode ========================================================
617
618 class ForLoopNode final : public StmtNode {
619 public:
620 // Constructors
621 using StmtNode::StmtNode;
622
623 // Visitor methods
624 3633 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitForLoop(this); }
625 1110 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitForLoop(this); }
626
627 // Other methods
628 5608 GET_CHILDREN(initDecl, condAssign, incAssign, body);
629
2/4
✓ Branch 0 (2→3) taken 3556 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 3556 times.
✗ Branch 3 (3→8) not taken.
3556 [[nodiscard]] std::string getScopeId() const { return "for:" + codeLoc.toString(); }
630 [[nodiscard]] bool returnsOnAllControlPaths(bool *doSetPredecessorsUnreachable) const override;
631
632 // Public members
633 DeclStmtNode *initDecl = nullptr;
634 AssignExprNode *condAssign = nullptr;
635 AssignExprNode *incAssign = nullptr;
636 StmtLstNode *body = nullptr;
637 Scope *bodyScope = nullptr;
638 };
639
640 // ======================================================== ForeachLoopNode ======================================================
641
642 class ForeachLoopNode final : public StmtNode {
643 public:
644 // Constructors
645 using StmtNode::StmtNode;
646
647 // Visitor methods
648 267 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitForeachLoop(this); }
649 100 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitForeachLoop(this); }
650
651 // Other methods
652 412 GET_CHILDREN(idxVarDecl, itemVarDecl, iteratorAssign, body);
653
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(); }
654
655 // Public members
656 DeclStmtNode *idxVarDecl = nullptr;
657 DeclStmtNode *itemVarDecl = nullptr;
658 AssignExprNode *iteratorAssign = nullptr;
659 StmtLstNode *body = nullptr;
660 Scope *bodyScope = nullptr;
661 Function *getIteratorFct = nullptr;
662 Function *getFct = nullptr;
663 Function *getIdxFct = nullptr;
664 Function *isValidFct = nullptr;
665 Function *nextFct = nullptr;
666 };
667
668 // ========================================================= WhileLoopNode =======================================================
669
670 class WhileLoopNode final : public StmtNode {
671 public:
672 // Constructors
673 using StmtNode::StmtNode;
674
675 // Visitor methods
676 2049 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitWhileLoop(this); }
677 623 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitWhileLoop(this); }
678
679 // Other methods
680 3112 GET_CHILDREN(condition, body);
681
2/4
✓ Branch 0 (2→3) taken 1998 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 1998 times.
✗ Branch 3 (3→8) not taken.
1998 [[nodiscard]] std::string getScopeId() const { return "while:" + codeLoc.toString(); }
682 [[nodiscard]] bool returnsOnAllControlPaths(bool *doSetPredecessorsUnreachable) const override;
683
684 // Public members
685 AssignExprNode *condition = nullptr;
686 StmtLstNode *body = nullptr;
687 Scope *bodyScope = nullptr;
688 };
689
690 // ======================================================== DoWhileLoopNode ======================================================
691
692 class DoWhileLoopNode final : public StmtNode {
693 public:
694 // Constructors
695 using StmtNode::StmtNode;
696
697 // Visitor methods
698 21 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitDoWhileLoop(this); }
699 8 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitDoWhileLoop(this); }
700
701 // Other methods
702 24 GET_CHILDREN(body, condition);
703
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(); }
704 [[nodiscard]] bool returnsOnAllControlPaths(bool *doSetPredecessorsUnreachable) const override;
705
706 // Public members
707 StmtLstNode *body = nullptr;
708 AssignExprNode *condition = nullptr;
709 Scope *bodyScope = nullptr;
710 };
711
712 // ========================================================== IfStmtNode =========================================================
713
714 class IfStmtNode final : public StmtNode {
715 public:
716 // Constructors
717 using StmtNode::StmtNode;
718
719 // Visitor methods
720 11197 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitIfStmt(this); }
721 3702 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitIfStmt(this); }
722
723 // Other methods
724 15935 GET_CHILDREN(condition, thenBody, elseStmt);
725
2/4
✓ Branch 0 (2→3) taken 11310 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 11310 times.
✗ Branch 3 (3→8) not taken.
11310 [[nodiscard]] std::string getScopeId() const { return "if:" + codeLoc.toString(); }
726 [[nodiscard]] bool returnsOnAllControlPaths(bool *doSetPredecessorsUnreachable) const override;
727
728 // Public members
729 AssignExprNode *condition = nullptr;
730 StmtLstNode *thenBody = nullptr;
731 ElseStmtNode *elseStmt = nullptr;
732 Scope *thenBodyScope = nullptr;
733 };
734
735 // ========================================================= ElseStmtNode ========================================================
736
737 class ElseStmtNode final : public StmtNode {
738 public:
739 // Constructors
740 using StmtNode::StmtNode;
741
742 // Visitor methods
743 489 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitElseStmt(this); }
744 147 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitElseStmt(this); }
745
746 // Other methods
747 727 GET_CHILDREN(ifStmt, body);
748
2/4
✓ Branch 0 (2→3) taken 333 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 333 times.
✗ Branch 3 (3→8) not taken.
333 [[nodiscard]] std::string getScopeId() const { return "if:" + codeLoc.toString(); }
749 [[nodiscard]] bool returnsOnAllControlPaths(bool *doSetPredecessorsUnreachable) const override;
750
751 // Public members
752 bool isElseIf = false;
753 IfStmtNode *ifStmt = nullptr;
754 StmtLstNode *body = nullptr;
755 Scope *elseBodyScope = nullptr;
756 };
757
758 // ======================================================== SwitchStmtNode =======================================================
759
760 class SwitchStmtNode final : public StmtNode {
761 public:
762 // Constructors
763 using StmtNode::StmtNode;
764
765 // Visitor methods
766 29 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitSwitchStmt(this); }
767 8 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitSwitchStmt(this); }
768
769 // Other methods
770 57 GET_CHILDREN(assignExpr, caseBranches, defaultBranch);
771 [[nodiscard]] bool returnsOnAllControlPaths(bool *doSetPredecessorsUnreachable) const override;
772
773 // Public members
774 AssignExprNode *assignExpr = nullptr;
775 std::vector<CaseBranchNode *> caseBranches;
776 DefaultBranchNode *defaultBranch = nullptr;
777 bool hasDefaultBranch = false;
778 };
779
780 // ======================================================== CaseBranchNode =======================================================
781
782 class CaseBranchNode final : public ASTNode {
783 public:
784 // Constructors
785 using ASTNode::ASTNode;
786
787 // Visitor methods
788 137 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitCaseBranch(this); }
789 49 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitCaseBranch(this); }
790
791 // Other methods
792 168 GET_CHILDREN(caseConstants, body);
793
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(); }
794 [[nodiscard]] bool returnsOnAllControlPaths(bool *doSetPredecessorsUnreachable) const override;
795
796 // Public members
797 std::vector<CaseConstantNode *> caseConstants;
798 StmtLstNode *body = nullptr;
799 Scope *bodyScope = nullptr;
800 };
801
802 // ======================================================= DefaultBranchNode =====================================================
803
804 class DefaultBranchNode final : public ASTNode {
805 public:
806 // Constructors
807 using ASTNode::ASTNode;
808
809 // Visitor methods
810 15 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitDefaultBranch(this); }
811 4 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitDefaultBranch(this); }
812
813 // Other methods
814 18 GET_CHILDREN(body);
815
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(); }
816 [[nodiscard]] bool returnsOnAllControlPaths(bool *doSetPredecessorsUnreachable) const override;
817
818 // Public members
819 StmtLstNode *body = nullptr;
820 Scope *bodyScope = nullptr;
821 };
822
823 // ==================================================== AnonymousBlockStmtNode ===================================================
824
825 class AnonymousBlockStmtNode final : public StmtNode {
826 public:
827 // Constructors
828 using StmtNode::StmtNode;
829
830 // Visitor methods
831 56 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitAnonymousBlockStmt(this); }
832 28 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitAnonymousBlockStmt(this); }
833
834 // Other methods
835 84 GET_CHILDREN(body);
836
2/4
✓ Branch 0 (2→3) taken 84 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 84 times.
✗ Branch 3 (3→8) not taken.
84 [[nodiscard]] std::string getScopeId() const { return "anon:" + codeLoc.toString(); }
837
838 // Public members
839 StmtLstNode *body = nullptr;
840 Scope *bodyScope = nullptr;
841 };
842
843 // ========================================================= StmtLstNode =========================================================
844
845 class StmtLstNode final : public ASTNode {
846 public:
847 // Structs
848 struct ResourcesForManifestationToCleanup {
849 std::vector<std::pair<SymbolTableEntry *, Function *>> dtorFunctionsToCall;
850 std::vector<SymbolTableEntry *> heapVarsToFree;
851 };
852
853 // Constructors
854 using ASTNode::ASTNode;
855
856 // Visitor methods
857 55339 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitStmtLst(this); }
858 16897 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitStmtLst(this); }
859
860 // Other methods
861 98566 GET_CHILDREN(statements);
862 [[nodiscard]] bool returnsOnAllControlPaths(bool *doSetPredecessorsUnreachable) const override;
863 61322 void customItemsInitialization(const size_t manifestationCount) override { resourcesToCleanup.resize(manifestationCount); }
864 17488 [[nodiscard]] bool isStmtLst() const override { return true; }
865
866 // Public members
867 std::vector<StmtNode *> statements;
868 size_t complexity = 0;
869 std::vector<ResourcesForManifestationToCleanup> resourcesToCleanup;
870 CodeLoc closingBraceCodeLoc = CodeLoc(1, 0);
871 };
872
873 // ========================================================= TypeLstNode =========================================================
874
875 class TypeLstNode final : public ASTNode {
876 public:
877 // Constructors
878 using ASTNode::ASTNode;
879
880 // Visitor methods
881 6477 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitTypeLst(this); }
882 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitTypeLst(this); }
883
884 // Other methods
885 21246 GET_CHILDREN(dataTypes);
886
887 // Public members
888 std::vector<DataTypeNode *> dataTypes;
889 };
890
891 // =================================================== TypeLstWithEllipsisNode ===================================================
892
893 class TypeLstWithEllipsisNode final : public ASTNode {
894 public:
895 // Constructors
896 using ASTNode::ASTNode;
897
898 // Visitor methods
899 873 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitTypeLstWithEllipsis(this); }
900 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitTypeLstWithEllipsis(this); }
901
902 // Other methods
903 1753 GET_CHILDREN(typeLst);
904
905 // Public members
906 TypeLstNode *typeLst;
907 bool hasEllipsis = false;
908 };
909
910 // ======================================================= TypeAltsLstNode =======================================================
911
912 class TypeAltsLstNode final : public ASTNode {
913 public:
914 // Constructors
915 using ASTNode::ASTNode;
916
917 // Visitor methods
918 776 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitTypeAltsLst(this); }
919 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitTypeAltsLst(this); }
920
921 // Other methods
922 1589 GET_CHILDREN(dataTypes);
923
924 // Public members
925 std::vector<DataTypeNode *> dataTypes;
926 };
927
928 // ======================================================== ParamLstNode =========================================================
929
930 class ParamLstNode final : public ASTNode {
931 public:
932 // Constructors
933 using ASTNode::ASTNode;
934
935 // Visitor methods
936 31252 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitParamLst(this); }
937 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitParamLst(this); }
938
939 // Other methods
940 40922 GET_CHILDREN(params);
941
942 // Public members
943 std::vector<DeclStmtNode *> params;
944 };
945
946 // ========================================================== ArgLstNode =========================================================
947
948 class ArgLstNode final : public ASTNode {
949 public:
950 // Structs
951 struct ArgInfo {
952 Function *copyCtor = nullptr;
953 };
954
955 // Constructors
956 using ASTNode::ASTNode;
957
958 // Visitor methods
959 21568 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitArgLst(this); }
960 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitArgLst(this); }
961
962 // Other methods
963 59217 GET_CHILDREN(args);
964
965 // Public members
966 std::vector<AssignExprNode *> args;
967 std::vector<ArgInfo> argInfos;
968 };
969
970 // ======================================================== EnumItemLstNode ======================================================
971
972 class EnumItemLstNode final : public ASTNode {
973 public:
974 // Constructors
975 using ASTNode::ASTNode;
976
977 // Visitor methods
978 122 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitEnumItemLst(this); }
979 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitEnumItemLst(this); }
980
981 // Other methods
982 185 GET_CHILDREN(items);
983
984 // Public members
985 std::vector<EnumItemNode *> items;
986 };
987
988 // ========================================================= EnumItemNode ========================================================
989
990 class EnumItemNode final : public ASTNode {
991 public:
992 // Constructors
993 using ASTNode::ASTNode;
994
995 // Visitor methods
996 1448 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitEnumItem(this); }
997 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitEnumItem(this); }
998
999 // Other methods
1000 1442 GET_CHILDREN();
1001 37 [[nodiscard]] CompileTimeValue getCompileTimeValue() const override { return {.intValue = static_cast<int32_t>(itemValue)}; }
1002
1003 // Public members
1004 bool hasValue = false;
1005 uint32_t itemValue;
1006 std::string itemName;
1007 SymbolTableEntry *entry = nullptr;
1008 EnumDefNode *enumDef = nullptr;
1009 };
1010
1011 // ========================================================== FieldNode ==========================================================
1012
1013 class FieldNode final : public ASTNode {
1014 public:
1015 // Constructors
1016 using ASTNode::ASTNode;
1017
1018 // Visitor methods
1019 3734 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitField(this); }
1020 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitField(this); }
1021
1022 // Other methods
1023 4739 GET_CHILDREN(dataType, defaultValue);
1024
1025 // Public members
1026 DataTypeNode *dataType = nullptr;
1027 TernaryExprNode *defaultValue = nullptr;
1028 std::string fieldName;
1029 SymbolTableEntry *entry = nullptr;
1030 };
1031
1032 // ======================================================== SignatureNode ========================================================
1033
1034 class SignatureNode final : public ASTNode {
1035 public:
1036 // Enums
1037 enum class SignatureType : uint8_t {
1038 TYPE_NONE,
1039 TYPE_FUNCTION,
1040 TYPE_PROCEDURE,
1041 };
1042
1043 // Constructors
1044 using ASTNode::ASTNode;
1045
1046 // Visitor methods
1047 563 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitSignature(this); }
1048 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitSignature(this); }
1049
1050 // Other methods
1051 370 GET_CHILDREN(qualifierLst, returnType, templateTypeLst, paramTypeLst);
1052 std::vector<Function *> *getFctManifestations(const std::string &) override { return &signatureManifestations; }
1053
1054 // Public members
1055 QualifierLstNode *qualifierLst = nullptr;
1056 DataTypeNode *returnType = nullptr;
1057 TypeLstNode *templateTypeLst = nullptr;
1058 TypeLstNode *paramTypeLst = nullptr;
1059 bool hasReturnType = false;
1060 bool hasTemplateTypes = false;
1061 bool hasParams = false;
1062 SignatureType signatureType = SignatureType::TYPE_NONE;
1063 TypeQualifiers signatureQualifiers;
1064 std::string methodName;
1065 SymbolTableEntry *entry = nullptr;
1066 std::vector<Function *> signatureManifestations;
1067 };
1068
1069 // ========================================================= DeclStmtNode ========================================================
1070
1071 class DeclStmtNode final : public StmtNode {
1072 public:
1073 // Constructors
1074 using StmtNode::StmtNode;
1075
1076 // Visitor methods
1077 65626 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitDeclStmt(this); }
1078 7035 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitDeclStmt(this); }
1079
1080 // Other methods
1081 80075 GET_CHILDREN(dataType, assignExpr);
1082 58230 void customItemsInitialization(const size_t manifestationCount) override { entries.resize(manifestationCount); }
1083 702 [[nodiscard]] bool isParam() const override { return isFctParam; }
1084
1085 // Public members
1086 DataTypeNode *dataType = nullptr;
1087 AssignExprNode *assignExpr = nullptr;
1088 bool hasAssignment = false;
1089 bool isFctParam = false;
1090 bool isForEachItem = false;
1091 bool isCtorCallRequired = false; // For struct, in case there are reference fields, we need to call a user-defined ctor
1092 std::string varName;
1093 std::vector<SymbolTableEntry *> entries;
1094 Function *calledInitCtor = nullptr;
1095 Function *calledCopyCtor = nullptr;
1096 };
1097
1098 // ========================================================= ExprStmtNode ========================================================
1099
1100 class ExprStmtNode final : public StmtNode {
1101 public:
1102 // Constructors
1103 using StmtNode::StmtNode;
1104
1105 // Visitor methods
1106 34427 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitExprStmt(this); }
1107 10164 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitExprStmt(this); }
1108
1109 // Other methods
1110 94198 GET_CHILDREN(expr);
1111 229 [[nodiscard]] bool isExprStmt() const override { return true; }
1112
1113 // Public members
1114 AssignExprNode *expr = nullptr;
1115 };
1116
1117 // ======================================================= QualifierLstNode ======================================================
1118
1119 class QualifierLstNode final : public ASTNode {
1120 public:
1121 // Constructors
1122 using ASTNode::ASTNode;
1123
1124 // Visitor methods
1125 29229 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitQualifierLst(this); }
1126 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitQualifierLst(this); }
1127
1128 // Other methods
1129 109354 GET_CHILDREN(qualifiers);
1130
1131 // Public members
1132 std::vector<QualifierNode *> qualifiers;
1133 };
1134
1135 // ========================================================= QualifierNode =======================================================
1136
1137 class QualifierNode final : public ASTNode {
1138 public:
1139 // Enums
1140 enum class QualifierType : uint8_t {
1141 TY_NONE,
1142 TY_CONST,
1143 TY_SIGNED,
1144 TY_UNSIGNED,
1145 TY_INLINE,
1146 TY_PUBLIC,
1147 TY_HEAP,
1148 TY_COMPOSITION,
1149 };
1150
1151 // Constructors
1152 using ASTNode::ASTNode;
1153
1154 // Visitor methods
1155 34970 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitQualifier(this); }
1156 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitQualifier(this); }
1157
1158 // Other methods
1159 130729 GET_CHILDREN();
1160
1161 // Public members
1162 QualifierType type = QualifierType::TY_NONE;
1163 };
1164
1165 // ========================================================== ModAttrNode ========================================================
1166
1167 class ModAttrNode final : public ASTNode {
1168 public:
1169 // Constructors
1170 using ASTNode::ASTNode;
1171
1172 // Visitor methods
1173 1691 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitModAttr(this); }
1174 273 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitModAttr(this); }
1175
1176 // Other methods
1177 1690 GET_CHILDREN(attrLst);
1178
1179 // Public members
1180 AttrLstNode *attrLst = nullptr;
1181 };
1182
1183 // =================================================== TopLevelDefinitionAttrNode ================================================
1184
1185 class TopLevelDefinitionAttrNode final : public ASTNode {
1186 public:
1187 // Constructors
1188 using ASTNode::ASTNode;
1189
1190 // Visitor methods
1191 866 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitTopLevelDefinitionAttr(this); }
1192 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitTopLevelDefinitionAttr(this); }
1193
1194 // Other methods
1195 2058 GET_CHILDREN(attrLst);
1196
1197 // Public members
1198 AttrLstNode *attrLst = nullptr;
1199 };
1200
1201 // ========================================================= LambdaAttrNode ======================================================
1202
1203 class LambdaAttrNode final : public ASTNode {
1204 public:
1205 // Constructors
1206 using ASTNode::ASTNode;
1207
1208 // Visitor methods
1209 1 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitLambdaAttr(this); }
1210 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitLambdaAttr(this); }
1211
1212 // Other methods
1213 34 GET_CHILDREN(attrLst);
1214
1215 // Public members
1216 AttrLstNode *attrLst = nullptr;
1217 };
1218
1219 // ========================================================== AttrLstNode ========================================================
1220
1221 class AttrLstNode final : public ASTNode {
1222 public:
1223 // Constructors
1224 using ASTNode::ASTNode;
1225
1226 // Visitor methods
1227 2254 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitAttrLst(this); }
1228 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitAttrLst(this); }
1229
1230 // Other methods
1231 3782 GET_CHILDREN(attributes);
1232 [[nodiscard]] std::vector<const CompileTimeValue *> getAttrValuesByName(const std::string &key) const;
1233 [[nodiscard]] const CompileTimeValue *getAttrValueByName(const std::string &key) const;
1234 [[nodiscard]] bool hasAttr(const std::string &key) const;
1235
1236 // Public members
1237 std::vector<AttrNode *> attributes;
1238 };
1239
1240 // ============================================================ AttrNode =========================================================
1241
1242 class AttrNode final : public ASTNode {
1243 public:
1244 // Enums
1245 enum AttrTarget : uint8_t {
1246 TARGET_INVALID = 0,
1247 TARGET_MODULE = 1 << 0,
1248 TARGET_STRUCT = 1 << 1,
1249 TARGET_INTERFACE = 1 << 2,
1250 TARGET_FCT_PROC = 1 << 3,
1251 TARGET_EXT_DECL = 1 << 4,
1252 TARGET_LAMBDA = 1 << 5,
1253 };
1254
1255 enum class AttrType : uint8_t {
1256 ATTR_TYPE_INVALID,
1257 TYPE_STRING,
1258 TYPE_BOOL,
1259 TYPE_INT,
1260 };
1261
1262 // Constructors
1263 using ASTNode::ASTNode;
1264
1265 // Visitor methods
1266 4012 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitAttr(this); }
1267 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitAttr(this); }
1268
1269 // Other methods
1270 4775 GET_CHILDREN(value);
1271 [[nodiscard]] const CompileTimeValue *getValue() const;
1272
1273 // Public members
1274 ConstantNode *value = nullptr;
1275 AttrType type = AttrType::ATTR_TYPE_INVALID;
1276 AttrTarget target = TARGET_INVALID;
1277 std::string key;
1278 };
1279
1280 // ======================================================== CaseConstantNode =====================================================
1281
1282 class CaseConstantNode final : public ExprNode {
1283 public:
1284 // Constructors
1285 using ExprNode::ExprNode;
1286
1287 // Visitor methods
1288 188 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitCaseConstant(this); }
1289 66 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitCaseConstant(this); }
1290
1291 // Other methods
1292 236 GET_CHILDREN(constant);
1293
1294 // Public members
1295 ConstantNode *constant = nullptr;
1296 std::vector<std::string> identifierFragments;
1297 std::string fqIdentifier;
1298 const SymbolTableEntry *entry = nullptr;
1299 };
1300
1301 // ======================================================== ReturnStmtNode =======================================================
1302
1303 class ReturnStmtNode final : public StmtNode {
1304 public:
1305 // Constructors
1306 using StmtNode::StmtNode;
1307
1308 // Visitor methods
1309 25742 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitReturnStmt(this); }
1310 8341 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitReturnStmt(this); }
1311
1312 // Other methods
1313 43961 GET_CHILDREN(assignExpr);
1314 8136 [[nodiscard]] bool returnsOnAllControlPaths(bool *) const override { return true; }
1315
1/2
✓ Branch 0 (2→3) taken 8341 times.
✗ Branch 1 (2→4) not taken.
16682 [[nodiscard]] StmtLstNode *getParentScopeNode() const { return spice_pointer_cast<StmtLstNode *>(parent); }
1316
1317 // Public members
1318 AssignExprNode *assignExpr = nullptr;
1319 QualType returnType;
1320 Function *calledCopyCtor = nullptr;
1321 bool hasReturnValue = false;
1322 };
1323
1324 // ======================================================== BreakStmtNode ========================================================
1325
1326 class BreakStmtNode final : public StmtNode {
1327 public:
1328 // Constructors
1329 using StmtNode::StmtNode;
1330
1331 // Visitor methods
1332 312 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitBreakStmt(this); }
1333 98 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitBreakStmt(this); }
1334
1335 // Other methods
1336 561 GET_CHILDREN();
1337
1338 // Public members
1339 int breakTimes = 1;
1340 };
1341
1342 // ======================================================= ContinueStmtNode ======================================================
1343
1344 class ContinueStmtNode final : public StmtNode {
1345 public:
1346 // Constructors
1347 using StmtNode::StmtNode;
1348
1349 // Visitor methods
1350 718 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitContinueStmt(this); }
1351 325 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitContinueStmt(this); }
1352
1353 // Other methods
1354 1017 GET_CHILDREN();
1355
1356 // Public members
1357 int continueTimes = 1;
1358 };
1359
1360 // ====================================================== FallthroughStmtNode ====================================================
1361
1362 class FallthroughStmtNode final : public StmtNode {
1363 public:
1364 // Constructors
1365 using StmtNode::StmtNode;
1366
1367 // Visitor methods
1368 12 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitFallthroughStmt(this); }
1369 4 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitFallthroughStmt(this); }
1370
1371 // Other methods
1372 21 GET_CHILDREN();
1373 };
1374
1375 // ======================================================== AssertStmtNode =======================================================
1376
1377 class AssertStmtNode final : public StmtNode {
1378 public:
1379 // Constructors
1380 using StmtNode::StmtNode;
1381
1382 // Visitor methods
1383 1532 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitAssertStmt(this); }
1384 739 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitAssertStmt(this); }
1385
1386 // Other methods
1387 2224 GET_CHILDREN(assignExpr);
1388 [[nodiscard]] bool returnsOnAllControlPaths(bool *doSetPredecessorsUnreachable) const override;
1389
1390 // Public members
1391 AssignExprNode *assignExpr = nullptr;
1392 std::string expressionString;
1393 };
1394
1395 // ======================================================== BuiltinCallNode ======================================================
1396
1397 class BuiltinCallNode final : public ExprNode {
1398 public:
1399 // Constructors
1400 using ExprNode::ExprNode;
1401
1402 // Visitor methods
1403 4816 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitBuiltinCall(this); }
1404 1497 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitBuiltinCall(this); }
1405
1406 // Other methods
1407 9737 GET_CHILDREN(printfCall, sizeofCall, alignofCall, typeidCall, lenCall, panicCall, sysCall);
1408
1409 // Public members
1410 PrintfCallNode *printfCall = nullptr;
1411 SizeofCallNode *sizeofCall = nullptr;
1412 AlignofCallNode *alignofCall = nullptr;
1413 TypeidCallNode *typeidCall = nullptr;
1414 LenCallNode *lenCall = nullptr;
1415 PanicCallNode *panicCall = nullptr;
1416 SysCallNode *sysCall = nullptr;
1417 };
1418
1419 // ======================================================== PrintfCallNode =======================================================
1420
1421 class PrintfCallNode final : public ExprNode {
1422 public:
1423 // Constructors
1424 using ExprNode::ExprNode;
1425
1426 // Visitor methods
1427 962 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitPrintfCall(this); }
1428 715 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitPrintfCall(this); }
1429
1430 // Other methods
1431 3276 GET_CHILDREN(args);
1432 [[nodiscard]] bool hasCompileTimeValue() const override { return false; }
1433
1434 // Public members
1435 std::vector<AssignExprNode *> args;
1436 std::string templatedString;
1437 };
1438
1439 // ======================================================== SizeofCallNode =======================================================
1440
1441 class SizeofCallNode final : public ExprNode {
1442 public:
1443 // Constructors
1444 using ExprNode::ExprNode;
1445
1446 // Visitor methods
1447 419 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitSizeofCall(this); }
1448 132 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitSizeofCall(this); }
1449
1450 // Other methods
1451 958 GET_CHILDREN(assignExpr, dataType);
1452 8 [[nodiscard]] bool hasCompileTimeValue() const override { return false; }
1453
1454 // Public members
1455 union {
1456 AssignExprNode *assignExpr = nullptr;
1457 DataTypeNode *dataType;
1458 };
1459 bool isType = false;
1460 };
1461
1462 // ======================================================== AlignofCallNode ======================================================
1463
1464 class AlignofCallNode final : public ExprNode {
1465 public:
1466 // Constructors
1467 using ExprNode::ExprNode;
1468
1469 // Visitor methods
1470 11 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitAlignofCall(this); }
1471 11 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitAlignofCall(this); }
1472
1473 // Other methods
1474 44 GET_CHILDREN(assignExpr, dataType);
1475 [[nodiscard]] bool hasCompileTimeValue() const override { return false; }
1476
1477 // Public members
1478 union {
1479 AssignExprNode *assignExpr = nullptr;
1480 DataTypeNode *dataType;
1481 };
1482 bool isType = false;
1483 };
1484
1485 // ======================================================== TypeidCallNode ======================================================
1486
1487 class TypeidCallNode final : public ExprNode {
1488 public:
1489 // Constructors
1490 using ExprNode::ExprNode;
1491
1492 // Visitor methods
1493 2 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitTypeidCall(this); }
1494 2 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitTypeidCall(this); }
1495
1496 // Other methods
1497 8 GET_CHILDREN(assignExpr, dataType);
1498 [[nodiscard]] bool hasCompileTimeValue() const override { return false; }
1499
1500 // Public members
1501 union {
1502 AssignExprNode *assignExpr = nullptr;
1503 DataTypeNode *dataType;
1504 };
1505 bool isType = false;
1506 };
1507
1508 // ========================================================= LenCallNode =========================================================
1509
1510 class LenCallNode final : public ExprNode {
1511 public:
1512 // Constructors
1513 using ExprNode::ExprNode;
1514
1515 // Visitor methods
1516 216 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitLenCall(this); }
1517 45 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitLenCall(this); }
1518
1519 // Other methods
1520 7 [[nodiscard]] bool hasCompileTimeValue() const override { return false; }
1521
1522 // Other methods
1523 606 GET_CHILDREN(assignExpr);
1524
1525 // Public members
1526 AssignExprNode *assignExpr = nullptr;
1527 };
1528
1529 // ======================================================== PanicCallNode ========================================================
1530
1531 class PanicCallNode final : public ExprNode {
1532 public:
1533 // Constructors
1534 using ExprNode::ExprNode;
1535
1536 // Visitor methods
1537 1609 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitPanicCall(this); }
1538 591 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitPanicCall(this); }
1539
1540 // Other methods
1541 3989 GET_CHILDREN(assignExpr);
1542 [[nodiscard]] bool hasCompileTimeValue() const override { return false; }
1543 802 [[nodiscard]] bool returnsOnAllControlPaths(bool *) const override { return true; }
1544
1545 // Public members
1546 AssignExprNode *assignExpr = nullptr;
1547 };
1548
1549 // ========================================================= SysCallNode =========================================================
1550
1551 class SysCallNode final : public ExprNode {
1552 public:
1553 // Constructors
1554 using ExprNode::ExprNode;
1555
1556 // Visitor methods
1557 1 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitSysCall(this); }
1558 1 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitSysCall(this); }
1559
1560 // Other methods
1561 5 GET_CHILDREN(args);
1562
1563 // Public members
1564 std::vector<AssignExprNode *> args;
1565 };
1566
1567 // ======================================================= AssignExprNode ========================================================
1568
1569 class AssignExprNode final : public ExprNode {
1570 public:
1571 // Enums
1572 enum class AssignOp : uint8_t {
1573 OP_NONE,
1574 OP_ASSIGN,
1575 OP_PLUS_EQUAL,
1576 OP_MINUS_EQUAL,
1577 OP_MUL_EQUAL,
1578 OP_DIV_EQUAL,
1579 OP_REM_EQUAL,
1580 OP_SHL_EQUAL,
1581 OP_SHR_EQUAL,
1582 OP_AND_EQUAL,
1583 OP_OR_EQUAL,
1584 OP_XOR_EQUAL
1585 };
1586
1587 // Constructors
1588 using ExprNode::ExprNode;
1589
1590 // Visitor methods
1591 194610 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitAssignExpr(this); }
1592 61969 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitAssignExpr(this); }
1593
1594 // Other methods
1595 358852 GET_CHILDREN(lhs, rhs, ternaryExpr);
1596 [[nodiscard]] bool returnsOnAllControlPaths(bool *doSetPredecessorsUnreachable) const override;
1597 7062 [[nodiscard]] bool isAssignExpr() const override { return true; }
1598 286 [[nodiscard]] std::vector<std::vector<const Function *>> *getOpFctPointers() override { return &opFct; }
1599 835 [[nodiscard]] const std::vector<std::vector<const Function *>> *getOpFctPointers() const override { return &opFct; }
1600
2/4
✓ Branch 0 (4→5) taken 215499 times.
✗ Branch 1 (4→11) not taken.
✓ Branch 2 (5→6) taken 215499 times.
✗ Branch 3 (5→9) not taken.
646497 void customItemsInitialization(const size_t manifestationCount) override { opFct.resize(manifestationCount, {nullptr}); }
1601
1602 // Public members
1603 PrefixUnaryExprNode *lhs = nullptr;
1604 AssignExprNode *rhs = nullptr;
1605 TernaryExprNode *ternaryExpr = nullptr;
1606 AssignOp op = AssignOp::OP_NONE;
1607 std::vector<std::vector<const Function *>> opFct; // Operator overloading functions
1608 };
1609
1610 // ======================================================= TernaryExprNode =======================================================
1611
1612 class TernaryExprNode final : public ExprNode {
1613 public:
1614 // Constructors
1615 using ExprNode::ExprNode;
1616
1617 // Visitor methods
1618 176539 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitTernaryExpr(this); }
1619 56753 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitTernaryExpr(this); }
1620
1621 // Other methods
1622 322924 GET_CHILDREN(condition, trueExpr, falseExpr);
1623 [[nodiscard]] bool hasCompileTimeValue() const override;
1624 [[nodiscard]] CompileTimeValue getCompileTimeValue() const override;
1625
1626 // Public members
1627 LogicalOrExprNode *condition = nullptr;
1628 LogicalOrExprNode *trueExpr = nullptr;
1629 LogicalOrExprNode *falseExpr = nullptr;
1630 Function *calledCopyCtor = nullptr;
1631 bool trueSideCallsCopyCtor = false;
1632 bool falseSideCallsCopyCtor = false;
1633 bool isShortened = false;
1634 };
1635
1636 // ===================================================== LogicalOrExprNode =======================================================
1637
1638 class LogicalOrExprNode final : public ExprNode {
1639 public:
1640 // Constructors
1641 using ExprNode::ExprNode;
1642
1643 // Visitor methods
1644 179033 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitLogicalOrExpr(this); }
1645 57627 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitLogicalOrExpr(this); }
1646
1647 // Other methods
1648 329200 GET_CHILDREN(operands);
1649
1650 // Public members
1651 std::vector<LogicalAndExprNode *> operands;
1652 [[nodiscard]] bool hasCompileTimeValue() const override;
1653 [[nodiscard]] CompileTimeValue getCompileTimeValue() const override;
1654 };
1655
1656 // ===================================================== LogicalAndExprNode ======================================================
1657
1658 class LogicalAndExprNode final : public ExprNode {
1659 public:
1660 // Constructors
1661 using ExprNode::ExprNode;
1662
1663 // Visitor methods
1664 182388 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitLogicalAndExpr(this); }
1665 58689 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitLogicalAndExpr(this); }
1666
1667 // Other methods
1668 336795 GET_CHILDREN(operands);
1669
1670 // Public members
1671 std::vector<BitwiseOrExprNode *> operands;
1672 [[nodiscard]] bool hasCompileTimeValue() const override;
1673 [[nodiscard]] CompileTimeValue getCompileTimeValue() const override;
1674 };
1675
1676 // ===================================================== BitwiseOrExprNode =======================================================
1677
1678 class BitwiseOrExprNode final : public ExprNode {
1679 public:
1680 // Constructors
1681 using ExprNode::ExprNode;
1682
1683 // Visitor methods
1684 183024 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitBitwiseOrExpr(this); }
1685 58865 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitBitwiseOrExpr(this); }
1686
1687 // Other methods
1688 338224 GET_CHILDREN(operands);
1689
1690 // Public members
1691 std::vector<BitwiseXorExprNode *> operands;
1692 [[nodiscard]] bool hasCompileTimeValue() const override;
1693 [[nodiscard]] CompileTimeValue getCompileTimeValue() const override;
1694 };
1695
1696 // ==================================================== BitwiseXorExprNode =======================================================
1697
1698 class BitwiseXorExprNode final : public ExprNode {
1699 public:
1700 // Constructors
1701 using ExprNode::ExprNode;
1702
1703 // Visitor methods
1704 183225 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitBitwiseXorExpr(this); }
1705 58932 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitBitwiseXorExpr(this); }
1706
1707 // Other methods
1708 338625 GET_CHILDREN(operands);
1709
1710 // Public members
1711 std::vector<BitwiseAndExprNode *> operands;
1712 [[nodiscard]] bool hasCompileTimeValue() const override;
1713 [[nodiscard]] CompileTimeValue getCompileTimeValue() const override;
1714 };
1715
1716 // ==================================================== BitwiseAndExprNode =======================================================
1717
1718 class BitwiseAndExprNode final : public ExprNode {
1719 public:
1720 // Constructors
1721 using ExprNode::ExprNode;
1722
1723 // Visitor methods
1724 183249 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitBitwiseAndExpr(this); }
1725 58940 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitBitwiseAndExpr(this); }
1726
1727 // Other methods
1728 338673 GET_CHILDREN(operands);
1729
1730 // Public members
1731 std::vector<EqualityExprNode *> operands;
1732 [[nodiscard]] bool hasCompileTimeValue() const override;
1733 [[nodiscard]] CompileTimeValue getCompileTimeValue() const override;
1734 };
1735
1736 // ===================================================== EqualityExprNode ========================================================
1737
1738 class EqualityExprNode final : public ExprNode {
1739 public:
1740 // Enums
1741 enum class EqualityOp : uint8_t {
1742 OP_NONE,
1743 OP_EQUAL,
1744 OP_NOT_EQUAL,
1745 };
1746
1747 // Constructors
1748 using ExprNode::ExprNode;
1749
1750 // Visitor methods
1751 183315 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitEqualityExpr(this); }
1752 58966 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitEqualityExpr(this); }
1753
1754 // Other methods
1755 338476 GET_CHILDREN(operands);
1756 [[nodiscard]] bool hasCompileTimeValue() const override;
1757 [[nodiscard]] CompileTimeValue getCompileTimeValue() const override;
1758 822 [[nodiscard]] std::vector<std::vector<const Function *>> *getOpFctPointers() override { return &opFct; }
1759 9407 [[nodiscard]] const std::vector<std::vector<const Function *>> *getOpFctPointers() const override { return &opFct; }
1760
2/4
✓ Branch 0 (4→5) taken 201109 times.
✗ Branch 1 (4→11) not taken.
✓ Branch 2 (5→6) taken 201109 times.
✗ Branch 3 (5→9) not taken.
603327 void customItemsInitialization(const size_t manifestationCount) override { opFct.resize(manifestationCount, {nullptr}); }
1761
1762 // Public members
1763 std::vector<RelationalExprNode *> operands;
1764 EqualityOp op = EqualityOp::OP_NONE;
1765 std::vector<std::vector<const Function *>> opFct; // Operator overloading functions
1766 };
1767
1768 // ==================================================== RelationalExprNode =======================================================
1769
1770 class RelationalExprNode final : public ExprNode {
1771 public:
1772 // Enums
1773 enum class RelationalOp : uint8_t {
1774 OP_NONE,
1775 OP_LESS,
1776 OP_GREATER,
1777 OP_LESS_EQUAL,
1778 OP_GREATER_EQUAL,
1779 };
1780
1781 // Constructors
1782 using ExprNode::ExprNode;
1783
1784 // Visitor methods
1785 196810 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitRelationalExpr(this); }
1786 63480 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitRelationalExpr(this); }
1787
1788 // Other methods
1789 369758 GET_CHILDREN(operands);
1790 [[nodiscard]] bool hasCompileTimeValue() const override;
1791 [[nodiscard]] CompileTimeValue getCompileTimeValue() const override;
1792
1793 // Public members
1794 std::vector<ShiftExprNode *> operands;
1795 RelationalOp op = RelationalOp::OP_NONE;
1796 };
1797
1798 // ====================================================== ShiftExprNode ==========================================================
1799
1800 class ShiftExprNode final : public ExprNode {
1801 public:
1802 // Enums
1803 enum class ShiftOp : uint8_t {
1804 OP_NONE,
1805 OP_SHIFT_LEFT,
1806 OP_SHIFT_RIGHT,
1807 };
1808
1809 // Typedefs
1810 using OpQueue = std::queue<std::pair<ShiftOp, QualType>>;
1811
1812 // Constructors
1813 using ExprNode::ExprNode;
1814
1815 // Visitor methods
1816 205881 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitShiftExpr(this); }
1817 66677 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitShiftExpr(this); }
1818
1819 // Other methods
1820 393946 GET_CHILDREN(operands);
1821 [[nodiscard]] bool hasCompileTimeValue() const override;
1822 [[nodiscard]] CompileTimeValue getCompileTimeValue() const override;
1823 172 [[nodiscard]] std::vector<std::vector<const Function *>> *getOpFctPointers() override { return &opFct; }
1824 356 [[nodiscard]] const std::vector<std::vector<const Function *>> *getOpFctPointers() const override { return &opFct; }
1825
2/4
✓ Branch 0 (4→5) taken 227252 times.
✗ Branch 1 (4→11) not taken.
✓ Branch 2 (5→6) taken 227252 times.
✗ Branch 3 (5→9) not taken.
681756 void customItemsInitialization(const size_t manifestationCount) override { opFct.resize(manifestationCount, {nullptr}); }
1826
1827 // Public members
1828 std::vector<AdditiveExprNode *> operands;
1829 OpQueue opQueue;
1830 std::vector<std::vector<const Function *>> opFct; // Operator overloading functions
1831 };
1832
1833 // ==================================================== AdditiveExprNode =========================================================
1834
1835 class AdditiveExprNode final : public ExprNode {
1836 public:
1837 // Enums
1838 enum class AdditiveOp : uint8_t {
1839 OP_PLUS,
1840 OP_MINUS,
1841 };
1842
1843 // Typedefs
1844 using OpQueue = std::queue<std::pair<AdditiveOp, QualType>>;
1845
1846 // Constructors
1847 using ExprNode::ExprNode;
1848
1849 // Visitor methods
1850 206223 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitAdditiveExpr(this); }
1851 66812 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitAdditiveExpr(this); }
1852
1853 // Other methods
1854 394188 GET_CHILDREN(operands);
1855 [[nodiscard]] bool hasCompileTimeValue() const override;
1856 [[nodiscard]] CompileTimeValue getCompileTimeValue() const override;
1857 126 [[nodiscard]] std::vector<std::vector<const Function *>> *getOpFctPointers() override { return &opFct; }
1858 8311 [[nodiscard]] const std::vector<std::vector<const Function *>> *getOpFctPointers() const override { return &opFct; }
1859
2/4
✓ Branch 0 (4→5) taken 227541 times.
✗ Branch 1 (4→11) not taken.
✓ Branch 2 (5→6) taken 227541 times.
✗ Branch 3 (5→9) not taken.
682623 void customItemsInitialization(const size_t manifestationCount) override { opFct.resize(manifestationCount, {nullptr}); }
1860
1861 // Public members
1862 std::vector<MultiplicativeExprNode *> operands;
1863 OpQueue opQueue;
1864 std::vector<std::vector<const Function *>> opFct; // Operator overloading functions
1865 };
1866
1867 // ================================================== MultiplicativeExprNode =====================================================
1868
1869 class MultiplicativeExprNode final : public ExprNode {
1870 public:
1871 // Enums
1872 enum class MultiplicativeOp : uint8_t {
1873 OP_MUL,
1874 OP_DIV,
1875 OP_REM,
1876 };
1877
1878 // Typedefs
1879 using OpQueue = std::queue<std::pair<MultiplicativeOp, QualType>>;
1880
1881 // Constructors
1882 using ExprNode::ExprNode;
1883
1884 // Visitor methods
1885 217858 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitMultiplicativeExpr(this); }
1886 70936 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitMultiplicativeExpr(this); }
1887
1888 // Other methods
1889 422045 GET_CHILDREN(operands);
1890 [[nodiscard]] bool hasCompileTimeValue() const override;
1891 [[nodiscard]] CompileTimeValue getCompileTimeValue() const override;
1892 24 [[nodiscard]] std::vector<std::vector<const Function *>> *getOpFctPointers() override { return &opFct; }
1893 1568 [[nodiscard]] const std::vector<std::vector<const Function *>> *getOpFctPointers() const override { return &opFct; }
1894
2/4
✓ Branch 0 (4→5) taken 240735 times.
✗ Branch 1 (4→11) not taken.
✓ Branch 2 (5→6) taken 240735 times.
✗ Branch 3 (5→9) not taken.
722205 void customItemsInitialization(const size_t manifestationCount) override { opFct.resize(manifestationCount, {nullptr}); }
1895
1896 // Public members
1897 std::vector<CastExprNode *> operands;
1898 OpQueue opQueue;
1899 std::vector<std::vector<const Function *>> opFct; // Operator overloading functions
1900 };
1901
1902 // ======================================================= CastExprNode ==========================================================
1903
1904 class CastExprNode final : public ExprNode {
1905 public:
1906 // Constructors
1907 using ExprNode::ExprNode;
1908
1909 // Visitor methods
1910 221003 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitCastExpr(this); }
1911 71724 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitCastExpr(this); }
1912
1913 // Other methods
1914 429528 GET_CHILDREN(prefixUnaryExpr, dataType, assignExpr);
1915 [[nodiscard]] bool hasCompileTimeValue() const override;
1916 [[nodiscard]] CompileTimeValue getCompileTimeValue() const override;
1917
1918 // Public members
1919 PrefixUnaryExprNode *prefixUnaryExpr = nullptr;
1920 DataTypeNode *dataType = nullptr;
1921 AssignExprNode *assignExpr = nullptr;
1922 bool isCast = false;
1923 };
1924
1925 // ==================================================== PrefixUnaryExprNode ======================================================
1926
1927 class PrefixUnaryExprNode final : public ExprNode {
1928 public:
1929 // Enums
1930 enum class PrefixUnaryOp : uint8_t {
1931 OP_NONE,
1932 OP_MINUS,
1933 OP_PLUS_PLUS,
1934 OP_MINUS_MINUS,
1935 OP_NOT,
1936 OP_BITWISE_NOT,
1937 OP_DEREFERENCE,
1938 OP_ADDRESS_OF,
1939 };
1940
1941 // Constructors
1942 using ExprNode::ExprNode;
1943
1944 // Visitor methods
1945 235646 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitPrefixUnaryExpr(this); }
1946 75868 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitPrefixUnaryExpr(this); }
1947
1948 // Other methods
1949 459089 GET_CHILDREN(prefixUnaryExpr, postfixUnaryExpr);
1950 [[nodiscard]] bool hasCompileTimeValue() const override;
1951 [[nodiscard]] CompileTimeValue getCompileTimeValue() const override;
1952
1953 // Public members
1954 PrefixUnaryExprNode *prefixUnaryExpr = nullptr;
1955 PostfixUnaryExprNode *postfixUnaryExpr = nullptr;
1956 PrefixUnaryOp op = PrefixUnaryOp::OP_NONE;
1957 };
1958
1959 // =================================================== PostfixUnaryExprNode ======================================================
1960
1961 class PostfixUnaryExprNode final : public ExprNode {
1962 public:
1963 // Enums
1964 enum class PostfixUnaryOp : uint8_t {
1965 OP_NONE,
1966 OP_SUBSCRIPT,
1967 OP_MEMBER_ACCESS,
1968 OP_PLUS_PLUS,
1969 OP_MINUS_MINUS,
1970 };
1971
1972 // Constructors
1973 using ExprNode::ExprNode;
1974
1975 // Visitor methods
1976 293632 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitPostfixUnaryExpr(this); }
1977 93335 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitPostfixUnaryExpr(this); }
1978
1979 // Other methods
1980 581489 GET_CHILDREN(atomicExpr, postfixUnaryExpr, subscriptIndexExpr);
1981 [[nodiscard]] bool hasCompileTimeValue() const override;
1982 [[nodiscard]] CompileTimeValue getCompileTimeValue() const override;
1983 252 [[nodiscard]] std::vector<std::vector<const Function *>> *getOpFctPointers() override { return &opFct; }
1984 13220 [[nodiscard]] const std::vector<std::vector<const Function *>> *getOpFctPointers() const override { return &opFct; }
1985
2/4
✓ Branch 0 (4→5) taken 333167 times.
✗ Branch 1 (4→11) not taken.
✓ Branch 2 (5→6) taken 333167 times.
✗ Branch 3 (5→9) not taken.
999501 void customItemsInitialization(const size_t manifestationCount) override { opFct.resize(manifestationCount, {nullptr}); }
1986
1987 // Public members
1988 AtomicExprNode *atomicExpr = nullptr;
1989 PostfixUnaryExprNode *postfixUnaryExpr = nullptr;
1990 AssignExprNode *subscriptIndexExpr = nullptr;
1991 PostfixUnaryOp op = PostfixUnaryOp::OP_NONE;
1992 std::vector<std::vector<const Function *>> opFct; // Operator overloading functions
1993 std::string identifier; // Only set when operator is member access
1994 };
1995
1996 // ====================================================== AtomicExprNode =========================================================
1997
1998 class AtomicExprNode final : public ExprNode {
1999 public:
2000 // Structs
2001 struct VarAccessData {
2002 SymbolTableEntry *entry = nullptr;
2003 Scope *accessScope = nullptr;
2004 Capture *capture = nullptr;
2005 };
2006
2007 // Constructors
2008 using ExprNode::ExprNode;
2009
2010 // Visitor methods
2011 232605 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitAtomicExpr(this); }
2012 74943 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitAtomicExpr(this); }
2013
2014 // Other methods
2015 441737 GET_CHILDREN(constant, value, assignExpr, builtinCall);
2016 258815 void customItemsInitialization(const size_t manifestationCount) override { data.resize(manifestationCount); }
2017
2018 // Public members
2019 ConstantNode *constant = nullptr;
2020 ValueNode *value = nullptr;
2021 AssignExprNode *assignExpr = nullptr;
2022 BuiltinCallNode *builtinCall = nullptr;
2023 std::vector<std::string> identifierFragments;
2024 std::string fqIdentifier;
2025 std::vector<VarAccessData> data; // Only set if identifier is set as well
2026 };
2027
2028 // ======================================================== ValueNode ============================================================
2029
2030 class ValueNode final : public ExprNode {
2031 public:
2032 // Constructors
2033 using ExprNode::ExprNode;
2034
2035 // Visitor methods
2036 45894 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitValue(this); }
2037 15116 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitValue(this); }
2038
2039 // Other methods
2040 93972 GET_CHILDREN(fctCall, arrayInitialization, structInstantiation, lambdaFunc, lambdaProc, lambdaExpr, nilType);
2041 1403 [[nodiscard]] bool hasCompileTimeValue() const override { return isNil; }
2042
2043 // Public members
2044 FctCallNode *fctCall = nullptr;
2045 ArrayInitializationNode *arrayInitialization = nullptr;
2046 StructInstantiationNode *structInstantiation = nullptr;
2047 LambdaFuncNode *lambdaFunc = nullptr;
2048 LambdaProcNode *lambdaProc = nullptr;
2049 LambdaExprNode *lambdaExpr = nullptr;
2050 DataTypeNode *nilType = nullptr;
2051 bool isNil = false;
2052 };
2053
2054 // ====================================================== ConstantNode ===========================================================
2055
2056 class ConstantNode final : public ExprNode {
2057 public:
2058 // Enum
2059 enum class PrimitiveValueType : uint8_t {
2060 TYPE_NONE,
2061 TYPE_DOUBLE,
2062 TYPE_INT,
2063 TYPE_SHORT,
2064 TYPE_LONG,
2065 TYPE_BYTE,
2066 TYPE_CHAR,
2067 TYPE_STRING,
2068 TYPE_BOOL
2069 };
2070
2071 // Constructors
2072 using ExprNode::ExprNode;
2073
2074 // Visitor methods
2075 46992 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitConstant(this); }
2076 14533 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitConstant(this); }
2077
2078 // Other methods
2079 74681 GET_CHILDREN();
2080 14664 [[nodiscard]] CompileTimeValue getCompileTimeValue() const override { return compileTimeValue; }
2081 468 [[nodiscard]] bool hasCompileTimeValue() const override { return true; }
2082
2083 // Public members
2084 PrimitiveValueType type = PrimitiveValueType::TYPE_NONE;
2085 CompileTimeValue compileTimeValue;
2086 };
2087
2088 // ====================================================== FctCallNode ============================================================
2089
2090 class FctCallNode final : public ExprNode {
2091 public:
2092 // Enums
2093 enum class FctCallType : uint8_t {
2094 TYPE_ORDINARY,
2095 TYPE_METHOD,
2096 TYPE_CTOR,
2097 TYPE_FCT_PTR,
2098 };
2099
2100 // Structs
2101 struct FctCallData {
2102 // Members
2103 FctCallType callType = FctCallType::TYPE_ORDINARY;
2104 bool isImported = false;
2105 QualTypeList templateTypes;
2106 QualType thisType = QualType(TY_DYN); // Is filled if method or ctor call
2107 ArgList args;
2108 Function *callee = nullptr;
2109 Scope *calleeParentScope = nullptr;
2110
2111 // Methods
2112 16924 [[nodiscard]] bool isOrdinaryCall() const { return callType == FctCallType::TYPE_ORDINARY; }
2113 67398 [[nodiscard]] bool isMethodCall() const { return callType == FctCallType::TYPE_METHOD; }
2114
4/4
✓ Branch 0 (3→4) taken 6407 times.
✓ Branch 1 (3→7) taken 15513 times.
✓ Branch 2 (5→6) taken 30 times.
✓ Branch 3 (5→7) taken 6377 times.
21920 [[nodiscard]] bool isVirtualMethodCall() const { return isMethodCall() && thisType.isBase(TY_INTERFACE); }
2115 69612 [[nodiscard]] bool isCtorCall() const { return callType == FctCallType::TYPE_CTOR; }
2116 131011 [[nodiscard]] bool isFctPtrCall() const { return callType == FctCallType::TYPE_FCT_PTR; }
2117 };
2118
2119 // Constructors
2120 using ExprNode::ExprNode;
2121
2122 // Visitor methods
2123 41247 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitFctCall(this); }
2124 13446 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitFctCall(this); }
2125
2126 // Other methods
2127 74975 GET_CHILDREN(templateTypeLst, argLst);
2128 [[nodiscard]] bool hasCompileTimeValue() const override { return false; }
2129 44368 void customItemsInitialization(const size_t manifestationCount) override { data.resize(manifestationCount); }
2130 [[nodiscard]] bool hasReturnValueReceiver() const;
2131
2132 // Public members
2133 TypeLstNode *templateTypeLst = nullptr;
2134 ArgLstNode *argLst = nullptr;
2135 bool hasArgs = false;
2136 bool hasTemplateTypes = false;
2137 std::string fqFunctionName;
2138 std::vector<std::string> functionNameFragments;
2139 std::vector<FctCallData> data;
2140 };
2141
2142 // ================================================= ArrayInitializationNode =====================================================
2143
2144 class ArrayInitializationNode final : public ExprNode {
2145 public:
2146 // Constructors
2147 using ExprNode::ExprNode;
2148
2149 // Visitor methods
2150 149 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitArrayInitialization(this); }
2151 54 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitArrayInitialization(this); }
2152
2153 // Other methods
2154 220 GET_CHILDREN(itemLst);
2155
2156 // Public members
2157 ArgLstNode *itemLst = nullptr;
2158 size_t actualSize = 0z;
2159 };
2160
2161 // ================================================= StructInstantiationNode =====================================================
2162
2163 class StructInstantiationNode final : public ExprNode {
2164 public:
2165 // Constructors
2166 using ExprNode::ExprNode;
2167
2168 // Visitor methods
2169 656 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitStructInstantiation(this); }
2170 271 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitStructInstantiation(this); }
2171
2172 // Other methods
2173 940 GET_CHILDREN(templateTypeLst, fieldLst);
2174 565 void customItemsInitialization(const size_t manifestationCount) override { instantiatedStructs.resize(manifestationCount); }
2175
2176 // Public members
2177 TypeLstNode *templateTypeLst = nullptr;
2178 ArgLstNode *fieldLst = nullptr;
2179 bool hasTemplateTypes = false;
2180 std::string fqStructName;
2181 std::vector<std::string> structNameFragments;
2182 std::vector<Struct *> instantiatedStructs;
2183 };
2184
2185 // ====================================================== LambdaBaseNode =========================================================
2186
2187 class LambdaBaseNode : public ExprNode {
2188 public:
2189 // Constructors
2190 using ExprNode::ExprNode;
2191
2192 // Other methods
2193
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(); }
2194 [[nodiscard]] bool hasCompileTimeValue() const override { return false; }
2195 81 void customItemsInitialization(const size_t manifestationCount) override { manifestations.resize(manifestationCount); }
2196
2197 // Public members
2198 ParamLstNode *paramLst = nullptr;
2199 bool hasParams = false;
2200 Scope *bodyScope = nullptr;
2201 std::vector<Function> manifestations;
2202 };
2203
2204 // ====================================================== LambdaFuncNode =========================================================
2205
2206 class LambdaFuncNode final : public LambdaBaseNode {
2207 public:
2208 // Constructors
2209 using LambdaBaseNode::LambdaBaseNode;
2210
2211 // Visit methods
2212 24 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitLambdaFunc(this); }
2213 8 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitLambdaFunc(this); }
2214
2215 // Other methods
2216 24 GET_CHILDREN(returnType, paramLst, body, lambdaAttr);
2217 [[nodiscard]] bool returnsOnAllControlPaths(bool *overrideUnreachable) const override;
2218
2219 // Public members
2220 DataTypeNode *returnType = nullptr;
2221 StmtLstNode *body = nullptr;
2222 LambdaAttrNode *lambdaAttr = nullptr;
2223 };
2224
2225 // ====================================================== LambdaProcNode =========================================================
2226
2227 class LambdaProcNode final : public LambdaBaseNode {
2228 public:
2229 // Constructors
2230 using LambdaBaseNode::LambdaBaseNode;
2231
2232 // Visit methods
2233 57 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitLambdaProc(this); }
2234 26 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitLambdaProc(this); }
2235
2236 // Other methods
2237 57 GET_CHILDREN(paramLst, body, lambdaAttr);
2238 bool returnsOnAllControlPaths(bool *overrideUnreachable) const override;
2239
2240 // Public members
2241 StmtLstNode *body = nullptr;
2242 LambdaAttrNode *lambdaAttr = nullptr;
2243 };
2244
2245 // ====================================================== LambdaExprNode =========================================================
2246
2247 class LambdaExprNode final : public LambdaBaseNode {
2248 public:
2249 // Constructors
2250 using LambdaBaseNode::LambdaBaseNode;
2251
2252 // Visit methods
2253 2 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitLambdaExpr(this); }
2254 1 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitLambdaExpr(this); }
2255
2256 // Other methods
2257 2 GET_CHILDREN(paramLst, lambdaExpr);
2258
2259 // Public members
2260 AssignExprNode *lambdaExpr = nullptr;
2261 };
2262
2263 // ======================================================= DataTypeNode ==========================================================
2264
2265 class DataTypeNode final : public ExprNode {
2266 public:
2267 // Enums
2268 enum class TypeModifierType : uint8_t {
2269 TYPE_PTR,
2270 TYPE_REF,
2271 TYPE_ARRAY,
2272 };
2273
2274 // Structs
2275 struct TypeModifier {
2276 TypeModifierType modifierType = TypeModifierType::TYPE_PTR;
2277 bool hasSize = false;
2278 unsigned int hardcodedSize = 0;
2279 std::string sizeVarName;
2280 };
2281
2282 // Constructors
2283 using ExprNode::ExprNode;
2284
2285 // Visitor methods
2286 99075 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitDataType(this); }
2287 2561 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitDataType(this); }
2288
2289 // Other methods
2290 163644 GET_CHILDREN(qualifierLst, baseDataType);
2291 void setFieldTypeRecursive();
2292
2293 // Public members
2294 QualifierLstNode *qualifierLst = nullptr;
2295 BaseDataTypeNode *baseDataType = nullptr;
2296 bool isParamType = false;
2297 bool isGlobalType = false;
2298 bool isFieldType = false;
2299 bool isReturnType = false;
2300 std::queue<TypeModifier> tmQueue;
2301 };
2302
2303 // ==================================================== BaseDataTypeNode =========================================================
2304
2305 class BaseDataTypeNode final : public ExprNode {
2306 public:
2307 // Enums
2308 enum class Type : uint8_t {
2309 TYPE_NONE,
2310 TYPE_DOUBLE,
2311 TYPE_INT,
2312 TYPE_SHORT,
2313 TYPE_LONG,
2314 TYPE_BYTE,
2315 TYPE_CHAR,
2316 TYPE_STRING,
2317 TYPE_BOOL,
2318 TYPE_DYN,
2319 TYPE_CUSTOM,
2320 TYPE_FUNCTION
2321 };
2322
2323 // Constructors
2324 using ExprNode::ExprNode;
2325
2326 // Visitor methods
2327 99075 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitBaseDataType(this); }
2328 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitBaseDataType(this); }
2329
2330 // Other methods
2331 163635 GET_CHILDREN(customDataType, functionDataType);
2332
2333 // Public members
2334 CustomDataTypeNode *customDataType = nullptr;
2335 FunctionDataTypeNode *functionDataType = nullptr;
2336 Type type = Type::TYPE_NONE;
2337 };
2338
2339 // ==================================================== CustomDataTypeNode =======================================================
2340
2341 class CustomDataTypeNode final : public ExprNode {
2342 public:
2343 // Constructors
2344 using ExprNode::ExprNode;
2345
2346 // Visitor methods
2347 34116 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitCustomDataType(this); }
2348 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitCustomDataType(this); }
2349
2350 // Other methods
2351 59779 GET_CHILDREN(templateTypeLst);
2352 43409 void customItemsInitialization(const size_t manifestationCount) override { customTypes.resize(manifestationCount); }
2353
2354 // Public members
2355 TypeLstNode *templateTypeLst = nullptr;
2356 std::string fqTypeName;
2357 std::vector<std::string> typeNameFragments;
2358 std::vector<SymbolTableEntry *> customTypes;
2359 };
2360
2361 // =================================================== FunctionDataTypeNode ======================================================
2362
2363 class FunctionDataTypeNode final : public ExprNode {
2364 public:
2365 // Constructors
2366 using ExprNode::ExprNode;
2367
2368 // Visitor methods
2369 159 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitFunctionDataType(this); }
2370 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitFunctionDataType(this); }
2371
2372 // Other methods
2373 222 GET_CHILDREN(returnType, paramTypeLst);
2374 175 void customItemsInitialization(const size_t manifestationCount) override { customTypes.resize(manifestationCount); }
2375
2376 // Public members
2377 DataTypeNode *returnType = nullptr;
2378 TypeLstNode *paramTypeLst = nullptr;
2379 bool isFunction = false; // Function or procedure
2380 std::vector<SymbolTableEntry *> customTypes;
2381 };
2382
2383 } // namespace spice::compiler
2384