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