GCC Code Coverage Report


Directory: ../
File: src/ast/ASTNodes.h
Date: 2024-11-22 23:10:59
Exec Total Coverage
Lines: 408 437 93.4%
Functions: 426 452 94.2%
Branches: 93 154 60.4%

Line Branch Exec Source
1 // Copyright (c) 2021-2024 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/TypeSpecifiers.h>
16 #include <typechecker/ExprResult.h>
17 #include <util/CodeLoc.h>
18
19 namespace spice::compiler {
20
21 // Operator overload function names
22 constexpr const char *const OP_FCT_PREFIX = "op.";
23 constexpr const char *const OP_FCT_PLUS = "op.plus";
24 constexpr const char *const OP_FCT_MINUS = "op.minus";
25 constexpr const char *const OP_FCT_MUL = "op.mul";
26 constexpr const char *const OP_FCT_DIV = "op.div";
27 constexpr const char *const OP_FCT_EQUAL = "op.equal";
28 constexpr const char *const OP_FCT_NOT_EQUAL = "op.notequal";
29 constexpr const char *const OP_FCT_SHL = "op.shl";
30 constexpr const char *const OP_FCT_SHR = "op.shr";
31 constexpr const char *const OP_FCT_PLUS_EQUAL = "op.plusequal";
32 constexpr const char *const OP_FCT_MINUS_EQUAL = "op.minusequal";
33 constexpr const char *const OP_FCT_MUL_EQUAL = "op.mulequal";
34 constexpr const char *const OP_FCT_DIV_EQUAL = "op.divequal";
35 constexpr const char *const OP_FCT_POSTFIX_PLUS_PLUS = "op.plusplus.post";
36 constexpr const char *const OP_FCT_POSTFIX_MINUS_MINUS = "op.minusminus.post";
37
38 /**
39 * Saves a constant value for an AST node to realize features like array-out-of-bounds checks
40 */
41 struct CompileTimeValue {
42 double_t doubleValue = 0.0;
43 int32_t intValue = 0;
44 int16_t shortValue = 0;
45 int64_t longValue = 0;
46 int8_t charValue = 0;
47 bool boolValue = false;
48 size_t stringValueOffset = 0; // Offset into vector of strings in GlobalResourceManager
49 };
50
51 // Make sure we have no unexpected increases in memory consumption
52 static_assert(sizeof(CompileTimeValue) == 40);
53
54 // =========================================================== AstNode ===========================================================
55
56 class ASTNode {
57 public:
58 // Constructors
59 1117716 explicit ASTNode(const CodeLoc &codeLoc) : codeLoc(codeLoc) {}
60 2235432 virtual ~ASTNode() = default;
61 ASTNode(const ASTNode &) = delete;
62
63 // Virtual methods
64 virtual std::any accept(AbstractASTVisitor *visitor) = 0;
65 virtual std::any accept(ParallelizableASTVisitor *visitor) const = 0;
66
67 // Public methods
68 1015809 void addChild(ASTNode *node) {
69 1015809 children.push_back(node);
70 1015809 node->parent = this;
71 1015809 }
72
73 3756324 template <typename T> [[nodiscard]] T *getChild(size_t i = 0) const {
74 static_assert(std::is_base_of_v<ASTNode, T>, "T must be derived from ASTNode");
75 3756324 size_t j = 0;
76
2/2
✓ Branch 5 taken 1670778 times.
✓ Branch 6 taken 787244 times.
4916044 for (ASTNode *child : children) {
77
3/4
✓ Branch 0 taken 1670778 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1093139 times.
✓ Branch 3 taken 577639 times.
3341556 if (auto *typedChild = dynamic_cast<T *>(child)) [[unlikely]] {
78
2/2
✓ Branch 0 taken 1090918 times.
✓ Branch 1 taken 2221 times.
2186278 if (j++ == i)
79 2181836 return typedChild;
80 }
81 }
82 1574488 return nullptr;
83 }
84
85 3321286 template <typename T> [[nodiscard]] std::vector<T *> getChildren() const {
86 static_assert(std::is_base_of_v<ASTNode, T>, "T must be derived from ASTNode");
87 3321286 std::vector<T *> nodes;
88
2/2
✓ Branch 5 taken 1810396 times.
✓ Branch 6 taken 1660643 times.
6942078 for (ASTNode *child : children) {
89
3/4
✓ Branch 0 taken 1810396 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1777984 times.
✓ Branch 3 taken 32412 times.
3620792 if (auto *typedChild = dynamic_cast<T *>(child)) [[unlikely]] {
90
1/2
✓ Branch 1 taken 1777984 times.
✗ Branch 2 not taken.
3555968 nodes.push_back(typedChild);
91 }
92 }
93 3321286 return nodes;
94 }
95
96 7235118 void resizeToNumberOfManifestations(size_t manifestationCount) { // NOLINT(misc-no-recursion)
97 // Resize children
98
2/2
✓ Branch 5 taken 7184840 times.
✓ Branch 6 taken 7235118 times.
14419958 for (ASTNode *child : children) {
99
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7184840 times.
7184840 assert(child != nullptr);
100
1/2
✓ Branch 1 taken 7184840 times.
✗ Branch 2 not taken.
7184840 child->resizeToNumberOfManifestations(manifestationCount);
101 }
102 // Reserve this node
103
2/4
✓ Branch 1 taken 7235118 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7235118 times.
✗ Branch 5 not taken.
7235118 symbolTypes.resize(manifestationCount, QualType(TY_INVALID));
104 // Do custom work
105 7235118 customItemsInitialization(manifestationCount);
106 7235118 }
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 4158612 virtual void customItemsInitialization(size_t) {} // Noop
118
119 260433 QualType setEvaluatedSymbolType(const QualType &symbolType, const size_t idx) {
120
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 260433 times.
260433 assert(symbolTypes.size() > idx);
121 260433 symbolTypes.at(idx) = symbolType;
122 260433 return symbolType;
123 }
124
125 251028 [[nodiscard]] const QualType &getEvaluatedSymbolType(const size_t idx) const { // NOLINT(misc-no-recursion)
126
5/6
✓ Branch 1 taken 251028 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 110118 times.
✓ Branch 6 taken 140910 times.
✓ Branch 7 taken 110118 times.
✓ Branch 8 taken 140910 times.
251028 if (!symbolTypes.empty() && !symbolTypes.at(idx).is(TY_INVALID))
127 110118 return symbolTypes.at(idx);
128
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 140910 times.
140910 if (children.size() != 1)
129 throw CompilerError(INTERNAL_ERROR, "Cannot deduce evaluated symbol type");
130 140910 return children.front()->getEvaluatedSymbolType(idx);
131 }
132
133 12591 [[nodiscard]] virtual bool hasCompileTimeValue() const { // NOLINT(misc-no-recursion)
134
2/2
✓ Branch 1 taken 4187 times.
✓ Branch 2 taken 8404 times.
12591 if (children.size() != 1)
135 4187 return false;
136 8404 return children.front()->hasCompileTimeValue();
137 }
138
139 165 [[nodiscard]] virtual CompileTimeValue getCompileTimeValue() const { // NOLINT(misc-no-recursion)
140
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
165 if (children.size() != 1)
141 return {};
142 165 return children.front()->getCompileTimeValue();
143 }
144
145 [[nodiscard]] std::string getErrorMessage() const;
146
147 96294 [[nodiscard]] virtual bool returnsOnAllControlPaths(bool *doSetPredecessorsUnreachable) const { // NOLINT(misc-no-recursion)
148
4/4
✓ Branch 1 taken 89215 times.
✓ Branch 2 taken 7079 times.
✓ Branch 5 taken 7085 times.
✓ Branch 6 taken 82130 times.
96294 return children.size() == 1 && children.front()->returnsOnAllControlPaths(doSetPredecessorsUnreachable);
149 }
150
151 [[nodiscard]] virtual std::vector<Function *> *getFctManifestations(const std::string &) { // LCOV_EXCL_LINE
152 assert_fail("Must be called on a FctDefNode, ProcDefNode, ExtDeclNode, StructDefNode or SignatureNode"); // LCOV_EXCL_LINE
153 return nullptr; // LCOV_EXCL_LINE
154 } // LCOV_EXCL_LINE
155
156 [[nodiscard]] virtual std::vector<Struct *> *getStructManifestations() { // LCOV_EXCL_LINE
157 assert_fail("Must be called on a StructDefNode"); // LCOV_EXCL_LINE
158 return nullptr; // LCOV_EXCL_LINE
159 } // LCOV_EXCL_LINE
160
161 [[nodiscard]] virtual std::vector<Interface *> *getInterfaceManifestations() { // LCOV_EXCL_LINE
162 assert_fail("Must be called on a InterfaceDefNode"); // LCOV_EXCL_LINE
163 return nullptr; // LCOV_EXCL_LINE
164 } // LCOV_EXCL_LINE
165
166 [[nodiscard]] const StmtLstNode *getNextOuterStmtLst() const;
167
168 154720 [[nodiscard]] virtual bool isFctOrProcDef() const { return false; }
169 127162 [[nodiscard]] virtual bool isStructDef() const { return false; }
170 9 [[nodiscard]] virtual bool isParamNode() const { return false; }
171 10901 [[nodiscard]] virtual bool isStmtLstNode() const { return false; }
172 94813 [[nodiscard]] virtual bool isAssignExpr() const { return false; }
173
174 // Public members
175 ASTNode *parent = nullptr;
176 std::vector<ASTNode *> children;
177 const CodeLoc codeLoc;
178 QualTypeList symbolTypes;
179 bool unreachable = false;
180 };
181
182 // Make sure we have no unexpected increases in memory consumption
183 static_assert(sizeof(ASTNode) == 104);
184
185 // ========================================================== EntryNode ==========================================================
186
187 class EntryNode final : public ASTNode {
188 public:
189 // Constructors
190 using ASTNode::ASTNode;
191
192 // Visitor methods
193 6838 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitEntry(this); }
194 678 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitEntry(this); }
195
196 // Public get methods
197 894 [[nodiscard]] std::vector<ModAttrNode *> modAttrs() const { return getChildren<ModAttrNode>(); }
198 894 [[nodiscard]] std::vector<ImportDefNode *> importDefs() const { return getChildren<ImportDefNode>(); }
199 };
200
201 // ======================================================= TopLevelDefNode =======================================================
202
203 class TopLevelDefNode : public ASTNode {
204 public:
205 // Constructors
206 using ASTNode::ASTNode;
207
208 // Visitor methods
209 std::any accept(AbstractASTVisitor *visitor) override = 0;
210 std::any accept(ParallelizableASTVisitor *visitor) const override = 0;
211 };
212
213 // =========================================================== StmtNode ==========================================================
214
215 class StmtNode : public ASTNode {
216 public:
217 // Constructors
218 using ASTNode::ASTNode;
219
220 // Visitor methods
221 std::any accept(AbstractASTVisitor *visitor) override = 0;
222 std::any accept(ParallelizableASTVisitor *visitor) const override = 0;
223 };
224
225 // ========================================================== ExprNode ===========================================================
226
227 class ExprNode : public ASTNode {
228 public:
229 // Constructors
230 using ASTNode::ASTNode;
231
232 // Visitor methods
233 std::any accept(AbstractASTVisitor *visitor) override = 0;
234 std::any accept(ParallelizableASTVisitor *visitor) const override = 0;
235 };
236
237 // ======================================================== MainFctDefNode =======================================================
238
239 class MainFctDefNode final : public TopLevelDefNode {
240 public:
241 // Constructors
242 using TopLevelDefNode::TopLevelDefNode;
243
244 // Visitor methods
245 1092 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitMainFctDef(this); }
246 213 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitMainFctDef(this); }
247
248 // Public get methods
249 362 [[nodiscard]] TopLevelDefinitionAttrNode *attrs() const { return getChild<TopLevelDefinitionAttrNode>(); }
250 16 [[nodiscard]] ParamLstNode *paramLst() const { return getChild<ParamLstNode>(); }
251 1255 [[nodiscard]] StmtLstNode *body() const { return getChild<StmtLstNode>(); }
252
253 // Other methods
254
1/2
✓ Branch 1 taken 359 times.
✗ Branch 2 not taken.
1077 [[nodiscard]] static std::string getScopeId() { return "fct:main"; }
255 bool returnsOnAllControlPaths(bool *doSetPredecessorsUnreachable) const override;
256 [[nodiscard]] bool isFctOrProcDef() const override { return true; }
257
258 // Public members
259 bool takesArgs = false;
260 SymbolTableEntry *entry = nullptr;
261 Scope *bodyScope = nullptr;
262 };
263
264 // ========================================================== FctNameNode =======================================================
265
266 class FctNameNode final : public ASTNode {
267 public:
268 // Constructors
269 using ASTNode::ASTNode;
270
271 // Visitor methods
272 6757 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitFctName(this); }
273 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitFctName(this); }
274
275 // Other methods
276 [[nodiscard]] constexpr bool isOperatorOverload() const { return name.starts_with(OP_FCT_PREFIX); }
277 [[nodiscard]] bool supportsInverseOperator() const { return name == OP_FCT_EQUAL || name == OP_FCT_NOT_EQUAL; }
278
279 // Public members
280 std::string name;
281 std::string structName;
282 std::string fqName;
283 std::vector<std::string> nameFragments;
284 };
285
286 // ======================================================== FctDefBaseNode =======================================================
287
288 class FctDefBaseNode : public TopLevelDefNode {
289 public:
290 // Constructors
291 using TopLevelDefNode::TopLevelDefNode;
292
293 // Public get methods
294 24704 [[nodiscard]] TopLevelDefinitionAttrNode *attrs() const { return getChild<TopLevelDefinitionAttrNode>(); }
295 6953 [[nodiscard]] SpecifierLstNode *specifierLst() const { return getChild<SpecifierLstNode>(); }
296 1213 [[nodiscard]] TypeLstNode *templateTypeLst() const { return getChild<TypeLstNode>(); }
297 30794 [[nodiscard]] ParamLstNode *paramLst() const { return getChild<ParamLstNode>(); }
298 26306 [[nodiscard]] StmtLstNode *body() const { return getChild<StmtLstNode>(); }
299
300 // Other methods
301 13890 [[nodiscard]] std::string getSymbolTableEntryName() const { return Function::getSymbolTableEntryName(name->name, codeLoc); }
302 1429 std::vector<Function *> *getFctManifestations(const std::string &) override { return &manifestations; }
303 501995 [[nodiscard]] bool isFctOrProcDef() const override { return true; }
304 bool returnsOnAllControlPaths(bool *doSetPredecessorsUnreachable) const override;
305
306 // Public members
307 bool isMethod = false;
308 bool hasTemplateTypes = false;
309 bool hasParams = false;
310 TypeSpecifiers specifiers = TypeSpecifiers::of(TY_FUNCTION);
311 FctNameNode *name;
312 SymbolTableEntry *entry = nullptr;
313 Scope *structScope = nullptr;
314 Scope *scope = nullptr;
315 std::vector<Function *> manifestations;
316 };
317
318 // ========================================================== FctDefNode =========================================================
319
320 class FctDefNode final : public FctDefBaseNode {
321 public:
322 // Constructors
323 using FctDefBaseNode::FctDefBaseNode;
324
325 // Visitor methods
326 40106 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitFctDef(this); }
327 3920 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitFctDef(this); }
328
329 // Public get methods
330 8494 [[nodiscard]] DataTypeNode *returnType() const { return getChild<DataTypeNode>(); }
331
332 // Other methods
333
2/4
✓ Branch 1 taken 9021 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 9021 times.
✗ Branch 5 not taken.
9021 [[nodiscard]] std::string getScopeId() const { return "fct:" + codeLoc.toString(); }
334 };
335
336 // ========================================================== ProcDefNode ========================================================
337
338 class ProcDefNode final : public FctDefBaseNode {
339 public:
340 // Constructors
341 using FctDefBaseNode::FctDefBaseNode;
342
343 // Visitor methods
344 26583 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitProcDef(this); }
345 2472 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitProcDef(this); }
346
347 // Other methods
348
2/4
✓ Branch 1 taken 5525 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5525 times.
✗ Branch 5 not taken.
5525 [[nodiscard]] std::string getScopeId() const { return "proc:" + codeLoc.toString(); }
349
350 // Public members
351 bool isCtor = false;
352 };
353
354 // ========================================================= StructDefNode =======================================================
355
356 class StructDefNode final : public TopLevelDefNode {
357 public:
358 // Constructors
359 using TopLevelDefNode::TopLevelDefNode;
360
361 // Visitor methods
362 4559 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitStructDef(this); }
363 457 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitStructDef(this); }
364
365 // Public get methods
366 3651 [[nodiscard]] TopLevelDefinitionAttrNode *attrs() const { return getChild<TopLevelDefinitionAttrNode>(); }
367 545 [[nodiscard]] SpecifierLstNode *specifierLst() const { return getChild<SpecifierLstNode>(); }
368 5704 [[nodiscard]] std::vector<FieldNode *> fields() const { return getChildren<FieldNode>(); }
369 516 [[nodiscard]] TypeLstNode *templateTypeLst() const { return getChild<TypeLstNode>(0); }
370
2/2
✓ Branch 0 taken 213 times.
✓ Branch 1 taken 48 times.
261 [[nodiscard]] TypeLstNode *interfaceTypeLst() const { return getChild<TypeLstNode>(hasTemplateTypes ? 1 : 0); }
371
372 // Other methods
373 20207 std::vector<Struct *> *getStructManifestations() override { return &structManifestations; }
374 366 std::vector<Function *> *getFctManifestations(const std::string &fctName) override {
375
2/2
✓ Branch 1 taken 244 times.
✓ Branch 2 taken 122 times.
366 if (!defaultFctManifestations.contains(fctName))
376
2/4
✓ Branch 2 taken 244 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 244 times.
✗ Branch 6 not taken.
244 defaultFctManifestations.insert({fctName, {}});
377 366 return &defaultFctManifestations.at(fctName);
378 }
379 28734 [[nodiscard]] bool isStructDef() const override { return true; }
380
381 // Public members
382 bool hasTemplateTypes = false;
383 bool hasInterfaces = false;
384 bool emitVTable = false;
385 TypeSpecifiers structSpecifiers = TypeSpecifiers::of(TY_STRUCT);
386 std::string structName;
387 uint64_t typeId;
388 SymbolTableEntry *entry = nullptr;
389 std::vector<Struct *> structManifestations;
390 std::map<const std::string, std::vector<Function *>> defaultFctManifestations;
391 Scope *structScope = nullptr;
392 };
393
394 // ======================================================= InterfaceDefNode ======================================================
395
396 class InterfaceDefNode final : public TopLevelDefNode {
397 public:
398 // Constructors
399 using TopLevelDefNode::TopLevelDefNode;
400
401 // Visitor methods
402 553 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitInterfaceDef(this); }
403 60 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitInterfaceDef(this); }
404
405 // Public get methods
406 440 [[nodiscard]] TopLevelDefinitionAttrNode *attrs() const { return getChild<TopLevelDefinitionAttrNode>(); }
407 75 [[nodiscard]] SpecifierLstNode *specifierLst() const { return getChild<SpecifierLstNode>(); }
408 223 [[nodiscard]] std::vector<SignatureNode *> signatures() const { return getChildren<SignatureNode>(); }
409 168 [[nodiscard]] TypeLstNode *templateTypeLst() const { return getChild<TypeLstNode>(0); }
410
411 // Other methods
412 102 std::vector<Interface *> *getInterfaceManifestations() override { return &interfaceManifestations; }
413
414 // Public members
415 bool hasTemplateTypes = false;
416 TypeSpecifiers interfaceSpecifiers = TypeSpecifiers::of(TY_INTERFACE);
417 std::string interfaceName;
418 uint64_t typeId;
419 SymbolTableEntry *entry = nullptr;
420 std::vector<Interface *> interfaceManifestations;
421 Scope *interfaceScope = nullptr;
422 };
423
424 // ========================================================== EnumDefNode ========================================================
425
426 class EnumDefNode final : public TopLevelDefNode {
427 public:
428 // Constructors
429 using TopLevelDefNode::TopLevelDefNode;
430
431 // Visitor methods
432 194 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitEnumDef(this); }
433 37 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitEnumDef(this); }
434
435 // Public get methods
436 66 [[nodiscard]] SpecifierLstNode *specifierLst() const { return getChild<SpecifierLstNode>(); }
437 157 [[nodiscard]] EnumItemLstNode *itemLst() const { return getChild<EnumItemLstNode>(); }
438
439 // Public members
440 TypeSpecifiers enumSpecifiers = TypeSpecifiers::of(TY_ENUM);
441 std::string enumName;
442 uint64_t typeId;
443 SymbolTableEntry *entry = nullptr;
444 Scope *enumScope;
445 };
446
447 // ====================================================== GenericTypeDefNode =====================================================
448
449 class GenericTypeDefNode final : public TopLevelDefNode {
450 public:
451 // Constructors
452 using TopLevelDefNode::TopLevelDefNode;
453
454 // Visitor methods
455 6956 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitGenericTypeDef(this); }
456 647 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitGenericTypeDef(this); }
457
458 // Public get methods
459 1445 [[nodiscard]] TypeAltsLstNode *typeAltsLst() const { return getChild<TypeAltsLstNode>(); }
460
461 // Public members
462 std::string typeName;
463 SymbolTableEntry *entry = nullptr;
464 };
465
466 // ========================================================= AliasDefNode ========================================================
467
468 class AliasDefNode final : public TopLevelDefNode {
469 public:
470 // Constructors
471 using TopLevelDefNode::TopLevelDefNode;
472
473 // Visitor methods
474 170 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitAliasDef(this); }
475 29 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitAliasDef(this); }
476
477 // Public get methods
478 31 [[nodiscard]] SpecifierLstNode *specifierLst() const { return getChild<SpecifierLstNode>(); }
479 30 [[nodiscard]] DataTypeNode *dataType() const { return getChild<DataTypeNode>(); }
480
481 // Public members
482 TypeSpecifiers aliasSpecifiers = TypeSpecifiers::of(TY_ALIAS);
483 std::string aliasName;
484 std::string dataTypeString;
485 uint64_t typeId;
486 SymbolTableEntry *entry = nullptr;
487 SymbolTableEntry *aliasedTypeContainerEntry = nullptr;
488 };
489
490 // ======================================================= GlobalVarDefNode ======================================================
491
492 class GlobalVarDefNode final : public TopLevelDefNode {
493 public:
494 // Constructors
495 using TopLevelDefNode::TopLevelDefNode;
496
497 // Visitor methods
498 6089 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitGlobalVarDef(this); }
499 709 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitGlobalVarDef(this); }
500
501 // Public get methods
502 2183 [[nodiscard]] DataTypeNode *dataType() const { return getChild<DataTypeNode>(); }
503 2940 [[nodiscard]] ConstantNode *constant() const { return getChild<ConstantNode>(); }
504
505 // Other methods
506 [[nodiscard]] bool hasCompileTimeValue() const override { return true; }
507 [[nodiscard]] CompileTimeValue getCompileTimeValue() const override;
508
509 // Public members
510 bool hasValue = false;
511 std::string varName;
512 SymbolTableEntry *entry = nullptr;
513 };
514
515 // ========================================================== ExtDeclNode ========================================================
516
517 class ExtDeclNode final : public TopLevelDefNode {
518 public:
519 // Constructors
520 using TopLevelDefNode::TopLevelDefNode;
521
522 // Visitor methods
523 5856 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitExtDecl(this); }
524 667 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitExtDecl(this); }
525
526 // Public get methods
527 2777 [[nodiscard]] TopLevelDefinitionAttrNode *attrs() const { return getChild<TopLevelDefinitionAttrNode>(); }
528 1857 [[nodiscard]] DataTypeNode *returnType() const { return getChild<DataTypeNode>(); }
529 1354 [[nodiscard]] TypeLstNode *argTypeLst() const { return getChild<TypeLstNode>(); }
530
531 // Other methods
532 2 std::vector<Function *> *getFctManifestations(const std::string &) override { return &extFunctionManifestations; }
533 1402 [[nodiscard]] std::string getScopeId() const {
534
2/2
✓ Branch 0 taken 906 times.
✓ Branch 1 taken 496 times.
1402 const char *prefix = hasReturnType ? "func:" : "proc:";
535
2/4
✓ Branch 1 taken 1402 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1402 times.
✗ Branch 5 not taken.
1402 return prefix + codeLoc.toString();
536 }
537
538 // Public members
539 bool hasArgs = false;
540 bool isVarArg = false;
541 bool hasReturnType = false;
542 std::string extFunctionName;
543 SymbolTableEntry *entry = nullptr;
544 Function *extFunction = nullptr;
545 std::vector<Function *> extFunctionManifestations;
546 };
547
548 // ======================================================== ImportDefNode ========================================================
549
550 class ImportDefNode final : public TopLevelDefNode {
551 public:
552 // Constructors
553 using TopLevelDefNode::TopLevelDefNode;
554
555 // Visitor methods
556 2406 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitImportDef(this); }
557 340 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitImportDef(this); }
558
559 // Public members
560 std::string importPath;
561 std::string importName;
562 SymbolTableEntry *entry = nullptr;
563 };
564
565 // ======================================================== UnsafeBlockNode ======================================================
566
567 class UnsafeBlockNode final : public StmtNode {
568 public:
569 // Constructors
570 using StmtNode::StmtNode;
571
572 // Visitor methods
573 5271 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitUnsafeBlock(this); }
574 1517 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitUnsafeBlockDef(this); }
575
576 // Public get methods
577 6794 [[nodiscard]] StmtLstNode *body() const { return getChild<StmtLstNode>(); }
578
579 // Other methods
580
2/4
✓ Branch 1 taken 4986 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4986 times.
✗ Branch 5 not taken.
4986 [[nodiscard]] std::string getScopeId() const { return "unsafe:" + codeLoc.toString(); }
581
582 // Public members
583 Scope *bodyScope = nullptr;
584 };
585
586 // ========================================================== ForLoopNode ========================================================
587
588 class ForLoopNode final : public StmtNode {
589 public:
590 // Constructors
591 using StmtNode::StmtNode;
592
593 // Visitor methods
594 2967 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitForLoop(this); }
595 950 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitForLoop(this); }
596
597 // Public get methods
598 2983 [[nodiscard]] DeclStmtNode *initDecl() const { return getChild<DeclStmtNode>(); }
599 2808 [[nodiscard]] AssignExprNode *condAssign() const { return getChild<AssignExprNode>(0); }
600 1998 [[nodiscard]] AssignExprNode *incAssign() const { return getChild<AssignExprNode>(1); }
601 3966 [[nodiscard]] StmtLstNode *body() const { return getChild<StmtLstNode>(); }
602
603 // Other methods
604
2/4
✓ Branch 1 taken 2983 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2983 times.
✗ Branch 5 not taken.
2983 [[nodiscard]] std::string getScopeId() const { return "for:" + codeLoc.toString(); }
605 [[nodiscard]] bool returnsOnAllControlPaths(bool *doSetPredecessorsUnreachable) const override;
606
607 // Public members
608 Scope *bodyScope = nullptr;
609 };
610
611 // ======================================================== ForeachLoopNode ======================================================
612
613 class ForeachLoopNode final : public StmtNode {
614 public:
615 // Constructors
616 using StmtNode::StmtNode;
617
618 // Visitor methods
619 227 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitForeachLoop(this); }
620 85 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitForeachLoop(this); }
621
622 // Public get methods
623 273 [[nodiscard]] DeclStmtNode *idxVarDecl() const {
624
1/2
✓ Branch 1 taken 273 times.
✗ Branch 2 not taken.
273 std::vector<DeclStmtNode *> declStmtNodes = getChildren<DeclStmtNode>();
625
2/2
✓ Branch 1 taken 31 times.
✓ Branch 2 taken 242 times.
546 return declStmtNodes.size() == 2 ? declStmtNodes.front() : nullptr;
626 273 }
627
1/2
✓ Branch 1 taken 517 times.
✗ Branch 2 not taken.
517 [[nodiscard]] DeclStmtNode *itemVarDecl() const { return getChildren<DeclStmtNode>().back(); }
628 179 [[nodiscard]] AssignExprNode *iteratorAssign() const { return getChild<AssignExprNode>(); }
629 344 [[nodiscard]] StmtLstNode *body() const { return getChild<StmtLstNode>(); }
630
631 // Other methods
632
2/4
✓ Branch 1 taken 261 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 261 times.
✗ Branch 5 not taken.
261 [[nodiscard]] std::string getScopeId() const { return "foreach:" + codeLoc.toString(); }
633
634 // Public members
635 Scope *bodyScope = nullptr;
636 Function *getIteratorFct = nullptr;
637 Function *getFct = nullptr;
638 Function *getIdxFct = nullptr;
639 Function *isValidFct = nullptr;
640 Function *nextFct = nullptr;
641 };
642
643 // ========================================================= WhileLoopNode =======================================================
644
645 class WhileLoopNode final : public StmtNode {
646 public:
647 // Constructors
648 using StmtNode::StmtNode;
649
650 // Visitor methods
651 1248 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitWhileLoop(this); }
652 422 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitWhileLoop(this); }
653
654 // Public get methods
655 1675 [[nodiscard]] AssignExprNode *condition() const { return getChild<AssignExprNode>(); }
656 1687 [[nodiscard]] StmtLstNode *body() const { return getChild<StmtLstNode>(); }
657
658 // Other methods
659
2/4
✓ Branch 1 taken 1288 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1288 times.
✗ Branch 5 not taken.
1288 [[nodiscard]] std::string getScopeId() const { return "while:" + codeLoc.toString(); }
660 [[nodiscard]] bool returnsOnAllControlPaths(bool *doSetPredecessorsUnreachable) const override;
661
662 // Public members
663 Scope *bodyScope = nullptr;
664 };
665
666 // ======================================================== DoWhileLoopNode ======================================================
667
668 class DoWhileLoopNode final : public StmtNode {
669 public:
670 // Constructors
671 using StmtNode::StmtNode;
672
673 // Visitor methods
674 21 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitDoWhileLoop(this); }
675 8 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitDoWhileLoop(this); }
676
677 // Public get methods
678 28 [[nodiscard]] AssignExprNode *condition() const { return getChild<AssignExprNode>(); }
679 44 [[nodiscard]] StmtLstNode *body() const { return getChild<StmtLstNode>(); }
680
681 // Other methods
682
2/4
✓ Branch 1 taken 26 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 26 times.
✗ Branch 5 not taken.
26 [[nodiscard]] std::string getScopeId() const { return "dowhile:" + codeLoc.toString(); }
683 [[nodiscard]] bool returnsOnAllControlPaths(bool *doSetPredecessorsUnreachable) const override;
684
685 // Public members
686 Scope *bodyScope = nullptr;
687 };
688
689 // ========================================================== IfStmtNode =========================================================
690
691 class IfStmtNode final : public StmtNode {
692 public:
693 // Constructors
694 using StmtNode::StmtNode;
695
696 // Visitor methods
697 8800 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitIfStmt(this); }
698 2795 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitIfStmt(this); }
699
700 // Public get methods
701 11086 [[nodiscard]] AssignExprNode *condition() const { return getChild<AssignExprNode>(); }
702 13987 [[nodiscard]] StmtLstNode *thenBody() const { return getChild<StmtLstNode>(); }
703 16481 [[nodiscard]] ElseStmtNode *elseStmt() const { return getChild<ElseStmtNode>(); }
704
705 // Other methods
706
2/4
✓ Branch 1 taken 8743 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8743 times.
✗ Branch 5 not taken.
8743 [[nodiscard]] std::string getScopeId() const { return "if:" + codeLoc.toString(); }
707 [[nodiscard]] bool returnsOnAllControlPaths(bool *doSetPredecessorsUnreachable) const override;
708
709 // Public members
710 Scope *thenBodyScope = nullptr;
711 };
712
713 // ========================================================= ElseStmtNode ========================================================
714
715 class ElseStmtNode final : public StmtNode {
716 public:
717 // Constructors
718 using StmtNode::StmtNode;
719
720 // Visitor methods
721 466 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitElseStmt(this); }
722 140 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitElseStmt(this); }
723
724 // Public get methods
725 284 [[nodiscard]] IfStmtNode *ifStmt() const { return getChild<IfStmtNode>(); }
726 453 [[nodiscard]] StmtLstNode *body() const { return getChild<StmtLstNode>(); }
727
728 // Other methods
729
2/4
✓ Branch 1 taken 315 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 315 times.
✗ Branch 5 not taken.
315 [[nodiscard]] std::string getScopeId() const { return "if:" + codeLoc.toString(); }
730 [[nodiscard]] bool returnsOnAllControlPaths(bool *doSetPredecessorsUnreachable) const override;
731
732 // Public members
733 bool isElseIf = false;
734 Scope *elseBodyScope = nullptr;
735 };
736
737 // ======================================================== SwitchStmtNode =======================================================
738
739 class SwitchStmtNode final : public StmtNode {
740 public:
741 // Constructors
742 using StmtNode::StmtNode;
743
744 // Visitor methods
745 17 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitSwitchStmt(this); }
746 4 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitSwitchStmt(this); }
747
748 // Public get methods
749 14 [[nodiscard]] AssignExprNode *assignExpr() const { return getChild<AssignExprNode>(); }
750 19 [[nodiscard]] std::vector<CaseBranchNode *> caseBranches() const { return getChildren<CaseBranchNode>(); }
751 15 [[nodiscard]] DefaultBranchNode *defaultBranch() const { return getChild<DefaultBranchNode>(); }
752
753 // Other methods
754 [[nodiscard]] bool returnsOnAllControlPaths(bool *doSetPredecessorsUnreachable) const override;
755
756 // Public members
757 bool hasDefaultBranch = false;
758 };
759
760 // ======================================================== CaseBranchNode =======================================================
761
762 class CaseBranchNode final : public ASTNode {
763 public:
764 // Constructors
765 using ASTNode::ASTNode;
766
767 // Visitor methods
768 62 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitCaseBranch(this); }
769 24 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitCaseBranch(this); }
770
771 // Public get methods
772 80 [[nodiscard]] std::vector<CaseConstantNode *> caseConstants() const { return getChildren<CaseConstantNode>(); }
773 131 [[nodiscard]] StmtLstNode *body() const { return getChild<StmtLstNode>(); }
774
775 // Other methods
776
2/4
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 80 times.
✗ Branch 5 not taken.
80 [[nodiscard]] std::string getScopeId() const { return "case:" + codeLoc.toString(); }
777 [[nodiscard]] bool returnsOnAllControlPaths(bool *doSetPredecessorsUnreachable) const override;
778
779 // Public members
780 Scope *bodyScope = nullptr;
781 };
782
783 // ======================================================= DefaultBranchNode =====================================================
784
785 class DefaultBranchNode final : public ASTNode {
786 public:
787 // Constructors
788 using ASTNode::ASTNode;
789
790 // Visitor methods
791 6 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitDefaultBranch(this); }
792 1 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitDefaultBranch(this); }
793
794 // Public get methods
795 13 [[nodiscard]] StmtLstNode *body() const { return getChild<StmtLstNode>(); }
796
797 // Other methods
798
2/4
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
7 [[nodiscard]] std::string getScopeId() const { return "default:" + codeLoc.toString(); }
799 [[nodiscard]] bool returnsOnAllControlPaths(bool *doSetPredecessorsUnreachable) const override;
800
801 // Public members
802 Scope *bodyScope = nullptr;
803 };
804
805 // ==================================================== AnonymousBlockStmtNode ===================================================
806
807 class AnonymousBlockStmtNode final : public StmtNode {
808 public:
809 // Constructors
810 using StmtNode::StmtNode;
811
812 // Visitor methods
813 26 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitAnonymousBlockStmt(this); }
814 13 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitAnonymousBlockStmt(this); }
815
816 // Public get methods
817 52 [[nodiscard]] StmtLstNode *body() const { return getChild<StmtLstNode>(); }
818
819 // Other methods
820
2/4
✓ Branch 1 taken 39 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 39 times.
✗ Branch 5 not taken.
39 [[nodiscard]] std::string getScopeId() const { return "anon:" + codeLoc.toString(); }
821
822 // Public members
823 Scope *bodyScope = nullptr;
824 };
825
826 // ========================================================= StmtLstNode =========================================================
827
828 class StmtLstNode final : public ASTNode {
829 public:
830 // Structs
831 struct ResourcesForManifestationToCleanup {
832 std::vector<std::pair<SymbolTableEntry *, Function *>> dtorFunctionsToCall;
833 std::vector<SymbolTableEntry *> heapVarsToFree;
834 };
835
836 // Constructors
837 using ASTNode::ASTNode;
838
839 // Visitor methods
840 39872 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitStmtLst(this); }
841 12124 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitStmtLst(this); }
842
843 // Other methods
844 [[nodiscard]] bool returnsOnAllControlPaths(bool *doSetPredecessorsUnreachable) const override;
845 103051 void customItemsInitialization(size_t manifestationCount) override { resourcesToCleanup.resize(manifestationCount); }
846 12604 [[nodiscard]] bool isStmtLstNode() const override { return true; }
847
848 // Public members
849 size_t complexity = 0;
850 std::vector<ResourcesForManifestationToCleanup> resourcesToCleanup;
851 CodeLoc closingBraceCodeLoc = CodeLoc(1, 0);
852 };
853
854 // ========================================================= TypeLstNode =========================================================
855
856 class TypeLstNode final : public ASTNode {
857 public:
858 // Constructors
859 using ASTNode::ASTNode;
860
861 // Visitor methods
862 5114 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitTypeLst(this); }
863 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitTypeLst(this); }
864
865 // Public get methods
866 7815 [[nodiscard]] std::vector<DataTypeNode *> dataTypes() const { return getChildren<DataTypeNode>(); }
867 };
868
869 // ======================================================= TypeAltsLstNode =======================================================
870
871 class TypeAltsLstNode final : public ASTNode {
872 public:
873 // Constructors
874 using ASTNode::ASTNode;
875
876 // Visitor methods
877 688 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitTypeAltsLst(this); }
878 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitTypeAltsLst(this); }
879
880 // Public get methods
881 1444 [[nodiscard]] std::vector<DataTypeNode *> dataTypes() const { return getChildren<DataTypeNode>(); }
882 };
883
884 // ======================================================== ParamLstNode =========================================================
885
886 class ParamLstNode final : public ASTNode {
887 public:
888 // Constructors
889 using ASTNode::ASTNode;
890
891 // Visitor methods
892 19258 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitParamLst(this); }
893 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitParamLst(this); }
894
895 // Public get methods
896 24894 [[nodiscard]] std::vector<DeclStmtNode *> params() const { return getChildren<DeclStmtNode>(); }
897 };
898
899 // ========================================================== ArgLstNode =========================================================
900
901 class ArgLstNode final : public ASTNode {
902 public:
903 // Constructors
904 using ASTNode::ASTNode;
905
906 // Visitor methods
907 14152 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitArgLst(this); }
908 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitArgLst(this); }
909
910 // Public get methods
911 22414 [[nodiscard]] std::vector<AssignExprNode *> args() const { return getChildren<AssignExprNode>(); }
912 };
913
914 // ======================================================== EnumItemLstNode ======================================================
915
916 class EnumItemLstNode final : public ASTNode {
917 public:
918 // Constructors
919 using ASTNode::ASTNode;
920
921 // Visitor methods
922 72 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitEnumItemLst(this); }
923 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitEnumItemLst(this); }
924
925 // Public get methods
926 117 [[nodiscard]] std::vector<EnumItemNode *> items() const { return getChildren<EnumItemNode>(); }
927 };
928
929 // ========================================================= EnumItemNode ========================================================
930
931 class EnumItemNode final : public ASTNode {
932 public:
933 // Constructors
934 using ASTNode::ASTNode;
935
936 // Visitor methods
937 846 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitEnumItem(this); }
938 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitEnumItem(this); }
939
940 // Public members
941 bool hasValue = false;
942 uint32_t itemValue;
943 std::string itemName;
944 SymbolTableEntry *entry = nullptr;
945 EnumDefNode *enumDef = nullptr;
946 };
947
948 // ========================================================== FieldNode ==========================================================
949
950 class FieldNode final : public ASTNode {
951 public:
952 // Constructors
953 using ASTNode::ASTNode;
954
955 // Visitor methods
956 3357 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitField(this); }
957 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitField(this); }
958
959 // Public get methods
960 2377 [[nodiscard]] DataTypeNode *dataType() const { return getChild<DataTypeNode>(); }
961 16909 [[nodiscard]] TernaryExprNode *defaultValue() const { return getChild<TernaryExprNode>(); }
962
963 // Public members
964 std::string fieldName;
965 SymbolTableEntry *entry = nullptr;
966 };
967
968 // ======================================================== SignatureNode ========================================================
969
970 class SignatureNode final : public ASTNode {
971 public:
972 // Enums
973 enum SignatureType : uint8_t {
974 TYPE_NONE,
975 TYPE_FUNCTION,
976 TYPE_PROCEDURE,
977 };
978
979 // Constructors
980 using ASTNode::ASTNode;
981
982 // Visitor methods
983 503 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitSignature(this); }
984 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitSignature(this); }
985
986 // Public get methods
987 173 [[nodiscard]] SpecifierLstNode *specifierLst() const { return getChild<SpecifierLstNode>(); }
988 133 [[nodiscard]] DataTypeNode *returnType() const { return getChild<DataTypeNode>(); }
989 91 [[nodiscard]] TypeLstNode *templateTypeLst() const { return getChild<TypeLstNode>(0); }
990
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 16 times.
26 [[nodiscard]] TypeLstNode *paramTypeLst() const { return getChild<TypeLstNode>(hasTemplateTypes ? 1 : 0); }
991
992 // Other methods
993 std::vector<Function *> *getFctManifestations(const std::string &) override { return &signatureManifestations; }
994
995 // Public members
996 bool hasParams = false;
997 bool hasTemplateTypes = false;
998 SignatureType signatureType = TYPE_NONE;
999 TypeSpecifiers signatureSpecifiers;
1000 std::string methodName;
1001 SymbolTableEntry *entry = nullptr;
1002 std::vector<Function *> signatureManifestations;
1003 };
1004
1005 // ========================================================= DeclStmtNode ========================================================
1006
1007 class DeclStmtNode final : public StmtNode {
1008 public:
1009 // Constructors
1010 using StmtNode::StmtNode;
1011
1012 // Visitor methods
1013 45318 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitDeclStmt(this); }
1014 5747 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitDeclStmt(this); }
1015
1016 // Public get methods
1017 28554 [[nodiscard]] DataTypeNode *dataType() const { return getChild<DataTypeNode>(); }
1018 23871 [[nodiscard]] AssignExprNode *assignExpr() const { return getChild<AssignExprNode>(); }
1019
1020 // Util methods
1021 96930 void customItemsInitialization(size_t manifestationCount) override { entries.resize(manifestationCount); }
1022 661 [[nodiscard]] bool isParamNode() const override { return isParam; }
1023
1024 // Public members
1025 bool hasAssignment = false;
1026 bool isParam = false;
1027 bool isForEachItem = false;
1028 bool isCtorCallRequired = false; // For struct, in case there are reference fields, we need to call a user-defined ctor
1029 std::string varName;
1030 std::vector<SymbolTableEntry *> entries;
1031 Function *calledInitCtor = nullptr;
1032 Function *calledCopyCtor = nullptr;
1033 };
1034
1035 // ======================================================= SpecifierLstNode ======================================================
1036
1037 class SpecifierLstNode final : public ASTNode {
1038 public:
1039 // Constructors
1040 using ASTNode::ASTNode;
1041
1042 // Visitor methods
1043 21322 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitSpecifierLst(this); }
1044 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitSpecifierLst(this); }
1045
1046 // Public get methods
1047 43281 [[nodiscard]] std::vector<SpecifierNode *> specifiers() const { return getChildren<SpecifierNode>(); }
1048 };
1049
1050 // ========================================================= SpecifierNode =======================================================
1051
1052 class SpecifierNode final : public ASTNode {
1053 public:
1054 // Enums
1055 enum SpecifierType : uint8_t {
1056 TY_NONE,
1057 TY_CONST,
1058 TY_SIGNED,
1059 TY_UNSIGNED,
1060 TY_INLINE,
1061 TY_PUBLIC,
1062 TY_HEAP,
1063 TY_COMPOSITION,
1064 };
1065
1066 // Constructors
1067 using ASTNode::ASTNode;
1068
1069 // Visitor methods
1070 24662 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitSpecifier(this); }
1071 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitSpecifier(this); }
1072
1073 // Public members
1074 SpecifierType type = TY_NONE;
1075 };
1076
1077 // ========================================================== ModAttrNode ========================================================
1078
1079 class ModAttrNode final : public ASTNode {
1080 public:
1081 // Constructors
1082 using ASTNode::ASTNode;
1083
1084 // Visitor methods
1085 3351 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitModAttr(this); }
1086 246 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitModAttr(this); }
1087
1088 // Public get methods
1089 830 [[nodiscard]] AttrLstNode *attrLst() const { return getChild<AttrLstNode>(); }
1090 };
1091
1092 // =================================================== TopLevelDefinitionAttrNode ================================================
1093
1094 class TopLevelDefinitionAttrNode final : public ASTNode {
1095 public:
1096 // Constructors
1097 using ASTNode::ASTNode;
1098
1099 // Visitor methods
1100 273 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitTopLevelDefinitionAttr(this); }
1101 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitTopLevelDefinitionAttr(this); }
1102
1103 // Public get methods
1104 452 [[nodiscard]] AttrLstNode *attrLst() const { return getChild<AttrLstNode>(); }
1105 };
1106
1107 // ========================================================= LambdaAttrNode ======================================================
1108
1109 class LambdaAttrNode final : public ASTNode {
1110 public:
1111 // Constructors
1112 using ASTNode::ASTNode;
1113
1114 // Visitor methods
1115 1 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitLambdaAttr(this); }
1116 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitLambdaAttr(this); }
1117
1118 // Public get methods
1119 80 [[nodiscard]] AttrLstNode *attrLst() const { return getChild<AttrLstNode>(); }
1120 };
1121
1122 // ========================================================== AttrLstNode ========================================================
1123
1124 class AttrLstNode : public ASTNode {
1125 public:
1126 // Constructors
1127 using ASTNode::ASTNode;
1128
1129 // Visitor methods
1130 3348 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitAttrLst(this); }
1131 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitAttrLst(this); }
1132
1133 // Public get methods
1134 2502 [[nodiscard]] std::vector<AttrNode *> attributes() const { return getChildren<AttrNode>(); }
1135
1136 // Other methods
1137 [[nodiscard]] std::vector<const CompileTimeValue *> getAttrValuesByName(const std::string &key) const;
1138 [[nodiscard]] const CompileTimeValue *getAttrValueByName(const std::string &key) const;
1139 [[nodiscard]] bool hasAttr(const std::string &key) const;
1140 };
1141
1142 // ============================================================ AttrNode =========================================================
1143
1144 class AttrNode final : public ASTNode {
1145 public:
1146 // Enums
1147 enum AttrTarget : uint8_t {
1148 TARGET_INVALID = 0,
1149 TARGET_MODULE = 1 << 0,
1150 TARGET_STRUCT = 1 << 1,
1151 TARGET_INTERFACE = 1 << 2,
1152 TARGET_FCT_PROC = 1 << 3,
1153 TARGET_EXT_DECL = 1 << 4,
1154 TARGET_LAMBDA = 1 << 5,
1155 };
1156
1157 enum AttrType : uint8_t {
1158 ATTR_TYPE_INVALID,
1159 TYPE_STRING,
1160 TYPE_BOOL,
1161 TYPE_INT,
1162 };
1163
1164 // Constructors
1165 using ASTNode::ASTNode;
1166
1167 // Visitor methods
1168 4407 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitAttr(this); }
1169 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitAttr(this); }
1170
1171 // Public get methods
1172 1908 [[nodiscard]] ConstantNode *value() const { return getChild<ConstantNode>(); }
1173
1174 // Other methods
1175 [[nodiscard]] const CompileTimeValue *getValue() const;
1176
1177 // Public members
1178 AttrType type = ATTR_TYPE_INVALID;
1179 AttrTarget target = TARGET_INVALID;
1180 std::string key;
1181 };
1182
1183 // ======================================================== CaseConstantNode =====================================================
1184
1185 class CaseConstantNode final : public ASTNode {
1186 public:
1187 // Constructors
1188 using ASTNode::ASTNode;
1189
1190 // Visitor methods
1191 62 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitCaseConstant(this); }
1192 24 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitCaseConstant(this); }
1193
1194 // Public get methods
1195 131 [[nodiscard]] ConstantNode *constant() const { return getChild<ConstantNode>(); }
1196
1197 // Public members
1198 std::vector<std::string> identifierFragments;
1199 std::string fqIdentifier;
1200 const SymbolTableEntry *enumItemEntry = nullptr;
1201 };
1202
1203 // ======================================================== ReturnStmtNode =======================================================
1204
1205 class ReturnStmtNode final : public StmtNode {
1206 public:
1207 // Constructors
1208 using StmtNode::StmtNode;
1209
1210 // Visitor methods
1211 16926 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitReturnStmt(this); }
1212 5398 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitReturnStmt(this); }
1213
1214 // Public get methods
1215 16976 [[nodiscard]] AssignExprNode *assignExpr() const { return getChild<AssignExprNode>(); }
1216
1217 // Other methods
1218 5247 [[nodiscard]] bool returnsOnAllControlPaths(bool *) const override { return true; }
1219
1/2
✓ Branch 0 taken 5398 times.
✗ Branch 1 not taken.
10796 [[nodiscard]] StmtLstNode *getParentScopeNode() const { return spice_pointer_cast<StmtLstNode *>(parent); }
1220
1221 // Public members
1222 bool hasReturnValue = false;
1223 };
1224
1225 // ======================================================== BreakStmtNode ========================================================
1226
1227 class BreakStmtNode final : public StmtNode {
1228 public:
1229 // Constructors
1230 using StmtNode::StmtNode;
1231
1232 // Visitor methods
1233 291 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitBreakStmt(this); }
1234 91 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitBreakStmt(this); }
1235
1236 // Public members
1237 int breakTimes = 1;
1238 };
1239
1240 // ======================================================= ContinueStmtNode ======================================================
1241
1242 class ContinueStmtNode final : public StmtNode {
1243 public:
1244 // Constructors
1245 using StmtNode::StmtNode;
1246
1247 // Visitor methods
1248 670 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitContinueStmt(this); }
1249 301 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitContinueStmt(this); }
1250
1251 // Public members
1252 int continueTimes = 1;
1253 };
1254
1255 // ====================================================== FallthroughStmtNode ====================================================
1256
1257 class FallthroughStmtNode final : public StmtNode {
1258 public:
1259 // Constructors
1260 using StmtNode::StmtNode;
1261
1262 // Visitor methods
1263 12 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitFallthroughStmt(this); }
1264 4 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitFallthroughStmt(this); }
1265 };
1266
1267 // ======================================================== AssertStmtNode =======================================================
1268
1269 class AssertStmtNode final : public StmtNode {
1270 public:
1271 // Constructors
1272 using StmtNode::StmtNode;
1273
1274 // Visitor methods
1275 1331 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitAssertStmt(this); }
1276 653 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitAssertStmt(this); }
1277
1278 // Public get methods
1279 1922 [[nodiscard]] AssignExprNode *assignExpr() const { return getChild<AssignExprNode>(); }
1280
1281 // Other methods
1282 [[nodiscard]] bool returnsOnAllControlPaths(bool *doSetPredecessorsUnreachable) const override;
1283
1284 // Public members
1285 std::string expressionString;
1286 };
1287
1288 // ======================================================== PrintfCallNode =======================================================
1289
1290 class PrintfCallNode final : public ExprNode {
1291 public:
1292 // Constructors
1293 using ExprNode::ExprNode;
1294
1295 // Visitor methods
1296 1463 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitPrintfCall(this); }
1297 579 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitPrintfCall(this); }
1298
1299 // Public get methods
1300 2307 [[nodiscard]] std::vector<AssignExprNode *> args() const { return getChildren<AssignExprNode>(); }
1301
1302 // Other methods
1303 [[nodiscard]] bool hasCompileTimeValue() const override { return false; }
1304
1305 // Public members
1306 std::string templatedString;
1307 };
1308
1309 // ======================================================== SizeofCallNode =======================================================
1310
1311 class SizeofCallNode final : public ExprNode {
1312 public:
1313 // Constructors
1314 using ExprNode::ExprNode;
1315
1316 // Visitor methods
1317 474 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitSizeofCall(this); }
1318 119 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitSizeofCall(this); }
1319
1320 // Public get methods
1321 34 [[nodiscard]] AssignExprNode *assignExpr() const { return getChild<AssignExprNode>(); }
1322 204 [[nodiscard]] DataTypeNode *dataType() const { return getChild<DataTypeNode>(); }
1323
1324 // Other methods
1325 4 [[nodiscard]] bool hasCompileTimeValue() const override { return false; }
1326
1327 // Public members
1328 bool isType = false;
1329 };
1330
1331 // ======================================================== AlignofCallNode ======================================================
1332
1333 class AlignofCallNode final : public ExprNode {
1334 public:
1335 // Constructors
1336 using ExprNode::ExprNode;
1337
1338 // Visitor methods
1339 22 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitAlignofCall(this); }
1340 11 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitAlignofCall(this); }
1341
1342 // Public get methods
1343 20 [[nodiscard]] AssignExprNode *assignExpr() const { return getChild<AssignExprNode>(); }
1344 2 [[nodiscard]] DataTypeNode *dataType() const { return getChild<DataTypeNode>(); }
1345
1346 // Other methods
1347 [[nodiscard]] bool hasCompileTimeValue() const override { return false; }
1348
1349 // Public members
1350 bool isType = false;
1351 };
1352
1353 // ========================================================= LenCallNode =========================================================
1354
1355 class LenCallNode final : public ExprNode {
1356 public:
1357 // Constructors
1358 using ExprNode::ExprNode;
1359
1360 // Visitor methods
1361 76 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitLenCall(this); }
1362 35 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitLenCall(this); }
1363
1364 // Public get methods
1365 96 [[nodiscard]] AssignExprNode *assignExpr() const { return getChild<AssignExprNode>(); }
1366
1367 // Other methods
1368 5 [[nodiscard]] bool hasCompileTimeValue() const override { return false; }
1369 };
1370
1371 // ======================================================== PanicCallNode ========================================================
1372
1373 class PanicCallNode final : public ExprNode {
1374 public:
1375 // Constructors
1376 using ExprNode::ExprNode;
1377
1378 // Visitor methods
1379 1283 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitPanicCall(this); }
1380 348 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitPanicCall(this); }
1381
1382 // Public get methods
1383 366 [[nodiscard]] AssignExprNode *assignExpr() const { return getChild<AssignExprNode>(); }
1384
1385 // Other methods
1386 [[nodiscard]] bool hasCompileTimeValue() const override { return false; }
1387 456 [[nodiscard]] bool returnsOnAllControlPaths(bool *) const override { return true; }
1388 };
1389
1390 // ========================================================= SysCallNode =========================================================
1391
1392 class SysCallNode final : public ExprNode {
1393 public:
1394 // Constructors
1395 using ExprNode::ExprNode;
1396
1397 // Visitor methods
1398 2 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitSysCall(this); }
1399 1 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitSysCall(this); }
1400
1401 // Public get methods
1402 3 [[nodiscard]] std::vector<AssignExprNode *> assignExprs() const { return getChildren<AssignExprNode>(); }
1403 };
1404
1405 // ======================================================= AssignExprNode ========================================================
1406
1407 class AssignExprNode final : public ExprNode {
1408 public:
1409 // Enums
1410 enum AssignOp : uint8_t {
1411 OP_NONE,
1412 OP_ASSIGN,
1413 OP_PLUS_EQUAL,
1414 OP_MINUS_EQUAL,
1415 OP_MUL_EQUAL,
1416 OP_DIV_EQUAL,
1417 OP_REM_EQUAL,
1418 OP_SHL_EQUAL,
1419 OP_SHR_EQUAL,
1420 OP_AND_EQUAL,
1421 OP_OR_EQUAL,
1422 OP_XOR_EQUAL
1423 };
1424
1425 // Constructors
1426 using ExprNode::ExprNode;
1427
1428 // Visitor methods
1429 136110 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitAssignExpr(this); }
1430 43019 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitAssignExpr(this); }
1431
1432 // Public get methods
1433 9232 [[nodiscard]] AssignExprNode *rhs() const { return getChild<AssignExprNode>(); }
1434 18713 [[nodiscard]] PrefixUnaryExprNode *lhs() const { return getChild<PrefixUnaryExprNode>(); }
1435 174016 [[nodiscard]] TernaryExprNode *ternaryExpr() const { return getChild<TernaryExprNode>(); }
1436
1437 // Other methods
1438 [[nodiscard]] bool returnsOnAllControlPaths(bool *doSetPredecessorsUnreachable) const override;
1439 5117 [[nodiscard]] bool isAssignExpr() const override { return true; }
1440 240 [[nodiscard]] std::vector<std::vector<const Function *>> *getOpFctPointers() override { return &opFct; }
1441 684 [[nodiscard]] const std::vector<std::vector<const Function *>> *getOpFctPointers() const override { return &opFct; }
1442
2/4
✓ Branch 1 taken 345158 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 345158 times.
✗ Branch 5 not taken.
1035474 void customItemsInitialization(size_t manifestationCount) override { opFct.resize(manifestationCount, {nullptr}); }
1443
1444 // Public members
1445 AssignOp op = OP_NONE;
1446 std::vector<std::vector<const Function *>> opFct; // Operator overloading functions
1447 };
1448
1449 // ======================================================= TernaryExprNode =======================================================
1450
1451 class TernaryExprNode final : public ExprNode {
1452 public:
1453 // Constructors
1454 using ExprNode::ExprNode;
1455
1456 // Visitor methods
1457 121639 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitTernaryExpr(this); }
1458 38789 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitTernaryExpr(this); }
1459
1460 // Public get methods
1461 130369 [[nodiscard]] std::vector<LogicalOrExprNode *> operands() const { return getChildren<LogicalOrExprNode>(); }
1462
1463 // Other methods
1464 [[nodiscard]] bool hasCompileTimeValue() const override;
1465 [[nodiscard]] CompileTimeValue getCompileTimeValue() const override;
1466
1467 bool isShortened = false;
1468 };
1469
1470 // ===================================================== LogicalOrExprNode =======================================================
1471
1472 class LogicalOrExprNode final : public ExprNode {
1473 public:
1474 // Constructors
1475 using ExprNode::ExprNode;
1476
1477 // Visitor methods
1478 123193 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitLogicalOrExpr(this); }
1479 39314 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitLogicalOrExpr(this); }
1480
1481 // Public get methods
1482 133756 [[nodiscard]] std::vector<LogicalAndExprNode *> operands() const { return getChildren<LogicalAndExprNode>(); }
1483
1484 // Other methods
1485 [[nodiscard]] bool hasCompileTimeValue() const override;
1486 [[nodiscard]] CompileTimeValue getCompileTimeValue() const override;
1487 };
1488
1489 // ===================================================== LogicalAndExprNode ======================================================
1490
1491 class LogicalAndExprNode final : public ExprNode {
1492 public:
1493 // Constructors
1494 using ExprNode::ExprNode;
1495
1496 // Visitor methods
1497 124121 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitLogicalAndExpr(this); }
1498 39579 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitLogicalAndExpr(this); }
1499
1500 // Public get methods
1501 132376 [[nodiscard]] std::vector<BitwiseOrExprNode *> operands() const { return getChildren<BitwiseOrExprNode>(); }
1502
1503 // Other methods
1504 [[nodiscard]] bool hasCompileTimeValue() const override;
1505 [[nodiscard]] CompileTimeValue getCompileTimeValue() const override;
1506 };
1507
1508 // ===================================================== BitwiseOrExprNode =======================================================
1509
1510 class BitwiseOrExprNode final : public ExprNode {
1511 public:
1512 // Constructors
1513 using ExprNode::ExprNode;
1514
1515 // Visitor methods
1516 124392 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitBitwiseOrExpr(this); }
1517 39640 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitBitwiseOrExpr(this); }
1518
1519 // Public get methods
1520 132107 [[nodiscard]] std::vector<BitwiseXorExprNode *> operands() const { return getChildren<BitwiseXorExprNode>(); }
1521
1522 // Other methods
1523 [[nodiscard]] bool hasCompileTimeValue() const override;
1524 [[nodiscard]] CompileTimeValue getCompileTimeValue() const override;
1525 };
1526
1527 // ==================================================== BitwiseXorExprNode =======================================================
1528
1529 class BitwiseXorExprNode final : public ExprNode {
1530 public:
1531 // Constructors
1532 using ExprNode::ExprNode;
1533
1534 // Visitor methods
1535 124485 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitBitwiseXorExpr(this); }
1536 39671 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitBitwiseXorExpr(this); }
1537
1538 // Public get methods
1539 132035 [[nodiscard]] std::vector<BitwiseAndExprNode *> operands() const { return getChildren<BitwiseAndExprNode>(); }
1540
1541 // Other methods
1542 [[nodiscard]] bool hasCompileTimeValue() const override;
1543 [[nodiscard]] CompileTimeValue getCompileTimeValue() const override;
1544 };
1545
1546 // ==================================================== BitwiseAndExprNode =======================================================
1547
1548 class BitwiseAndExprNode final : public ExprNode {
1549 public:
1550 // Constructors
1551 using ExprNode::ExprNode;
1552
1553 // Visitor methods
1554 124494 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitBitwiseAndExpr(this); }
1555 39674 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitBitwiseAndExpr(this); }
1556
1557 // Public get methods
1558 132204 [[nodiscard]] std::vector<EqualityExprNode *> operands() const { return getChildren<EqualityExprNode>(); }
1559
1560 // Other methods
1561 [[nodiscard]] bool hasCompileTimeValue() const override;
1562 [[nodiscard]] CompileTimeValue getCompileTimeValue() const override;
1563 };
1564
1565 // ===================================================== EqualityExprNode ========================================================
1566
1567 class EqualityExprNode final : public ExprNode {
1568 public:
1569 // Enums
1570 enum EqualityOp : uint8_t {
1571 OP_NONE,
1572 OP_EQUAL,
1573 OP_NOT_EQUAL,
1574 };
1575
1576 // Constructors
1577 using ExprNode::ExprNode;
1578
1579 // Visitor methods
1580 124569 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitEqualityExpr(this); }
1581 39703 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitEqualityExpr(this); }
1582
1583 // Public get methods
1584 139249 [[nodiscard]] std::vector<RelationalExprNode *> operands() const { return getChildren<RelationalExprNode>(); }
1585
1586 // Other methods
1587 [[nodiscard]] bool hasCompileTimeValue() const override;
1588 [[nodiscard]] CompileTimeValue getCompileTimeValue() const override;
1589 734 [[nodiscard]] std::vector<std::vector<const Function *>> *getOpFctPointers() override { return &opFct; }
1590 7205 [[nodiscard]] const std::vector<std::vector<const Function *>> *getOpFctPointers() const override { return &opFct; }
1591
2/4
✓ Branch 1 taken 308471 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 308471 times.
✗ Branch 5 not taken.
925413 void customItemsInitialization(size_t manifestationCount) override { opFct.resize(manifestationCount, {nullptr}); }
1592
1593 // Public members
1594 EqualityOp op = OP_NONE;
1595 std::vector<std::vector<const Function *>> opFct; // Operator overloading functions
1596 };
1597
1598 // ==================================================== RelationalExprNode =======================================================
1599
1600 class RelationalExprNode final : public ExprNode {
1601 public:
1602 // Enums
1603 enum RelationalOp : uint8_t {
1604 OP_NONE,
1605 OP_LESS,
1606 OP_GREATER,
1607 OP_LESS_EQUAL,
1608 OP_GREATER_EQUAL,
1609 };
1610
1611 // Constructors
1612 using ExprNode::ExprNode;
1613
1614 // Visitor methods
1615 134923 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitRelationalExpr(this); }
1616 43138 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitRelationalExpr(this); }
1617
1618 // Public get methods
1619 147550 [[nodiscard]] std::vector<ShiftExprNode *> operands() const { return getChildren<ShiftExprNode>(); }
1620
1621 // Other methods
1622 [[nodiscard]] bool hasCompileTimeValue() const override;
1623 [[nodiscard]] CompileTimeValue getCompileTimeValue() const override;
1624
1625 // Public members
1626 RelationalOp op = OP_NONE;
1627 };
1628
1629 // ====================================================== ShiftExprNode ==========================================================
1630
1631 class ShiftExprNode final : public ExprNode {
1632 public:
1633 // Enums
1634 enum ShiftOp : uint8_t {
1635 OP_NONE,
1636 OP_SHIFT_LEFT,
1637 OP_SHIFT_RIGHT,
1638 };
1639
1640 // Constructors
1641 using ExprNode::ExprNode;
1642
1643 // Visitor methods
1644 141516 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitShiftExpr(this); }
1645 45454 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitShiftExpr(this); }
1646
1647 // Public get methods
1648 149898 [[nodiscard]] std::vector<AdditiveExprNode *> operands() const { return getChildren<AdditiveExprNode>(); }
1649
1650 // Other methods
1651 [[nodiscard]] bool hasCompileTimeValue() const override;
1652 [[nodiscard]] CompileTimeValue getCompileTimeValue() const override;
1653 4 [[nodiscard]] std::vector<std::vector<const Function *>> *getOpFctPointers() override { return &opFct; }
1654 32 [[nodiscard]] const std::vector<std::vector<const Function *>> *getOpFctPointers() const override { return &opFct; }
1655
2/4
✓ Branch 1 taken 354386 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 354386 times.
✗ Branch 5 not taken.
1063158 void customItemsInitialization(size_t manifestationCount) override { opFct.resize(manifestationCount, {nullptr}); }
1656
1657 // Public members
1658 ShiftOp op = OP_NONE;
1659 std::vector<std::vector<const Function *>> opFct; // Operator overloading functions
1660 };
1661
1662 // ==================================================== AdditiveExprNode =========================================================
1663
1664 class AdditiveExprNode final : public ExprNode {
1665 public:
1666 // Enums
1667 enum AdditiveOp : uint8_t {
1668 OP_PLUS,
1669 OP_MINUS,
1670 };
1671
1672 // Typedefs
1673 using OpQueue = std::queue<std::pair<AdditiveOp, QualType>>;
1674
1675 // Constructors
1676 using ExprNode::ExprNode;
1677
1678 // Visitor methods
1679 141553 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitAdditiveExpr(this); }
1680 45469 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitAdditiveExpr(this); }
1681
1682 // Public get methods
1683 156465 [[nodiscard]] std::vector<MultiplicativeExprNode *> operands() const { return getChildren<MultiplicativeExprNode>(); }
1684
1685 // Other methods
1686 [[nodiscard]] bool hasCompileTimeValue() const override;
1687 [[nodiscard]] CompileTimeValue getCompileTimeValue() const override;
1688 94 [[nodiscard]] std::vector<std::vector<const Function *>> *getOpFctPointers() override { return &opFct; }
1689 6277 [[nodiscard]] const std::vector<std::vector<const Function *>> *getOpFctPointers() const override { return &opFct; }
1690
2/4
✓ Branch 1 taken 354424 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 354424 times.
✗ Branch 5 not taken.
1063272 void customItemsInitialization(size_t manifestationCount) override { opFct.resize(manifestationCount, {nullptr}); }
1691
1692 // Public members
1693 OpQueue opQueue;
1694 std::vector<std::vector<const Function *>> opFct; // Operator overloading functions
1695 };
1696
1697 // ================================================== MultiplicativeExprNode =====================================================
1698
1699 class MultiplicativeExprNode final : public ExprNode {
1700 public:
1701 // Enums
1702 enum MultiplicativeOp : uint8_t {
1703 OP_MUL,
1704 OP_DIV,
1705 OP_REM,
1706 };
1707
1708 // Typedefs
1709 using OpQueue = std::queue<std::pair<MultiplicativeOp, QualType>>;
1710
1711 // Constructors
1712 using ExprNode::ExprNode;
1713
1714 // Visitor methods
1715 150358 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitMultiplicativeExpr(this); }
1716 48584 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitMultiplicativeExpr(this); }
1717
1718 // Public get methods
1719 161253 [[nodiscard]] std::vector<CastExprNode *> operands() const { return getChildren<CastExprNode>(); }
1720
1721 // Other methods
1722 [[nodiscard]] bool hasCompileTimeValue() const override;
1723 [[nodiscard]] CompileTimeValue getCompileTimeValue() const override;
1724 24 [[nodiscard]] std::vector<std::vector<const Function *>> *getOpFctPointers() override { return &opFct; }
1725 1604 [[nodiscard]] const std::vector<std::vector<const Function *>> *getOpFctPointers() const override { return &opFct; }
1726
2/4
✓ Branch 1 taken 378118 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 378118 times.
✗ Branch 5 not taken.
1134354 void customItemsInitialization(size_t manifestationCount) override { opFct.resize(manifestationCount, {nullptr}); }
1727
1728 // Public members
1729 OpQueue opQueue;
1730 std::vector<std::vector<const Function *>> opFct; // Operator overloading functions
1731 };
1732
1733 // ======================================================= CastExprNode ==========================================================
1734
1735 class CastExprNode final : public ExprNode {
1736 public:
1737 // Constructors
1738 using ExprNode::ExprNode;
1739
1740 // Visitor methods
1741 153232 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitCastExpr(this); }
1742 49389 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitCastExpr(this); }
1743
1744 // Public get methods
1745 2357 [[nodiscard]] DataTypeNode *dataType() const { return getChild<DataTypeNode>(); }
1746 112669 [[nodiscard]] PrefixUnaryExprNode *prefixUnaryExpr() const { return getChild<PrefixUnaryExprNode>(); }
1747
1748 // Other methods
1749 [[nodiscard]] bool hasCompileTimeValue() const override;
1750 [[nodiscard]] CompileTimeValue getCompileTimeValue() const override;
1751
1752 // Public members
1753 bool isCast = false;
1754 };
1755
1756 // ==================================================== PrefixUnaryExprNode ======================================================
1757
1758 class PrefixUnaryExprNode final : public ExprNode {
1759 public:
1760 // Enums
1761 enum PrefixUnaryOp : uint8_t {
1762 OP_NONE,
1763 OP_MINUS,
1764 OP_PLUS_PLUS,
1765 OP_MINUS_MINUS,
1766 OP_NOT,
1767 OP_BITWISE_NOT,
1768 OP_DEREFERENCE,
1769 OP_ADDRESS_OF,
1770 };
1771
1772 // Constructors
1773 using ExprNode::ExprNode;
1774
1775 // Visitor methods
1776 171153 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitPrefixUnaryExpr(this); }
1777 54534 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitPrefixUnaryExpr(this); }
1778
1779 // Public get methods
1780 1785 [[nodiscard]] PrefixUnaryExprNode *prefixUnary() const { return getChild<PrefixUnaryExprNode>(); }
1781 138857 [[nodiscard]] PostfixUnaryExprNode *postfixUnaryExpr() const { return getChild<PostfixUnaryExprNode>(); }
1782
1783 // Other methods
1784 [[nodiscard]] bool hasCompileTimeValue() const override;
1785 [[nodiscard]] CompileTimeValue getCompileTimeValue() const override;
1786
1787 // Public members
1788 PrefixUnaryOp op = OP_NONE;
1789 };
1790
1791 // =================================================== PostfixUnaryExprNode ======================================================
1792
1793 class PostfixUnaryExprNode final : public ExprNode {
1794 public:
1795 // Enums
1796 enum PostfixUnaryOp : uint8_t {
1797 OP_NONE,
1798 OP_SUBSCRIPT,
1799 OP_MEMBER_ACCESS,
1800 OP_PLUS_PLUS,
1801 OP_MINUS_MINUS,
1802 };
1803
1804 // Constructors
1805 using ExprNode::ExprNode;
1806
1807 // Visitor methods
1808 217429 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitPostfixUnaryExpr(this); }
1809 68564 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitPostfixUnaryExpr(this); }
1810
1811 // Public get methods
1812 132742 [[nodiscard]] AtomicExprNode *atomicExpr() const { return getChild<AtomicExprNode>(); }
1813 30785 [[nodiscard]] PostfixUnaryExprNode *postfixUnaryExpr() const { return getChild<PostfixUnaryExprNode>(); }
1814 4446 [[nodiscard]] AssignExprNode *assignExpr() const { return getChild<AssignExprNode>(); }
1815
1816 // Other methods
1817 [[nodiscard]] bool hasCompileTimeValue() const override;
1818 [[nodiscard]] CompileTimeValue getCompileTimeValue() const override;
1819 30 [[nodiscard]] std::vector<std::vector<const Function *>> *getOpFctPointers() override { return &opFct; }
1820 5919 [[nodiscard]] const std::vector<std::vector<const Function *>> *getOpFctPointers() const override { return &opFct; }
1821
2/4
✓ Branch 1 taken 569266 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 569266 times.
✗ Branch 5 not taken.
1707798 void customItemsInitialization(size_t manifestationCount) override { opFct.resize(manifestationCount, {nullptr}); }
1822
1823 // Public members
1824 PostfixUnaryOp op = OP_NONE;
1825 std::vector<std::vector<const Function *>> opFct; // Operator overloading functions
1826 std::string identifier; // Only set when operator is member access
1827 };
1828
1829 // ====================================================== AtomicExprNode =========================================================
1830
1831 class AtomicExprNode final : public ExprNode {
1832 public:
1833 // Structs
1834 struct VarAccessData {
1835 SymbolTableEntry *entry = nullptr;
1836 Scope *accessScope = nullptr;
1837 Capture *capture = nullptr;
1838 };
1839
1840 // Constructors
1841 using ExprNode::ExprNode;
1842
1843 // Visitor methods
1844 168646 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitAtomicExpr(this); }
1845 53837 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitAtomicExpr(this); }
1846
1847 // Public get methods
1848 135733 [[nodiscard]] ConstantNode *constant() const { return getChild<ConstantNode>(); }
1849 115610 [[nodiscard]] ValueNode *value() const { return getChild<ValueNode>(); }
1850 72070 [[nodiscard]] AssignExprNode *assignExpr() const { return getChild<AssignExprNode>(); }
1851 73003 [[nodiscard]] PrintfCallNode *printfCall() const { return getChild<PrintfCallNode>(); }
1852 70781 [[nodiscard]] SizeofCallNode *sizeofCall() const { return getChild<SizeofCallNode>(); }
1853 70327 [[nodiscard]] AlignofCallNode *alignofCall() const { return getChild<AlignofCallNode>(); }
1854 70354 [[nodiscard]] LenCallNode *lenCall() const { return getChild<LenCallNode>(); }
1855 70926 [[nodiscard]] PanicCallNode *panicCall() const { return getChild<PanicCallNode>(); }
1856 69500 [[nodiscard]] SysCallNode *sysCall() const { return getChild<SysCallNode>(); }
1857
1858 // Other methods
1859 430575 void customItemsInitialization(size_t manifestationCount) override { data.resize(manifestationCount); }
1860
1861 // Public members
1862 std::vector<std::string> identifierFragments;
1863 std::string fqIdentifier;
1864 std::vector<VarAccessData> data; // Only set if identifier is set as well
1865 };
1866
1867 // ======================================================== ValueNode ============================================================
1868
1869 class ValueNode final : public ExprNode {
1870 public:
1871 // Constructors
1872 using ExprNode::ExprNode;
1873
1874 // Visitor methods
1875 31779 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitValue(this); }
1876 10317 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitValue(this); }
1877
1878 // Public get methods
1879 41061 [[nodiscard]] FctCallNode *fctCall() const { return getChild<FctCallNode>(); }
1880 2410 [[nodiscard]] ArrayInitializationNode *arrayInitialization() const { return getChild<ArrayInitializationNode>(); }
1881 2523 [[nodiscard]] StructInstantiationNode *structInstantiation() const { return getChild<StructInstantiationNode>(); }
1882 1859 [[nodiscard]] LambdaFuncNode *lambdaFunc() const { return getChild<LambdaFuncNode>(); }
1883 1885 [[nodiscard]] LambdaProcNode *lambdaProc() const { return getChild<LambdaProcNode>(); }
1884 1779 [[nodiscard]] LambdaExprNode *lambdaExpr() const { return getChild<LambdaExprNode>(); }
1885 1775 [[nodiscard]] DataTypeNode *nilType() const { return getChild<DataTypeNode>(); }
1886
1887 // Other methods
1888 1056 [[nodiscard]] bool hasCompileTimeValue() const override { return isNil; }
1889
1890 // Public members
1891 bool isNil = false;
1892 };
1893
1894 // ====================================================== ConstantNode ===========================================================
1895
1896 class ConstantNode final : public ExprNode {
1897 public:
1898 // Enum
1899 enum PrimitiveValueType : uint8_t {
1900 TYPE_NONE,
1901 TYPE_DOUBLE,
1902 TYPE_INT,
1903 TYPE_SHORT,
1904 TYPE_LONG,
1905 TYPE_BYTE,
1906 TYPE_CHAR,
1907 TYPE_STRING,
1908 TYPE_BOOL
1909 };
1910
1911 // Constructors
1912 using ExprNode::ExprNode;
1913
1914 // Visitor methods
1915 34680 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitConstant(this); }
1916 9706 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitConstant(this); }
1917
1918 // Other methods
1919 9817 [[nodiscard]] CompileTimeValue getCompileTimeValue() const override { return compileTimeValue; }
1920 232 [[nodiscard]] bool hasCompileTimeValue() const override { return true; }
1921
1922 // Public members
1923 PrimitiveValueType type = TYPE_NONE;
1924 CompileTimeValue compileTimeValue;
1925 };
1926
1927 // ====================================================== FctCallNode ============================================================
1928
1929 class FctCallNode final : public ExprNode {
1930 public:
1931 // Enums
1932 enum FctCallType : uint8_t {
1933 TYPE_ORDINARY,
1934 TYPE_METHOD,
1935 TYPE_CTOR,
1936 TYPE_FCT_PTR,
1937 };
1938
1939 // Structs
1940 struct FctCallData {
1941 // Members
1942 FctCallType callType = TYPE_ORDINARY;
1943 bool isImported = false;
1944 QualType thisType = QualType(TY_DYN); // Is filled if method or ctor call
1945 std::vector<ExprResult> argResults;
1946 Function *callee = nullptr;
1947 Scope *calleeParentScope = nullptr;
1948
1949 // Methods
1950 5325 [[nodiscard]] bool isOrdinaryCall() const { return callType == TYPE_ORDINARY; }
1951 45938 [[nodiscard]] bool isMethodCall() const { return callType == TYPE_METHOD; }
1952
4/4
✓ Branch 1 taken 5367 times.
✓ Branch 2 taken 9141 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 5351 times.
14508 [[nodiscard]] bool isVirtualMethodCall() const { return isMethodCall() && thisType.isBase(TY_INTERFACE); }
1953 59075 [[nodiscard]] bool isCtorCall() const { return callType == TYPE_CTOR; }
1954 82775 [[nodiscard]] bool isFctPtrCall() const { return callType == TYPE_FCT_PTR; }
1955 };
1956
1957 // Constructors
1958 using ExprNode::ExprNode;
1959
1960 // Visitor methods
1961 28795 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitFctCall(this); }
1962 9264 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitFctCall(this); }
1963
1964 // Public get methods
1965 10413 [[nodiscard]] TypeLstNode *templateTypeLst() const { return getChild<TypeLstNode>(); }
1966 31065 [[nodiscard]] ArgLstNode *argLst() const { return getChild<ArgLstNode>(); }
1967
1968 // Other methods
1969 [[nodiscard]] bool hasCompileTimeValue() const override { return false; }
1970 66215 void customItemsInitialization(size_t manifestationCount) override { data.resize(manifestationCount); }
1971 [[nodiscard]] bool hasReturnValueReceiver() const;
1972
1973 // Public members
1974 bool hasArgs = false;
1975 bool hasTemplateTypes = false;
1976 std::string fqFunctionName;
1977 std::vector<std::string> functionNameFragments;
1978 std::vector<FctCallData> data;
1979 };
1980
1981 // ================================================= ArrayInitializationNode =====================================================
1982
1983 class ArrayInitializationNode final : public ExprNode {
1984 public:
1985 // Constructors
1986 using ExprNode::ExprNode;
1987
1988 // Visitor methods
1989 134 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitArrayInitialization(this); }
1990 46 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitArrayInitialization(this); }
1991
1992 // Public get methods
1993 289 [[nodiscard]] ArgLstNode *itemLst() const { return getChild<ArgLstNode>(); }
1994
1995 // Public members
1996 long actualSize = 0;
1997 };
1998
1999 // ================================================= StructInstantiationNode =====================================================
2000
2001 class StructInstantiationNode final : public ExprNode {
2002 public:
2003 // Constructors
2004 using ExprNode::ExprNode;
2005
2006 // Visitor methods
2007 398 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitStructInstantiation(this); }
2008 162 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitStructInstantiation(this); }
2009
2010 // Public get methods
2011 205 [[nodiscard]] TypeLstNode *templateTypeLst() const { return getChild<TypeLstNode>(); }
2012 1633 [[nodiscard]] ArgLstNode *fieldLst() const { return getChild<ArgLstNode>(); }
2013
2014 // Util methods
2015 387 void customItemsInitialization(size_t manifestationCount) override { instantiatedStructs.resize(manifestationCount); }
2016
2017 // Public members
2018 std::string fqStructName;
2019 std::vector<std::string> structNameFragments;
2020 std::vector<Struct *> instantiatedStructs;
2021 };
2022
2023 // ====================================================== LambdaBaseNode =========================================================
2024
2025 class LambdaBaseNode : public ExprNode {
2026 public:
2027 // Constructors
2028 using ExprNode::ExprNode;
2029
2030 // Public get methods
2031 87 [[nodiscard]] ParamLstNode *paramLst() const { return getChild<ParamLstNode>(); }
2032
2033 // Other methods
2034
2/4
✓ Branch 1 taken 106 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 106 times.
✗ Branch 5 not taken.
106 [[nodiscard]] std::string getScopeId() const { return "lambda:" + codeLoc.toString(); }
2035 [[nodiscard]] bool hasCompileTimeValue() const override { return false; }
2036 75 void customItemsInitialization(size_t manifestationCount) override { manifestations.resize(manifestationCount); }
2037
2038 // Public members
2039 bool hasParams = false;
2040 Scope *bodyScope = nullptr;
2041 std::vector<Function> manifestations;
2042 };
2043
2044 // ====================================================== LambdaFuncNode =========================================================
2045
2046 class LambdaFuncNode final : public LambdaBaseNode {
2047 public:
2048 // Constructors
2049 using LambdaBaseNode::LambdaBaseNode;
2050
2051 // Visit methods
2052 18 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitLambdaFunc(this); }
2053 5 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitLambdaFunc(this); }
2054
2055 // Public get methods
2056 8 [[nodiscard]] DataTypeNode *returnType() const { return getChild<DataTypeNode>(); }
2057 39 [[nodiscard]] StmtLstNode *body() const { return getChild<StmtLstNode>(); }
2058 15 [[nodiscard]] LambdaAttrNode *lambdaAttr() const { return getChild<LambdaAttrNode>(); }
2059
2060 // Other methods
2061 [[nodiscard]] bool returnsOnAllControlPaths(bool *overrideUnreachable) const override;
2062 };
2063
2064 // ====================================================== LambdaProcNode =========================================================
2065
2066 class LambdaProcNode final : public LambdaBaseNode {
2067 public:
2068 // Constructors
2069 using LambdaBaseNode::LambdaBaseNode;
2070
2071 // Visit methods
2072 57 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitLambdaProc(this); }
2073 26 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitLambdaProc(this); }
2074
2075 // Public get methods
2076 146 [[nodiscard]] StmtLstNode *body() const { return getChild<StmtLstNode>(); }
2077 87 [[nodiscard]] LambdaAttrNode *lambdaAttr() const { return getChild<LambdaAttrNode>(); }
2078
2079 // Other methods
2080 bool returnsOnAllControlPaths(bool *overrideUnreachable) const override;
2081 };
2082
2083 // ====================================================== LambdaExprNode =========================================================
2084
2085 class LambdaExprNode final : public LambdaBaseNode {
2086 public:
2087 // Constructors
2088 using LambdaBaseNode::LambdaBaseNode;
2089
2090 // Visit methods
2091 2 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitLambdaExpr(this); }
2092 1 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitLambdaExpr(this); }
2093
2094 // Public get methods
2095 4 [[nodiscard]] AssignExprNode *lambdaExpr() const { return getChild<AssignExprNode>(); }
2096 };
2097
2098 // ======================================================= DataTypeNode ==========================================================
2099
2100 class DataTypeNode final : public ASTNode {
2101 public:
2102 // Enums
2103 enum TypeModifierType : uint8_t {
2104 TYPE_PTR,
2105 TYPE_REF,
2106 TYPE_ARRAY,
2107 };
2108
2109 // Structs
2110 struct TypeModifier {
2111 TypeModifierType modifierType = TYPE_PTR;
2112 bool hasSize = false;
2113 unsigned int hardcodedSize = 0;
2114 std::string sizeVarName;
2115 };
2116
2117 // Constructors
2118 using ASTNode::ASTNode;
2119
2120 // Visitor methods
2121 71010 std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitDataType(this); }
2122 1633 std::any accept(ParallelizableASTVisitor *visitor) const override { return visitor->visitDataType(this); }
2123
2124 // Public get methods
2125 55208 [[nodiscard]] SpecifierLstNode *specifierLst() const { return getChild<SpecifierLstNode>(); }
2126 40128 [[nodiscard]] BaseDataTypeNode *baseDataType() const { return getChild<BaseDataTypeNode>(); }
2127
2128 // Other methods
2129 void setFieldTypeRecursive();
2130
2131 // Public members
2132 bool isParamType = false;
2133 bool isGlobalType = false;
2134 bool isFieldType = false;
2135 bool isReturnType = false;
2136 std::queue<TypeModifier> tmQueue;
2137 };
2138
2139 // ==================================================== BaseDataTypeNode =========================================================
2140
2141 class BaseDataTypeNode final : public ASTNode {
2142 public:
2143 // Enums
2144 enum Type : uint8_t {
2145 TYPE_NONE,
2146 TYPE_DOUBLE,
2147 TYPE_INT,
2148 TYPE_SHORT,
2149 TYPE_LONG,
2150 TYPE_BYTE,
2151 TYPE_CHAR,
2152 TYPE_STRING,
2153 TYPE_BOOL,
2154 TYPE_DYN,
2155 TYPE_CUSTOM,
2156 TYPE_FUNCTION
2157 };
2158
2159