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