src/typechecker/TypeCheckerExpressions.cpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // Copyright (c) 2021-2026 ChilliBits. All rights reserved. | ||
| 2 | |||
| 3 | #include "TypeChecker.h" | ||
| 4 | |||
| 5 | #include <SourceFile.h> | ||
| 6 | #include <global/GlobalResourceManager.h> | ||
| 7 | #include <symboltablebuilder/Scope.h> | ||
| 8 | #include <symboltablebuilder/SymbolTableBuilder.h> | ||
| 9 | #include <typechecker/MacroDefs.h> | ||
| 10 | |||
| 11 | namespace spice::compiler { | ||
| 12 | |||
| 13 | 7051 | std::any TypeChecker::visitAssignExpr(AssignExprNode *node) { | |
| 14 | // Check if ternary | ||
| 15 |
1/2✗ Branch 2 → 3 not taken.
✓ Branch 2 → 10 taken 7051 times.
|
7051 | if (node->ternaryExpr) { |
| 16 | ✗ | auto result = std::any_cast<ExprResult>(visit(node->ternaryExpr)); | |
| 17 | ✗ | node->setEvaluatedSymbolType(result.type, manIdx); | |
| 18 | ✗ | return result; | |
| 19 | } | ||
| 20 | |||
| 21 | // Check if assignment | ||
| 22 |
1/2✓ Branch 10 → 11 taken 7051 times.
✗ Branch 10 → 86 not taken.
|
7051 | if (node->op != AssignExprNode::AssignOp::OP_NONE) { |
| 23 | // Visit the right side first | ||
| 24 |
2/4✓ Branch 11 → 12 taken 7051 times.
✗ Branch 11 → 101 not taken.
✓ Branch 12 → 13 taken 7051 times.
✗ Branch 12 → 99 not taken.
|
7051 | auto rhs = std::any_cast<ExprResult>(visit(node->rhs)); |
| 25 | 7051 | auto [rhsType, rhsEntry] = rhs; | |
| 26 |
5/8✓ Branch 14 → 15 taken 7051 times.
✗ Branch 14 → 120 not taken.
✓ Branch 15 → 16 taken 1 time.
✓ Branch 15 → 20 taken 7050 times.
✓ Branch 16 → 17 taken 1 time.
✗ Branch 16 → 102 not taken.
✓ Branch 17 → 18 taken 1 time.
✗ Branch 17 → 102 not taken.
|
7051 | HANDLE_UNRESOLVED_TYPE_ER(rhsType) |
| 27 | // Then visit the left side | ||
| 28 |
2/4✓ Branch 20 → 21 taken 7050 times.
✗ Branch 20 → 105 not taken.
✓ Branch 21 → 22 taken 7050 times.
✗ Branch 21 → 103 not taken.
|
7050 | auto lhs = std::any_cast<ExprResult>(visit(node->lhs)); |
| 29 | 7050 | auto [lhsType, lhsVar] = lhs; | |
| 30 |
5/8✓ Branch 23 → 24 taken 7050 times.
✗ Branch 23 → 120 not taken.
✓ Branch 24 → 25 taken 1 time.
✓ Branch 24 → 29 taken 7049 times.
✓ Branch 25 → 26 taken 1 time.
✗ Branch 25 → 106 not taken.
✓ Branch 26 → 27 taken 1 time.
✗ Branch 26 → 106 not taken.
|
7050 | HANDLE_UNRESOLVED_TYPE_ER(lhsType) |
| 31 | |||
| 32 | // Take a look at the operator | ||
| 33 |
2/2✓ Branch 29 → 30 taken 6177 times.
✓ Branch 29 → 42 taken 872 times.
|
7049 | if (node->op == AssignExprNode::AssignOp::OP_ASSIGN) { |
| 34 |
8/10✓ Branch 30 → 31 taken 6176 times.
✓ Branch 30 → 37 taken 1 time.
✓ Branch 31 → 32 taken 6176 times.
✗ Branch 31 → 120 not taken.
✓ Branch 32 → 33 taken 4882 times.
✓ Branch 32 → 37 taken 1294 times.
✓ Branch 34 → 35 taken 4882 times.
✗ Branch 34 → 120 not taken.
✓ Branch 35 → 36 taken 1087 times.
✓ Branch 35 → 37 taken 3795 times.
|
6177 | const bool isDecl = lhs.entry != nullptr && lhs.entry->isField() && !lhs.entry->getLifecycle().isInitialized(); |
| 35 |
2/2✓ Branch 38 → 39 taken 6176 times.
✓ Branch 38 → 107 taken 1 time.
|
6177 | rhsType = opRuleManager.getAssignResultType(node, lhs, rhs, isDecl).first; |
| 36 | |||
| 37 | // If there is an anonymous entry attached (e.g. for struct instantiation), delete it | ||
| 38 |
4/4✓ Branch 39 → 40 taken 2910 times.
✓ Branch 39 → 72 taken 3266 times.
✓ Branch 40 → 41 taken 220 times.
✓ Branch 40 → 72 taken 2690 times.
|
6176 | if (rhsEntry != nullptr && rhsEntry->anonymous) |
| 39 |
1/2✓ Branch 41 → 72 taken 220 times.
✗ Branch 41 → 120 not taken.
|
220 | currentScope->symbolTable.deleteAnonymous(rhsEntry->name); |
| 40 |
2/2✓ Branch 42 → 43 taken 285 times.
✓ Branch 42 → 45 taken 587 times.
|
872 | } else if (node->op == AssignExprNode::AssignOp::OP_PLUS_EQUAL) { |
| 41 |
1/2✓ Branch 43 → 44 taken 285 times.
✗ Branch 43 → 108 not taken.
|
285 | rhsType = opRuleManager.getPlusEqualResultType(node, lhs, rhs).type; |
| 42 |
2/2✓ Branch 45 → 46 taken 49 times.
✓ Branch 45 → 48 taken 538 times.
|
587 | } else if (node->op == AssignExprNode::AssignOp::OP_MINUS_EQUAL) { |
| 43 |
1/2✓ Branch 46 → 47 taken 49 times.
✗ Branch 46 → 109 not taken.
|
49 | rhsType = opRuleManager.getMinusEqualResultType(node, lhs, rhs).type; |
| 44 |
2/2✓ Branch 48 → 49 taken 51 times.
✓ Branch 48 → 51 taken 487 times.
|
538 | } else if (node->op == AssignExprNode::AssignOp::OP_MUL_EQUAL) { |
| 45 |
1/2✓ Branch 49 → 50 taken 51 times.
✗ Branch 49 → 110 not taken.
|
51 | rhsType = opRuleManager.getMulEqualResultType(node, lhs, rhs).type; |
| 46 |
2/2✓ Branch 51 → 52 taken 55 times.
✓ Branch 51 → 54 taken 432 times.
|
487 | } else if (node->op == AssignExprNode::AssignOp::OP_DIV_EQUAL) { |
| 47 |
1/2✓ Branch 52 → 53 taken 55 times.
✗ Branch 52 → 111 not taken.
|
55 | rhsType = opRuleManager.getDivEqualResultType(node, lhs, rhs).type; |
| 48 |
2/2✓ Branch 54 → 55 taken 17 times.
✓ Branch 54 → 57 taken 415 times.
|
432 | } else if (node->op == AssignExprNode::AssignOp::OP_REM_EQUAL) { |
| 49 |
1/2✓ Branch 55 → 56 taken 17 times.
✗ Branch 55 → 112 not taken.
|
17 | rhsType = opRuleManager.getRemEqualResultType(node, lhs, rhs); |
| 50 |
2/2✓ Branch 57 → 58 taken 12 times.
✓ Branch 57 → 60 taken 403 times.
|
415 | } else if (node->op == AssignExprNode::AssignOp::OP_SHL_EQUAL) { |
| 51 |
1/2✓ Branch 58 → 59 taken 12 times.
✗ Branch 58 → 113 not taken.
|
12 | rhsType = opRuleManager.getSHLEqualResultType(node, lhs, rhs); |
| 52 |
2/2✓ Branch 60 → 61 taken 13 times.
✓ Branch 60 → 63 taken 390 times.
|
403 | } else if (node->op == AssignExprNode::AssignOp::OP_SHR_EQUAL) { |
| 53 |
1/2✓ Branch 61 → 62 taken 13 times.
✗ Branch 61 → 114 not taken.
|
13 | rhsType = opRuleManager.getSHREqualResultType(node, lhs, rhs); |
| 54 |
2/2✓ Branch 63 → 64 taken 11 times.
✓ Branch 63 → 66 taken 379 times.
|
390 | } else if (node->op == AssignExprNode::AssignOp::OP_AND_EQUAL) { |
| 55 |
1/2✓ Branch 64 → 65 taken 11 times.
✗ Branch 64 → 115 not taken.
|
11 | rhsType = opRuleManager.getAndEqualResultType(node, lhs, rhs); |
| 56 |
2/2✓ Branch 66 → 67 taken 11 times.
✓ Branch 66 → 69 taken 368 times.
|
379 | } else if (node->op == AssignExprNode::AssignOp::OP_OR_EQUAL) { |
| 57 |
1/2✓ Branch 67 → 68 taken 11 times.
✗ Branch 67 → 116 not taken.
|
11 | rhsType = opRuleManager.getOrEqualResultType(node, lhs, rhs); |
| 58 |
1/2✓ Branch 69 → 70 taken 368 times.
✗ Branch 69 → 72 not taken.
|
368 | } else if (node->op == AssignExprNode::AssignOp::OP_XOR_EQUAL) { |
| 59 |
1/2✓ Branch 70 → 71 taken 368 times.
✗ Branch 70 → 117 not taken.
|
368 | rhsType = opRuleManager.getXorEqualResultType(node, lhs, rhs); |
| 60 | } | ||
| 61 | |||
| 62 |
1/2✓ Branch 72 → 73 taken 7048 times.
✗ Branch 72 → 81 not taken.
|
7048 | if (lhsVar) { // Variable is involved on the left side |
| 63 | // Perform type inference | ||
| 64 |
3/4✓ Branch 73 → 74 taken 7048 times.
✗ Branch 73 → 120 not taken.
✓ Branch 74 → 75 taken 1 time.
✓ Branch 74 → 76 taken 7047 times.
|
7048 | if (lhsType.is(TY_DYN)) |
| 65 |
1/2✓ Branch 75 → 76 taken 1 time.
✗ Branch 75 → 120 not taken.
|
1 | lhsVar->updateType(rhsType, false); |
| 66 | |||
| 67 | // In case the lhs variable is captured, notify the capture about the write access | ||
| 68 |
3/4✓ Branch 76 → 77 taken 7048 times.
✗ Branch 76 → 120 not taken.
✓ Branch 77 → 78 taken 3 times.
✓ Branch 77 → 79 taken 7045 times.
|
7048 | if (Capture *lhsCapture = currentScope->symbolTable.lookupCapture(lhsVar->name); lhsCapture) |
| 69 |
1/2✓ Branch 78 → 79 taken 3 times.
✗ Branch 78 → 120 not taken.
|
3 | lhsCapture->setAccessType(READ_WRITE); |
| 70 | |||
| 71 | // Update the state of the variable | ||
| 72 |
1/2✓ Branch 79 → 80 taken 7048 times.
✗ Branch 79 → 118 not taken.
|
7048 | lhsVar->updateState(INITIALIZED, node); |
| 73 | } | ||
| 74 | |||
| 75 |
2/4✓ Branch 81 → 82 taken 7048 times.
✗ Branch 81 → 119 not taken.
✓ Branch 82 → 83 taken 7048 times.
✗ Branch 82 → 119 not taken.
|
7048 | return ExprResult{node->setEvaluatedSymbolType(rhsType, manIdx)}; |
| 76 | } | ||
| 77 | |||
| 78 | − | throw CompilerError(UNHANDLED_BRANCH, "AssignExpr fall-through"); // GCOV_EXCL_LINE | |
| 79 | } | ||
| 80 | |||
| 81 | 534 | std::any TypeChecker::visitTernaryExpr(TernaryExprNode *node) { | |
| 82 | // Check if there is a ternary operator applied | ||
| 83 |
1/2✗ Branch 2 → 3 not taken.
✓ Branch 2 → 5 taken 534 times.
|
534 | if (!node->falseExpr) |
| 84 | ✗ | return visit(node->condition); | |
| 85 | |||
| 86 | // Visit condition | ||
| 87 |
2/4✓ Branch 5 → 6 taken 534 times.
✗ Branch 5 → 115 not taken.
✓ Branch 6 → 7 taken 534 times.
✗ Branch 6 → 113 not taken.
|
534 | const auto condition = std::any_cast<ExprResult>(visit(node->condition)); |
| 88 |
2/8✓ Branch 8 → 9 taken 534 times.
✗ Branch 8 → 150 not taken.
✗ Branch 9 → 10 not taken.
✓ Branch 9 → 14 taken 534 times.
✗ Branch 10 → 11 not taken.
✗ Branch 10 → 116 not taken.
✗ Branch 11 → 12 not taken.
✗ Branch 11 → 116 not taken.
|
534 | HANDLE_UNRESOLVED_TYPE_ER(condition.type) |
| 89 |
6/10✓ Branch 14 → 15 taken 1 time.
✓ Branch 14 → 16 taken 533 times.
✓ Branch 16 → 17 taken 533 times.
✗ Branch 16 → 117 not taken.
✓ Branch 17 → 18 taken 533 times.
✗ Branch 17 → 117 not taken.
✓ Branch 18 → 19 taken 533 times.
✓ Branch 18 → 20 taken 1 time.
✗ Branch 117 → 118 not taken.
✗ Branch 117 → 119 not taken.
|
534 | const auto trueExpr = node->isShortened ? condition : std::any_cast<ExprResult>(visit(node->trueExpr)); |
| 90 | 534 | const auto [trueType, trueEntry] = trueExpr; | |
| 91 |
2/8✓ Branch 20 → 21 taken 534 times.
✗ Branch 20 → 150 not taken.
✗ Branch 21 → 22 not taken.
✓ Branch 21 → 26 taken 534 times.
✗ Branch 22 → 23 not taken.
✗ Branch 22 → 121 not taken.
✗ Branch 23 → 24 not taken.
✗ Branch 23 → 121 not taken.
|
534 | HANDLE_UNRESOLVED_TYPE_ER(trueType) |
| 92 |
2/4✓ Branch 26 → 27 taken 534 times.
✗ Branch 26 → 124 not taken.
✓ Branch 27 → 28 taken 534 times.
✗ Branch 27 → 122 not taken.
|
534 | const auto falseExpr = std::any_cast<ExprResult>(visit(node->falseExpr)); |
| 93 | 534 | const auto [falseType, falseEntry] = falseExpr; | |
| 94 |
2/8✓ Branch 29 → 30 taken 534 times.
✗ Branch 29 → 150 not taken.
✗ Branch 30 → 31 not taken.
✓ Branch 30 → 35 taken 534 times.
✗ Branch 31 → 32 not taken.
✗ Branch 31 → 125 not taken.
✗ Branch 32 → 33 not taken.
✗ Branch 32 → 125 not taken.
|
534 | HANDLE_UNRESOLVED_TYPE_ER(falseType) |
| 95 | |||
| 96 | // Check if the condition evaluates to bool | ||
| 97 |
3/4✓ Branch 35 → 36 taken 534 times.
✗ Branch 35 → 150 not taken.
✓ Branch 36 → 37 taken 1 time.
✓ Branch 36 → 47 taken 533 times.
|
534 | if (!condition.type.is(TY_BOOL)) |
| 98 |
4/8✓ Branch 39 → 40 taken 1 time.
✗ Branch 39 → 128 not taken.
✓ Branch 40 → 41 taken 1 time.
✗ Branch 40 → 126 not taken.
✓ Branch 43 → 44 taken 1 time.
✗ Branch 43 → 132 not taken.
✓ Branch 44 → 45 taken 1 time.
✗ Branch 44 → 132 not taken.
|
3 | SOFT_ERROR_ER(node->condition, OPERATOR_WRONG_DATA_TYPE, "Condition operand in ternary must be a bool") |
| 99 | |||
| 100 | // Check if trueType and falseType are matching | ||
| 101 |
1/2✓ Branch 47 → 48 taken 533 times.
✗ Branch 47 → 150 not taken.
|
533 | const QualType trueTypeModified = trueType.removeReferenceWrapper(); |
| 102 |
1/2✓ Branch 48 → 49 taken 533 times.
✗ Branch 48 → 150 not taken.
|
533 | const QualType falseTypeModified = falseType.removeReferenceWrapper(); |
| 103 |
3/4✓ Branch 49 → 50 taken 533 times.
✗ Branch 49 → 150 not taken.
✓ Branch 50 → 51 taken 1 time.
✓ Branch 50 → 66 taken 532 times.
|
533 | if (!trueTypeModified.matches(falseTypeModified, false, true, false)) |
| 104 |
8/16✓ Branch 51 → 52 taken 1 time.
✗ Branch 51 → 146 not taken.
✓ Branch 52 → 53 taken 1 time.
✗ Branch 52 → 141 not taken.
✓ Branch 53 → 54 taken 1 time.
✗ Branch 53 → 139 not taken.
✓ Branch 54 → 55 taken 1 time.
✗ Branch 54 → 137 not taken.
✓ Branch 55 → 56 taken 1 time.
✗ Branch 55 → 135 not taken.
✓ Branch 56 → 57 taken 1 time.
✗ Branch 56 → 133 not taken.
✓ Branch 62 → 63 taken 1 time.
✗ Branch 62 → 148 not taken.
✓ Branch 63 → 64 taken 1 time.
✗ Branch 63 → 148 not taken.
|
1 | SOFT_ERROR_ER(node, OPERATOR_WRONG_DATA_TYPE, |
| 105 | "True and false operands in ternary must be of same data type. Got " + trueType.getName(true) + " and " + | ||
| 106 | falseType.getName(true)) | ||
| 107 | |||
| 108 | // If there is an anonymous symbol attached to left or right, remove it, | ||
| 109 | // since the result takes over the ownership of any destructible object. | ||
| 110 | 532 | bool removedAnonymousSymbols = false; | |
| 111 |
2/2✓ Branch 66 → 67 taken 134 times.
✓ Branch 66 → 78 taken 398 times.
|
532 | if (trueEntry) { |
| 112 |
2/2✓ Branch 67 → 68 taken 88 times.
✓ Branch 67 → 70 taken 46 times.
|
134 | if (trueEntry->anonymous) { |
| 113 |
1/2✓ Branch 68 → 69 taken 88 times.
✗ Branch 68 → 150 not taken.
|
88 | currentScope->symbolTable.deleteAnonymous(trueEntry->name); |
| 114 | 88 | removedAnonymousSymbols = true; | |
| 115 |
8/10✓ Branch 70 → 71 taken 46 times.
✗ Branch 70 → 150 not taken.
✓ Branch 71 → 72 taken 38 times.
✓ Branch 71 → 75 taken 8 times.
✓ Branch 72 → 73 taken 38 times.
✗ Branch 72 → 150 not taken.
✓ Branch 73 → 74 taken 8 times.
✓ Branch 73 → 75 taken 30 times.
✓ Branch 76 → 77 taken 8 times.
✓ Branch 76 → 78 taken 38 times.
|
46 | } else if (!trueType.isRef() && !trueType.isTriviallyCopyable(node)) { |
| 116 | 8 | node->trueSideCallsCopyCtor = true; | |
| 117 | } | ||
| 118 | } | ||
| 119 |
2/2✓ Branch 78 → 79 taken 354 times.
✓ Branch 78 → 90 taken 178 times.
|
532 | if (falseEntry) { |
| 120 |
2/2✓ Branch 79 → 80 taken 87 times.
✓ Branch 79 → 82 taken 267 times.
|
354 | if (falseEntry->anonymous) { |
| 121 |
1/2✓ Branch 80 → 81 taken 87 times.
✗ Branch 80 → 150 not taken.
|
87 | currentScope->symbolTable.deleteAnonymous(falseEntry->name); |
| 122 | 87 | removedAnonymousSymbols = true; | |
| 123 |
8/10✓ Branch 82 → 83 taken 267 times.
✗ Branch 82 → 150 not taken.
✓ Branch 83 → 84 taken 258 times.
✓ Branch 83 → 87 taken 9 times.
✓ Branch 84 → 85 taken 258 times.
✗ Branch 84 → 150 not taken.
✓ Branch 85 → 86 taken 8 times.
✓ Branch 85 → 87 taken 250 times.
✓ Branch 88 → 89 taken 8 times.
✓ Branch 88 → 90 taken 259 times.
|
267 | } else if (!falseType.isRef() && !falseType.isTriviallyCopyable(node)) { |
| 124 | 8 | node->falseSideCallsCopyCtor = true; | |
| 125 | } | ||
| 126 | } | ||
| 127 | |||
| 128 | // Create a new anonymous symbol for the result if required | ||
| 129 | 532 | const QualType &resultType = trueType; | |
| 130 | 532 | SymbolTableEntry *anonymousSymbol = nullptr; | |
| 131 |
4/4✓ Branch 90 → 91 taken 524 times.
✓ Branch 90 → 92 taken 8 times.
✓ Branch 91 → 92 taken 2 times.
✓ Branch 91 → 93 taken 522 times.
|
532 | const bool calledCopyCtor = node->trueSideCallsCopyCtor || node->falseSideCallsCopyCtor; |
| 132 |
9/10✓ Branch 94 → 95 taken 442 times.
✓ Branch 94 → 98 taken 90 times.
✓ Branch 95 → 96 taken 436 times.
✓ Branch 95 → 98 taken 6 times.
✓ Branch 96 → 97 taken 436 times.
✗ Branch 96 → 150 not taken.
✓ Branch 97 → 98 taken 9 times.
✓ Branch 97 → 99 taken 427 times.
✓ Branch 100 → 101 taken 105 times.
✓ Branch 100 → 103 taken 427 times.
|
532 | if (removedAnonymousSymbols || calledCopyCtor || resultType.isRef()) |
| 133 |
1/2✓ Branch 101 → 102 taken 105 times.
✗ Branch 101 → 150 not taken.
|
105 | anonymousSymbol = currentScope->symbolTable.insertAnonymous(resultType, node); |
| 134 | |||
| 135 | // Look up the copy ctor if at least one side needs it | ||
| 136 |
4/4✓ Branch 103 → 104 taken 524 times.
✓ Branch 103 → 105 taken 8 times.
✓ Branch 104 → 105 taken 2 times.
✓ Branch 104 → 107 taken 522 times.
|
532 | if (node->trueSideCallsCopyCtor || node->falseSideCallsCopyCtor) |
| 137 |
1/2✓ Branch 105 → 106 taken 10 times.
✗ Branch 105 → 150 not taken.
|
10 | node->calledCopyCtor = matchCopyCtor(trueTypeModified, node); |
| 138 | |||
| 139 |
2/4✓ Branch 107 → 108 taken 532 times.
✗ Branch 107 → 149 not taken.
✓ Branch 108 → 109 taken 532 times.
✗ Branch 108 → 149 not taken.
|
532 | return ExprResult{node->setEvaluatedSymbolType(resultType, manIdx), anonymousSymbol}; |
| 140 | } | ||
| 141 | |||
| 142 | 1008 | std::any TypeChecker::visitLogicalOrExpr(LogicalOrExprNode *node) { | |
| 143 | // Check if a logical or operator is applied | ||
| 144 |
1/2✗ Branch 3 → 4 not taken.
✓ Branch 3 → 7 taken 1008 times.
|
1008 | if (node->operands.size() == 1) |
| 145 | ✗ | return visit(node->operands.front()); | |
| 146 | |||
| 147 | // Visit leftmost operand | ||
| 148 |
2/4✓ Branch 8 → 9 taken 1008 times.
✗ Branch 8 → 39 not taken.
✓ Branch 9 → 10 taken 1008 times.
✗ Branch 9 → 37 not taken.
|
1008 | auto currentOperand = std::any_cast<ExprResult>(visit(node->operands[0])); |
| 149 |
2/8✓ Branch 11 → 12 taken 1008 times.
✗ Branch 11 → 46 not taken.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 17 taken 1008 times.
✗ Branch 13 → 14 not taken.
✗ Branch 13 → 40 not taken.
✗ Branch 14 → 15 not taken.
✗ Branch 14 → 40 not taken.
|
1008 | HANDLE_UNRESOLVED_TYPE_ER(currentOperand.type) |
| 150 | |||
| 151 | // Loop through all remaining operands | ||
| 152 |
2/2✓ Branch 31 → 18 taken 1293 times.
✓ Branch 31 → 32 taken 1007 times.
|
2300 | for (size_t i = 1; i < node->operands.size(); i++) { |
| 153 |
2/4✓ Branch 19 → 20 taken 1293 times.
✗ Branch 19 → 43 not taken.
✓ Branch 20 → 21 taken 1293 times.
✗ Branch 20 → 41 not taken.
|
1293 | auto rhsOperand = std::any_cast<ExprResult>(visit(node->operands[i])); |
| 154 |
2/8✓ Branch 22 → 23 taken 1293 times.
✗ Branch 22 → 45 not taken.
✗ Branch 23 → 24 not taken.
✓ Branch 23 → 28 taken 1293 times.
✗ Branch 24 → 25 not taken.
✗ Branch 24 → 44 not taken.
✗ Branch 25 → 26 not taken.
✗ Branch 25 → 44 not taken.
|
1293 | HANDLE_UNRESOLVED_TYPE_ER(rhsOperand.type) |
| 155 |
2/2✓ Branch 28 → 29 taken 1292 times.
✓ Branch 28 → 45 taken 1 time.
|
1293 | currentOperand = {OpRuleManager::getLogicalOrResultType(node, currentOperand, rhsOperand)}; |
| 156 | } | ||
| 157 | |||
| 158 |
1/2✓ Branch 32 → 33 taken 1007 times.
✗ Branch 32 → 46 not taken.
|
1007 | node->setEvaluatedSymbolType(currentOperand.type, manIdx); |
| 159 |
1/2✓ Branch 33 → 34 taken 1007 times.
✗ Branch 33 → 46 not taken.
|
1007 | return currentOperand; |
| 160 | } | ||
| 161 | |||
| 162 | 190 | std::any TypeChecker::visitLogicalAndExpr(LogicalAndExprNode *node) { | |
| 163 | // Check if a logical and operator is applied | ||
| 164 |
1/2✗ Branch 3 → 4 not taken.
✓ Branch 3 → 7 taken 190 times.
|
190 | if (node->operands.size() == 1) |
| 165 | ✗ | return visit(node->operands.front()); | |
| 166 | |||
| 167 | // Visit leftmost operand | ||
| 168 |
2/4✓ Branch 8 → 9 taken 190 times.
✗ Branch 8 → 39 not taken.
✓ Branch 9 → 10 taken 190 times.
✗ Branch 9 → 37 not taken.
|
190 | auto currentOperand = std::any_cast<ExprResult>(visit(node->operands[0])); |
| 169 |
2/8✓ Branch 11 → 12 taken 190 times.
✗ Branch 11 → 46 not taken.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 17 taken 190 times.
✗ Branch 13 → 14 not taken.
✗ Branch 13 → 40 not taken.
✗ Branch 14 → 15 not taken.
✗ Branch 14 → 40 not taken.
|
190 | HANDLE_UNRESOLVED_TYPE_ER(currentOperand.type) |
| 170 | |||
| 171 | // Loop through all remaining operands | ||
| 172 |
2/2✓ Branch 31 → 18 taken 225 times.
✓ Branch 31 → 32 taken 190 times.
|
415 | for (size_t i = 1; i < node->operands.size(); i++) { |
| 173 |
2/4✓ Branch 19 → 20 taken 225 times.
✗ Branch 19 → 43 not taken.
✓ Branch 20 → 21 taken 225 times.
✗ Branch 20 → 41 not taken.
|
225 | auto rhsOperand = std::any_cast<ExprResult>(visit(node->operands[i])); |
| 174 |
2/8✓ Branch 22 → 23 taken 225 times.
✗ Branch 22 → 45 not taken.
✗ Branch 23 → 24 not taken.
✓ Branch 23 → 28 taken 225 times.
✗ Branch 24 → 25 not taken.
✗ Branch 24 → 44 not taken.
✗ Branch 25 → 26 not taken.
✗ Branch 25 → 44 not taken.
|
225 | HANDLE_UNRESOLVED_TYPE_ER(rhsOperand.type) |
| 175 |
1/2✓ Branch 28 → 29 taken 225 times.
✗ Branch 28 → 45 not taken.
|
225 | currentOperand = {OpRuleManager::getLogicalAndResultType(node, currentOperand, rhsOperand)}; |
| 176 | } | ||
| 177 | |||
| 178 |
1/2✓ Branch 32 → 33 taken 190 times.
✗ Branch 32 → 46 not taken.
|
190 | node->setEvaluatedSymbolType(currentOperand.type, manIdx); |
| 179 |
1/2✓ Branch 33 → 34 taken 190 times.
✗ Branch 33 → 46 not taken.
|
190 | return currentOperand; |
| 180 | } | ||
| 181 | |||
| 182 | 92 | std::any TypeChecker::visitBitwiseOrExpr(BitwiseOrExprNode *node) { | |
| 183 | // Check if a bitwise or operator is applied | ||
| 184 |
1/2✗ Branch 3 → 4 not taken.
✓ Branch 3 → 7 taken 92 times.
|
92 | if (node->operands.size() == 1) |
| 185 | ✗ | return visit(node->operands.front()); | |
| 186 | |||
| 187 | // Visit leftmost operand | ||
| 188 |
2/4✓ Branch 8 → 9 taken 92 times.
✗ Branch 8 → 39 not taken.
✓ Branch 9 → 10 taken 92 times.
✗ Branch 9 → 37 not taken.
|
92 | auto currentOperand = std::any_cast<ExprResult>(visit(node->operands[0])); |
| 189 |
2/8✓ Branch 11 → 12 taken 92 times.
✗ Branch 11 → 46 not taken.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 17 taken 92 times.
✗ Branch 13 → 14 not taken.
✗ Branch 13 → 40 not taken.
✗ Branch 14 → 15 not taken.
✗ Branch 14 → 40 not taken.
|
92 | HANDLE_UNRESOLVED_TYPE_ER(currentOperand.type) |
| 190 | |||
| 191 | // Loop through all remaining operands | ||
| 192 |
2/2✓ Branch 31 → 18 taken 95 times.
✓ Branch 31 → 32 taken 91 times.
|
186 | for (size_t i = 1; i < node->operands.size(); i++) { |
| 193 |
2/4✓ Branch 19 → 20 taken 95 times.
✗ Branch 19 → 43 not taken.
✓ Branch 20 → 21 taken 95 times.
✗ Branch 20 → 41 not taken.
|
95 | auto rhsOperand = std::any_cast<ExprResult>(visit(node->operands[i])); |
| 194 |
2/8✓ Branch 22 → 23 taken 95 times.
✗ Branch 22 → 45 not taken.
✗ Branch 23 → 24 not taken.
✓ Branch 23 → 28 taken 95 times.
✗ Branch 24 → 25 not taken.
✗ Branch 24 → 44 not taken.
✗ Branch 25 → 26 not taken.
✗ Branch 25 → 44 not taken.
|
95 | HANDLE_UNRESOLVED_TYPE_ER(rhsOperand.type) |
| 195 |
2/2✓ Branch 28 → 29 taken 94 times.
✓ Branch 28 → 45 taken 1 time.
|
95 | currentOperand = {OpRuleManager::getBitwiseOrResultType(node, currentOperand, rhsOperand)}; |
| 196 | } | ||
| 197 | |||
| 198 |
1/2✓ Branch 32 → 33 taken 91 times.
✗ Branch 32 → 46 not taken.
|
91 | node->setEvaluatedSymbolType(currentOperand.type, manIdx); |
| 199 |
1/2✓ Branch 33 → 34 taken 91 times.
✗ Branch 33 → 46 not taken.
|
91 | return currentOperand; |
| 200 | } | ||
| 201 | |||
| 202 | 16 | std::any TypeChecker::visitBitwiseXorExpr(BitwiseXorExprNode *node) { | |
| 203 | // Check if a bitwise xor operator is applied | ||
| 204 |
1/2✗ Branch 3 → 4 not taken.
✓ Branch 3 → 7 taken 16 times.
|
16 | if (node->operands.size() == 1) |
| 205 | ✗ | return visit(node->operands.front()); | |
| 206 | |||
| 207 | // Visit leftmost operand | ||
| 208 |
2/4✓ Branch 8 → 9 taken 16 times.
✗ Branch 8 → 39 not taken.
✓ Branch 9 → 10 taken 16 times.
✗ Branch 9 → 37 not taken.
|
16 | auto currentOperand = std::any_cast<ExprResult>(visit(node->operands[0])); |
| 209 |
2/8✓ Branch 11 → 12 taken 16 times.
✗ Branch 11 → 46 not taken.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 17 taken 16 times.
✗ Branch 13 → 14 not taken.
✗ Branch 13 → 40 not taken.
✗ Branch 14 → 15 not taken.
✗ Branch 14 → 40 not taken.
|
16 | HANDLE_UNRESOLVED_TYPE_ER(currentOperand.type) |
| 210 | |||
| 211 | // Loop through all remaining operands | ||
| 212 |
2/2✓ Branch 31 → 18 taken 19 times.
✓ Branch 31 → 32 taken 16 times.
|
35 | for (size_t i = 1; i < node->operands.size(); i++) { |
| 213 |
2/4✓ Branch 19 → 20 taken 19 times.
✗ Branch 19 → 43 not taken.
✓ Branch 20 → 21 taken 19 times.
✗ Branch 20 → 41 not taken.
|
19 | auto rhsOperand = std::any_cast<ExprResult>(visit(node->operands[i])); |
| 214 |
2/8✓ Branch 22 → 23 taken 19 times.
✗ Branch 22 → 45 not taken.
✗ Branch 23 → 24 not taken.
✓ Branch 23 → 28 taken 19 times.
✗ Branch 24 → 25 not taken.
✗ Branch 24 → 44 not taken.
✗ Branch 25 → 26 not taken.
✗ Branch 25 → 44 not taken.
|
19 | HANDLE_UNRESOLVED_TYPE_ER(rhsOperand.type) |
| 215 |
1/2✓ Branch 28 → 29 taken 19 times.
✗ Branch 28 → 45 not taken.
|
19 | currentOperand = {OpRuleManager::getBitwiseXorResultType(node, currentOperand, rhsOperand)}; |
| 216 | } | ||
| 217 | |||
| 218 |
1/2✓ Branch 32 → 33 taken 16 times.
✗ Branch 32 → 46 not taken.
|
16 | node->setEvaluatedSymbolType(currentOperand.type, manIdx); |
| 219 |
1/2✓ Branch 33 → 34 taken 16 times.
✗ Branch 33 → 46 not taken.
|
16 | return currentOperand; |
| 220 | } | ||
| 221 | |||
| 222 | 46 | std::any TypeChecker::visitBitwiseAndExpr(BitwiseAndExprNode *node) { | |
| 223 | // Check if a bitwise and operator is applied | ||
| 224 |
1/2✗ Branch 3 → 4 not taken.
✓ Branch 3 → 7 taken 46 times.
|
46 | if (node->operands.size() == 1) |
| 225 | ✗ | return visit(node->operands.front()); | |
| 226 | |||
| 227 | // Visit leftmost operand | ||
| 228 |
2/4✓ Branch 8 → 9 taken 46 times.
✗ Branch 8 → 39 not taken.
✓ Branch 9 → 10 taken 46 times.
✗ Branch 9 → 37 not taken.
|
46 | auto currentOperand = std::any_cast<ExprResult>(visit(node->operands[0])); |
| 229 |
2/8✓ Branch 11 → 12 taken 46 times.
✗ Branch 11 → 46 not taken.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 17 taken 46 times.
✗ Branch 13 → 14 not taken.
✗ Branch 13 → 40 not taken.
✗ Branch 14 → 15 not taken.
✗ Branch 14 → 40 not taken.
|
46 | HANDLE_UNRESOLVED_TYPE_ER(currentOperand.type) |
| 230 | |||
| 231 | // Loop through all remaining operands | ||
| 232 |
2/2✓ Branch 31 → 18 taken 49 times.
✓ Branch 31 → 32 taken 46 times.
|
95 | for (size_t i = 1; i < node->operands.size(); i++) { |
| 233 |
2/4✓ Branch 19 → 20 taken 49 times.
✗ Branch 19 → 43 not taken.
✓ Branch 20 → 21 taken 49 times.
✗ Branch 20 → 41 not taken.
|
49 | auto rhsOperand = std::any_cast<ExprResult>(visit(node->operands[i])); |
| 234 |
2/8✓ Branch 22 → 23 taken 49 times.
✗ Branch 22 → 45 not taken.
✗ Branch 23 → 24 not taken.
✓ Branch 23 → 28 taken 49 times.
✗ Branch 24 → 25 not taken.
✗ Branch 24 → 44 not taken.
✗ Branch 25 → 26 not taken.
✗ Branch 25 → 44 not taken.
|
49 | HANDLE_UNRESOLVED_TYPE_ER(rhsOperand.type) |
| 235 |
1/2✓ Branch 28 → 29 taken 49 times.
✗ Branch 28 → 45 not taken.
|
49 | currentOperand = {OpRuleManager::getBitwiseAndResultType(node, currentOperand, rhsOperand)}; |
| 236 | } | ||
| 237 | |||
| 238 |
1/2✓ Branch 32 → 33 taken 46 times.
✗ Branch 32 → 46 not taken.
|
46 | node->setEvaluatedSymbolType(currentOperand.type, manIdx); |
| 239 |
1/2✓ Branch 33 → 34 taken 46 times.
✗ Branch 33 → 46 not taken.
|
46 | return currentOperand; |
| 240 | } | ||
| 241 | |||
| 242 | 6159 | std::any TypeChecker::visitEqualityExpr(EqualityExprNode *node) { | |
| 243 | // Check if at least one equality operator is applied | ||
| 244 |
1/2✗ Branch 3 → 4 not taken.
✓ Branch 3 → 7 taken 6159 times.
|
6159 | if (node->operands.size() == 1) |
| 245 | ✗ | return visit(node->operands.front()); | |
| 246 | |||
| 247 | // Visit right side first, then left side | ||
| 248 |
2/4✓ Branch 8 → 9 taken 6159 times.
✗ Branch 8 → 58 not taken.
✓ Branch 9 → 10 taken 6159 times.
✗ Branch 9 → 56 not taken.
|
6159 | const auto rhs = std::any_cast<ExprResult>(visit(node->operands[1])); |
| 249 |
2/8✓ Branch 11 → 12 taken 6159 times.
✗ Branch 11 → 73 not taken.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 17 taken 6159 times.
✗ Branch 13 → 14 not taken.
✗ Branch 13 → 59 not taken.
✗ Branch 14 → 15 not taken.
✗ Branch 14 → 59 not taken.
|
6159 | HANDLE_UNRESOLVED_TYPE_ER(rhs.type) |
| 250 |
2/4✓ Branch 18 → 19 taken 6159 times.
✗ Branch 18 → 62 not taken.
✓ Branch 19 → 20 taken 6159 times.
✗ Branch 19 → 60 not taken.
|
6159 | const auto lhs = std::any_cast<ExprResult>(visit(node->operands[0])); |
| 251 |
2/8✓ Branch 21 → 22 taken 6159 times.
✗ Branch 21 → 73 not taken.
✗ Branch 22 → 23 not taken.
✓ Branch 22 → 27 taken 6159 times.
✗ Branch 23 → 24 not taken.
✗ Branch 23 → 63 not taken.
✗ Branch 24 → 25 not taken.
✗ Branch 24 → 63 not taken.
|
6159 | HANDLE_UNRESOLVED_TYPE_ER(lhs.type) |
| 252 | |||
| 253 | // Check if we need the string runtime to perform a string comparison | ||
| 254 |
10/14✓ Branch 27 → 28 taken 6159 times.
✗ Branch 27 → 73 not taken.
✓ Branch 28 → 29 taken 156 times.
✓ Branch 28 → 36 taken 6003 times.
✓ Branch 29 → 30 taken 156 times.
✗ Branch 29 → 73 not taken.
✓ Branch 30 → 31 taken 155 times.
✓ Branch 30 → 36 taken 1 time.
✓ Branch 31 → 32 taken 155 times.
✗ Branch 31 → 73 not taken.
✓ Branch 34 → 35 taken 155 times.
✗ Branch 34 → 36 not taken.
✓ Branch 37 → 38 taken 155 times.
✓ Branch 37 → 39 taken 6004 times.
|
6314 | if (lhs.type.is(TY_STRING) && rhs.type.is(TY_STRING) && !sourceFile->isStringRT()) |
| 255 |
1/2✓ Branch 38 → 39 taken 155 times.
✗ Branch 38 → 73 not taken.
|
155 | sourceFile->requestRuntimeModule(STRING_RT); |
| 256 | |||
| 257 | // Check operator | ||
| 258 | 6159 | ExprResult result; | |
| 259 |
2/2✓ Branch 39 → 40 taken 4473 times.
✓ Branch 39 → 41 taken 1686 times.
|
6159 | if (node->op == EqualityExprNode::EqualityOp::OP_EQUAL) // Operator was equal |
| 260 |
2/2✓ Branch 40 → 51 taken 4472 times.
✓ Branch 40 → 73 taken 1 time.
|
4473 | result = opRuleManager.getEqualResultType(node, lhs, rhs); |
| 261 |
1/2✓ Branch 41 → 42 taken 1686 times.
✗ Branch 41 → 43 not taken.
|
1686 | else if (node->op == EqualityExprNode::EqualityOp::OP_NOT_EQUAL) // Operator was not equal |
| 262 |
1/2✓ Branch 42 → 51 taken 1686 times.
✗ Branch 42 → 73 not taken.
|
1686 | result = opRuleManager.getNotEqualResultType(node, lhs, rhs); |
| 263 | else | ||
| 264 | − | throw CompilerError(UNHANDLED_BRANCH, "EqualityExpr fall-through"); // GCOV_EXCL_LINE | |
| 265 | |||
| 266 |
1/2✓ Branch 51 → 52 taken 6158 times.
✗ Branch 51 → 73 not taken.
|
6158 | node->setEvaluatedSymbolType(result.type, manIdx); |
| 267 |
1/2✓ Branch 52 → 53 taken 6158 times.
✗ Branch 52 → 73 not taken.
|
6158 | return result; |
| 268 | } | ||
| 269 | |||
| 270 | 4163 | std::any TypeChecker::visitRelationalExpr(RelationalExprNode *node) { | |
| 271 | // Check if a relational operator is applied | ||
| 272 |
1/2✗ Branch 3 → 4 not taken.
✓ Branch 3 → 7 taken 4163 times.
|
4163 | if (node->operands.size() == 1) |
| 273 | ✗ | return visit(node->operands.front()); | |
| 274 | |||
| 275 | // Visit right side first, then left side | ||
| 276 |
2/4✓ Branch 8 → 9 taken 4163 times.
✗ Branch 8 → 55 not taken.
✓ Branch 9 → 10 taken 4163 times.
✗ Branch 9 → 53 not taken.
|
4163 | const auto rhs = std::any_cast<ExprResult>(visit(node->operands[1])); |
| 277 |
5/8✓ Branch 11 → 12 taken 4163 times.
✗ Branch 11 → 75 not taken.
✓ Branch 12 → 13 taken 1 time.
✓ Branch 12 → 17 taken 4162 times.
✓ Branch 13 → 14 taken 1 time.
✗ Branch 13 → 56 not taken.
✓ Branch 14 → 15 taken 1 time.
✗ Branch 14 → 56 not taken.
|
4163 | HANDLE_UNRESOLVED_TYPE_ER(rhs.type) |
| 278 |
2/4✓ Branch 18 → 19 taken 4162 times.
✗ Branch 18 → 59 not taken.
✓ Branch 19 → 20 taken 4162 times.
✗ Branch 19 → 57 not taken.
|
4162 | const auto lhs = std::any_cast<ExprResult>(visit(node->operands[0])); |
| 279 |
2/8✓ Branch 21 → 22 taken 4162 times.
✗ Branch 21 → 75 not taken.
✗ Branch 22 → 23 not taken.
✓ Branch 22 → 27 taken 4162 times.
✗ Branch 23 → 24 not taken.
✗ Branch 23 → 60 not taken.
✗ Branch 24 → 25 not taken.
✗ Branch 24 → 60 not taken.
|
4162 | HANDLE_UNRESOLVED_TYPE_ER(lhs.type) |
| 280 | |||
| 281 | // Check operator | ||
| 282 | 4162 | QualType resultType; | |
| 283 |
2/2✓ Branch 27 → 28 taken 2046 times.
✓ Branch 27 → 30 taken 2116 times.
|
4162 | if (node->op == RelationalExprNode::RelationalOp::OP_LESS) // Operator was less |
| 284 |
1/2✓ Branch 28 → 29 taken 2046 times.
✗ Branch 28 → 61 not taken.
|
2046 | resultType = OpRuleManager::getLessResultType(node, lhs, rhs); |
| 285 |
2/2✓ Branch 30 → 31 taken 577 times.
✓ Branch 30 → 33 taken 1539 times.
|
2116 | else if (node->op == RelationalExprNode::RelationalOp::OP_GREATER) // Operator was greater |
| 286 |
2/2✓ Branch 31 → 32 taken 576 times.
✓ Branch 31 → 62 taken 1 time.
|
577 | resultType = OpRuleManager::getGreaterResultType(node, lhs, rhs); |
| 287 |
2/2✓ Branch 33 → 34 taken 441 times.
✓ Branch 33 → 36 taken 1098 times.
|
1539 | else if (node->op == RelationalExprNode::RelationalOp::OP_LESS_EQUAL) // Operator was less equal |
| 288 |
1/2✓ Branch 34 → 35 taken 441 times.
✗ Branch 34 → 63 not taken.
|
441 | resultType = OpRuleManager::getLessEqualResultType(node, lhs, rhs); |
| 289 |
1/2✓ Branch 36 → 37 taken 1098 times.
✗ Branch 36 → 39 not taken.
|
1098 | else if (node->op == RelationalExprNode::RelationalOp::OP_GREATER_EQUAL) // Operator was greater equal |
| 290 |
1/2✓ Branch 37 → 38 taken 1098 times.
✗ Branch 37 → 64 not taken.
|
1098 | resultType = OpRuleManager::getGreaterEqualResultType(node, lhs, rhs); |
| 291 | else | ||
| 292 | − | throw CompilerError(UNHANDLED_BRANCH, "RelationalExpr fall-through"); // GCOV_EXCL_LINE | |
| 293 | |||
| 294 |
2/4✓ Branch 47 → 48 taken 4161 times.
✗ Branch 47 → 74 not taken.
✓ Branch 48 → 49 taken 4161 times.
✗ Branch 48 → 74 not taken.
|
4161 | return ExprResult{node->setEvaluatedSymbolType(resultType, manIdx)}; |
| 295 | } | ||
| 296 | |||
| 297 | 137 | std::any TypeChecker::visitShiftExpr(ShiftExprNode *node) { | |
| 298 | // Check if at least one shift operator is applied | ||
| 299 |
1/2✗ Branch 3 → 4 not taken.
✓ Branch 3 → 7 taken 137 times.
|
137 | if (node->operands.size() == 1) |
| 300 | ✗ | return visit(node->operands.front()); | |
| 301 | |||
| 302 | // Visit leftmost operand | ||
| 303 |
2/4✓ Branch 8 → 9 taken 137 times.
✗ Branch 8 → 53 not taken.
✓ Branch 9 → 10 taken 137 times.
✗ Branch 9 → 51 not taken.
|
137 | auto currentResult = std::any_cast<ExprResult>(visit(node->operands[0])); |
| 304 |
2/8✓ Branch 11 → 12 taken 137 times.
✗ Branch 11 → 69 not taken.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 17 taken 137 times.
✗ Branch 13 → 14 not taken.
✗ Branch 13 → 54 not taken.
✗ Branch 14 → 15 not taken.
✗ Branch 14 → 54 not taken.
|
137 | HANDLE_UNRESOLVED_TYPE_ER(currentResult.type) |
| 305 | |||
| 306 | // Loop through remaining operands | ||
| 307 |
2/2✓ Branch 45 → 18 taken 177 times.
✓ Branch 45 → 46 taken 137 times.
|
314 | for (size_t i = 0; i < node->opQueue.size(); i++) { |
| 308 |
2/4✓ Branch 19 → 20 taken 177 times.
✗ Branch 19 → 57 not taken.
✓ Branch 20 → 21 taken 177 times.
✗ Branch 20 → 55 not taken.
|
177 | auto operandResult = std::any_cast<ExprResult>(visit(node->operands[i + 1])); |
| 309 |
2/8✓ Branch 22 → 23 taken 177 times.
✗ Branch 22 → 68 not taken.
✗ Branch 23 → 24 not taken.
✓ Branch 23 → 28 taken 177 times.
✗ Branch 24 → 25 not taken.
✗ Branch 24 → 58 not taken.
✗ Branch 25 → 26 not taken.
✗ Branch 25 → 58 not taken.
|
177 | HANDLE_UNRESOLVED_TYPE_ER(operandResult.type) |
| 310 | |||
| 311 | // Check operator | ||
| 312 | 177 | const ShiftExprNode::ShiftOp &op = node->opQueue.front().first; | |
| 313 |
2/2✓ Branch 29 → 30 taken 108 times.
✓ Branch 29 → 31 taken 69 times.
|
177 | if (op == ShiftExprNode::ShiftOp::OP_SHIFT_LEFT) |
| 314 |
1/2✓ Branch 30 → 41 taken 108 times.
✗ Branch 30 → 68 not taken.
|
108 | currentResult = opRuleManager.getShiftLeftResultType(node, currentResult, operandResult, i); |
| 315 |
1/2✓ Branch 31 → 32 taken 69 times.
✗ Branch 31 → 33 not taken.
|
69 | else if (op == ShiftExprNode::ShiftOp::OP_SHIFT_RIGHT) |
| 316 |
1/2✓ Branch 32 → 41 taken 69 times.
✗ Branch 32 → 68 not taken.
|
69 | currentResult = opRuleManager.getShiftRightResultType(node, currentResult, operandResult, i); |
| 317 | else | ||
| 318 | − | throw CompilerError(UNHANDLED_BRANCH, "ShiftExpr fall-through"); // GCOV_EXCL_LINE | |
| 319 | |||
| 320 | // Push the new item and pop the old one on the other side of the queue | ||
| 321 |
1/2✓ Branch 41 → 42 taken 177 times.
✗ Branch 41 → 68 not taken.
|
177 | node->opQueue.emplace(op, currentResult.type); |
| 322 | 177 | node->opQueue.pop(); | |
| 323 | } | ||
| 324 | |||
| 325 |
1/2✓ Branch 46 → 47 taken 137 times.
✗ Branch 46 → 69 not taken.
|
137 | node->setEvaluatedSymbolType(currentResult.type, manIdx); |
| 326 |
1/2✓ Branch 47 → 48 taken 137 times.
✗ Branch 47 → 69 not taken.
|
137 | return currentResult; |
| 327 | } | ||
| 328 | |||
| 329 | 4632 | std::any TypeChecker::visitAdditiveExpr(AdditiveExprNode *node) { | |
| 330 | // Check if at least one additive operator is applied | ||
| 331 |
1/2✗ Branch 3 → 4 not taken.
✓ Branch 3 → 7 taken 4632 times.
|
4632 | if (node->operands.size() == 1) |
| 332 | ✗ | return visit(node->operands.front()); | |
| 333 | |||
| 334 | // Visit leftmost operand | ||
| 335 |
2/4✓ Branch 8 → 9 taken 4632 times.
✗ Branch 8 → 53 not taken.
✓ Branch 9 → 10 taken 4632 times.
✗ Branch 9 → 51 not taken.
|
4632 | auto currentResult = std::any_cast<ExprResult>(visit(node->operands[0])); |
| 336 |
2/8✓ Branch 11 → 12 taken 4632 times.
✗ Branch 11 → 69 not taken.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 17 taken 4632 times.
✗ Branch 13 → 14 not taken.
✗ Branch 13 → 54 not taken.
✗ Branch 14 → 15 not taken.
✗ Branch 14 → 54 not taken.
|
4632 | HANDLE_UNRESOLVED_TYPE_ER(currentResult.type) |
| 337 | |||
| 338 | // Loop through remaining operands | ||
| 339 |
2/2✓ Branch 45 → 18 taken 5283 times.
✓ Branch 45 → 46 taken 4631 times.
|
9914 | for (size_t i = 0; i < node->opQueue.size(); i++) { |
| 340 |
2/4✓ Branch 19 → 20 taken 5283 times.
✗ Branch 19 → 57 not taken.
✓ Branch 20 → 21 taken 5283 times.
✗ Branch 20 → 55 not taken.
|
5283 | auto operandResult = std::any_cast<ExprResult>(visit(node->operands[i + 1])); |
| 341 |
2/8✓ Branch 22 → 23 taken 5283 times.
✗ Branch 22 → 68 not taken.
✗ Branch 23 → 24 not taken.
✓ Branch 23 → 28 taken 5283 times.
✗ Branch 24 → 25 not taken.
✗ Branch 24 → 58 not taken.
✗ Branch 25 → 26 not taken.
✗ Branch 25 → 58 not taken.
|
5283 | HANDLE_UNRESOLVED_TYPE_ER(operandResult.type) |
| 342 | |||
| 343 | // Check operator | ||
| 344 | 5283 | const AdditiveExprNode::AdditiveOp &op = node->opQueue.front().first; | |
| 345 |
2/2✓ Branch 29 → 30 taken 3231 times.
✓ Branch 29 → 31 taken 2052 times.
|
5283 | if (op == AdditiveExprNode::AdditiveOp::OP_PLUS) |
| 346 |
2/2✓ Branch 30 → 41 taken 3230 times.
✓ Branch 30 → 68 taken 1 time.
|
3231 | currentResult = opRuleManager.getPlusResultType(node, currentResult, operandResult, i); |
| 347 |
1/2✓ Branch 31 → 32 taken 2052 times.
✗ Branch 31 → 33 not taken.
|
2052 | else if (op == AdditiveExprNode::AdditiveOp::OP_MINUS) |
| 348 |
1/2✓ Branch 32 → 41 taken 2052 times.
✗ Branch 32 → 68 not taken.
|
2052 | currentResult = opRuleManager.getMinusResultType(node, currentResult, operandResult, i); |
| 349 | else | ||
| 350 | − | throw CompilerError(UNHANDLED_BRANCH, "AdditiveExpr fall-through"); // GCOV_EXCL_LINE | |
| 351 | |||
| 352 | // Push the new item and pop the old one on the other side of the queue | ||
| 353 |
1/2✓ Branch 41 → 42 taken 5282 times.
✗ Branch 41 → 68 not taken.
|
5282 | node->opQueue.emplace(op, currentResult.type); |
| 354 | 5282 | node->opQueue.pop(); | |
| 355 | } | ||
| 356 | |||
| 357 |
1/2✓ Branch 46 → 47 taken 4631 times.
✗ Branch 46 → 69 not taken.
|
4631 | node->setEvaluatedSymbolType(currentResult.type, manIdx); |
| 358 |
1/2✓ Branch 47 → 48 taken 4631 times.
✗ Branch 47 → 69 not taken.
|
4631 | return currentResult; |
| 359 | } | ||
| 360 | |||
| 361 | 1006 | std::any TypeChecker::visitMultiplicativeExpr(MultiplicativeExprNode *node) { | |
| 362 | // Check if at least one multiplicative operator is applied | ||
| 363 |
1/2✗ Branch 3 → 4 not taken.
✓ Branch 3 → 7 taken 1006 times.
|
1006 | if (node->operands.size() == 1) |
| 364 | ✗ | return visit(node->operands.front()); | |
| 365 | |||
| 366 | // Visit leftmost operand | ||
| 367 |
2/4✓ Branch 8 → 9 taken 1006 times.
✗ Branch 8 → 55 not taken.
✓ Branch 9 → 10 taken 1006 times.
✗ Branch 9 → 53 not taken.
|
1006 | auto currentResult = std::any_cast<ExprResult>(visit(node->operands[0])); |
| 368 |
2/8✓ Branch 11 → 12 taken 1006 times.
✗ Branch 11 → 71 not taken.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 17 taken 1006 times.
✗ Branch 13 → 14 not taken.
✗ Branch 13 → 56 not taken.
✗ Branch 14 → 15 not taken.
✗ Branch 14 → 56 not taken.
|
1006 | HANDLE_UNRESOLVED_TYPE_ER(currentResult.type) |
| 369 | // Loop through remaining operands | ||
| 370 |
2/2✓ Branch 47 → 18 taken 1030 times.
✓ Branch 47 → 48 taken 1005 times.
|
2035 | for (size_t i = 0; i < node->opQueue.size(); i++) { |
| 371 |
2/4✓ Branch 19 → 20 taken 1030 times.
✗ Branch 19 → 59 not taken.
✓ Branch 20 → 21 taken 1030 times.
✗ Branch 20 → 57 not taken.
|
1030 | auto operandResult = std::any_cast<ExprResult>(visit(node->operands[i + 1])); |
| 372 |
2/8✓ Branch 22 → 23 taken 1030 times.
✗ Branch 22 → 70 not taken.
✗ Branch 23 → 24 not taken.
✓ Branch 23 → 28 taken 1030 times.
✗ Branch 24 → 25 not taken.
✗ Branch 24 → 60 not taken.
✗ Branch 25 → 26 not taken.
✗ Branch 25 → 60 not taken.
|
1030 | HANDLE_UNRESOLVED_TYPE_ER(operandResult.type) |
| 373 | |||
| 374 | // Check operator | ||
| 375 | 1030 | const MultiplicativeExprNode::MultiplicativeOp &op = node->opQueue.front().first; | |
| 376 |
2/2✓ Branch 29 → 30 taken 835 times.
✓ Branch 29 → 31 taken 195 times.
|
1030 | if (op == MultiplicativeExprNode::MultiplicativeOp::OP_MUL) |
| 377 |
2/2✓ Branch 30 → 43 taken 834 times.
✓ Branch 30 → 70 taken 1 time.
|
835 | currentResult = opRuleManager.getMulResultType(node, currentResult, operandResult, i); |
| 378 |
2/2✓ Branch 31 → 32 taken 170 times.
✓ Branch 31 → 33 taken 25 times.
|
195 | else if (op == MultiplicativeExprNode::MultiplicativeOp::OP_DIV) |
| 379 |
1/2✓ Branch 32 → 43 taken 170 times.
✗ Branch 32 → 70 not taken.
|
170 | currentResult = opRuleManager.getDivResultType(node, currentResult, operandResult, i); |
| 380 |
1/2✓ Branch 33 → 34 taken 25 times.
✗ Branch 33 → 35 not taken.
|
25 | else if (op == MultiplicativeExprNode::MultiplicativeOp::OP_REM) |
| 381 |
1/2✓ Branch 34 → 43 taken 25 times.
✗ Branch 34 → 70 not taken.
|
25 | currentResult = OpRuleManager::getRemResultType(node, currentResult, operandResult); |
| 382 | else | ||
| 383 | − | throw CompilerError(UNHANDLED_BRANCH, "Multiplicative fall-through"); // GCOV_EXCL_LINE | |
| 384 | |||
| 385 | // Push the new item and pop the old one on the other side of the queue | ||
| 386 |
1/2✓ Branch 43 → 44 taken 1029 times.
✗ Branch 43 → 70 not taken.
|
1029 | node->opQueue.emplace(op, currentResult.type); |
| 387 | 1029 | node->opQueue.pop(); | |
| 388 | } | ||
| 389 | |||
| 390 |
1/2✓ Branch 48 → 49 taken 1005 times.
✗ Branch 48 → 71 not taken.
|
1005 | node->setEvaluatedSymbolType(currentResult.type, manIdx); |
| 391 |
1/2✓ Branch 49 → 50 taken 1005 times.
✗ Branch 49 → 71 not taken.
|
1005 | return currentResult; |
| 392 | } | ||
| 393 | |||
| 394 | 2830 | std::any TypeChecker::visitCastExpr(CastExprNode *node) { | |
| 395 | // Check if cast is applied | ||
| 396 |
1/2✗ Branch 2 → 3 not taken.
✓ Branch 2 → 5 taken 2830 times.
|
2830 | if (!node->isCast) |
| 397 | ✗ | return visit(node->prefixUnaryExpr); | |
| 398 | |||
| 399 | // Visit destination type | ||
| 400 |
2/4✓ Branch 5 → 6 taken 2830 times.
✗ Branch 5 → 49 not taken.
✓ Branch 6 → 7 taken 2830 times.
✗ Branch 6 → 47 not taken.
|
2830 | const auto dstType = std::any_cast<QualType>(visit(node->dataType)); |
| 401 |
2/8✓ Branch 8 → 9 taken 2830 times.
✗ Branch 8 → 65 not taken.
✗ Branch 9 → 10 not taken.
✓ Branch 9 → 14 taken 2830 times.
✗ Branch 10 → 11 not taken.
✗ Branch 10 → 50 not taken.
✗ Branch 11 → 12 not taken.
✗ Branch 11 → 50 not taken.
|
2830 | HANDLE_UNRESOLVED_TYPE_ER(dstType) |
| 402 | // Visit source type | ||
| 403 |
2/4✓ Branch 14 → 15 taken 2830 times.
✗ Branch 14 → 53 not taken.
✓ Branch 15 → 16 taken 2830 times.
✗ Branch 15 → 51 not taken.
|
2830 | const auto src = std::any_cast<ExprResult>(visit(node->assignExpr)); |
| 404 |
2/8✓ Branch 17 → 18 taken 2830 times.
✗ Branch 17 → 65 not taken.
✗ Branch 18 → 19 not taken.
✓ Branch 18 → 23 taken 2830 times.
✗ Branch 19 → 20 not taken.
✗ Branch 19 → 54 not taken.
✗ Branch 20 → 21 not taken.
✗ Branch 20 → 54 not taken.
|
2830 | HANDLE_UNRESOLVED_TYPE_ER(src.type) |
| 405 | |||
| 406 | // Check for identity cast | ||
| 407 |
3/4✓ Branch 23 → 24 taken 2830 times.
✗ Branch 23 → 65 not taken.
✓ Branch 24 → 25 taken 297 times.
✓ Branch 24 → 34 taken 2533 times.
|
2830 | if (src.type == dstType) { |
| 408 |
2/4✓ Branch 27 → 28 taken 297 times.
✗ Branch 27 → 57 not taken.
✓ Branch 28 → 29 taken 297 times.
✗ Branch 28 → 55 not taken.
|
297 | const CompilerWarning warning(node->codeLoc, IDENTITY_CAST, "You cast from a type to itself. Thus, this can be simplified."); |
| 409 |
1/2✓ Branch 31 → 32 taken 297 times.
✗ Branch 31 → 61 not taken.
|
297 | sourceFile->compilerOutput.warnings.push_back(warning); |
| 410 | 297 | } | |
| 411 | |||
| 412 | // Get result type | ||
| 413 |
1/2✓ Branch 34 → 35 taken 2830 times.
✗ Branch 34 → 65 not taken.
|
2830 | const QualType resultType = opRuleManager.getCastResultType(node, dstType, src); |
| 414 | |||
| 415 |
1/2✓ Branch 35 → 36 taken 2830 times.
✗ Branch 35 → 65 not taken.
|
2830 | const bool typesMatch = dstType.matches(src.type, false, true, true); |
| 416 |
1/2✓ Branch 36 → 37 taken 2830 times.
✗ Branch 36 → 65 not taken.
|
2830 | const bool sameContainerType = src.type.isSameContainerTypeAs(dstType); |
| 417 |
4/4✓ Branch 37 → 38 taken 2533 times.
✓ Branch 37 → 39 taken 297 times.
✓ Branch 38 → 39 taken 133 times.
✓ Branch 38 → 40 taken 2400 times.
|
2830 | SymbolTableEntry *entry = typesMatch || sameContainerType ? src.entry : nullptr; |
| 418 |
2/4✓ Branch 41 → 42 taken 2830 times.
✗ Branch 41 → 64 not taken.
✓ Branch 42 → 43 taken 2830 times.
✗ Branch 42 → 64 not taken.
|
2830 | return ExprResult{node->setEvaluatedSymbolType(resultType, manIdx), entry}; |
| 419 | } | ||
| 420 | |||
| 421 | 2159 | std::any TypeChecker::visitPrefixUnaryExpr(PrefixUnaryExprNode *node) { | |
| 422 | // If no operator is applied, simply visit the postfix unary expression | ||
| 423 |
1/2✗ Branch 2 → 3 not taken.
✓ Branch 2 → 5 taken 2159 times.
|
2159 | if (node->op == PrefixUnaryExprNode::PrefixUnaryOp::OP_NONE) |
| 424 | ✗ | return visit(node->postfixUnaryExpr); | |
| 425 | |||
| 426 | // Visit the right side | ||
| 427 | 2159 | ExprNode *rhsNode = node->prefixUnaryExpr; | |
| 428 |
2/4✓ Branch 5 → 6 taken 2159 times.
✗ Branch 5 → 57 not taken.
✓ Branch 6 → 7 taken 2159 times.
✗ Branch 6 → 55 not taken.
|
2159 | auto operand = std::any_cast<ExprResult>(visit(rhsNode)); |
| 429 | 2159 | auto [operandType, operandEntry] = operand; | |
| 430 |
5/8✓ Branch 8 → 9 taken 2159 times.
✗ Branch 8 → 78 not taken.
✓ Branch 9 → 10 taken 1 time.
✓ Branch 9 → 14 taken 2158 times.
✓ Branch 10 → 11 taken 1 time.
✗ Branch 10 → 58 not taken.
✓ Branch 11 → 12 taken 1 time.
✗ Branch 11 → 58 not taken.
|
2159 | HANDLE_UNRESOLVED_TYPE_ER(operandType) |
| 431 | // Determine action, based on the given operator | ||
| 432 |
7/8✓ Branch 14 → 15 taken 893 times.
✓ Branch 14 → 17 taken 26 times.
✓ Branch 14 → 25 taken 11 times.
✓ Branch 14 → 33 taken 803 times.
✓ Branch 14 → 35 taken 5 times.
✓ Branch 14 → 37 taken 238 times.
✓ Branch 14 → 39 taken 182 times.
✗ Branch 14 → 41 not taken.
|
2158 | switch (node->op) { |
| 433 | 893 | case PrefixUnaryExprNode::PrefixUnaryOp::OP_MINUS: | |
| 434 |
1/2✓ Branch 15 → 16 taken 893 times.
✗ Branch 15 → 59 not taken.
|
893 | operandType = OpRuleManager::getPrefixMinusResultType(node, operand); |
| 435 | 893 | break; | |
| 436 | 26 | case PrefixUnaryExprNode::PrefixUnaryOp::OP_PLUS_PLUS: | |
| 437 |
1/2✓ Branch 17 → 18 taken 26 times.
✗ Branch 17 → 60 not taken.
|
26 | operandType = opRuleManager.getPrefixPlusPlusResultType(node, operand); |
| 438 | |||
| 439 |
2/2✓ Branch 18 → 19 taken 23 times.
✓ Branch 18 → 24 taken 3 times.
|
26 | if (operandEntry) { |
| 440 | // In case the lhs is captured, notify the capture about the write access | ||
| 441 |
2/4✓ Branch 19 → 20 taken 23 times.
✗ Branch 19 → 78 not taken.
✗ Branch 20 → 21 not taken.
✓ Branch 20 → 22 taken 23 times.
|
23 | if (Capture *lhsCapture = currentScope->symbolTable.lookupCapture(operandEntry->name); lhsCapture) |
| 442 | ✗ | lhsCapture->setAccessType(READ_WRITE); | |
| 443 | |||
| 444 | // Update the state of the variable | ||
| 445 |
1/2✓ Branch 22 → 23 taken 23 times.
✗ Branch 22 → 61 not taken.
|
23 | operandEntry->updateState(INITIALIZED, node); |
| 446 | } | ||
| 447 | |||
| 448 | 26 | break; | |
| 449 | 11 | case PrefixUnaryExprNode::PrefixUnaryOp::OP_MINUS_MINUS: | |
| 450 |
2/2✓ Branch 25 → 26 taken 10 times.
✓ Branch 25 → 62 taken 1 time.
|
11 | operandType = opRuleManager.getPrefixMinusMinusResultType(node, operand); |
| 451 | |||
| 452 |
2/2✓ Branch 26 → 27 taken 7 times.
✓ Branch 26 → 32 taken 3 times.
|
10 | if (operandEntry) { |
| 453 | // In case the lhs is captured, notify the capture about the write access | ||
| 454 |
2/4✓ Branch 27 → 28 taken 7 times.
✗ Branch 27 → 78 not taken.
✗ Branch 28 → 29 not taken.
✓ Branch 28 → 30 taken 7 times.
|
7 | if (Capture *lhsCapture = currentScope->symbolTable.lookupCapture(operandEntry->name); lhsCapture) |
| 455 | ✗ | lhsCapture->setAccessType(READ_WRITE); | |
| 456 | |||
| 457 | // Update the state of the variable | ||
| 458 |
1/2✓ Branch 30 → 31 taken 7 times.
✗ Branch 30 → 63 not taken.
|
7 | operandEntry->updateState(INITIALIZED, node); |
| 459 | } | ||
| 460 | |||
| 461 | 10 | break; | |
| 462 | 803 | case PrefixUnaryExprNode::PrefixUnaryOp::OP_NOT: | |
| 463 |
1/2✓ Branch 33 → 34 taken 803 times.
✗ Branch 33 → 64 not taken.
|
803 | operandType = OpRuleManager::getPrefixNotResultType(node, operand); |
| 464 | 803 | break; | |
| 465 | 5 | case PrefixUnaryExprNode::PrefixUnaryOp::OP_BITWISE_NOT: | |
| 466 |
1/2✓ Branch 35 → 36 taken 5 times.
✗ Branch 35 → 65 not taken.
|
5 | operandType = OpRuleManager::getPrefixBitwiseNotResultType(node, operand); |
| 467 | 5 | break; | |
| 468 | 238 | case PrefixUnaryExprNode::PrefixUnaryOp::OP_DEREFERENCE: | |
| 469 |
2/2✓ Branch 37 → 38 taken 237 times.
✓ Branch 37 → 66 taken 1 time.
|
238 | operandType = OpRuleManager::getPrefixMulResultType(node, operand); |
| 470 | 237 | break; | |
| 471 | 182 | case PrefixUnaryExprNode::PrefixUnaryOp::OP_ADDRESS_OF: | |
| 472 |
1/2✓ Branch 39 → 40 taken 182 times.
✗ Branch 39 → 67 not taken.
|
182 | operandType = OpRuleManager::getPrefixBitwiseAndResultType(node, operand); |
| 473 | 182 | break; | |
| 474 | − | default: // GCOV_EXCL_LINE | |
| 475 | − | throw CompilerError(UNHANDLED_BRANCH, "PrefixUnaryExpr fall-through"); // GCOV_EXCL_LINE | |
| 476 | } | ||
| 477 | |||
| 478 |
2/4✓ Branch 49 → 50 taken 2156 times.
✗ Branch 49 → 77 not taken.
✓ Branch 50 → 51 taken 2156 times.
✗ Branch 50 → 77 not taken.
|
2156 | return ExprResult{node->setEvaluatedSymbolType(operandType, manIdx), operandEntry}; |
| 479 | } | ||
| 480 | |||
| 481 | 23582 | std::any TypeChecker::visitPostfixUnaryExpr(PostfixUnaryExprNode *node) { | |
| 482 | // If no operator is applied, simply visit the atomic expression | ||
| 483 |
1/2✗ Branch 2 → 3 not taken.
✓ Branch 2 → 5 taken 23582 times.
|
23582 | if (node->op == PostfixUnaryExprNode::PostfixUnaryOp::OP_NONE) |
| 484 | ✗ | return visit(node->atomicExpr); | |
| 485 | |||
| 486 | // Visit left side | ||
| 487 | 23582 | ExprNode *lhsNode = node->postfixUnaryExpr; | |
| 488 |
2/4✓ Branch 5 → 6 taken 23582 times.
✗ Branch 5 → 211 not taken.
✓ Branch 6 → 7 taken 23582 times.
✗ Branch 6 → 209 not taken.
|
23582 | auto operand = std::any_cast<ExprResult>(visit(lhsNode)); |
| 489 | 23582 | auto [operandType, operandEntry] = operand; | |
| 490 |
5/8✓ Branch 8 → 9 taken 23582 times.
✗ Branch 8 → 316 not taken.
✓ Branch 9 → 10 taken 6 times.
✓ Branch 9 → 14 taken 23576 times.
✓ Branch 10 → 11 taken 6 times.
✗ Branch 10 → 212 not taken.
✓ Branch 11 → 12 taken 6 times.
✗ Branch 11 → 212 not taken.
|
23582 | HANDLE_UNRESOLVED_TYPE_ER(operandType) |
| 491 | |||
| 492 |
4/5✓ Branch 14 → 15 taken 3666 times.
✓ Branch 14 → 101 taken 17508 times.
✓ Branch 14 → 159 taken 1952 times.
✓ Branch 14 → 167 taken 450 times.
✗ Branch 14 → 175 not taken.
|
23576 | switch (node->op) { |
| 493 | 3666 | case PostfixUnaryExprNode::PostfixUnaryOp::OP_SUBSCRIPT: { | |
| 494 | // Visit index assignment | ||
| 495 | 3666 | ExprNode *indexAssignExpr = node->subscriptIndexExpr; | |
| 496 |
2/4✓ Branch 15 → 16 taken 3666 times.
✗ Branch 15 → 215 not taken.
✓ Branch 16 → 17 taken 3666 times.
✗ Branch 16 → 213 not taken.
|
3666 | const auto index = std::any_cast<ExprResult>(visit(indexAssignExpr)); |
| 497 |
2/8✓ Branch 18 → 19 taken 3666 times.
✗ Branch 18 → 258 not taken.
✗ Branch 19 → 20 not taken.
✓ Branch 19 → 24 taken 3666 times.
✗ Branch 20 → 21 not taken.
✗ Branch 20 → 216 not taken.
✗ Branch 21 → 22 not taken.
✗ Branch 21 → 216 not taken.
|
3666 | HANDLE_UNRESOLVED_TYPE_ER(index.type) |
| 498 | |||
| 499 | // Check is there is an overloaded operator function available, if yes accept it | ||
| 500 |
1/2✓ Branch 24 → 25 taken 3666 times.
✗ Branch 24 → 217 not taken.
|
3666 | const auto [type, _] = opRuleManager.isOperatorOverloadingFctAvailable<2>(node, OP_FCT_SUBSCRIPT, {operand, index}, 0); |
| 501 |
3/4✓ Branch 25 → 26 taken 3666 times.
✗ Branch 25 → 258 not taken.
✓ Branch 26 → 27 taken 125 times.
✓ Branch 26 → 28 taken 3541 times.
|
3666 | if (!type.is(TY_INVALID)) { |
| 502 | 125 | operandType = type; | |
| 503 | 3664 | break; | |
| 504 | } | ||
| 505 | |||
| 506 |
1/2✓ Branch 28 → 29 taken 3541 times.
✗ Branch 28 → 218 not taken.
|
3541 | operandType = operandType.removeReferenceWrapper(); |
| 507 | |||
| 508 | // Check if the index is of the right type | ||
| 509 |
3/4✓ Branch 29 → 30 taken 3541 times.
✗ Branch 29 → 219 not taken.
✓ Branch 30 → 31 taken 1 time.
✓ Branch 30 → 41 taken 3540 times.
|
3541 | if (!index.type.isOneOf({TY_INT, TY_LONG})) |
| 510 |
4/8✓ Branch 33 → 34 taken 1 time.
✗ Branch 33 → 222 not taken.
✓ Branch 34 → 35 taken 1 time.
✗ Branch 34 → 220 not taken.
✓ Branch 37 → 38 taken 1 time.
✗ Branch 37 → 226 not taken.
✓ Branch 38 → 39 taken 1 time.
✗ Branch 38 → 226 not taken.
|
3 | SOFT_ERROR_ER(node, ARRAY_INDEX_NOT_INT_OR_LONG, "Array index must be of type int or long") |
| 511 | |||
| 512 | // Check if we can apply the subscript operator on the lhs type | ||
| 513 |
2/4✓ Branch 41 → 42 taken 3540 times.
✗ Branch 41 → 227 not taken.
✗ Branch 42 → 43 not taken.
✓ Branch 42 → 52 taken 3540 times.
|
3540 | if (!operandType.isOneOf({TY_ARRAY, TY_PTR, TY_STRING})) |
| 514 | ✗ | SOFT_ERROR_ER(node, OPERATOR_WRONG_DATA_TYPE, | |
| 515 | "Can only apply subscript operator on array type, got " + operandType.getName(true)) | ||
| 516 | |||
| 517 | // Check if we have an unsafe operation | ||
| 518 |
6/10✓ Branch 52 → 53 taken 3540 times.
✗ Branch 52 → 258 not taken.
✓ Branch 53 → 54 taken 2509 times.
✓ Branch 53 → 57 taken 1031 times.
✓ Branch 54 → 55 taken 2509 times.
✗ Branch 54 → 258 not taken.
✗ Branch 55 → 56 not taken.
✓ Branch 55 → 57 taken 2509 times.
✗ Branch 58 → 59 not taken.
✓ Branch 58 → 69 taken 3540 times.
|
3540 | if (operandType.isPtr() && !currentScope->doesAllowUnsafeOperations()) |
| 519 | ✗ | SOFT_ERROR_ER( | |
| 520 | node, UNSAFE_OPERATION_IN_SAFE_CONTEXT, | ||
| 521 | "The subscript operator on pointers is an unsafe operation. Use unsafe blocks if you know what you are doing.") | ||
| 522 | |||
| 523 | // In case of compile time index value and known array size, perform a compile time out-of-bounds check | ||
| 524 |
8/10✓ Branch 69 → 70 taken 3540 times.
✗ Branch 69 → 258 not taken.
✓ Branch 70 → 71 taken 187 times.
✓ Branch 70 → 76 taken 3353 times.
✓ Branch 71 → 72 taken 187 times.
✗ Branch 71 → 258 not taken.
✓ Branch 72 → 73 taken 146 times.
✓ Branch 72 → 76 taken 41 times.
✓ Branch 77 → 78 taken 81 times.
✓ Branch 77 → 96 taken 3459 times.
|
3686 | if (operandType.isArray() && operandType.getArraySize() != ARRAY_SIZE_UNKNOWN && |
| 525 |
3/4✓ Branch 73 → 74 taken 146 times.
✗ Branch 73 → 258 not taken.
✓ Branch 74 → 75 taken 81 times.
✓ Branch 74 → 76 taken 65 times.
|
146 | indexAssignExpr->hasCompileTimeValue(manIdx)) { |
| 526 |
1/2✓ Branch 78 → 79 taken 81 times.
✗ Branch 78 → 258 not taken.
|
81 | const int32_t constIndex = indexAssignExpr->getCompileTimeValue(manIdx).intValue; |
| 527 |
1/2✓ Branch 79 → 80 taken 81 times.
✗ Branch 79 → 258 not taken.
|
81 | const unsigned int constSize = operandType.getArraySize(); |
| 528 | // Check if we are accessing out-of-bounds memory | ||
| 529 |
2/2✓ Branch 80 → 81 taken 1 time.
✓ Branch 80 → 96 taken 80 times.
|
81 | if (constIndex >= static_cast<int32_t>(constSize)) { |
| 530 | 1 | const std::string idxStr = std::to_string(constIndex); | |
| 531 | 1 | const std::string sizeStr = std::to_string(constSize); | |
| 532 |
6/12✓ Branch 83 → 84 taken 1 time.
✗ Branch 83 → 248 not taken.
✓ Branch 84 → 85 taken 1 time.
✗ Branch 84 → 246 not taken.
✓ Branch 85 → 86 taken 1 time.
✗ Branch 85 → 244 not taken.
✓ Branch 86 → 87 taken 1 time.
✗ Branch 86 → 242 not taken.
✓ Branch 90 → 91 taken 1 time.
✗ Branch 90 → 251 not taken.
✓ Branch 91 → 92 taken 1 time.
✗ Branch 91 → 251 not taken.
|
1 | SOFT_ERROR_ER(node, ARRAY_INDEX_OUT_OF_BOUNDS, |
| 533 | "You are trying to access element with index " + idxStr + " of an array with size " + sizeStr) | ||
| 534 | 1 | } | |
| 535 | } | ||
| 536 | |||
| 537 | // Get item type | ||
| 538 |
1/2✓ Branch 96 → 97 taken 3539 times.
✗ Branch 96 → 257 not taken.
|
3539 | operandType = operandType.getContained(); |
| 539 | |||
| 540 | // Remove heap qualifier | ||
| 541 | 3539 | operandType.getQualifiers().isHeap = false; | |
| 542 | |||
| 543 | 3539 | break; | |
| 544 | } | ||
| 545 | 17508 | case PostfixUnaryExprNode::PostfixUnaryOp::OP_MEMBER_ACCESS: { | |
| 546 | 17508 | const std::string &fieldName = node->identifier; | |
| 547 | |||
| 548 | // Check if lhs is enum or strobj | ||
| 549 |
1/2✓ Branch 101 → 102 taken 17508 times.
✗ Branch 101 → 286 not taken.
|
17508 | const QualType lhsBaseTy = operandType.autoDeReference(); |
| 550 |
3/4✓ Branch 102 → 103 taken 17508 times.
✗ Branch 102 → 286 not taken.
✓ Branch 103 → 104 taken 1 time.
✓ Branch 103 → 113 taken 17507 times.
|
17508 | if (!lhsBaseTy.is(TY_STRUCT)) |
| 551 |
5/10✓ Branch 104 → 105 taken 1 time.
✗ Branch 104 → 263 not taken.
✓ Branch 105 → 106 taken 1 time.
✗ Branch 105 → 261 not taken.
✓ Branch 106 → 107 taken 1 time.
✗ Branch 106 → 259 not taken.
✓ Branch 109 → 110 taken 1 time.
✗ Branch 109 → 265 not taken.
✓ Branch 110 → 111 taken 1 time.
✗ Branch 110 → 265 not taken.
|
1 | SOFT_ERROR_ER(node, INVALID_MEMBER_ACCESS, "Cannot apply member access operator on " + operandType.getName(false)) |
| 552 | |||
| 553 | // Retrieve registry entry | ||
| 554 |
1/2✓ Branch 113 → 114 taken 17507 times.
✗ Branch 113 → 286 not taken.
|
17507 | const std::string &structName = lhsBaseTy.getSubType(); |
| 555 |
1/2✓ Branch 114 → 115 taken 17507 times.
✗ Branch 114 → 286 not taken.
|
17507 | Scope *structScope = lhsBaseTy.getBodyScope(); |
| 556 | |||
| 557 | // If we only have the generic struct scope, lookup the concrete manifestation scope | ||
| 558 |
2/2✓ Branch 115 → 116 taken 119 times.
✓ Branch 115 → 120 taken 17388 times.
|
17507 | if (structScope->isGenericScope) { |
| 559 |
1/2✓ Branch 116 → 117 taken 119 times.
✗ Branch 116 → 286 not taken.
|
119 | const Struct *spiceStruct = lhsBaseTy.getStruct(node); |
| 560 |
1/2✗ Branch 117 → 118 not taken.
✓ Branch 117 → 119 taken 119 times.
|
119 | assert(spiceStruct != nullptr); |
| 561 | 119 | structScope = spiceStruct->scope; | |
| 562 | } | ||
| 563 |
1/2✗ Branch 120 → 121 not taken.
✓ Branch 120 → 122 taken 17507 times.
|
17507 | assert(!structScope->isGenericScope); // At this point we always expect a substantiation scope |
| 564 | |||
| 565 | // Get accessed field | ||
| 566 | 17507 | std::vector<size_t> indexPath; | |
| 567 |
1/2✓ Branch 122 → 123 taken 17507 times.
✗ Branch 122 → 284 not taken.
|
17507 | SymbolTableEntry *memberEntry = structScope->symbolTable.lookupInComposedFields(fieldName, indexPath); |
| 568 |
2/2✓ Branch 123 → 124 taken 2 times.
✓ Branch 123 → 135 taken 17505 times.
|
17507 | if (!memberEntry) |
| 569 |
6/12✓ Branch 124 → 125 taken 2 times.
✗ Branch 124 → 272 not taken.
✓ Branch 125 → 126 taken 2 times.
✗ Branch 125 → 270 not taken.
✓ Branch 126 → 127 taken 2 times.
✗ Branch 126 → 268 not taken.
✓ Branch 127 → 128 taken 2 times.
✗ Branch 127 → 266 not taken.
✓ Branch 131 → 132 taken 2 times.
✗ Branch 131 → 275 not taken.
✓ Branch 132 → 133 taken 2 times.
✗ Branch 132 → 275 not taken.
|
2 | SOFT_ERROR_ER(node, REFERENCED_UNDEFINED_VARIABLE, "Field '" + node->identifier + "' not found in struct " + structName) |
| 570 |
1/2✓ Branch 135 → 136 taken 17505 times.
✗ Branch 135 → 284 not taken.
|
17505 | const QualType memberType = memberEntry->getQualType(); |
| 571 | |||
| 572 | // Check for insufficient visibility | ||
| 573 |
8/14✓ Branch 136 → 137 taken 17505 times.
✗ Branch 136 → 276 not taken.
✓ Branch 137 → 138 taken 97 times.
✓ Branch 137 → 143 taken 17408 times.
✓ Branch 138 → 139 taken 97 times.
✗ Branch 138 → 276 not taken.
✓ Branch 139 → 140 taken 97 times.
✗ Branch 139 → 276 not taken.
✓ Branch 140 → 141 taken 97 times.
✗ Branch 140 → 276 not taken.
✗ Branch 141 → 142 not taken.
✓ Branch 141 → 143 taken 97 times.
✗ Branch 144 → 145 not taken.
✓ Branch 144 → 154 taken 17505 times.
|
17505 | if (structScope->isImportedBy(rootScope) && !memberEntry->getQualType().getBase().isPublic()) |
| 574 | ✗ | SOFT_ERROR_ER(node, INSUFFICIENT_VISIBILITY, "Cannot access field '" + fieldName + "' due to its private visibility") | |
| 575 | |||
| 576 | // Set field to used | ||
| 577 | 17505 | memberEntry->used = true; | |
| 578 | |||
| 579 | // Overwrite type and entry of left side with member type and entry | ||
| 580 | 17505 | operandType = memberType; | |
| 581 | 17505 | operandEntry = memberEntry; | |
| 582 | 17505 | break; | |
| 583 |
2/2✓ Branch 156 → 157 taken 2 times.
✓ Branch 156 → 158 taken 17505 times.
|
17507 | } |
| 584 | 1952 | case PostfixUnaryExprNode::PostfixUnaryOp::OP_PLUS_PLUS: { | |
| 585 |
2/2✓ Branch 159 → 160 taken 1950 times.
✓ Branch 159 → 287 taken 2 times.
|
1952 | operandType = opRuleManager.getPostfixPlusPlusResultType(node, operand).type; |
| 586 | |||
| 587 |
2/2✓ Branch 160 → 161 taken 1946 times.
✓ Branch 160 → 166 taken 4 times.
|
1950 | if (operandEntry) { |
| 588 | // In case the lhs is captured, notify the capture about the write access | ||
| 589 |
3/4✓ Branch 161 → 162 taken 1946 times.
✗ Branch 161 → 316 not taken.
✓ Branch 162 → 163 taken 4 times.
✓ Branch 162 → 164 taken 1942 times.
|
1946 | if (Capture *lhsCapture = currentScope->symbolTable.lookupCapture(operandEntry->name); lhsCapture) |
| 590 |
1/2✓ Branch 163 → 164 taken 4 times.
✗ Branch 163 → 316 not taken.
|
4 | lhsCapture->setAccessType(READ_WRITE); |
| 591 | |||
| 592 | // Update the state of the variable | ||
| 593 |
1/2✓ Branch 164 → 165 taken 1946 times.
✗ Branch 164 → 288 not taken.
|
1946 | operandEntry->updateState(INITIALIZED, node); |
| 594 | } | ||
| 595 | |||
| 596 | 1950 | break; | |
| 597 | } | ||
| 598 | 450 | case PostfixUnaryExprNode::PostfixUnaryOp::OP_MINUS_MINUS: { | |
| 599 |
1/2✓ Branch 167 → 168 taken 450 times.
✗ Branch 167 → 289 not taken.
|
450 | operandType = opRuleManager.getPostfixMinusMinusResultType(node, operand).type; |
| 600 | |||
| 601 |
2/2✓ Branch 168 → 169 taken 446 times.
✓ Branch 168 → 174 taken 4 times.
|
450 | if (operandEntry) { |
| 602 | // In case the lhs is captured, notify the capture about the write access | ||
| 603 |
2/4✓ Branch 169 → 170 taken 446 times.
✗ Branch 169 → 316 not taken.
✗ Branch 170 → 171 not taken.
✓ Branch 170 → 172 taken 446 times.
|
446 | if (Capture *lhsCapture = currentScope->symbolTable.lookupCapture(operandEntry->name); lhsCapture) |
| 604 | ✗ | lhsCapture->setAccessType(READ_WRITE); | |
| 605 | |||
| 606 | // Update the state of the variable | ||
| 607 |
1/2✓ Branch 172 → 173 taken 446 times.
✗ Branch 172 → 290 not taken.
|
446 | operandEntry->updateState(INITIALIZED, node); |
| 608 | } | ||
| 609 | |||
| 610 | 450 | break; | |
| 611 | } | ||
| 612 | − | default: // GCOV_EXCL_LINE | |
| 613 | − | throw CompilerError(UNHANDLED_BRANCH, "PostfixUnaryExpr fall-through"); // GCOV_EXCL_LINE | |
| 614 | } | ||
| 615 | |||
| 616 |
2/4✓ Branch 183 → 184 taken 23569 times.
✗ Branch 183 → 316 not taken.
✗ Branch 184 → 185 not taken.
✓ Branch 184 → 203 taken 23569 times.
|
23569 | if (operandType.is(TY_INVALID)) { |
| 617 | ✗ | const std::string &varName = operandEntry ? operandEntry->name : ""; | |
| 618 | ✗ | SOFT_ERROR_ER(node, REFERENCED_UNDEFINED_VARIABLE, "Variable '" + varName + "' was referenced before declared") | |
| 619 | ✗ | } | |
| 620 | |||
| 621 |
2/4✓ Branch 203 → 204 taken 23569 times.
✗ Branch 203 → 315 not taken.
✓ Branch 204 → 205 taken 23569 times.
✗ Branch 204 → 315 not taken.
|
23569 | return ExprResult{node->setEvaluatedSymbolType(operandType, manIdx), operandEntry}; |
| 622 | } | ||
| 623 | |||
| 624 | 105483 | std::any TypeChecker::visitAtomicExpr(AtomicExprNode *node) { | |
| 625 | // Check if constant | ||
| 626 |
2/2✓ Branch 2 → 3 taken 21641 times.
✓ Branch 2 → 5 taken 83842 times.
|
105483 | if (node->constant) |
| 627 |
1/2✓ Branch 3 → 4 taken 21641 times.
✗ Branch 3 → 216 not taken.
|
21641 | return visit(node->constant); |
| 628 | |||
| 629 | // Check if value | ||
| 630 |
2/2✓ Branch 5 → 6 taken 22224 times.
✓ Branch 5 → 8 taken 61618 times.
|
83842 | if (node->value) |
| 631 |
2/2✓ Branch 6 → 7 taken 22219 times.
✓ Branch 6 → 216 taken 5 times.
|
22224 | return visit(node->value); |
| 632 | |||
| 633 | // Check for assign expression within parentheses | ||
| 634 |
2/2✓ Branch 8 → 9 taken 635 times.
✓ Branch 8 → 11 taken 60983 times.
|
61618 | if (node->assignExpr) |
| 635 |
2/2✓ Branch 9 → 10 taken 632 times.
✓ Branch 9 → 216 taken 3 times.
|
635 | return visit(node->assignExpr); |
| 636 | |||
| 637 | // Identifier (local or global variable access) | ||
| 638 |
1/2✗ Branch 12 → 13 not taken.
✓ Branch 12 → 14 taken 60983 times.
|
60983 | assert(!node->fqIdentifier.empty()); |
| 639 | |||
| 640 |
1/2✓ Branch 14 → 15 taken 60983 times.
✗ Branch 14 → 216 not taken.
|
60983 | auto &[entry, accessScope, capture] = node->data.at(manIdx); |
| 641 | 60983 | accessScope = currentScope; | |
| 642 | |||
| 643 | // Check if a local or global variable can be found by searching for the name | ||
| 644 |
2/2✓ Branch 16 → 17 taken 60674 times.
✓ Branch 16 → 22 taken 309 times.
|
60983 | if (node->identifierFragments.size() == 1) |
| 645 | 121348 | entry = accessScope->lookup(node->identifierFragments.back()); | |
| 646 | |||
| 647 | // If no local or global was found, search in the name registry | ||
| 648 |
2/2✓ Branch 22 → 23 taken 398 times.
✓ Branch 22 → 35 taken 60585 times.
|
60983 | if (!entry) { |
| 649 |
1/2✓ Branch 23 → 24 taken 398 times.
✗ Branch 23 → 216 not taken.
|
398 | const NameRegistryEntry *registryEntry = sourceFile->getNameRegistryEntry(node->fqIdentifier); |
| 650 |
2/2✓ Branch 24 → 25 taken 1 time.
✓ Branch 24 → 34 taken 397 times.
|
398 | if (!registryEntry) |
| 651 |
5/10✓ Branch 25 → 26 taken 1 time.
✗ Branch 25 → 164 not taken.
✓ Branch 26 → 27 taken 1 time.
✗ Branch 26 → 162 not taken.
✓ Branch 27 → 28 taken 1 time.
✗ Branch 27 → 160 not taken.
✓ Branch 30 → 31 taken 1 time.
✗ Branch 30 → 166 not taken.
✓ Branch 31 → 32 taken 1 time.
✗ Branch 31 → 166 not taken.
|
1 | SOFT_ERROR_ER(node, REFERENCED_UNDEFINED_VARIABLE, "The variable '" + node->fqIdentifier + "' could not be found") |
| 652 | 397 | entry = registryEntry->targetEntry; | |
| 653 | 397 | accessScope = registryEntry->targetScope; | |
| 654 | } | ||
| 655 |
1/2✗ Branch 35 → 36 not taken.
✓ Branch 35 → 37 taken 60982 times.
|
60982 | assert(entry != nullptr); |
| 656 | 60982 | entry->used = true; | |
| 657 |
1/2✓ Branch 37 → 38 taken 60982 times.
✗ Branch 37 → 216 not taken.
|
60982 | capture = accessScope->symbolTable.lookupCapture(entry->name); |
| 658 | |||
| 659 |
1/2✓ Branch 38 → 39 taken 60982 times.
✗ Branch 38 → 216 not taken.
|
60982 | const QualType varType = entry->getQualType(); |
| 660 |
5/8✓ Branch 39 → 40 taken 60982 times.
✗ Branch 39 → 216 not taken.
✓ Branch 40 → 41 taken 9 times.
✓ Branch 40 → 45 taken 60973 times.
✓ Branch 41 → 42 taken 9 times.
✗ Branch 41 → 167 not taken.
✓ Branch 42 → 43 taken 9 times.
✗ Branch 42 → 167 not taken.
|
60982 | HANDLE_UNRESOLVED_TYPE_ER(varType) |
| 661 |
3/4✓ Branch 45 → 46 taken 60973 times.
✗ Branch 45 → 216 not taken.
✓ Branch 46 → 47 taken 2 times.
✓ Branch 46 → 56 taken 60971 times.
|
60973 | if (varType.is(TY_INVALID)) |
| 662 |
5/10✓ Branch 47 → 48 taken 2 times.
✗ Branch 47 → 172 not taken.
✓ Branch 48 → 49 taken 2 times.
✗ Branch 48 → 170 not taken.
✓ Branch 49 → 50 taken 2 times.
✗ Branch 49 → 168 not taken.
✓ Branch 52 → 53 taken 2 times.
✗ Branch 52 → 174 not taken.
✓ Branch 53 → 54 taken 2 times.
✗ Branch 53 → 174 not taken.
|
2 | SOFT_ERROR_ER(node, USED_BEFORE_DECLARED, "Symbol '" + entry->name + "' was used before declared.") |
| 663 | |||
| 664 |
7/8✓ Branch 56 → 57 taken 60971 times.
✗ Branch 56 → 175 not taken.
✓ Branch 57 → 58 taken 67 times.
✓ Branch 57 → 60 taken 60904 times.
✓ Branch 58 → 59 taken 20 times.
✓ Branch 58 → 60 taken 47 times.
✓ Branch 61 → 62 taken 20 times.
✓ Branch 61 → 90 taken 60951 times.
|
60971 | if (varType.isOneOf({TY_FUNCTION, TY_PROCEDURE}) && entry->global) { |
| 665 | // Check if overloaded function was referenced | ||
| 666 |
1/2✓ Branch 62 → 63 taken 20 times.
✗ Branch 62 → 216 not taken.
|
20 | const std::vector<Function *> *manifestations = entry->declNode->getFctManifestations(entry->name); |
| 667 |
2/2✓ Branch 64 → 65 taken 1 time.
✓ Branch 64 → 75 taken 19 times.
|
20 | if (manifestations->size() > 1) |
| 668 |
4/8✓ Branch 67 → 68 taken 1 time.
✗ Branch 67 → 178 not taken.
✓ Branch 68 → 69 taken 1 time.
✗ Branch 68 → 176 not taken.
✓ Branch 71 → 72 taken 1 time.
✗ Branch 71 → 182 not taken.
✓ Branch 72 → 73 taken 1 time.
✗ Branch 72 → 182 not taken.
|
3 | SOFT_ERROR_ER(node, REFERENCED_OVERLOADED_FCT, "Overloaded functions / functions with optional params cannot be referenced") |
| 669 |
2/2✓ Branch 77 → 78 taken 1 time.
✓ Branch 77 → 88 taken 18 times.
|
19 | if (!manifestations->front()->templateTypes.empty()) |
| 670 |
4/8✓ Branch 80 → 81 taken 1 time.
✗ Branch 80 → 185 not taken.
✓ Branch 81 → 82 taken 1 time.
✗ Branch 81 → 183 not taken.
✓ Branch 84 → 85 taken 1 time.
✗ Branch 84 → 189 not taken.
✓ Branch 85 → 86 taken 1 time.
✗ Branch 85 → 189 not taken.
|
3 | SOFT_ERROR_ER(node, REFERENCED_OVERLOADED_FCT, "Generic functions cannot be referenced") |
| 671 | // Set referenced function to used | ||
| 672 | 18 | Function *referencedFunction = manifestations->front(); | |
| 673 | 18 | referencedFunction->used = true; | |
| 674 | 18 | referencedFunction->entry->used = true; | |
| 675 | } | ||
| 676 | |||
| 677 | // The base type should be an extended primitive | ||
| 678 |
1/2✓ Branch 90 → 91 taken 60969 times.
✗ Branch 90 → 216 not taken.
|
60969 | const QualType baseType = varType.getBase(); |
| 679 |
6/10✓ Branch 91 → 92 taken 60969 times.
✗ Branch 91 → 216 not taken.
✓ Branch 92 → 93 taken 4 times.
✓ Branch 92 → 96 taken 60965 times.
✓ Branch 93 → 94 taken 4 times.
✗ Branch 93 → 216 not taken.
✗ Branch 94 → 95 not taken.
✓ Branch 94 → 96 taken 4 times.
✗ Branch 97 → 98 not taken.
✓ Branch 97 → 109 taken 60969 times.
|
60969 | if (!baseType.isExtendedPrimitive() && !baseType.is(TY_DYN)) |
| 680 | ✗ | SOFT_ERROR_ER(node, INVALID_SYMBOL_ACCESS, "A symbol of type " + varType.getName(false) + " cannot be accessed here") | |
| 681 | |||
| 682 | // Check if we have seen a 'this.' prefix, because the generator needs that | ||
| 683 |
6/8✓ Branch 109 → 110 taken 1 time.
✓ Branch 109 → 114 taken 60968 times.
✓ Branch 111 → 112 taken 1 time.
✗ Branch 111 → 216 not taken.
✓ Branch 112 → 113 taken 1 time.
✗ Branch 112 → 114 not taken.
✓ Branch 115 → 116 taken 1 time.
✓ Branch 115 → 125 taken 60968 times.
|
60969 | if (entry->scope->type == ScopeType::STRUCT && node->identifierFragments.front() != THIS_VARIABLE_NAME) |
| 684 |
5/10✓ Branch 116 → 117 taken 1 time.
✗ Branch 116 → 204 not taken.
✓ Branch 117 → 118 taken 1 time.
✗ Branch 117 → 202 not taken.
✓ Branch 118 → 119 taken 1 time.
✗ Branch 118 → 200 not taken.
✓ Branch 121 → 122 taken 1 time.
✗ Branch 121 → 206 not taken.
✓ Branch 122 → 123 taken 1 time.
✗ Branch 122 → 206 not taken.
|
1 | SOFT_ERROR_ER(node, REFERENCED_UNDEFINED_VARIABLE, |
| 685 | "The symbol '" + node->fqIdentifier + "' could not be found. Missing 'this.' prefix?") | ||
| 686 | |||
| 687 | // Ensure that the entry is public, if the symbol is imported. | ||
| 688 | // An exception are enum items. There it is sufficient, that the enum itself is public. | ||
| 689 |
7/8✓ Branch 125 → 126 taken 60968 times.
✗ Branch 125 → 216 not taken.
✓ Branch 126 → 127 taken 209 times.
✓ Branch 126 → 129 taken 60759 times.
✓ Branch 127 → 128 taken 82 times.
✓ Branch 127 → 129 taken 127 times.
✓ Branch 130 → 131 taken 82 times.
✓ Branch 130 → 144 taken 60886 times.
|
60968 | if (accessScope->isImportedBy(rootScope) && accessScope->type != ScopeType::ENUM) |
| 690 |
5/8✓ Branch 131 → 132 taken 82 times.
✗ Branch 131 → 207 not taken.
✓ Branch 132 → 133 taken 82 times.
✗ Branch 132 → 207 not taken.
✓ Branch 133 → 134 taken 82 times.
✗ Branch 133 → 207 not taken.
✓ Branch 134 → 135 taken 1 time.
✓ Branch 134 → 144 taken 81 times.
|
82 | if (!entry->getQualType().getBase().isPublic()) |
| 691 |
5/10✓ Branch 135 → 136 taken 1 time.
✗ Branch 135 → 212 not taken.
✓ Branch 136 → 137 taken 1 time.
✗ Branch 136 → 210 not taken.
✓ Branch 137 → 138 taken 1 time.
✗ Branch 137 → 208 not taken.
✓ Branch 140 → 141 taken 1 time.
✗ Branch 140 → 214 not taken.
✓ Branch 141 → 142 taken 1 time.
✗ Branch 141 → 214 not taken.
|
1 | SOFT_ERROR_ER(node, INSUFFICIENT_VISIBILITY, "Cannot access '" + entry->name + "' due to its private visibility") |
| 692 | |||
| 693 | // For enum item access, use access scope of the enum | ||
| 694 |
2/2✓ Branch 144 → 145 taken 304 times.
✓ Branch 144 → 146 taken 60663 times.
|
60967 | if (entry->scope->type == ScopeType::ENUM) |
| 695 | 304 | accessScope = entry->scope; | |
| 696 | |||
| 697 | // For struct access, use access scope of the struct | ||
| 698 |
3/4✓ Branch 146 → 147 taken 60967 times.
✗ Branch 146 → 216 not taken.
✓ Branch 147 → 148 taken 19830 times.
✓ Branch 147 → 154 taken 41137 times.
|
60967 | if (baseType.is(TY_STRUCT)) { |
| 699 |
1/2✓ Branch 148 → 149 taken 19830 times.
✗ Branch 148 → 216 not taken.
|
19830 | const std::string &structName = baseType.getSubType(); |
| 700 |
1/2✓ Branch 149 → 150 taken 19830 times.
✗ Branch 149 → 216 not taken.
|
19830 | const NameRegistryEntry *nameRegistryEntry = sourceFile->getNameRegistryEntry(structName); |
| 701 |
1/2✗ Branch 150 → 151 not taken.
✓ Branch 150 → 152 taken 19830 times.
|
19830 | assert(nameRegistryEntry != nullptr); |
| 702 | 19830 | accessScope = nameRegistryEntry->targetScope; | |
| 703 |
1/2✗ Branch 152 → 153 not taken.
✓ Branch 152 → 154 taken 19830 times.
|
19830 | assert(accessScope != nullptr); |
| 704 | } | ||
| 705 | |||
| 706 |
2/4✓ Branch 154 → 155 taken 60967 times.
✗ Branch 154 → 215 not taken.
✓ Branch 155 → 156 taken 60967 times.
✗ Branch 155 → 215 not taken.
|
60967 | return ExprResult{node->setEvaluatedSymbolType(varType, manIdx), entry}; |
| 707 | } | ||
| 708 | |||
| 709 | } // namespace spice::compiler | ||
| 710 |