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