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