src/ast/ASTBuilder.cpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // Copyright (c) 2021-2026 ChilliBits. All rights reserved. | ||
| 2 | |||
| 3 | #include "ASTBuilder.h" | ||
| 4 | |||
| 5 | #include <regex> | ||
| 6 | |||
| 7 | #include <SourceFile.h> | ||
| 8 | #include <ast/ASTNodes.h> | ||
| 9 | #include <ast/Attributes.h> | ||
| 10 | #include <exception/ParserError.h> | ||
| 11 | #include <typechecker/OpRuleManager.h> | ||
| 12 | #include <util/GlobalDefinitions.h> | ||
| 13 | |||
| 14 | namespace spice::compiler { | ||
| 15 | |||
| 16 | 1242 | ASTBuilder::ASTBuilder(GlobalResourceManager &resourceManager, SourceFile *sourceFile, antlr4::ANTLRInputStream *inputStream) | |
| 17 |
1/2✓ Branch 4 → 5 taken 1242 times.
✗ Branch 4 → 6 not taken.
|
1242 | : CompilerPass(resourceManager, sourceFile), inputStream(inputStream) {} |
| 18 | |||
| 19 | 1240 | std::any ASTBuilder::visitEntry(SpiceParser::EntryContext *ctx) { | |
| 20 | 1240 | const auto entryNode = createNode<EntryNode>(ctx); | |
| 21 | |||
| 22 | // Visit children | ||
| 23 |
2/2✓ Branch 127 → 5 taken 19436 times.
✓ Branch 127 → 128 taken 1234 times.
|
20670 | for (ParserRuleContext::ParseTree *child : ctx->children) { |
| 24 |
3/4✓ Branch 6 → 7 taken 19436 times.
✗ Branch 6 → 8 not taken.
✓ Branch 9 → 10 taken 438 times.
✓ Branch 9 → 15 taken 18998 times.
|
19436 | if (auto *mainFctDefCtx = dynamic_cast<SpiceParser::MainFunctionDefContext *>(child)) |
| 25 |
4/6✓ Branch 10 → 11 taken 434 times.
✓ Branch 10 → 140 taken 4 times.
✓ Branch 11 → 12 taken 434 times.
✗ Branch 11 → 138 not taken.
✓ Branch 12 → 13 taken 434 times.
✗ Branch 12 → 138 not taken.
|
438 | entryNode->topLevelDefs.push_back(std::any_cast<MainFctDefNode *>(visit(mainFctDefCtx))); |
| 26 |
3/4✓ Branch 15 → 16 taken 18998 times.
✗ Branch 15 → 17 not taken.
✓ Branch 18 → 19 taken 8243 times.
✓ Branch 18 → 24 taken 10755 times.
|
18998 | else if (auto *fctDefCtx = dynamic_cast<SpiceParser::FunctionDefContext *>(child)) |
| 27 |
3/6✓ Branch 19 → 20 taken 8243 times.
✗ Branch 19 → 144 not taken.
✓ Branch 20 → 21 taken 8243 times.
✗ Branch 20 → 142 not taken.
✓ Branch 21 → 22 taken 8243 times.
✗ Branch 21 → 142 not taken.
|
8243 | entryNode->topLevelDefs.push_back(std::any_cast<FctDefNode *>(visit(fctDefCtx))); |
| 28 |
3/4✓ Branch 24 → 25 taken 10755 times.
✗ Branch 24 → 26 not taken.
✓ Branch 27 → 28 taken 4270 times.
✓ Branch 27 → 33 taken 6485 times.
|
10755 | else if (auto *procDefCtx = dynamic_cast<SpiceParser::ProcedureDefContext *>(child)) |
| 29 |
3/6✓ Branch 28 → 29 taken 4270 times.
✗ Branch 28 → 148 not taken.
✓ Branch 29 → 30 taken 4270 times.
✗ Branch 29 → 146 not taken.
✓ Branch 30 → 31 taken 4270 times.
✗ Branch 30 → 146 not taken.
|
4270 | entryNode->topLevelDefs.push_back(std::any_cast<ProcDefNode *>(visit(procDefCtx))); |
| 30 |
3/4✓ Branch 33 → 34 taken 6485 times.
✗ Branch 33 → 35 not taken.
✓ Branch 36 → 37 taken 740 times.
✓ Branch 36 → 42 taken 5745 times.
|
6485 | else if (auto *structDefCtx = dynamic_cast<SpiceParser::StructDefContext *>(child)) |
| 31 |
4/6✓ Branch 37 → 38 taken 739 times.
✓ Branch 37 → 152 taken 1 time.
✓ Branch 38 → 39 taken 739 times.
✗ Branch 38 → 150 not taken.
✓ Branch 39 → 40 taken 739 times.
✗ Branch 39 → 150 not taken.
|
740 | entryNode->topLevelDefs.push_back(std::any_cast<StructDefNode *>(visit(structDefCtx))); |
| 32 |
3/4✓ Branch 42 → 43 taken 5745 times.
✗ Branch 42 → 44 not taken.
✓ Branch 45 → 46 taken 108 times.
✓ Branch 45 → 51 taken 5637 times.
|
5745 | else if (auto *interfaceDefCtx = dynamic_cast<SpiceParser::InterfaceDefContext *>(child)) |
| 33 |
3/6✓ Branch 46 → 47 taken 108 times.
✗ Branch 46 → 156 not taken.
✓ Branch 47 → 48 taken 108 times.
✗ Branch 47 → 154 not taken.
✓ Branch 48 → 49 taken 108 times.
✗ Branch 48 → 154 not taken.
|
108 | entryNode->topLevelDefs.push_back(std::any_cast<InterfaceDefNode *>(visit(interfaceDefCtx))); |
| 34 |
3/4✓ Branch 51 → 52 taken 5637 times.
✗ Branch 51 → 53 not taken.
✓ Branch 54 → 55 taken 68 times.
✓ Branch 54 → 60 taken 5569 times.
|
5637 | else if (auto *enumDefCtx = dynamic_cast<SpiceParser::EnumDefContext *>(child)) |
| 35 |
3/6✓ Branch 55 → 56 taken 68 times.
✗ Branch 55 → 160 not taken.
✓ Branch 56 → 57 taken 68 times.
✗ Branch 56 → 158 not taken.
✓ Branch 57 → 58 taken 68 times.
✗ Branch 57 → 158 not taken.
|
68 | entryNode->topLevelDefs.push_back(std::any_cast<EnumDefNode *>(visit(enumDefCtx))); |
| 36 |
3/4✓ Branch 60 → 61 taken 5569 times.
✗ Branch 60 → 62 not taken.
✓ Branch 63 → 64 taken 999 times.
✓ Branch 63 → 69 taken 4570 times.
|
5569 | else if (auto *genericTypeDefCtx = dynamic_cast<SpiceParser::GenericTypeDefContext *>(child)) |
| 37 |
3/6✓ Branch 64 → 65 taken 999 times.
✗ Branch 64 → 164 not taken.
✓ Branch 65 → 66 taken 999 times.
✗ Branch 65 → 162 not taken.
✓ Branch 66 → 67 taken 999 times.
✗ Branch 66 → 162 not taken.
|
999 | entryNode->topLevelDefs.push_back(std::any_cast<GenericTypeDefNode *>(visit(genericTypeDefCtx))); |
| 38 |
3/4✓ Branch 69 → 70 taken 4570 times.
✗ Branch 69 → 71 not taken.
✓ Branch 72 → 73 taken 71 times.
✓ Branch 72 → 78 taken 4499 times.
|
4570 | else if (auto *aliasDefCtx = dynamic_cast<SpiceParser::AliasDefContext *>(child)) |
| 39 |
3/6✓ Branch 73 → 74 taken 71 times.
✗ Branch 73 → 168 not taken.
✓ Branch 74 → 75 taken 71 times.
✗ Branch 74 → 166 not taken.
✓ Branch 75 → 76 taken 71 times.
✗ Branch 75 → 166 not taken.
|
71 | entryNode->topLevelDefs.push_back(std::any_cast<AliasDefNode *>(visit(aliasDefCtx))); |
| 40 |
3/4✓ Branch 78 → 79 taken 4499 times.
✗ Branch 78 → 80 not taken.
✓ Branch 81 → 82 taken 1201 times.
✓ Branch 81 → 87 taken 3298 times.
|
4499 | else if (auto *globalVarDefCtx = dynamic_cast<SpiceParser::GlobalVarDefContext *>(child)) |
| 41 |
3/6✓ Branch 82 → 83 taken 1201 times.
✗ Branch 82 → 172 not taken.
✓ Branch 83 → 84 taken 1201 times.
✗ Branch 83 → 170 not taken.
✓ Branch 84 → 85 taken 1201 times.
✗ Branch 84 → 170 not taken.
|
1201 | entryNode->topLevelDefs.push_back(std::any_cast<GlobalVarDefNode *>(visit(globalVarDefCtx))); |
| 42 |
3/4✓ Branch 87 → 88 taken 3298 times.
✗ Branch 87 → 89 not taken.
✓ Branch 90 → 91 taken 654 times.
✓ Branch 90 → 96 taken 2644 times.
|
3298 | else if (auto *importDefCtx = dynamic_cast<SpiceParser::ImportDefContext *>(child)) |
| 43 |
3/6✓ Branch 91 → 92 taken 654 times.
✗ Branch 91 → 176 not taken.
✓ Branch 92 → 93 taken 654 times.
✗ Branch 92 → 174 not taken.
✓ Branch 93 → 94 taken 654 times.
✗ Branch 93 → 174 not taken.
|
654 | entryNode->importDefs.push_back(std::any_cast<ImportDefNode *>(visit(importDefCtx))); |
| 44 |
3/4✓ Branch 96 → 97 taken 2644 times.
✗ Branch 96 → 98 not taken.
✓ Branch 99 → 100 taken 1040 times.
✓ Branch 99 → 105 taken 1604 times.
|
2644 | else if (auto *extDeclCtx = dynamic_cast<SpiceParser::ExtDeclContext *>(child)) |
| 45 |
3/6✓ Branch 100 → 101 taken 1040 times.
✗ Branch 100 → 180 not taken.
✓ Branch 101 → 102 taken 1040 times.
✗ Branch 101 → 178 not taken.
✓ Branch 102 → 103 taken 1040 times.
✗ Branch 102 → 178 not taken.
|
1040 | entryNode->topLevelDefs.push_back(std::any_cast<ExtDeclNode *>(visit(extDeclCtx))); |
| 46 |
3/4✓ Branch 105 → 106 taken 1604 times.
✗ Branch 105 → 107 not taken.
✓ Branch 108 → 109 taken 370 times.
✓ Branch 108 → 114 taken 1234 times.
|
1604 | else if (auto *modAttrCtx = dynamic_cast<SpiceParser::ModAttrContext *>(child)) |
| 47 |
4/6✓ Branch 109 → 110 taken 369 times.
✓ Branch 109 → 184 taken 1 time.
✓ Branch 110 → 111 taken 369 times.
✗ Branch 110 → 182 not taken.
✓ Branch 111 → 112 taken 369 times.
✗ Branch 111 → 182 not taken.
|
370 | entryNode->modAttrs.push_back(std::any_cast<ModAttrNode *>(visit(modAttrCtx))); |
| 48 |
1/2✓ Branch 114 → 115 taken 1234 times.
✗ Branch 114 → 116 not taken.
|
1234 | else if (const auto *eofCtx = dynamic_cast<TerminalNode *>(child); |
| 49 |
5/10✓ Branch 117 → 118 taken 1234 times.
✗ Branch 117 → 121 not taken.
✓ Branch 118 → 119 taken 1234 times.
✗ Branch 118 → 186 not taken.
✓ Branch 119 → 120 taken 1234 times.
✗ Branch 119 → 186 not taken.
✗ Branch 120 → 121 not taken.
✓ Branch 120 → 122 taken 1234 times.
✗ Branch 123 → 124 not taken.
✓ Branch 123 → 125 taken 1234 times.
|
1234 | !eofCtx || eofCtx->getSymbol()->getType() != SpiceParser::EOF) |
| 50 | − | assert_fail("Unknown top level definition type"); // GCOV_EXCL_LINE | |
| 51 | } | ||
| 52 | |||
| 53 |
1/2✓ Branch 134 → 135 taken 1234 times.
✗ Branch 134 → 187 not taken.
|
1234 | return concludeNode(entryNode); |
| 54 | } | ||
| 55 | |||
| 56 | 438 | std::any ASTBuilder::visitMainFunctionDef(SpiceParser::MainFunctionDefContext *ctx) { | |
| 57 | 438 | const auto mainFctDefNode = createNode<MainFctDefNode>(ctx); | |
| 58 | |||
| 59 | // Visit children | ||
| 60 |
2/2✓ Branch 4 → 5 taken 1 time.
✓ Branch 4 → 10 taken 437 times.
|
438 | if (ctx->topLevelDefAttr()) |
| 61 |
3/6✓ Branch 5 → 6 taken 1 time.
✗ Branch 5 → 33 not taken.
✓ Branch 6 → 7 taken 1 time.
✗ Branch 6 → 33 not taken.
✓ Branch 7 → 8 taken 1 time.
✗ Branch 7 → 31 not taken.
|
1 | mainFctDefNode->attrs = std::any_cast<TopLevelDefinitionAttrNode *>(visit(ctx->topLevelDefAttr())); |
| 62 |
2/2✓ Branch 11 → 12 taken 4 times.
✓ Branch 11 → 17 taken 434 times.
|
438 | if (ctx->paramLst()) { |
| 63 | 4 | mainFctDefNode->takesArgs = true; | |
| 64 |
3/6✓ Branch 12 → 13 taken 4 times.
✗ Branch 12 → 36 not taken.
✓ Branch 13 → 14 taken 4 times.
✗ Branch 13 → 36 not taken.
✓ Branch 14 → 15 taken 4 times.
✗ Branch 14 → 34 not taken.
|
4 | mainFctDefNode->paramLst = std::any_cast<ParamLstNode *>(visit(ctx->paramLst())); |
| 65 | } | ||
| 66 |
4/6✓ Branch 17 → 18 taken 438 times.
✗ Branch 17 → 39 not taken.
✓ Branch 18 → 19 taken 434 times.
✓ Branch 18 → 39 taken 4 times.
✓ Branch 19 → 20 taken 434 times.
✗ Branch 19 → 37 not taken.
|
438 | mainFctDefNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 67 | |||
| 68 |
1/2✓ Branch 27 → 28 taken 434 times.
✗ Branch 27 → 40 not taken.
|
434 | return concludeNode(mainFctDefNode); |
| 69 | } | ||
| 70 | |||
| 71 | 8243 | std::any ASTBuilder::visitFunctionDef(SpiceParser::FunctionDefContext *ctx) { | |
| 72 | 8243 | const auto fctDefNode = createNode<FctDefNode>(ctx); | |
| 73 | |||
| 74 | // Visit children | ||
| 75 |
2/2✓ Branch 4 → 5 taken 339 times.
✓ Branch 4 → 16 taken 7904 times.
|
8243 | if (ctx->topLevelDefAttr()) { |
| 76 |
3/6✓ Branch 5 → 6 taken 339 times.
✗ Branch 5 → 62 not taken.
✓ Branch 6 → 7 taken 339 times.
✗ Branch 6 → 62 not taken.
✓ Branch 7 → 8 taken 339 times.
✗ Branch 7 → 60 not taken.
|
339 | fctDefNode->attrs = std::any_cast<TopLevelDefinitionAttrNode *>(visit(ctx->topLevelDefAttr())); |
| 77 | // Tell the attributes that they are function attributes | ||
| 78 |
2/2✓ Branch 14 → 11 taken 344 times.
✓ Branch 14 → 15 taken 339 times.
|
683 | for (AttrNode *attr : fctDefNode->attrs->attrLst->attributes) |
| 79 | 344 | attr->target = AttrNode::TARGET_FCT_PROC; | |
| 80 | } | ||
| 81 |
2/2✓ Branch 17 → 18 taken 8044 times.
✓ Branch 17 → 23 taken 199 times.
|
8243 | if (ctx->qualifierLst()) |
| 82 |
3/6✓ Branch 18 → 19 taken 8044 times.
✗ Branch 18 → 65 not taken.
✓ Branch 19 → 20 taken 8044 times.
✗ Branch 19 → 65 not taken.
✓ Branch 20 → 21 taken 8044 times.
✗ Branch 20 → 63 not taken.
|
8044 | fctDefNode->qualifierLst = std::any_cast<QualifierLstNode *>(visit(ctx->qualifierLst())); |
| 83 |
3/6✓ Branch 23 → 24 taken 8243 times.
✗ Branch 23 → 68 not taken.
✓ Branch 24 → 25 taken 8243 times.
✗ Branch 24 → 68 not taken.
✓ Branch 25 → 26 taken 8243 times.
✗ Branch 25 → 66 not taken.
|
8243 | fctDefNode->returnType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 84 | 8243 | fctDefNode->returnType->isReturnType = true; | |
| 85 |
3/6✓ Branch 27 → 28 taken 8243 times.
✗ Branch 27 → 71 not taken.
✓ Branch 28 → 29 taken 8243 times.
✗ Branch 28 → 71 not taken.
✓ Branch 29 → 30 taken 8243 times.
✗ Branch 29 → 69 not taken.
|
8243 | fctDefNode->name = std::any_cast<FctNameNode *>(visit(ctx->fctName())); |
| 86 | 8243 | fctDefNode->isMethod = fctDefNode->name->nameFragments.size() > 1; | |
| 87 |
2/2✓ Branch 33 → 34 taken 1112 times.
✓ Branch 33 → 39 taken 7131 times.
|
8243 | if (ctx->typeLst()) { |
| 88 | 1112 | fctDefNode->hasTemplateTypes = true; | |
| 89 |
3/6✓ Branch 34 → 35 taken 1112 times.
✗ Branch 34 → 74 not taken.
✓ Branch 35 → 36 taken 1112 times.
✗ Branch 35 → 74 not taken.
✓ Branch 36 → 37 taken 1112 times.
✗ Branch 36 → 72 not taken.
|
1112 | fctDefNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst())); |
| 90 | } | ||
| 91 |
2/2✓ Branch 40 → 41 taken 6348 times.
✓ Branch 40 → 46 taken 1895 times.
|
8243 | if (ctx->paramLst()) { |
| 92 | 6348 | fctDefNode->hasParams = true; | |
| 93 |
3/6✓ Branch 41 → 42 taken 6348 times.
✗ Branch 41 → 77 not taken.
✓ Branch 42 → 43 taken 6348 times.
✗ Branch 42 → 77 not taken.
✓ Branch 43 → 44 taken 6348 times.
✗ Branch 43 → 75 not taken.
|
6348 | fctDefNode->paramLst = std::any_cast<ParamLstNode *>(visit(ctx->paramLst())); |
| 94 | } | ||
| 95 |
3/6✓ Branch 46 → 47 taken 8243 times.
✗ Branch 46 → 80 not taken.
✓ Branch 47 → 48 taken 8243 times.
✗ Branch 47 → 80 not taken.
✓ Branch 48 → 49 taken 8243 times.
✗ Branch 48 → 78 not taken.
|
8243 | fctDefNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 96 | |||
| 97 |
1/2✓ Branch 56 → 57 taken 8243 times.
✗ Branch 56 → 81 not taken.
|
8243 | return concludeNode(fctDefNode); |
| 98 | } | ||
| 99 | |||
| 100 | 4270 | std::any ASTBuilder::visitProcedureDef(SpiceParser::ProcedureDefContext *ctx) { | |
| 101 | 4270 | const auto procDefNode = createNode<ProcDefNode>(ctx); | |
| 102 | |||
| 103 | // Visit children | ||
| 104 |
2/2✓ Branch 4 → 5 taken 1 time.
✓ Branch 4 → 16 taken 4269 times.
|
4270 | if (ctx->topLevelDefAttr()) { |
| 105 |
3/6✓ Branch 5 → 6 taken 1 time.
✗ Branch 5 → 58 not taken.
✓ Branch 6 → 7 taken 1 time.
✗ Branch 6 → 58 not taken.
✓ Branch 7 → 8 taken 1 time.
✗ Branch 7 → 56 not taken.
|
1 | procDefNode->attrs = std::any_cast<TopLevelDefinitionAttrNode *>(visit(ctx->topLevelDefAttr())); |
| 106 | // Tell the attributes that they are function attributes | ||
| 107 |
2/2✓ Branch 14 → 11 taken 1 time.
✓ Branch 14 → 15 taken 1 time.
|
2 | for (AttrNode *attr : procDefNode->attrs->attrLst->attributes) |
| 108 | 1 | attr->target = AttrNode::TARGET_FCT_PROC; | |
| 109 | } | ||
| 110 |
2/2✓ Branch 17 → 18 taken 3698 times.
✓ Branch 17 → 23 taken 572 times.
|
4270 | if (ctx->qualifierLst()) |
| 111 |
3/6✓ Branch 18 → 19 taken 3698 times.
✗ Branch 18 → 61 not taken.
✓ Branch 19 → 20 taken 3698 times.
✗ Branch 19 → 61 not taken.
✓ Branch 20 → 21 taken 3698 times.
✗ Branch 20 → 59 not taken.
|
3698 | procDefNode->qualifierLst = std::any_cast<QualifierLstNode *>(visit(ctx->qualifierLst())); |
| 112 |
3/6✓ Branch 23 → 24 taken 4270 times.
✗ Branch 23 → 64 not taken.
✓ Branch 24 → 25 taken 4270 times.
✗ Branch 24 → 64 not taken.
✓ Branch 25 → 26 taken 4270 times.
✗ Branch 25 → 62 not taken.
|
4270 | procDefNode->name = std::any_cast<FctNameNode *>(visit(ctx->fctName())); |
| 113 | 4270 | procDefNode->isMethod = procDefNode->name->nameFragments.size() > 1; | |
| 114 |
2/2✓ Branch 29 → 30 taken 1194 times.
✓ Branch 29 → 35 taken 3076 times.
|
4270 | if (ctx->typeLst()) { |
| 115 | 1194 | procDefNode->hasTemplateTypes = true; | |
| 116 |
3/6✓ Branch 30 → 31 taken 1194 times.
✗ Branch 30 → 67 not taken.
✓ Branch 31 → 32 taken 1194 times.
✗ Branch 31 → 67 not taken.
✓ Branch 32 → 33 taken 1194 times.
✗ Branch 32 → 65 not taken.
|
1194 | procDefNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst())); |
| 117 | } | ||
| 118 |
2/2✓ Branch 36 → 37 taken 3158 times.
✓ Branch 36 → 42 taken 1112 times.
|
4270 | if (ctx->paramLst()) { |
| 119 | 3158 | procDefNode->hasParams = true; | |
| 120 |
3/6✓ Branch 37 → 38 taken 3158 times.
✗ Branch 37 → 70 not taken.
✓ Branch 38 → 39 taken 3158 times.
✗ Branch 38 → 70 not taken.
✓ Branch 39 → 40 taken 3158 times.
✗ Branch 39 → 68 not taken.
|
3158 | procDefNode->paramLst = std::any_cast<ParamLstNode *>(visit(ctx->paramLst())); |
| 121 | } | ||
| 122 |
3/6✓ Branch 42 → 43 taken 4270 times.
✗ Branch 42 → 73 not taken.
✓ Branch 43 → 44 taken 4270 times.
✗ Branch 43 → 73 not taken.
✓ Branch 44 → 45 taken 4270 times.
✗ Branch 44 → 71 not taken.
|
4270 | procDefNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 123 | |||
| 124 |
1/2✓ Branch 52 → 53 taken 4270 times.
✗ Branch 52 → 74 not taken.
|
4270 | return concludeNode(procDefNode); |
| 125 | } | ||
| 126 | |||
| 127 | 12513 | std::any ASTBuilder::visitFctName(SpiceParser::FctNameContext *ctx) { | |
| 128 | 12513 | const auto fctNameNode = createNode<FctNameNode>(ctx); | |
| 129 | |||
| 130 | // Extract function name | ||
| 131 |
2/2✓ Branch 4 → 5 taken 6823 times.
✓ Branch 4 → 14 taken 5690 times.
|
12513 | if (ctx->TYPE_IDENTIFIER()) { |
| 132 |
2/4✓ Branch 5 → 6 taken 6823 times.
✗ Branch 5 → 42 not taken.
✓ Branch 6 → 7 taken 6823 times.
✗ Branch 6 → 42 not taken.
|
6823 | const std::string typeIdentifier = getIdentifier(ctx->TYPE_IDENTIFIER(), true); |
| 133 |
1/2✓ Branch 7 → 8 taken 6823 times.
✗ Branch 7 → 40 not taken.
|
6823 | fctNameNode->structName = typeIdentifier; |
| 134 |
1/2✓ Branch 8 → 9 taken 6823 times.
✗ Branch 8 → 39 not taken.
|
6823 | fctNameNode->fqName = typeIdentifier + MEMBER_ACCESS_TOKEN; |
| 135 |
1/2✓ Branch 11 → 12 taken 6823 times.
✗ Branch 11 → 40 not taken.
|
6823 | fctNameNode->nameFragments.push_back(typeIdentifier); |
| 136 | 6823 | } | |
| 137 |
2/2✓ Branch 15 → 16 taken 10670 times.
✓ Branch 15 → 23 taken 1843 times.
|
12513 | if (ctx->IDENTIFIER()) { |
| 138 |
2/4✓ Branch 16 → 17 taken 10670 times.
✗ Branch 16 → 45 not taken.
✓ Branch 17 → 18 taken 10670 times.
✗ Branch 17 → 45 not taken.
|
10670 | const std::string fctIdentifier = getIdentifier(ctx->IDENTIFIER(), false); |
| 139 |
1/2✓ Branch 18 → 19 taken 10670 times.
✗ Branch 18 → 43 not taken.
|
10670 | fctNameNode->name = fctIdentifier; |
| 140 |
1/2✓ Branch 19 → 20 taken 10670 times.
✗ Branch 19 → 43 not taken.
|
10670 | fctNameNode->fqName += fctIdentifier; |
| 141 |
1/2✓ Branch 20 → 21 taken 10670 times.
✗ Branch 20 → 43 not taken.
|
10670 | fctNameNode->nameFragments.push_back(fctIdentifier); |
| 142 | 10670 | } | |
| 143 | |||
| 144 | // Visit children | ||
| 145 |
2/2✓ Branch 24 → 25 taken 1843 times.
✓ Branch 24 → 29 taken 10670 times.
|
12513 | if (ctx->overloadableOp()) |
| 146 |
2/4✓ Branch 25 → 26 taken 1843 times.
✗ Branch 25 → 46 not taken.
✓ Branch 26 → 27 taken 1843 times.
✗ Branch 26 → 46 not taken.
|
1843 | visit(ctx->overloadableOp()); |
| 147 | |||
| 148 |
1/2✓ Branch 35 → 36 taken 12513 times.
✗ Branch 35 → 47 not taken.
|
12513 | return concludeNode(fctNameNode); |
| 149 | } | ||
| 150 | |||
| 151 | 740 | std::any ASTBuilder::visitStructDef(SpiceParser::StructDefContext *ctx) { | |
| 152 | 740 | const auto structDefNode = createNode<StructDefNode>(ctx); | |
| 153 | |||
| 154 | // Enrich | ||
| 155 |
3/4✓ Branch 3 → 4 taken 740 times.
✗ Branch 3 → 87 not taken.
✓ Branch 4 → 5 taken 739 times.
✓ Branch 4 → 87 taken 1 time.
|
740 | structDefNode->structName = getIdentifier(ctx->TYPE_IDENTIFIER(), true); |
| 156 | 739 | structDefNode->typeId = resourceManager.getNextCustomTypeId(); | |
| 157 | |||
| 158 | // Visit children | ||
| 159 |
2/2✓ Branch 9 → 10 taken 65 times.
✓ Branch 9 → 41 taken 674 times.
|
739 | if (ctx->topLevelDefAttr()) { |
| 160 |
3/6✓ Branch 10 → 11 taken 65 times.
✗ Branch 10 → 90 not taken.
✓ Branch 11 → 12 taken 65 times.
✗ Branch 11 → 90 not taken.
✓ Branch 12 → 13 taken 65 times.
✗ Branch 12 → 88 not taken.
|
65 | structDefNode->attrs = std::any_cast<TopLevelDefinitionAttrNode *>(visit(ctx->topLevelDefAttr())); |
| 161 | |||
| 162 | // Tell the attributes that they are struct attributes | ||
| 163 |
2/2✓ Branch 19 → 16 taken 65 times.
✓ Branch 19 → 20 taken 65 times.
|
130 | for (AttrNode *attr : structDefNode->attrs->attrLst->attributes) |
| 164 | 65 | attr->target = AttrNode::TARGET_STRUCT; | |
| 165 | |||
| 166 | // Check if a custom type id was set | ||
| 167 |
7/18✓ Branch 20 → 21 taken 65 times.
✗ Branch 20 → 27 not taken.
✓ Branch 23 → 24 taken 65 times.
✗ Branch 23 → 91 not taken.
✓ Branch 24 → 25 taken 65 times.
✗ Branch 24 → 91 not taken.
✗ Branch 25 → 26 not taken.
✓ Branch 25 → 27 taken 65 times.
✓ Branch 28 → 29 taken 65 times.
✗ Branch 28 → 30 not taken.
✓ Branch 30 → 31 taken 65 times.
✗ Branch 30 → 33 not taken.
✗ Branch 33 → 34 not taken.
✓ Branch 33 → 41 taken 65 times.
✗ Branch 91 → 92 not taken.
✗ Branch 91 → 93 not taken.
✗ Branch 95 → 96 not taken.
✗ Branch 95 → 98 not taken.
|
195 | if (structDefNode->attrs && structDefNode->attrs->attrLst->hasAttr(ATTR_CORE_COMPILER_FIXED_TYPE_ID)) |
| 168 | ✗ | structDefNode->typeId = structDefNode->attrs->attrLst->getAttrValueByName(ATTR_CORE_COMPILER_FIXED_TYPE_ID)->intValue; | |
| 169 | } | ||
| 170 |
2/2✓ Branch 42 → 43 taken 575 times.
✓ Branch 42 → 48 taken 164 times.
|
739 | if (ctx->qualifierLst()) |
| 171 |
3/6✓ Branch 43 → 44 taken 575 times.
✗ Branch 43 → 108 not taken.
✓ Branch 44 → 45 taken 575 times.
✗ Branch 44 → 108 not taken.
✓ Branch 45 → 46 taken 575 times.
✗ Branch 45 → 106 not taken.
|
575 | structDefNode->qualifierLst = std::any_cast<QualifierLstNode *>(visit(ctx->qualifierLst())); |
| 172 |
2/2✓ Branch 49 → 50 taken 261 times.
✓ Branch 49 → 55 taken 478 times.
|
739 | if (ctx->LESS()) { |
| 173 | 261 | structDefNode->hasTemplateTypes = true; | |
| 174 |
3/6✓ Branch 50 → 51 taken 261 times.
✗ Branch 50 → 111 not taken.
✓ Branch 51 → 52 taken 261 times.
✗ Branch 51 → 111 not taken.
✓ Branch 52 → 53 taken 261 times.
✗ Branch 52 → 109 not taken.
|
261 | structDefNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst(0))); |
| 175 | } | ||
| 176 |
2/2✓ Branch 56 → 57 taken 143 times.
✓ Branch 56 → 65 taken 596 times.
|
739 | if (ctx->COLON()) { |
| 177 | 143 | structDefNode->hasInterfaces = true; | |
| 178 |
5/8✓ Branch 57 → 58 taken 121 times.
✓ Branch 57 → 59 taken 22 times.
✓ Branch 60 → 61 taken 143 times.
✗ Branch 60 → 114 not taken.
✓ Branch 61 → 62 taken 143 times.
✗ Branch 61 → 114 not taken.
✓ Branch 62 → 63 taken 143 times.
✗ Branch 62 → 112 not taken.
|
143 | structDefNode->interfaceTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst(structDefNode->hasTemplateTypes ? 1 : 0))); |
| 179 | } | ||
| 180 |
3/4✓ Branch 65 → 66 taken 739 times.
✗ Branch 65 → 121 not taken.
✓ Branch 75 → 68 taken 1575 times.
✓ Branch 75 → 76 taken 739 times.
|
2314 | for (SpiceParser::FieldContext *field : ctx->field()) |
| 181 |
3/6✓ Branch 69 → 70 taken 1575 times.
✗ Branch 69 → 117 not taken.
✓ Branch 70 → 71 taken 1575 times.
✗ Branch 70 → 115 not taken.
✓ Branch 71 → 72 taken 1575 times.
✗ Branch 71 → 115 not taken.
|
2314 | structDefNode->fields.push_back(std::any_cast<FieldNode *>(visit(field))); |
| 182 | |||
| 183 |
1/2✓ Branch 83 → 84 taken 739 times.
✗ Branch 83 → 122 not taken.
|
739 | return concludeNode(structDefNode); |
| 184 | } | ||
| 185 | |||
| 186 | 108 | std::any ASTBuilder::visitInterfaceDef(SpiceParser::InterfaceDefContext *ctx) { | |
| 187 | 108 | const auto interfaceDefNode = createNode<InterfaceDefNode>(ctx); | |
| 188 | |||
| 189 | // Enrich | ||
| 190 |
2/4✓ Branch 3 → 4 taken 108 times.
✗ Branch 3 → 77 not taken.
✓ Branch 4 → 5 taken 108 times.
✗ Branch 4 → 77 not taken.
|
108 | interfaceDefNode->interfaceName = getIdentifier(ctx->TYPE_IDENTIFIER(), true); |
| 191 | 108 | interfaceDefNode->typeId = resourceManager.getNextCustomTypeId(); | |
| 192 | |||
| 193 | // Visit children | ||
| 194 |
2/2✓ Branch 9 → 10 taken 79 times.
✓ Branch 9 → 41 taken 29 times.
|
108 | if (ctx->topLevelDefAttr()) { |
| 195 |
3/6✓ Branch 10 → 11 taken 79 times.
✗ Branch 10 → 80 not taken.
✓ Branch 11 → 12 taken 79 times.
✗ Branch 11 → 80 not taken.
✓ Branch 12 → 13 taken 79 times.
✗ Branch 12 → 78 not taken.
|
79 | interfaceDefNode->attrs = std::any_cast<TopLevelDefinitionAttrNode *>(visit(ctx->topLevelDefAttr())); |
| 196 | |||
| 197 | // Tell the attributes that they are struct attributes | ||
| 198 |
2/2✓ Branch 19 → 16 taken 79 times.
✓ Branch 19 → 20 taken 79 times.
|
158 | for (AttrNode *attr : interfaceDefNode->attrs->attrLst->attributes) |
| 199 | 79 | attr->target = AttrNode::TARGET_INTERFACE; | |
| 200 | |||
| 201 | // Check if a custom type id was set | ||
| 202 |
7/18✓ Branch 20 → 21 taken 79 times.
✗ Branch 20 → 27 not taken.
✓ Branch 23 → 24 taken 79 times.
✗ Branch 23 → 81 not taken.
✓ Branch 24 → 25 taken 79 times.
✗ Branch 24 → 81 not taken.
✓ Branch 25 → 26 taken 79 times.
✗ Branch 25 → 27 not taken.
✓ Branch 28 → 29 taken 79 times.
✗ Branch 28 → 30 not taken.
✓ Branch 30 → 31 taken 79 times.
✗ Branch 30 → 33 not taken.
✓ Branch 33 → 34 taken 79 times.
✗ Branch 33 → 41 not taken.
✗ Branch 81 → 82 not taken.
✗ Branch 81 → 83 not taken.
✗ Branch 85 → 86 not taken.
✗ Branch 85 → 88 not taken.
|
237 | if (interfaceDefNode->attrs && interfaceDefNode->attrs->attrLst->hasAttr(ATTR_CORE_COMPILER_FIXED_TYPE_ID)) |
| 203 |
2/4✓ Branch 36 → 37 taken 79 times.
✗ Branch 36 → 92 not taken.
✓ Branch 37 → 38 taken 79 times.
✗ Branch 37 → 90 not taken.
|
237 | interfaceDefNode->typeId = interfaceDefNode->attrs->attrLst->getAttrValueByName(ATTR_CORE_COMPILER_FIXED_TYPE_ID)->intValue; |
| 204 | } | ||
| 205 |
2/2✓ Branch 42 → 43 taken 91 times.
✓ Branch 42 → 48 taken 17 times.
|
108 | if (ctx->qualifierLst()) |
| 206 |
3/6✓ Branch 43 → 44 taken 91 times.
✗ Branch 43 → 98 not taken.
✓ Branch 44 → 45 taken 91 times.
✗ Branch 44 → 98 not taken.
✓ Branch 45 → 46 taken 91 times.
✗ Branch 45 → 96 not taken.
|
91 | interfaceDefNode->qualifierLst = std::any_cast<QualifierLstNode *>(visit(ctx->qualifierLst())); |
| 207 |
2/2✓ Branch 49 → 50 taken 82 times.
✓ Branch 49 → 55 taken 26 times.
|
108 | if (ctx->LESS()) { |
| 208 | 82 | interfaceDefNode->hasTemplateTypes = true; | |
| 209 |
3/6✓ Branch 50 → 51 taken 82 times.
✗ Branch 50 → 101 not taken.
✓ Branch 51 → 52 taken 82 times.
✗ Branch 51 → 101 not taken.
✓ Branch 52 → 53 taken 82 times.
✗ Branch 52 → 99 not taken.
|
82 | interfaceDefNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst())); |
| 210 | } | ||
| 211 |
3/4✓ Branch 55 → 56 taken 108 times.
✗ Branch 55 → 108 not taken.
✓ Branch 65 → 58 taken 247 times.
✓ Branch 65 → 66 taken 108 times.
|
355 | for (SpiceParser::SignatureContext *signature : ctx->signature()) |
| 212 |
3/6✓ Branch 59 → 60 taken 247 times.
✗ Branch 59 → 104 not taken.
✓ Branch 60 → 61 taken 247 times.
✗ Branch 60 → 102 not taken.
✓ Branch 61 → 62 taken 247 times.
✗ Branch 61 → 102 not taken.
|
355 | interfaceDefNode->signatures.push_back(std::any_cast<SignatureNode *>(visit(signature))); |
| 213 | |||
| 214 |
1/2✓ Branch 73 → 74 taken 108 times.
✗ Branch 73 → 109 not taken.
|
108 | return concludeNode(interfaceDefNode); |
| 215 | } | ||
| 216 | |||
| 217 | 68 | std::any ASTBuilder::visitEnumDef(SpiceParser::EnumDefContext *ctx) { | |
| 218 | 68 | const auto enumDefNode = createNode<EnumDefNode>(ctx); | |
| 219 | |||
| 220 | // Enrich | ||
| 221 |
2/4✓ Branch 3 → 4 taken 68 times.
✗ Branch 3 → 35 not taken.
✓ Branch 4 → 5 taken 68 times.
✗ Branch 4 → 35 not taken.
|
68 | enumDefNode->enumName = getIdentifier(ctx->TYPE_IDENTIFIER(), true); |
| 222 | 68 | enumDefNode->typeId = resourceManager.getNextCustomTypeId(); | |
| 223 | |||
| 224 | // Visit children | ||
| 225 |
2/2✓ Branch 9 → 10 taken 52 times.
✓ Branch 9 → 15 taken 16 times.
|
68 | if (ctx->qualifierLst()) |
| 226 |
3/6✓ Branch 10 → 11 taken 52 times.
✗ Branch 10 → 38 not taken.
✓ Branch 11 → 12 taken 52 times.
✗ Branch 11 → 38 not taken.
✓ Branch 12 → 13 taken 52 times.
✗ Branch 12 → 36 not taken.
|
52 | enumDefNode->qualifierLst = std::any_cast<QualifierLstNode *>(visit(ctx->qualifierLst())); |
| 227 |
3/6✓ Branch 15 → 16 taken 68 times.
✗ Branch 15 → 41 not taken.
✓ Branch 16 → 17 taken 68 times.
✗ Branch 16 → 41 not taken.
✓ Branch 17 → 18 taken 68 times.
✗ Branch 17 → 39 not taken.
|
68 | enumDefNode->itemLst = std::any_cast<EnumItemLstNode *>(visit(ctx->enumItemLst())); |
| 228 | |||
| 229 | // Tell all items about the enum def | ||
| 230 |
2/2✓ Branch 24 → 21 taken 739 times.
✓ Branch 24 → 25 taken 68 times.
|
807 | for (EnumItemNode *enumItem : enumDefNode->itemLst->items) |
| 231 | 739 | enumItem->enumDef = enumDefNode; | |
| 232 | |||
| 233 |
1/2✓ Branch 31 → 32 taken 68 times.
✗ Branch 31 → 42 not taken.
|
68 | return concludeNode(enumDefNode); |
| 234 | } | ||
| 235 | |||
| 236 | 999 | std::any ASTBuilder::visitGenericTypeDef(SpiceParser::GenericTypeDefContext *ctx) { | |
| 237 | 999 | const auto genericTypeDefNode = createNode<GenericTypeDefNode>(ctx); | |
| 238 | |||
| 239 | // Enrich | ||
| 240 |
2/4✓ Branch 3 → 4 taken 999 times.
✗ Branch 3 → 21 not taken.
✓ Branch 4 → 5 taken 999 times.
✗ Branch 4 → 21 not taken.
|
999 | genericTypeDefNode->typeName = getIdentifier(ctx->TYPE_IDENTIFIER(), true); |
| 241 | |||
| 242 | // Visit children | ||
| 243 |
3/6✓ Branch 7 → 8 taken 999 times.
✗ Branch 7 → 24 not taken.
✓ Branch 8 → 9 taken 999 times.
✗ Branch 8 → 24 not taken.
✓ Branch 9 → 10 taken 999 times.
✗ Branch 9 → 22 not taken.
|
999 | genericTypeDefNode->typeAltsLst = std::any_cast<TypeAltsLstNode *>(visit(ctx->typeAltsLst())); |
| 244 | |||
| 245 |
1/2✓ Branch 17 → 18 taken 999 times.
✗ Branch 17 → 25 not taken.
|
999 | return concludeNode(genericTypeDefNode); |
| 246 | } | ||
| 247 | |||
| 248 | 71 | std::any ASTBuilder::visitAliasDef(SpiceParser::AliasDefContext *ctx) { | |
| 249 | 71 | const auto aliasDefNode = createNode<AliasDefNode>(ctx); | |
| 250 | |||
| 251 | // Enrich | ||
| 252 |
2/4✓ Branch 3 → 4 taken 71 times.
✗ Branch 3 → 33 not taken.
✓ Branch 4 → 5 taken 71 times.
✗ Branch 4 → 33 not taken.
|
71 | aliasDefNode->aliasName = getIdentifier(ctx->TYPE_IDENTIFIER(), true); |
| 253 |
2/4✓ Branch 7 → 8 taken 71 times.
✗ Branch 7 → 34 not taken.
✓ Branch 8 → 9 taken 71 times.
✗ Branch 8 → 34 not taken.
|
71 | aliasDefNode->dataTypeString = ctx->dataType()->getText(); |
| 254 | 71 | aliasDefNode->typeId = resourceManager.getNextCustomTypeId(); | |
| 255 | |||
| 256 | // Visit children | ||
| 257 |
2/2✓ Branch 13 → 14 taken 21 times.
✓ Branch 13 → 19 taken 50 times.
|
71 | if (ctx->qualifierLst()) |
| 258 |
3/6✓ Branch 14 → 15 taken 21 times.
✗ Branch 14 → 37 not taken.
✓ Branch 15 → 16 taken 21 times.
✗ Branch 15 → 37 not taken.
✓ Branch 16 → 17 taken 21 times.
✗ Branch 16 → 35 not taken.
|
21 | aliasDefNode->qualifierLst = std::any_cast<QualifierLstNode *>(visit(ctx->qualifierLst())); |
| 259 |
3/6✓ Branch 19 → 20 taken 71 times.
✗ Branch 19 → 40 not taken.
✓ Branch 20 → 21 taken 71 times.
✗ Branch 20 → 40 not taken.
✓ Branch 21 → 22 taken 71 times.
✗ Branch 21 → 38 not taken.
|
71 | aliasDefNode->dataType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 260 | |||
| 261 |
1/2✓ Branch 29 → 30 taken 71 times.
✗ Branch 29 → 41 not taken.
|
71 | return concludeNode(aliasDefNode); |
| 262 | } | ||
| 263 | |||
| 264 | 1201 | std::any ASTBuilder::visitGlobalVarDef(SpiceParser::GlobalVarDefContext *ctx) { | |
| 265 | 1201 | const auto globalVarDefNode = createNode<GlobalVarDefNode>(ctx); | |
| 266 | |||
| 267 | // Enrich | ||
| 268 |
2/4✓ Branch 3 → 4 taken 1201 times.
✗ Branch 3 → 28 not taken.
✓ Branch 4 → 5 taken 1201 times.
✗ Branch 4 → 28 not taken.
|
1201 | globalVarDefNode->varName = getIdentifier(ctx->TYPE_IDENTIFIER(), true); |
| 269 | |||
| 270 | // Visit children | ||
| 271 |
3/6✓ Branch 7 → 8 taken 1201 times.
✗ Branch 7 → 31 not taken.
✓ Branch 8 → 9 taken 1201 times.
✗ Branch 8 → 31 not taken.
✓ Branch 9 → 10 taken 1201 times.
✗ Branch 9 → 29 not taken.
|
1201 | globalVarDefNode->dataType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 272 | 1201 | globalVarDefNode->dataType->isGlobalType = true; | |
| 273 |
2/2✓ Branch 12 → 13 taken 1199 times.
✓ Branch 12 → 18 taken 2 times.
|
1201 | if (ctx->constant()) { |
| 274 | 1199 | globalVarDefNode->hasValue = true; | |
| 275 |
3/6✓ Branch 13 → 14 taken 1199 times.
✗ Branch 13 → 34 not taken.
✓ Branch 14 → 15 taken 1199 times.
✗ Branch 14 → 34 not taken.
✓ Branch 15 → 16 taken 1199 times.
✗ Branch 15 → 32 not taken.
|
1199 | globalVarDefNode->constant = std::any_cast<ConstantNode *>(visit(ctx->constant())); |
| 276 | } | ||
| 277 | |||
| 278 |
1/2✓ Branch 24 → 25 taken 1201 times.
✗ Branch 24 → 35 not taken.
|
1201 | return concludeNode(globalVarDefNode); |
| 279 | } | ||
| 280 | |||
| 281 | 1040 | std::any ASTBuilder::visitExtDecl(SpiceParser::ExtDeclContext *ctx) { | |
| 282 | 1040 | const auto extDeclNode = createNode<ExtDeclNode>(ctx); | |
| 283 | |||
| 284 | // Enrich | ||
| 285 |
6/10✓ Branch 3 → 4 taken 1040 times.
✗ Branch 3 → 49 not taken.
✓ Branch 4 → 5 taken 788 times.
✓ Branch 4 → 7 taken 252 times.
✓ Branch 5 → 6 taken 788 times.
✗ Branch 5 → 49 not taken.
✓ Branch 7 → 8 taken 252 times.
✗ Branch 7 → 49 not taken.
✓ Branch 9 → 10 taken 1040 times.
✗ Branch 9 → 49 not taken.
|
1040 | extDeclNode->extFunctionName = getIdentifier(ctx->IDENTIFIER() ? ctx->IDENTIFIER() : ctx->TYPE_IDENTIFIER(), false); |
| 286 | |||
| 287 | // Visit children | ||
| 288 |
2/2✓ Branch 13 → 14 taken 1 time.
✓ Branch 13 → 25 taken 1039 times.
|
1040 | if (ctx->topLevelDefAttr()) { |
| 289 |
3/6✓ Branch 14 → 15 taken 1 time.
✗ Branch 14 → 52 not taken.
✓ Branch 15 → 16 taken 1 time.
✗ Branch 15 → 52 not taken.
✓ Branch 16 → 17 taken 1 time.
✗ Branch 16 → 50 not taken.
|
1 | extDeclNode->attrs = std::any_cast<TopLevelDefinitionAttrNode *>(visit(ctx->topLevelDefAttr())); |
| 290 | |||
| 291 | // Tell the attributes that they are ext decl attributes | ||
| 292 |
2/2✓ Branch 23 → 20 taken 1 time.
✓ Branch 23 → 24 taken 1 time.
|
2 | for (AttrNode *attr : extDeclNode->attrs->attrLst->attributes) |
| 293 | 1 | attr->target = AttrNode::TARGET_EXT_DECL; | |
| 294 | } | ||
| 295 |
2/2✓ Branch 26 → 27 taken 680 times.
✓ Branch 26 → 32 taken 360 times.
|
1040 | if (ctx->F()) { |
| 296 |
3/6✓ Branch 27 → 28 taken 680 times.
✗ Branch 27 → 55 not taken.
✓ Branch 28 → 29 taken 680 times.
✗ Branch 28 → 55 not taken.
✓ Branch 29 → 30 taken 680 times.
✗ Branch 29 → 53 not taken.
|
680 | extDeclNode->returnType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 297 | 680 | extDeclNode->returnType->isReturnType = true; | |
| 298 | } | ||
| 299 |
2/2✓ Branch 33 → 34 taken 998 times.
✓ Branch 33 → 39 taken 42 times.
|
1040 | if (ctx->typeLstWithEllipsis()) { |
| 300 | 998 | extDeclNode->hasArgs = true; | |
| 301 |
3/6✓ Branch 34 → 35 taken 998 times.
✗ Branch 34 → 58 not taken.
✓ Branch 35 → 36 taken 998 times.
✗ Branch 35 → 58 not taken.
✓ Branch 36 → 37 taken 998 times.
✗ Branch 36 → 56 not taken.
|
998 | extDeclNode->argTypeLst = std::any_cast<TypeLstWithEllipsisNode *>(visit(ctx->typeLstWithEllipsis())); |
| 302 | } | ||
| 303 | |||
| 304 |
1/2✓ Branch 45 → 46 taken 1040 times.
✗ Branch 45 → 59 not taken.
|
1040 | return concludeNode(extDeclNode); |
| 305 | } | ||
| 306 | |||
| 307 | 654 | std::any ASTBuilder::visitImportDef(SpiceParser::ImportDefContext *ctx) { | |
| 308 |
1/2✓ Branch 2 → 3 taken 654 times.
✗ Branch 2 → 32 not taken.
|
654 | const auto importDefNode = createNode<ImportDefNode>(ctx); |
| 309 | |||
| 310 | // Extract path | ||
| 311 |
2/4✓ Branch 3 → 4 taken 654 times.
✗ Branch 3 → 32 not taken.
✓ Branch 4 → 5 taken 654 times.
✗ Branch 4 → 32 not taken.
|
654 | const std::string pathStr = ctx->STRING_LIT()->getText(); |
| 312 |
1/2✓ Branch 6 → 7 taken 654 times.
✗ Branch 6 → 27 not taken.
|
654 | importDefNode->importPath = pathStr.substr(1, pathStr.size() - 2); |
| 313 | |||
| 314 | // If no name is given, use the path as name | ||
| 315 |
6/10✓ Branch 9 → 10 taken 654 times.
✗ Branch 9 → 28 not taken.
✓ Branch 10 → 11 taken 33 times.
✓ Branch 10 → 13 taken 621 times.
✓ Branch 11 → 12 taken 33 times.
✗ Branch 11 → 28 not taken.
✓ Branch 12 → 14 taken 33 times.
✗ Branch 12 → 28 not taken.
✓ Branch 13 → 14 taken 621 times.
✗ Branch 13 → 28 not taken.
|
654 | importDefNode->importName = ctx->AS() ? getIdentifier(ctx->IDENTIFIER(), false) : importDefNode->importPath; |
| 316 | |||
| 317 |
1/2✓ Branch 22 → 23 taken 654 times.
✗ Branch 22 → 29 not taken.
|
1308 | return concludeNode(importDefNode); |
| 318 | 654 | } | |
| 319 | |||
| 320 | 2711 | std::any ASTBuilder::visitUnsafeBlock(SpiceParser::UnsafeBlockContext *ctx) { | |
| 321 | 2711 | const auto unsafeBlockDefNode = createNode<UnsafeBlockNode>(ctx); | |
| 322 | |||
| 323 | // Visit children | ||
| 324 |
3/6✓ Branch 3 → 4 taken 2711 times.
✗ Branch 3 → 19 not taken.
✓ Branch 4 → 5 taken 2711 times.
✗ Branch 4 → 19 not taken.
✓ Branch 5 → 6 taken 2711 times.
✗ Branch 5 → 17 not taken.
|
2711 | unsafeBlockDefNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 325 | |||
| 326 |
1/2✓ Branch 13 → 14 taken 2711 times.
✗ Branch 13 → 20 not taken.
|
2711 | return concludeNode(unsafeBlockDefNode); |
| 327 | } | ||
| 328 | |||
| 329 | 1450 | std::any ASTBuilder::visitForLoop(SpiceParser::ForLoopContext *ctx) { | |
| 330 | 1450 | const auto forLoopNode = createNode<ForLoopNode>(ctx); | |
| 331 | |||
| 332 |
2/4✓ Branch 3 → 4 taken 1450 times.
✗ Branch 3 → 20 not taken.
✓ Branch 4 → 5 taken 1450 times.
✗ Branch 4 → 20 not taken.
|
1450 | visit(ctx->forHead()); |
| 333 |
3/6✓ Branch 6 → 7 taken 1450 times.
✗ Branch 6 → 23 not taken.
✓ Branch 7 → 8 taken 1450 times.
✗ Branch 7 → 23 not taken.
✓ Branch 8 → 9 taken 1450 times.
✗ Branch 8 → 21 not taken.
|
1450 | forLoopNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 334 | |||
| 335 |
1/2✓ Branch 16 → 17 taken 1450 times.
✗ Branch 16 → 24 not taken.
|
1450 | return concludeNode(forLoopNode); |
| 336 | } | ||
| 337 | |||
| 338 | 1450 | std::any ASTBuilder::visitForHead(SpiceParser::ForHeadContext *ctx) { | |
| 339 | 1450 | const auto forLoopNode = resumeForExpansion<ForLoopNode>(); | |
| 340 | |||
| 341 | // Visit children | ||
| 342 |
3/6✓ Branch 12 → 13 taken 1450 times.
✗ Branch 12 → 29 not taken.
✓ Branch 13 → 14 taken 1450 times.
✗ Branch 13 → 29 not taken.
✓ Branch 14 → 15 taken 1450 times.
✗ Branch 14 → 27 not taken.
|
1450 | forLoopNode->initDecl = std::any_cast<DeclStmtNode *>(visit(ctx->declStmt())); |
| 343 |
3/6✓ Branch 16 → 17 taken 1450 times.
✗ Branch 16 → 32 not taken.
✓ Branch 17 → 18 taken 1450 times.
✗ Branch 17 → 32 not taken.
✓ Branch 18 → 19 taken 1450 times.
✗ Branch 18 → 30 not taken.
|
1450 | forLoopNode->condAssign = std::any_cast<AssignExprNode *>(visit(ctx->assignExpr(0))); |
| 344 |
3/6✓ Branch 20 → 21 taken 1450 times.
✗ Branch 20 → 35 not taken.
✓ Branch 21 → 22 taken 1450 times.
✗ Branch 21 → 35 not taken.
✓ Branch 22 → 23 taken 1450 times.
✗ Branch 22 → 33 not taken.
|
1450 | forLoopNode->incAssign = std::any_cast<AssignExprNode *>(visit(ctx->assignExpr(1))); |
| 345 | |||
| 346 |
1/2✓ Branch 24 → 25 taken 1450 times.
✗ Branch 24 → 36 not taken.
|
1450 | return nullptr; |
| 347 | } | ||
| 348 | |||
| 349 | 125 | std::any ASTBuilder::visitForeachLoop(SpiceParser::ForeachLoopContext *ctx) { | |
| 350 | 125 | const auto foreachLoopNode = createNode<ForeachLoopNode>(ctx); | |
| 351 | |||
| 352 | // Visit children | ||
| 353 |
2/4✓ Branch 3 → 4 taken 125 times.
✗ Branch 3 → 20 not taken.
✓ Branch 4 → 5 taken 125 times.
✗ Branch 4 → 20 not taken.
|
125 | visit(ctx->foreachHead()); |
| 354 |
3/6✓ Branch 6 → 7 taken 125 times.
✗ Branch 6 → 23 not taken.
✓ Branch 7 → 8 taken 125 times.
✗ Branch 7 → 23 not taken.
✓ Branch 8 → 9 taken 125 times.
✗ Branch 8 → 21 not taken.
|
125 | foreachLoopNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 355 | |||
| 356 | // Tell the foreach item that it is one | ||
| 357 | 125 | foreachLoopNode->itemVarDecl->isForEachItem = true; | |
| 358 | |||
| 359 |
1/2✓ Branch 16 → 17 taken 125 times.
✗ Branch 16 → 24 not taken.
|
125 | return concludeNode(foreachLoopNode); |
| 360 | } | ||
| 361 | |||
| 362 | 125 | std::any ASTBuilder::visitForeachHead(SpiceParser::ForeachHeadContext *ctx) { | |
| 363 | 125 | const auto foreachLoopNode = resumeForExpansion<ForeachLoopNode>(); | |
| 364 | |||
| 365 | // Visit children | ||
| 366 |
3/4✓ Branch 12 → 13 taken 125 times.
✗ Branch 12 → 42 not taken.
✓ Branch 15 → 16 taken 119 times.
✓ Branch 15 → 21 taken 6 times.
|
125 | if (ctx->declStmt().size() == 1) { |
| 367 |
3/6✓ Branch 16 → 17 taken 119 times.
✗ Branch 16 → 45 not taken.
✓ Branch 17 → 18 taken 119 times.
✗ Branch 17 → 45 not taken.
✓ Branch 18 → 19 taken 119 times.
✗ Branch 18 → 43 not taken.
|
119 | foreachLoopNode->itemVarDecl = std::any_cast<DeclStmtNode *>(visit(ctx->declStmt(0))); |
| 368 |
2/4✓ Branch 21 → 22 taken 6 times.
✗ Branch 21 → 46 not taken.
✓ Branch 24 → 25 taken 6 times.
✗ Branch 24 → 34 not taken.
|
6 | } else if (ctx->declStmt().size() == 2) { |
| 369 |
3/6✓ Branch 25 → 26 taken 6 times.
✗ Branch 25 → 49 not taken.
✓ Branch 26 → 27 taken 6 times.
✗ Branch 26 → 49 not taken.
✓ Branch 27 → 28 taken 6 times.
✗ Branch 27 → 47 not taken.
|
6 | foreachLoopNode->idxVarDecl = std::any_cast<DeclStmtNode *>(visit(ctx->declStmt(0))); |
| 370 |
3/6✓ Branch 29 → 30 taken 6 times.
✗ Branch 29 → 52 not taken.
✓ Branch 30 → 31 taken 6 times.
✗ Branch 30 → 52 not taken.
✓ Branch 31 → 32 taken 6 times.
✗ Branch 31 → 50 not taken.
|
6 | foreachLoopNode->itemVarDecl = std::any_cast<DeclStmtNode *>(visit(ctx->declStmt(1))); |
| 371 | } else { | ||
| 372 | − | assert_fail("Invalid number of decl statements in foreach loop"); // GCOV_EXCL_LINE | |
| 373 | } | ||
| 374 |
3/6✓ Branch 35 → 36 taken 125 times.
✗ Branch 35 → 55 not taken.
✓ Branch 36 → 37 taken 125 times.
✗ Branch 36 → 55 not taken.
✓ Branch 37 → 38 taken 125 times.
✗ Branch 37 → 53 not taken.
|
125 | foreachLoopNode->iteratorAssign = std::any_cast<AssignExprNode *>(visit(ctx->assignExpr())); |
| 375 | |||
| 376 |
1/2✓ Branch 39 → 40 taken 125 times.
✗ Branch 39 → 56 not taken.
|
125 | return nullptr; |
| 377 | } | ||
| 378 | |||
| 379 | 822 | std::any ASTBuilder::visitWhileLoop(SpiceParser::WhileLoopContext *ctx) { | |
| 380 | 822 | const auto whileLoopNode = createNode<WhileLoopNode>(ctx); | |
| 381 | |||
| 382 | // Visit children | ||
| 383 |
3/6✓ Branch 3 → 4 taken 822 times.
✗ Branch 3 → 23 not taken.
✓ Branch 4 → 5 taken 822 times.
✗ Branch 4 → 23 not taken.
✓ Branch 5 → 6 taken 822 times.
✗ Branch 5 → 21 not taken.
|
822 | whileLoopNode->condition = std::any_cast<AssignExprNode *>(visit(ctx->assignExpr())); |
| 384 |
3/6✓ Branch 7 → 8 taken 822 times.
✗ Branch 7 → 26 not taken.
✓ Branch 8 → 9 taken 822 times.
✗ Branch 8 → 26 not taken.
✓ Branch 9 → 10 taken 822 times.
✗ Branch 9 → 24 not taken.
|
822 | whileLoopNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 385 | |||
| 386 |
1/2✓ Branch 17 → 18 taken 822 times.
✗ Branch 17 → 27 not taken.
|
822 | return concludeNode(whileLoopNode); |
| 387 | } | ||
| 388 | |||
| 389 | 9 | std::any ASTBuilder::visitDoWhileLoop(SpiceParser::DoWhileLoopContext *ctx) { | |
| 390 | 9 | const auto doWhileLoopNode = createNode<DoWhileLoopNode>(ctx); | |
| 391 | |||
| 392 | // Visit children | ||
| 393 |
3/6✓ Branch 3 → 4 taken 9 times.
✗ Branch 3 → 23 not taken.
✓ Branch 4 → 5 taken 9 times.
✗ Branch 4 → 23 not taken.
✓ Branch 5 → 6 taken 9 times.
✗ Branch 5 → 21 not taken.
|
9 | doWhileLoopNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 394 |
3/6✓ Branch 7 → 8 taken 9 times.
✗ Branch 7 → 26 not taken.
✓ Branch 8 → 9 taken 9 times.
✗ Branch 8 → 26 not taken.
✓ Branch 9 → 10 taken 9 times.
✗ Branch 9 → 24 not taken.
|
9 | doWhileLoopNode->condition = std::any_cast<AssignExprNode *>(visit(ctx->assignExpr())); |
| 395 | |||
| 396 |
1/2✓ Branch 17 → 18 taken 9 times.
✗ Branch 17 → 27 not taken.
|
9 | return concludeNode(doWhileLoopNode); |
| 397 | } | ||
| 398 | |||
| 399 | 4408 | std::any ASTBuilder::visitIfStmt(SpiceParser::IfStmtContext *ctx) { | |
| 400 | 4408 | const auto ifStmtNode = createNode<IfStmtNode>(ctx); | |
| 401 | |||
| 402 | // Visit children | ||
| 403 |
3/6✓ Branch 3 → 4 taken 4408 times.
✗ Branch 3 → 47 not taken.
✓ Branch 4 → 5 taken 4408 times.
✗ Branch 4 → 47 not taken.
✓ Branch 5 → 6 taken 4408 times.
✗ Branch 5 → 45 not taken.
|
4408 | ifStmtNode->condition = std::any_cast<AssignExprNode *>(visit(ctx->assignExpr())); |
| 404 | |||
| 405 | // Check if the branches have to be compiled at all | ||
| 406 | 4408 | const bool constantCondition = ifStmtNode->condition->hasCompileTimeValue(); | |
| 407 |
4/4✓ Branch 8 → 9 taken 9 times.
✓ Branch 8 → 11 taken 4399 times.
✓ Branch 10 → 11 taken 4 times.
✓ Branch 10 → 12 taken 5 times.
|
4408 | ifStmtNode->compileThenBranch = !constantCondition || ifStmtNode->condition->getCompileTimeValue().boolValue; |
| 408 |
4/4✓ Branch 13 → 14 taken 9 times.
✓ Branch 13 → 16 taken 4399 times.
✓ Branch 15 → 16 taken 6 times.
✓ Branch 15 → 17 taken 3 times.
|
4408 | ifStmtNode->compileElseBranch = !constantCondition || !ifStmtNode->condition->getCompileTimeValue().boolValue; |
| 409 | |||
| 410 | // Only compile then/else branch if required | ||
| 411 |
2/2✓ Branch 18 → 19 taken 4403 times.
✓ Branch 18 → 24 taken 5 times.
|
4408 | if (ifStmtNode->compileThenBranch) |
| 412 |
3/6✓ Branch 19 → 20 taken 4403 times.
✗ Branch 19 → 50 not taken.
✓ Branch 20 → 21 taken 4403 times.
✗ Branch 20 → 50 not taken.
✓ Branch 21 → 22 taken 4403 times.
✗ Branch 21 → 48 not taken.
|
4403 | ifStmtNode->thenBody = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 413 |
6/6✓ Branch 24 → 25 taken 4405 times.
✓ Branch 24 → 28 taken 3 times.
✓ Branch 26 → 27 taken 249 times.
✓ Branch 26 → 28 taken 4156 times.
✓ Branch 29 → 30 taken 249 times.
✓ Branch 29 → 35 taken 4159 times.
|
4408 | if (ifStmtNode->compileElseBranch && ctx->elseStmt()) |
| 414 |
3/6✓ Branch 30 → 31 taken 249 times.
✗ Branch 30 → 53 not taken.
✓ Branch 31 → 32 taken 249 times.
✗ Branch 31 → 53 not taken.
✓ Branch 32 → 33 taken 249 times.
✗ Branch 32 → 51 not taken.
|
249 | ifStmtNode->elseStmt = std::any_cast<ElseStmtNode *>(visit(ctx->elseStmt())); |
| 415 | |||
| 416 |
1/2✓ Branch 41 → 42 taken 4408 times.
✗ Branch 41 → 54 not taken.
|
4408 | return concludeNode(ifStmtNode); |
| 417 | } | ||
| 418 | |||
| 419 | 249 | std::any ASTBuilder::visitElseStmt(SpiceParser::ElseStmtContext *ctx) { | |
| 420 | 249 | const auto elseStmtNode = createNode<ElseStmtNode>(ctx); | |
| 421 | |||
| 422 | // Visit children | ||
| 423 |
2/2✓ Branch 4 → 5 taken 73 times.
✓ Branch 4 → 10 taken 176 times.
|
249 | if (ctx->ifStmt()) { |
| 424 | 73 | elseStmtNode->isElseIf = true; | |
| 425 |
3/6✓ Branch 5 → 6 taken 73 times.
✗ Branch 5 → 27 not taken.
✓ Branch 6 → 7 taken 73 times.
✗ Branch 6 → 27 not taken.
✓ Branch 7 → 8 taken 73 times.
✗ Branch 7 → 25 not taken.
|
73 | elseStmtNode->ifStmt = std::any_cast<IfStmtNode *>(visit(ctx->ifStmt())); |
| 426 | } else { | ||
| 427 |
3/6✓ Branch 10 → 11 taken 176 times.
✗ Branch 10 → 30 not taken.
✓ Branch 11 → 12 taken 176 times.
✗ Branch 11 → 30 not taken.
✓ Branch 12 → 13 taken 176 times.
✗ Branch 12 → 28 not taken.
|
176 | elseStmtNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 428 | } | ||
| 429 | |||
| 430 |
1/2✓ Branch 21 → 22 taken 249 times.
✗ Branch 21 → 31 not taken.
|
249 | return concludeNode(elseStmtNode); |
| 431 | } | ||
| 432 | |||
| 433 | 12 | std::any ASTBuilder::visitSwitchStmt(SpiceParser::SwitchStmtContext *ctx) { | |
| 434 | 12 | const auto switchStmtNode = createNode<SwitchStmtNode>(ctx); | |
| 435 | |||
| 436 | // Visit children | ||
| 437 |
3/6✓ Branch 3 → 4 taken 12 times.
✗ Branch 3 → 29 not taken.
✓ Branch 4 → 5 taken 12 times.
✗ Branch 4 → 29 not taken.
✓ Branch 5 → 6 taken 12 times.
✗ Branch 5 → 27 not taken.
|
12 | switchStmtNode->assignExpr = std::any_cast<AssignExprNode *>(visit(ctx->assignExpr())); |
| 438 |
2/4✓ Branch 7 → 8 taken 12 times.
✗ Branch 7 → 32 not taken.
✓ Branch 8 → 9 taken 12 times.
✗ Branch 8 → 30 not taken.
|
12 | fetchChildrenIntoVector(switchStmtNode->caseBranches, ctx->caseBranch()); |
| 439 |
2/2✓ Branch 11 → 12 taken 6 times.
✓ Branch 11 → 17 taken 6 times.
|
12 | if (ctx->defaultBranch()) { |
| 440 | 6 | switchStmtNode->hasDefaultBranch = true; | |
| 441 |
3/6✓ Branch 12 → 13 taken 6 times.
✗ Branch 12 → 35 not taken.
✓ Branch 13 → 14 taken 6 times.
✗ Branch 13 → 35 not taken.
✓ Branch 14 → 15 taken 6 times.
✗ Branch 14 → 33 not taken.
|
6 | switchStmtNode->defaultBranch = std::any_cast<DefaultBranchNode *>(visit(ctx->defaultBranch())); |
| 442 | } | ||
| 443 | |||
| 444 |
1/2✓ Branch 23 → 24 taken 12 times.
✗ Branch 23 → 36 not taken.
|
12 | return concludeNode(switchStmtNode); |
| 445 | } | ||
| 446 | |||
| 447 | 53 | std::any ASTBuilder::visitCaseBranch(SpiceParser::CaseBranchContext *ctx) { | |
| 448 | 53 | const auto caseBranchNode = createNode<CaseBranchNode>(ctx); | |
| 449 | |||
| 450 | // Visit children | ||
| 451 |
2/4✓ Branch 3 → 4 taken 53 times.
✗ Branch 3 → 22 not taken.
✓ Branch 4 → 5 taken 53 times.
✗ Branch 4 → 20 not taken.
|
53 | fetchChildrenIntoVector(caseBranchNode->caseConstants, ctx->caseConstant()); |
| 452 |
3/6✓ Branch 6 → 7 taken 53 times.
✗ Branch 6 → 25 not taken.
✓ Branch 7 → 8 taken 53 times.
✗ Branch 7 → 25 not taken.
✓ Branch 8 → 9 taken 53 times.
✗ Branch 8 → 23 not taken.
|
53 | caseBranchNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 453 | |||
| 454 |
1/2✓ Branch 16 → 17 taken 53 times.
✗ Branch 16 → 26 not taken.
|
53 | return concludeNode(caseBranchNode); |
| 455 | } | ||
| 456 | |||
| 457 | 6 | std::any ASTBuilder::visitDefaultBranch(SpiceParser::DefaultBranchContext *ctx) { | |
| 458 | 6 | const auto defaultBranchNode = createNode<DefaultBranchNode>(ctx); | |
| 459 | |||
| 460 | // Visit children | ||
| 461 |
3/6✓ Branch 3 → 4 taken 6 times.
✗ Branch 3 → 19 not taken.
✓ Branch 4 → 5 taken 6 times.
✗ Branch 4 → 19 not taken.
✓ Branch 5 → 6 taken 6 times.
✗ Branch 5 → 17 not taken.
|
6 | defaultBranchNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 462 | |||
| 463 |
1/2✓ Branch 13 → 14 taken 6 times.
✗ Branch 13 → 20 not taken.
|
6 | return concludeNode(defaultBranchNode); |
| 464 | } | ||
| 465 | |||
| 466 | 32 | std::any ASTBuilder::visitAnonymousBlockStmt(SpiceParser::AnonymousBlockStmtContext *ctx) { | |
| 467 | 32 | const auto anonymousBlockStmtNode = createNode<AnonymousBlockStmtNode>(ctx); | |
| 468 | |||
| 469 | // Visit children | ||
| 470 |
3/6✓ Branch 3 → 4 taken 32 times.
✗ Branch 3 → 19 not taken.
✓ Branch 4 → 5 taken 32 times.
✗ Branch 4 → 19 not taken.
✓ Branch 5 → 6 taken 32 times.
✗ Branch 5 → 17 not taken.
|
32 | anonymousBlockStmtNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 471 | |||
| 472 |
1/2✓ Branch 13 → 14 taken 32 times.
✗ Branch 13 → 20 not taken.
|
32 | return concludeNode(anonymousBlockStmtNode); |
| 473 | } | ||
| 474 | |||
| 475 | 22785 | std::any ASTBuilder::visitStmtLst(SpiceParser::StmtLstContext *ctx) { | |
| 476 | 22785 | const auto stmtLstNode = createNode<StmtLstNode>(ctx); | |
| 477 | |||
| 478 | // Enrich | ||
| 479 |
2/4✓ Branch 3 → 4 taken 22785 times.
✗ Branch 3 → 116 not taken.
✓ Branch 4 → 5 taken 22785 times.
✗ Branch 4 → 116 not taken.
|
22785 | stmtLstNode->closingBraceCodeLoc = CodeLoc(ctx->getStop(), sourceFile); |
| 480 | |||
| 481 | // Visit children | ||
| 482 |
2/2✓ Branch 105 → 7 taken 87324 times.
✓ Branch 105 → 106 taken 22781 times.
|
110105 | for (ParserRuleContext::ParseTree *stmt : ctx->children) { |
| 483 |
3/4✓ Branch 8 → 9 taken 87324 times.
✗ Branch 8 → 10 not taken.
✓ Branch 11 → 12 taken 31487 times.
✓ Branch 11 → 17 taken 55837 times.
|
87324 | if (auto *stmtCtx = dynamic_cast<SpiceParser::StmtContext *>(stmt)) |
| 484 |
4/6✓ Branch 12 → 13 taken 31483 times.
✓ Branch 12 → 119 taken 4 times.
✓ Branch 13 → 14 taken 31483 times.
✗ Branch 13 → 117 not taken.
✓ Branch 14 → 15 taken 31483 times.
✗ Branch 14 → 117 not taken.
|
31487 | stmtLstNode->statements.push_back(std::any_cast<StmtNode *>(visit(stmtCtx))); |
| 485 |
3/4✓ Branch 17 → 18 taken 55837 times.
✗ Branch 17 → 19 not taken.
✓ Branch 20 → 21 taken 1450 times.
✓ Branch 20 → 26 taken 54387 times.
|
55837 | else if (auto *forLoopCtx = dynamic_cast<SpiceParser::ForLoopContext *>(stmt)) |
| 486 |
3/6✓ Branch 21 → 22 taken 1450 times.
✗ Branch 21 → 123 not taken.
✓ Branch 22 → 23 taken 1450 times.
✗ Branch 22 → 121 not taken.
✓ Branch 23 → 24 taken 1450 times.
✗ Branch 23 → 121 not taken.
|
1450 | stmtLstNode->statements.push_back(std::any_cast<ForLoopNode *>(visit(forLoopCtx))); |
| 487 |
3/4✓ Branch 26 → 27 taken 54387 times.
✗ Branch 26 → 28 not taken.
✓ Branch 29 → 30 taken 125 times.
✓ Branch 29 → 35 taken 54262 times.
|
54387 | else if (auto *foreachLoopCtx = dynamic_cast<SpiceParser::ForeachLoopContext *>(stmt)) |
| 488 |
3/6✓ Branch 30 → 31 taken 125 times.
✗ Branch 30 → 127 not taken.
✓ Branch 31 → 32 taken 125 times.
✗ Branch 31 → 125 not taken.
✓ Branch 32 → 33 taken 125 times.
✗ Branch 32 → 125 not taken.
|
125 | stmtLstNode->statements.push_back(std::any_cast<ForeachLoopNode *>(visit(foreachLoopCtx))); |
| 489 |
3/4✓ Branch 35 → 36 taken 54262 times.
✗ Branch 35 → 37 not taken.
✓ Branch 38 → 39 taken 822 times.
✓ Branch 38 → 44 taken 53440 times.
|
54262 | else if (auto *whileLoopCtx = dynamic_cast<SpiceParser::WhileLoopContext *>(stmt)) |
| 490 |
3/6✓ Branch 39 → 40 taken 822 times.
✗ Branch 39 → 131 not taken.
✓ Branch 40 → 41 taken 822 times.
✗ Branch 40 → 129 not taken.
✓ Branch 41 → 42 taken 822 times.
✗ Branch 41 → 129 not taken.
|
822 | stmtLstNode->statements.push_back(std::any_cast<WhileLoopNode *>(visit(whileLoopCtx))); |
| 491 |
3/4✓ Branch 44 → 45 taken 53440 times.
✗ Branch 44 → 46 not taken.
✓ Branch 47 → 48 taken 9 times.
✓ Branch 47 → 53 taken 53431 times.
|
53440 | else if (auto *doWhileLoopCtx = dynamic_cast<SpiceParser::DoWhileLoopContext *>(stmt)) |
| 492 |
3/6✓ Branch 48 → 49 taken 9 times.
✗ Branch 48 → 135 not taken.
✓ Branch 49 → 50 taken 9 times.
✗ Branch 49 → 133 not taken.
✓ Branch 50 → 51 taken 9 times.
✗ Branch 50 → 133 not taken.
|
9 | stmtLstNode->statements.push_back(std::any_cast<DoWhileLoopNode *>(visit(doWhileLoopCtx))); |
| 493 |
3/4✓ Branch 53 → 54 taken 53431 times.
✗ Branch 53 → 55 not taken.
✓ Branch 56 → 57 taken 4335 times.
✓ Branch 56 → 62 taken 49096 times.
|
53431 | else if (auto *ifStmtCtx = dynamic_cast<SpiceParser::IfStmtContext *>(stmt)) |
| 494 |
3/6✓ Branch 57 → 58 taken 4335 times.
✗ Branch 57 → 139 not taken.
✓ Branch 58 → 59 taken 4335 times.
✗ Branch 58 → 137 not taken.
✓ Branch 59 → 60 taken 4335 times.
✗ Branch 59 → 137 not taken.
|
4335 | stmtLstNode->statements.push_back(std::any_cast<IfStmtNode *>(visit(ifStmtCtx))); |
| 495 |
3/4✓ Branch 62 → 63 taken 49096 times.
✗ Branch 62 → 64 not taken.
✓ Branch 65 → 66 taken 12 times.
✓ Branch 65 → 71 taken 49084 times.
|
49096 | else if (auto *switchStmtCtx = dynamic_cast<SpiceParser::SwitchStmtContext *>(stmt)) |
| 496 |
3/6✓ Branch 66 → 67 taken 12 times.
✗ Branch 66 → 143 not taken.
✓ Branch 67 → 68 taken 12 times.
✗ Branch 67 → 141 not taken.
✓ Branch 68 → 69 taken 12 times.
✗ Branch 68 → 141 not taken.
|
12 | stmtLstNode->statements.push_back(std::any_cast<SwitchStmtNode *>(visit(switchStmtCtx))); |
| 497 |
3/4✓ Branch 71 → 72 taken 49084 times.
✗ Branch 71 → 73 not taken.
✓ Branch 74 → 75 taken 775 times.
✓ Branch 74 → 80 taken 48309 times.
|
49084 | else if (auto *assetStmtCtx = dynamic_cast<SpiceParser::AssertStmtContext *>(stmt)) |
| 498 |
3/6✓ Branch 75 → 76 taken 775 times.
✗ Branch 75 → 147 not taken.
✓ Branch 76 → 77 taken 775 times.
✗ Branch 76 → 145 not taken.
✓ Branch 77 → 78 taken 775 times.
✗ Branch 77 → 145 not taken.
|
775 | stmtLstNode->statements.push_back(std::any_cast<AssertStmtNode *>(visit(assetStmtCtx))); |
| 499 |
3/4✓ Branch 80 → 81 taken 48309 times.
✗ Branch 80 → 82 not taken.
✓ Branch 83 → 84 taken 2711 times.
✓ Branch 83 → 89 taken 45598 times.
|
48309 | else if (auto *unsafeBlockCtx = dynamic_cast<SpiceParser::UnsafeBlockContext *>(stmt)) |
| 500 |
3/6✓ Branch 84 → 85 taken 2711 times.
✗ Branch 84 → 151 not taken.
✓ Branch 85 → 86 taken 2711 times.
✗ Branch 85 → 149 not taken.
✓ Branch 86 → 87 taken 2711 times.
✗ Branch 86 → 149 not taken.
|
2711 | stmtLstNode->statements.push_back(std::any_cast<UnsafeBlockNode *>(visit(unsafeBlockCtx))); |
| 501 |
3/4✓ Branch 89 → 90 taken 45598 times.
✗ Branch 89 → 91 not taken.
✓ Branch 92 → 93 taken 32 times.
✓ Branch 92 → 98 taken 45566 times.
|
45598 | else if (auto *anonymousScopeCtx = dynamic_cast<SpiceParser::AnonymousBlockStmtContext *>(stmt)) |
| 502 |
3/6✓ Branch 93 → 94 taken 32 times.
✗ Branch 93 → 155 not taken.
✓ Branch 94 → 95 taken 32 times.
✗ Branch 94 → 153 not taken.
✓ Branch 95 → 96 taken 32 times.
✗ Branch 95 → 153 not taken.
|
32 | stmtLstNode->statements.push_back(std::any_cast<AnonymousBlockStmtNode *>(visit(anonymousScopeCtx))); |
| 503 | else | ||
| 504 | − | assert(dynamic_cast<TerminalNode *>(stmt) != nullptr); // GCOV_EXCL_LINE | |
| 505 | } | ||
| 506 | |||
| 507 |
1/2✓ Branch 112 → 113 taken 22781 times.
✗ Branch 112 → 158 not taken.
|
22781 | return concludeNode(stmtLstNode); |
| 508 | } | ||
| 509 | |||
| 510 | 7773 | std::any ASTBuilder::visitTypeLst(SpiceParser::TypeLstContext *ctx) { | |
| 511 | 7773 | const auto typeLstNode = createNode<TypeLstNode>(ctx); | |
| 512 | |||
| 513 | // Visit children | ||
| 514 |
2/4✓ Branch 3 → 4 taken 7773 times.
✗ Branch 3 → 18 not taken.
✓ Branch 4 → 5 taken 7773 times.
✗ Branch 4 → 16 not taken.
|
7773 | fetchChildrenIntoVector(typeLstNode->dataTypes, ctx->dataType()); |
| 515 | |||
| 516 |
1/2✓ Branch 12 → 13 taken 7773 times.
✗ Branch 12 → 19 not taken.
|
7773 | return concludeNode(typeLstNode); |
| 517 | } | ||
| 518 | |||
| 519 | 998 | std::any ASTBuilder::visitTypeLstWithEllipsis(SpiceParser::TypeLstWithEllipsisContext *ctx) { | |
| 520 | 998 | const auto typeLstWithEllipsisNode = createNode<TypeLstWithEllipsisNode>(ctx); | |
| 521 | |||
| 522 | // Visit children | ||
| 523 |
3/6✓ Branch 3 → 4 taken 998 times.
✗ Branch 3 → 20 not taken.
✓ Branch 4 → 5 taken 998 times.
✗ Branch 4 → 20 not taken.
✓ Branch 5 → 6 taken 998 times.
✗ Branch 5 → 18 not taken.
|
998 | typeLstWithEllipsisNode->typeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst())); |
| 524 | |||
| 525 | // Set some flags | ||
| 526 | 998 | typeLstWithEllipsisNode->hasEllipsis = ctx->ELLIPSIS() != nullptr; | |
| 527 | |||
| 528 |
1/2✓ Branch 14 → 15 taken 998 times.
✗ Branch 14 → 21 not taken.
|
998 | return concludeNode(typeLstWithEllipsisNode); |
| 529 | } | ||
| 530 | |||
| 531 | 999 | std::any ASTBuilder::visitTypeAltsLst(SpiceParser::TypeAltsLstContext *ctx) { | |
| 532 | 999 | const auto typeAltsLstNode = createNode<TypeAltsLstNode>(ctx); | |
| 533 | |||
| 534 | // Visit children | ||
| 535 |
2/4✓ Branch 3 → 4 taken 999 times.
✗ Branch 3 → 18 not taken.
✓ Branch 4 → 5 taken 999 times.
✗ Branch 4 → 16 not taken.
|
999 | fetchChildrenIntoVector(typeAltsLstNode->dataTypes, ctx->dataType()); |
| 536 | |||
| 537 |
1/2✓ Branch 12 → 13 taken 999 times.
✗ Branch 12 → 19 not taken.
|
999 | return concludeNode(typeAltsLstNode); |
| 538 | } | ||
| 539 | |||
| 540 | 9534 | std::any ASTBuilder::visitParamLst(SpiceParser::ParamLstContext *ctx) { | |
| 541 | 9534 | const auto paramLstNode = createNode<ParamLstNode>(ctx); | |
| 542 | |||
| 543 | // Visit children | ||
| 544 |
2/4✓ Branch 3 → 4 taken 9534 times.
✗ Branch 3 → 24 not taken.
✓ Branch 4 → 5 taken 9534 times.
✗ Branch 4 → 22 not taken.
|
9534 | fetchChildrenIntoVector(paramLstNode->params, ctx->declStmt()); |
| 545 | |||
| 546 | // Set some flags to later detect that the decl statements are parameters | ||
| 547 |
2/2✓ Branch 11 → 8 taken 14519 times.
✓ Branch 11 → 12 taken 9534 times.
|
24053 | for (DeclStmtNode *declStmt : paramLstNode->params) { |
| 548 | 14519 | declStmt->isFctParam = true; | |
| 549 | 14519 | declStmt->dataType->isParamType = true; | |
| 550 | } | ||
| 551 | |||
| 552 |
1/2✓ Branch 18 → 19 taken 9534 times.
✗ Branch 18 → 25 not taken.
|
9534 | return concludeNode(paramLstNode); |
| 553 | } | ||
| 554 | |||
| 555 | 13758 | std::any ASTBuilder::visitArgLst(SpiceParser::ArgLstContext *ctx) { | |
| 556 | 13758 | const auto argLstNode = createNode<ArgLstNode>(ctx); | |
| 557 | |||
| 558 | // Visit children | ||
| 559 |
2/4✓ Branch 3 → 4 taken 13758 times.
✗ Branch 3 → 20 not taken.
✓ Branch 4 → 5 taken 13758 times.
✗ Branch 4 → 18 not taken.
|
13758 | fetchChildrenIntoVector(argLstNode->args, ctx->assignExpr()); |
| 560 | 13758 | argLstNode->argInfos.reserve(argLstNode->args.size()); | |
| 561 | |||
| 562 |
1/2✓ Branch 14 → 15 taken 13758 times.
✗ Branch 14 → 21 not taken.
|
13758 | return concludeNode(argLstNode); |
| 563 | } | ||
| 564 | |||
| 565 | 68 | std::any ASTBuilder::visitEnumItemLst(SpiceParser::EnumItemLstContext *ctx) { | |
| 566 | 68 | const auto enumItemLstNode = createNode<EnumItemLstNode>(ctx); | |
| 567 | |||
| 568 | // Visit children | ||
| 569 |
2/4✓ Branch 3 → 4 taken 68 times.
✗ Branch 3 → 18 not taken.
✓ Branch 4 → 5 taken 68 times.
✗ Branch 4 → 16 not taken.
|
68 | fetchChildrenIntoVector(enumItemLstNode->items, ctx->enumItem()); |
| 570 | |||
| 571 |
1/2✓ Branch 12 → 13 taken 68 times.
✗ Branch 12 → 19 not taken.
|
68 | return concludeNode(enumItemLstNode); |
| 572 | } | ||
| 573 | |||
| 574 | 739 | std::any ASTBuilder::visitEnumItem(SpiceParser::EnumItemContext *ctx) { | |
| 575 | 739 | const auto enumItemNode = createNode<EnumItemNode>(ctx); | |
| 576 | |||
| 577 | // Enrich | ||
| 578 |
2/4✓ Branch 3 → 4 taken 739 times.
✗ Branch 3 → 22 not taken.
✓ Branch 4 → 5 taken 739 times.
✗ Branch 4 → 22 not taken.
|
739 | enumItemNode->itemName = getIdentifier(ctx->TYPE_IDENTIFIER(), false); |
| 579 |
2/2✓ Branch 8 → 9 taken 409 times.
✓ Branch 8 → 12 taken 330 times.
|
739 | if (ctx->ASSIGN()) { |
| 580 | 409 | enumItemNode->itemValue = parseInt(ctx->INT_LIT()); | |
| 581 | 409 | enumItemNode->hasValue = true; | |
| 582 | } | ||
| 583 | |||
| 584 |
1/2✓ Branch 18 → 19 taken 739 times.
✗ Branch 18 → 23 not taken.
|
739 | return concludeNode(enumItemNode); |
| 585 | } | ||
| 586 | |||
| 587 | 1575 | std::any ASTBuilder::visitField(SpiceParser::FieldContext *ctx) { | |
| 588 | 1575 | const auto fieldNode = createNode<FieldNode>(ctx); | |
| 589 | |||
| 590 | // Enrich | ||
| 591 |
2/4✓ Branch 3 → 4 taken 1575 times.
✗ Branch 3 → 29 not taken.
✓ Branch 4 → 5 taken 1575 times.
✗ Branch 4 → 29 not taken.
|
1575 | fieldNode->fieldName = getIdentifier(ctx->IDENTIFIER(), false); |
| 592 | |||
| 593 | // Visit children | ||
| 594 |
3/6✓ Branch 7 → 8 taken 1575 times.
✗ Branch 7 → 32 not taken.
✓ Branch 8 → 9 taken 1575 times.
✗ Branch 8 → 32 not taken.
✓ Branch 9 → 10 taken 1575 times.
✗ Branch 9 → 30 not taken.
|
1575 | fieldNode->dataType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 595 | 1575 | fieldNode->dataType->setFieldTypeRecursive(); | |
| 596 |
2/2✓ Branch 13 → 14 taken 234 times.
✓ Branch 13 → 19 taken 1341 times.
|
1575 | if (ctx->ternaryExpr()) |
| 597 |
3/6✓ Branch 14 → 15 taken 234 times.
✗ Branch 14 → 35 not taken.
✓ Branch 15 → 16 taken 234 times.
✗ Branch 15 → 35 not taken.
✓ Branch 16 → 17 taken 234 times.
✗ Branch 16 → 33 not taken.
|
234 | fieldNode->defaultValue = std::any_cast<TernaryExprNode *>(visit(ctx->ternaryExpr())); |
| 598 | |||
| 599 |
1/2✓ Branch 25 → 26 taken 1575 times.
✗ Branch 25 → 36 not taken.
|
1575 | return concludeNode(fieldNode); |
| 600 | } | ||
| 601 | |||
| 602 | 247 | std::any ASTBuilder::visitSignature(SpiceParser::SignatureContext *ctx) { | |
| 603 | 247 | const auto signatureNode = createNode<SignatureNode>(ctx); | |
| 604 | |||
| 605 | // Extract method name | ||
| 606 |
2/4✓ Branch 3 → 4 taken 247 times.
✗ Branch 3 → 73 not taken.
✓ Branch 4 → 5 taken 247 times.
✗ Branch 4 → 73 not taken.
|
247 | signatureNode->methodName = getIdentifier(ctx->IDENTIFIER(), false); |
| 607 | |||
| 608 | // Visit children | ||
| 609 |
2/2✓ Branch 8 → 9 taken 14 times.
✓ Branch 8 → 14 taken 233 times.
|
247 | if (ctx->qualifierLst()) { |
| 610 |
3/6✓ Branch 9 → 10 taken 14 times.
✗ Branch 9 → 76 not taken.
✓ Branch 10 → 11 taken 14 times.
✗ Branch 10 → 76 not taken.
✓ Branch 11 → 12 taken 14 times.
✗ Branch 11 → 74 not taken.
|
14 | signatureNode->qualifierLst = std::any_cast<QualifierLstNode *>(visit(ctx->qualifierLst())); |
| 611 | } | ||
| 612 |
2/2✓ Branch 15 → 16 taken 193 times.
✓ Branch 15 → 22 taken 54 times.
|
247 | if (ctx->F()) { |
| 613 | 193 | signatureNode->hasReturnType = true; | |
| 614 | 193 | signatureNode->signatureType = SignatureNode::SignatureType::TYPE_FUNCTION; | |
| 615 | 193 | signatureNode->signatureQualifiers = TypeQualifiers::of(TY_FUNCTION); | |
| 616 |
3/6✓ Branch 17 → 18 taken 193 times.
✗ Branch 17 → 79 not taken.
✓ Branch 18 → 19 taken 193 times.
✗ Branch 18 → 79 not taken.
✓ Branch 19 → 20 taken 193 times.
✗ Branch 19 → 77 not taken.
|
193 | signatureNode->returnType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 617 | } else { | ||
| 618 | 54 | signatureNode->signatureType = SignatureNode::SignatureType::TYPE_PROCEDURE; | |
| 619 | 54 | signatureNode->signatureQualifiers = TypeQualifiers::of(TY_PROCEDURE); | |
| 620 | } | ||
| 621 |
10/16✓ Branch 24 → 25 taken 193 times.
✓ Branch 24 → 28 taken 54 times.
✓ Branch 25 → 26 taken 193 times.
✗ Branch 25 → 80 not taken.
✓ Branch 28 → 29 taken 54 times.
✗ Branch 28 → 80 not taken.
✓ Branch 31 → 32 taken 54 times.
✓ Branch 31 → 33 taken 193 times.
✓ Branch 33 → 34 taken 193 times.
✓ Branch 33 → 35 taken 54 times.
✓ Branch 35 → 36 taken 126 times.
✓ Branch 35 → 41 taken 121 times.
✗ Branch 80 → 81 not taken.
✗ Branch 80 → 82 not taken.
✗ Branch 84 → 85 not taken.
✗ Branch 84 → 86 not taken.
|
247 | if (ctx->F() ? ctx->LESS().size() == 2 : ctx->LESS().size() == 1) { |
| 622 | 126 | signatureNode->hasTemplateTypes = true; | |
| 623 |
3/6✓ Branch 36 → 37 taken 126 times.
✗ Branch 36 → 90 not taken.
✓ Branch 37 → 38 taken 126 times.
✗ Branch 37 → 90 not taken.
✓ Branch 38 → 39 taken 126 times.
✗ Branch 38 → 88 not taken.
|
126 | signatureNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst(0))); |
| 624 | } | ||
| 625 |
13/20✓ Branch 41 → 42 taken 247 times.
✗ Branch 41 → 91 not taken.
✓ Branch 43 → 44 taken 245 times.
✓ Branch 43 → 48 taken 2 times.
✓ Branch 44 → 45 taken 245 times.
✗ Branch 44 → 91 not taken.
✓ Branch 46 → 47 taken 131 times.
✓ Branch 46 → 49 taken 114 times.
✓ Branch 47 → 48 taken 7 times.
✓ Branch 47 → 49 taken 124 times.
✓ Branch 50 → 51 taken 245 times.
✓ Branch 50 → 52 taken 2 times.
✓ Branch 52 → 53 taken 247 times.
✗ Branch 52 → 54 not taken.
✓ Branch 54 → 55 taken 9 times.
✓ Branch 54 → 63 taken 238 times.
✗ Branch 91 → 92 not taken.
✗ Branch 91 → 93 not taken.
✗ Branch 95 → 96 not taken.
✗ Branch 95 → 97 not taken.
|
247 | if (ctx->typeLst().size() == 2 || (ctx->typeLst().size() == 1 && !signatureNode->hasTemplateTypes)) { |
| 626 | 9 | signatureNode->hasParams = true; | |
| 627 |
5/8✓ Branch 55 → 56 taken 2 times.
✓ Branch 55 → 57 taken 7 times.
✓ Branch 58 → 59 taken 9 times.
✗ Branch 58 → 101 not taken.
✓ Branch 59 → 60 taken 9 times.
✗ Branch 59 → 101 not taken.
✓ Branch 60 → 61 taken 9 times.
✗ Branch 60 → 99 not taken.
|
9 | signatureNode->paramTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst(signatureNode->hasTemplateTypes ? 1 : 0))); |
| 628 | } | ||
| 629 | |||
| 630 |
1/2✓ Branch 69 → 70 taken 247 times.
✗ Branch 69 → 102 not taken.
|
247 | return concludeNode(signatureNode); |
| 631 | } | ||
| 632 | |||
| 633 | 31487 | std::any ASTBuilder::visitStmt(SpiceParser::StmtContext *ctx) { | |
| 634 |
2/2✓ Branch 3 → 4 taken 5616 times.
✓ Branch 3 → 11 taken 25871 times.
|
31487 | if (ctx->declStmt()) |
| 635 |
5/8✓ Branch 4 → 5 taken 5616 times.
✗ Branch 4 → 60 not taken.
✓ Branch 5 → 6 taken 5612 times.
✓ Branch 5 → 60 taken 4 times.
✓ Branch 6 → 7 taken 5612 times.
✗ Branch 6 → 58 not taken.
✓ Branch 7 → 8 taken 5612 times.
✗ Branch 7 → 58 not taken.
|
5616 | return static_cast<StmtNode *>(std::any_cast<DeclStmtNode *>(visit(ctx->declStmt()))); |
| 636 |
2/2✓ Branch 12 → 13 taken 15546 times.
✓ Branch 12 → 20 taken 10325 times.
|
25871 | if (ctx->exprStmt()) |
| 637 |
4/8✓ Branch 13 → 14 taken 15546 times.
✗ Branch 13 → 64 not taken.
✓ Branch 14 → 15 taken 15546 times.
✗ Branch 14 → 64 not taken.
✓ Branch 15 → 16 taken 15546 times.
✗ Branch 15 → 62 not taken.
✓ Branch 16 → 17 taken 15546 times.
✗ Branch 16 → 62 not taken.
|
15546 | return static_cast<StmtNode *>(std::any_cast<ExprStmtNode *>(visit(ctx->exprStmt()))); |
| 638 |
2/2✓ Branch 21 → 22 taken 9985 times.
✓ Branch 21 → 29 taken 340 times.
|
10325 | if (ctx->returnStmt()) |
| 639 |
4/8✓ Branch 22 → 23 taken 9985 times.
✗ Branch 22 → 68 not taken.
✓ Branch 23 → 24 taken 9985 times.
✗ Branch 23 → 68 not taken.
✓ Branch 24 → 25 taken 9985 times.
✗ Branch 24 → 66 not taken.
✓ Branch 25 → 26 taken 9985 times.
✗ Branch 25 → 66 not taken.
|
9985 | return static_cast<StmtNode *>(std::any_cast<ReturnStmtNode *>(visit(ctx->returnStmt()))); |
| 640 |
2/2✓ Branch 30 → 31 taken 125 times.
✓ Branch 30 → 38 taken 215 times.
|
340 | if (ctx->breakStmt()) |
| 641 |
4/8✓ Branch 31 → 32 taken 125 times.
✗ Branch 31 → 72 not taken.
✓ Branch 32 → 33 taken 125 times.
✗ Branch 32 → 72 not taken.
✓ Branch 33 → 34 taken 125 times.
✗ Branch 33 → 70 not taken.
✓ Branch 34 → 35 taken 125 times.
✗ Branch 34 → 70 not taken.
|
125 | return static_cast<StmtNode *>(std::any_cast<BreakStmtNode *>(visit(ctx->breakStmt()))); |
| 642 |
2/2✓ Branch 39 → 40 taken 209 times.
✓ Branch 39 → 47 taken 6 times.
|
215 | if (ctx->continueStmt()) |
| 643 |
4/8✓ Branch 40 → 41 taken 209 times.
✗ Branch 40 → 76 not taken.
✓ Branch 41 → 42 taken 209 times.
✗ Branch 41 → 76 not taken.
✓ Branch 42 → 43 taken 209 times.
✗ Branch 42 → 74 not taken.
✓ Branch 43 → 44 taken 209 times.
✗ Branch 43 → 74 not taken.
|
209 | return static_cast<StmtNode *>(std::any_cast<ContinueStmtNode *>(visit(ctx->continueStmt()))); |
| 644 |
1/2✓ Branch 48 → 49 taken 6 times.
✗ Branch 48 → 56 not taken.
|
6 | if (ctx->fallthroughStmt()) |
| 645 |
4/8✓ Branch 49 → 50 taken 6 times.
✗ Branch 49 → 80 not taken.
✓ Branch 50 → 51 taken 6 times.
✗ Branch 50 → 80 not taken.
✓ Branch 51 → 52 taken 6 times.
✗ Branch 51 → 78 not taken.
✓ Branch 52 → 53 taken 6 times.
✗ Branch 52 → 78 not taken.
|
6 | return static_cast<StmtNode *>(std::any_cast<FallthroughStmtNode *>(visit(ctx->fallthroughStmt()))); |
| 646 | − | assert_fail("Unknown statement type"); // GCOV_EXCL_LINE | |
| 647 | return nullptr; // GCOV_EXCL_LINE | ||
| 648 | } | ||
| 649 | |||
| 650 | 21716 | std::any ASTBuilder::visitDeclStmt(SpiceParser::DeclStmtContext *ctx) { | |
| 651 | 21716 | const auto declStmtNode = createNode<DeclStmtNode>(ctx); | |
| 652 | |||
| 653 | // Enrich | ||
| 654 |
3/4✓ Branch 3 → 4 taken 21716 times.
✗ Branch 3 → 28 not taken.
✓ Branch 4 → 5 taken 21715 times.
✓ Branch 4 → 28 taken 1 time.
|
21716 | declStmtNode->varName = getIdentifier(ctx->IDENTIFIER(), false); |
| 655 | |||
| 656 | // Visit children | ||
| 657 |
4/6✓ Branch 7 → 8 taken 21715 times.
✗ Branch 7 → 31 not taken.
✓ Branch 8 → 9 taken 21714 times.
✓ Branch 8 → 31 taken 1 time.
✓ Branch 9 → 10 taken 21714 times.
✗ Branch 9 → 29 not taken.
|
21715 | declStmtNode->dataType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 658 |
2/2✓ Branch 12 → 13 taken 7759 times.
✓ Branch 12 → 18 taken 13955 times.
|
21714 | if (ctx->assignExpr()) { |
| 659 | 7759 | declStmtNode->hasAssignment = true; | |
| 660 |
4/6✓ Branch 13 → 14 taken 7759 times.
✗ Branch 13 → 34 not taken.
✓ Branch 14 → 15 taken 7757 times.
✓ Branch 14 → 34 taken 2 times.
✓ Branch 15 → 16 taken 7757 times.
✗ Branch 15 → 32 not taken.
|
7759 | declStmtNode->assignExpr = std::any_cast<AssignExprNode *>(visit(ctx->assignExpr())); |
| 661 | } | ||
| 662 | |||
| 663 |
1/2✓ Branch 24 → 25 taken 21712 times.
✗ Branch 24 → 35 not taken.
|
21712 | return concludeNode(declStmtNode); |
| 664 | } | ||
| 665 | |||
| 666 | 15546 | std::any ASTBuilder::visitExprStmt(SpiceParser::ExprStmtContext *ctx) { | |
| 667 | 15546 | const auto exprStmtNode = createNode<ExprStmtNode>(ctx); | |
| 668 | |||
| 669 | // Enrich | ||
| 670 |
3/6✓ Branch 3 → 4 taken 15546 times.
✗ Branch 3 → 19 not taken.
✓ Branch 4 → 5 taken 15546 times.
✗ Branch 4 → 19 not taken.
✓ Branch 5 → 6 taken 15546 times.
✗ Branch 5 → 17 not taken.
|
15546 | exprStmtNode->expr = std::any_cast<AssignExprNode *>(visit(ctx->assignExpr())); |
| 671 | |||
| 672 |
1/2✓ Branch 13 → 14 taken 15546 times.
✗ Branch 13 → 20 not taken.
|
15546 | return concludeNode(exprStmtNode); |
| 673 | } | ||
| 674 | |||
| 675 | 32543 | std::any ASTBuilder::visitQualifierLst(SpiceParser::QualifierLstContext *ctx) { | |
| 676 | 32543 | const auto qualifierLstNode = createNode<QualifierLstNode>(ctx); | |
| 677 | |||
| 678 | // Visit children | ||
| 679 |
2/4✓ Branch 3 → 4 taken 32543 times.
✗ Branch 3 → 37 not taken.
✓ Branch 4 → 5 taken 32543 times.
✗ Branch 4 → 35 not taken.
|
32543 | fetchChildrenIntoVector(qualifierLstNode->qualifiers, ctx->qualifier()); |
| 680 | |||
| 681 | // Check if qualifier combination is invalid | ||
| 682 | 32543 | bool seenSignedOrUnsigned = false; | |
| 683 |
2/2✓ Branch 24 → 8 taken 39122 times.
✓ Branch 24 → 25 taken 32542 times.
|
71664 | for (const QualifierNode *qualifier : qualifierLstNode->qualifiers) { |
| 684 | // Check if we have both, signed and unsigned qualifier | ||
| 685 |
2/2✓ Branch 9 → 10 taken 39115 times.
✓ Branch 9 → 12 taken 7 times.
|
39122 | if (qualifier->type != QualifierNode::QualifierType::TY_SIGNED && |
| 686 |
2/2✓ Branch 10 → 11 taken 29366 times.
✓ Branch 10 → 12 taken 9749 times.
|
39115 | qualifier->type != QualifierNode::QualifierType::TY_UNSIGNED) |
| 687 | 29366 | continue; | |
| 688 |
2/2✓ Branch 12 → 13 taken 1 time.
✓ Branch 12 → 21 taken 9755 times.
|
9756 | if (seenSignedOrUnsigned) |
| 689 |
2/4✓ Branch 16 → 17 taken 1 time.
✗ Branch 16 → 41 not taken.
✓ Branch 17 → 18 taken 1 time.
✗ Branch 17 → 38 not taken.
|
3 | throw ParserError(qualifier->codeLoc, INVALID_QUALIFIER_COMBINATION, "A variable can not be signed and unsigned"); |
| 690 | 9755 | seenSignedOrUnsigned = true; | |
| 691 | } | ||
| 692 | |||
| 693 |
1/2✓ Branch 31 → 32 taken 32542 times.
✗ Branch 31 → 48 not taken.
|
32542 | return concludeNode(qualifierLstNode); |
| 694 | } | ||
| 695 | |||
| 696 | 39122 | std::any ASTBuilder::visitQualifier(SpiceParser::QualifierContext *ctx) { | |
| 697 | 39122 | const auto qualifierNode = createNode<QualifierNode>(ctx); | |
| 698 | |||
| 699 |
3/4✓ Branch 6 → 7 taken 39122 times.
✗ Branch 6 → 8 not taken.
✓ Branch 32 → 5 taken 39122 times.
✓ Branch 32 → 33 taken 39122 times.
|
78244 | for (ParserRuleContext::ParseTree *subTree : ctx->children) { |
| 700 | 39122 | const auto token = spice_pointer_cast<TerminalNode *>(subTree); | |
| 701 |
2/4✓ Branch 13 → 14 taken 39122 times.
✗ Branch 13 → 43 not taken.
✓ Branch 14 → 15 taken 39122 times.
✗ Branch 14 → 43 not taken.
|
39122 | const size_t symbolType = token->getSymbol()->getType(); |
| 702 |
2/2✓ Branch 15 → 16 taken 8278 times.
✓ Branch 15 → 17 taken 30844 times.
|
39122 | if (symbolType == SpiceParser::CONST) |
| 703 | 8278 | qualifierNode->type = QualifierNode::QualifierType::TY_CONST; | |
| 704 |
2/2✓ Branch 17 → 18 taken 7 times.
✓ Branch 17 → 19 taken 30837 times.
|
30844 | else if (symbolType == SpiceParser::SIGNED) |
| 705 | 7 | qualifierNode->type = QualifierNode::QualifierType::TY_SIGNED; | |
| 706 |
2/2✓ Branch 19 → 20 taken 9749 times.
✓ Branch 19 → 21 taken 21088 times.
|
30837 | else if (symbolType == SpiceParser::UNSIGNED) |
| 707 | 9749 | qualifierNode->type = QualifierNode::QualifierType::TY_UNSIGNED; | |
| 708 |
2/2✓ Branch 21 → 22 taken 3386 times.
✓ Branch 21 → 23 taken 17702 times.
|
21088 | else if (symbolType == SpiceParser::INLINE) |
| 709 | 3386 | qualifierNode->type = QualifierNode::QualifierType::TY_INLINE; | |
| 710 |
2/2✓ Branch 23 → 24 taken 13310 times.
✓ Branch 23 → 25 taken 4392 times.
|
17702 | else if (symbolType == SpiceParser::PUBLIC) |
| 711 | 13310 | qualifierNode->type = QualifierNode::QualifierType::TY_PUBLIC; | |
| 712 |
2/2✓ Branch 25 → 26 taken 4385 times.
✓ Branch 25 → 27 taken 7 times.
|
4392 | else if (symbolType == SpiceParser::HEAP) |
| 713 | 4385 | qualifierNode->type = QualifierNode::QualifierType::TY_HEAP; | |
| 714 |
1/2✓ Branch 27 → 28 taken 7 times.
✗ Branch 27 → 29 not taken.
|
7 | else if (symbolType == SpiceParser::COMPOSE) |
| 715 | 7 | qualifierNode->type = QualifierNode::QualifierType::TY_COMPOSITION; | |
| 716 | else | ||
| 717 | − | assert_fail("Unknown qualifier type"); // GCOV_EXCL_LINE | |
| 718 | } | ||
| 719 | |||
| 720 |
1/2✓ Branch 39 → 40 taken 39122 times.
✗ Branch 39 → 44 not taken.
|
39122 | return concludeNode(qualifierNode); |
| 721 | } | ||
| 722 | |||
| 723 | 370 | std::any ASTBuilder::visitModAttr(SpiceParser::ModAttrContext *ctx) { | |
| 724 | 370 | const auto modAttrNode = createNode<ModAttrNode>(ctx); | |
| 725 | |||
| 726 | // Visit children | ||
| 727 |
4/6✓ Branch 3 → 4 taken 370 times.
✗ Branch 3 → 25 not taken.
✓ Branch 4 → 5 taken 369 times.
✓ Branch 4 → 25 taken 1 time.
✓ Branch 5 → 6 taken 369 times.
✗ Branch 5 → 23 not taken.
|
370 | modAttrNode->attrLst = std::any_cast<AttrLstNode *>(visit(ctx->attrLst())); |
| 728 | |||
| 729 | // Tell the attributes that they are module attributes | ||
| 730 |
2/2✓ Branch 12 → 9 taken 651 times.
✓ Branch 12 → 13 taken 369 times.
|
1020 | for (AttrNode *attr : modAttrNode->attrLst->attributes) |
| 731 | 651 | attr->target = AttrNode::TARGET_MODULE; | |
| 732 | |||
| 733 |
1/2✓ Branch 19 → 20 taken 369 times.
✗ Branch 19 → 26 not taken.
|
369 | return concludeNode(modAttrNode); |
| 734 | } | ||
| 735 | |||
| 736 | 486 | std::any ASTBuilder::visitTopLevelDefAttr(SpiceParser::TopLevelDefAttrContext *ctx) { | |
| 737 | 486 | const auto fctAttrNode = createNode<TopLevelDefinitionAttrNode>(ctx); | |
| 738 | |||
| 739 | // Visit children | ||
| 740 |
3/6✓ Branch 3 → 4 taken 486 times.
✗ Branch 3 → 19 not taken.
✓ Branch 4 → 5 taken 486 times.
✗ Branch 4 → 19 not taken.
✓ Branch 5 → 6 taken 486 times.
✗ Branch 5 → 17 not taken.
|
486 | fctAttrNode->attrLst = std::any_cast<AttrLstNode *>(visit(ctx->attrLst())); |
| 741 | |||
| 742 |
1/2✓ Branch 13 → 14 taken 486 times.
✗ Branch 13 → 20 not taken.
|
486 | return concludeNode(fctAttrNode); |
| 743 | } | ||
| 744 | |||
| 745 | 16 | std::any ASTBuilder::visitLambdaAttr(SpiceParser::LambdaAttrContext *ctx) { | |
| 746 | 16 | const auto lambdaAttrNode = createNode<LambdaAttrNode>(ctx); | |
| 747 | |||
| 748 | // Visit children | ||
| 749 |
3/6✓ Branch 3 → 4 taken 16 times.
✗ Branch 3 → 25 not taken.
✓ Branch 4 → 5 taken 16 times.
✗ Branch 4 → 25 not taken.
✓ Branch 5 → 6 taken 16 times.
✗ Branch 5 → 23 not taken.
|
16 | lambdaAttrNode->attrLst = std::any_cast<AttrLstNode *>(visit(ctx->attrLst())); |
| 750 | |||
| 751 | // Tell the attributes that they are module attributes | ||
| 752 |
2/2✓ Branch 12 → 9 taken 16 times.
✓ Branch 12 → 13 taken 16 times.
|
32 | for (AttrNode *attr : lambdaAttrNode->attrLst->attributes) |
| 753 | 16 | attr->target = AttrNode::TARGET_LAMBDA; | |
| 754 | |||
| 755 |
1/2✓ Branch 19 → 20 taken 16 times.
✗ Branch 19 → 26 not taken.
|
16 | return concludeNode(lambdaAttrNode); |
| 756 | } | ||
| 757 | |||
| 758 | 872 | std::any ASTBuilder::visitAttrLst(SpiceParser::AttrLstContext *ctx) { | |
| 759 | 872 | const auto attrLstNode = createNode<AttrLstNode>(ctx); | |
| 760 | |||
| 761 | // Visit children | ||
| 762 |
3/4✓ Branch 3 → 4 taken 872 times.
✗ Branch 3 → 18 not taken.
✓ Branch 4 → 5 taken 871 times.
✓ Branch 4 → 16 taken 1 time.
|
873 | fetchChildrenIntoVector(attrLstNode->attributes, ctx->attr()); |
| 763 | |||
| 764 |
1/2✓ Branch 12 → 13 taken 871 times.
✗ Branch 12 → 19 not taken.
|
871 | return concludeNode(attrLstNode); |
| 765 | } | ||
| 766 | |||
| 767 | 1159 | std::any ASTBuilder::visitAttr(SpiceParser::AttrContext *ctx) { | |
| 768 | 1159 | const auto attrNode = createNode<AttrNode>(ctx); | |
| 769 | |||
| 770 | // Extract key | ||
| 771 |
3/4✓ Branch 3 → 4 taken 1159 times.
✗ Branch 3 → 66 not taken.
✓ Branch 16 → 6 taken 2812 times.
✓ Branch 16 → 17 taken 1159 times.
|
3971 | for (const TerminalNode *keyFragment : ctx->IDENTIFIER()) { |
| 772 |
2/2✓ Branch 8 → 9 taken 1653 times.
✓ Branch 8 → 10 taken 1159 times.
|
2812 | if (!attrNode->key.empty()) |
| 773 |
1/2✓ Branch 9 → 10 taken 1653 times.
✗ Branch 9 → 64 not taken.
|
1653 | attrNode->key += MEMBER_ACCESS_TOKEN; |
| 774 |
3/6✓ Branch 10 → 11 taken 2812 times.
✗ Branch 10 → 63 not taken.
✓ Branch 11 → 12 taken 2812 times.
✗ Branch 11 → 63 not taken.
✓ Branch 12 → 13 taken 2812 times.
✗ Branch 12 → 61 not taken.
|
2812 | attrNode->key += keyFragment->getSymbol()->getText(); |
| 775 | 1159 | } | |
| 776 | |||
| 777 | // Visit children | ||
| 778 |
2/2✓ Branch 19 → 20 taken 803 times.
✓ Branch 19 → 50 taken 356 times.
|
1159 | if (ctx->constant()) { |
| 779 |
3/6✓ Branch 20 → 21 taken 803 times.
✗ Branch 20 → 69 not taken.
✓ Branch 21 → 22 taken 803 times.
✗ Branch 21 → 69 not taken.
✓ Branch 22 → 23 taken 803 times.
✗ Branch 22 → 67 not taken.
|
803 | attrNode->value = std::any_cast<ConstantNode *>(visit(ctx->constant())); |
| 780 | |||
| 781 |
2/2✓ Branch 26 → 27 taken 293 times.
✓ Branch 26 → 28 taken 510 times.
|
803 | if (ctx->constant()->STRING_LIT()) |
| 782 | 293 | attrNode->type = AttrNode::AttrType::TYPE_STRING; | |
| 783 |
2/2✓ Branch 30 → 31 taken 80 times.
✓ Branch 30 → 32 taken 430 times.
|
510 | else if (ctx->constant()->INT_LIT()) |
| 784 | 80 | attrNode->type = AttrNode::AttrType::TYPE_INT; | |
| 785 |
6/6✓ Branch 34 → 35 taken 5 times.
✓ Branch 34 → 38 taken 425 times.
✓ Branch 37 → 38 taken 4 times.
✓ Branch 37 → 39 taken 1 time.
✓ Branch 40 → 41 taken 429 times.
✓ Branch 40 → 42 taken 1 time.
|
430 | else if (ctx->constant()->TRUE() || ctx->constant()->FALSE()) |
| 786 | 429 | attrNode->type = AttrNode::AttrType::TYPE_BOOL; | |
| 787 | else | ||
| 788 |
2/4✓ Branch 45 → 46 taken 1 time.
✗ Branch 45 → 73 not taken.
✓ Branch 46 → 47 taken 1 time.
✗ Branch 46 → 70 not taken.
|
3 | throw ParserError(attrNode->value->codeLoc, INVALID_ATTR_VALUE_TYPE, "Invalid attribute value type"); |
| 789 | } else { | ||
| 790 | // If no value is given, use the bool type | ||
| 791 | 356 | attrNode->type = AttrNode::AttrType::TYPE_BOOL; | |
| 792 | } | ||
| 793 | |||
| 794 |
1/2✓ Branch 57 → 58 taken 1158 times.
✗ Branch 57 → 79 not taken.
|
1158 | return concludeNode(attrNode); |
| 795 | } | ||
| 796 | |||
| 797 | 70 | std::any ASTBuilder::visitCaseConstant(SpiceParser::CaseConstantContext *ctx) { | |
| 798 | 70 | const auto caseConstantNode = createNode<CaseConstantNode>(ctx); | |
| 799 | |||
| 800 | // Visit children | ||
| 801 |
2/2✓ Branch 4 → 5 taken 18 times.
✓ Branch 4 → 10 taken 52 times.
|
70 | if (ctx->constant()) { |
| 802 |
3/6✓ Branch 5 → 6 taken 18 times.
✗ Branch 5 → 61 not taken.
✓ Branch 6 → 7 taken 18 times.
✗ Branch 6 → 61 not taken.
✓ Branch 7 → 8 taken 18 times.
✗ Branch 7 → 59 not taken.
|
18 | caseConstantNode->constant = std::any_cast<ConstantNode *>(visit(ctx->constant())); |
| 803 |
2/4✓ Branch 10 → 11 taken 52 times.
✗ Branch 10 → 62 not taken.
✓ Branch 13 → 14 taken 52 times.
✗ Branch 13 → 48 not taken.
|
52 | } else if (!ctx->TYPE_IDENTIFIER().empty()) { |
| 804 |
2/2✓ Branch 46 → 16 taken 126 times.
✓ Branch 46 → 47 taken 52 times.
|
178 | for (ParserRuleContext::ParseTree *subTree : ctx->children) { |
| 805 |
1/2✓ Branch 17 → 18 taken 126 times.
✗ Branch 17 → 19 not taken.
|
126 | const auto terminal = dynamic_cast<TerminalNode *>(subTree); |
| 806 |
1/2✗ Branch 20 → 21 not taken.
✓ Branch 20 → 22 taken 126 times.
|
126 | if (!terminal) |
| 807 | ✗ | continue; | |
| 808 | |||
| 809 |
3/6✓ Branch 22 → 23 taken 126 times.
✗ Branch 22 → 69 not taken.
✓ Branch 23 → 24 taken 126 times.
✗ Branch 23 → 69 not taken.
✗ Branch 24 → 25 not taken.
✓ Branch 24 → 33 taken 126 times.
|
126 | if (terminal->getSymbol()->getType() == SpiceParser::IDENTIFIER) { |
| 810 | ✗ | const std::string fragment = getIdentifier(terminal, false); | |
| 811 | ✗ | caseConstantNode->identifierFragments.push_back(fragment); | |
| 812 | ✗ | if (!caseConstantNode->fqIdentifier.empty()) | |
| 813 | ✗ | caseConstantNode->fqIdentifier += SCOPE_ACCESS_TOKEN; | |
| 814 | ✗ | caseConstantNode->fqIdentifier += fragment; | |
| 815 |
4/6✓ Branch 33 → 34 taken 126 times.
✗ Branch 33 → 69 not taken.
✓ Branch 34 → 35 taken 126 times.
✗ Branch 34 → 69 not taken.
✓ Branch 35 → 36 taken 89 times.
✓ Branch 35 → 44 taken 37 times.
|
126 | } else if (terminal->getSymbol()->getType() == SpiceParser::TYPE_IDENTIFIER) { |
| 816 |
1/2✓ Branch 36 → 37 taken 89 times.
✗ Branch 36 → 68 not taken.
|
89 | const std::string fragment = getIdentifier(terminal, false); |
| 817 |
1/2✓ Branch 37 → 38 taken 89 times.
✗ Branch 37 → 66 not taken.
|
89 | caseConstantNode->identifierFragments.push_back(fragment); |
| 818 |
2/2✓ Branch 39 → 40 taken 37 times.
✓ Branch 39 → 41 taken 52 times.
|
89 | if (!caseConstantNode->fqIdentifier.empty()) |
| 819 |
1/2✓ Branch 40 → 41 taken 37 times.
✗ Branch 40 → 66 not taken.
|
37 | caseConstantNode->fqIdentifier += SCOPE_ACCESS_TOKEN; |
| 820 |
1/2✓ Branch 41 → 42 taken 89 times.
✗ Branch 41 → 66 not taken.
|
89 | caseConstantNode->fqIdentifier += fragment; |
| 821 | 89 | } | |
| 822 | } | ||
| 823 | } else { | ||
| 824 | − | assert_fail("Unknown case constant type"); // GCOV_EXCL_LINE | |
| 825 | } | ||
| 826 | |||
| 827 |
1/2✓ Branch 55 → 56 taken 70 times.
✗ Branch 55 → 70 not taken.
|
70 | return concludeNode(caseConstantNode); |
| 828 | } | ||
| 829 | |||
| 830 | 9985 | std::any ASTBuilder::visitReturnStmt(SpiceParser::ReturnStmtContext *ctx) { | |
| 831 | 9985 | const auto returnStmtNode = createNode<ReturnStmtNode>(ctx); | |
| 832 | |||
| 833 | // Visit children | ||
| 834 |
2/2✓ Branch 4 → 5 taken 9735 times.
✓ Branch 4 → 10 taken 250 times.
|
9985 | if (ctx->assignExpr()) { |
| 835 | 9735 | returnStmtNode->hasReturnValue = true; | |
| 836 |
3/6✓ Branch 5 → 6 taken 9735 times.
✗ Branch 5 → 22 not taken.
✓ Branch 6 → 7 taken 9735 times.
✗ Branch 6 → 22 not taken.
✓ Branch 7 → 8 taken 9735 times.
✗ Branch 7 → 20 not taken.
|
9735 | returnStmtNode->assignExpr = std::any_cast<AssignExprNode *>(visit(ctx->assignExpr())); |
| 837 | } | ||
| 838 | |||
| 839 |
1/2✓ Branch 16 → 17 taken 9985 times.
✗ Branch 16 → 23 not taken.
|
9985 | return concludeNode(returnStmtNode); |
| 840 | } | ||
| 841 | |||
| 842 | 125 | std::any ASTBuilder::visitBreakStmt(SpiceParser::BreakStmtContext *ctx) { | |
| 843 | 125 | const auto breakStmtNode = createNode<BreakStmtNode>(ctx); | |
| 844 | |||
| 845 | // Extract number of breaks | ||
| 846 |
2/2✓ Branch 4 → 5 taken 6 times.
✓ Branch 4 → 10 taken 119 times.
|
125 | if (ctx->INT_LIT()) |
| 847 |
3/6✓ Branch 5 → 6 taken 6 times.
✗ Branch 5 → 24 not taken.
✓ Branch 6 → 7 taken 6 times.
✗ Branch 6 → 24 not taken.
✓ Branch 7 → 8 taken 6 times.
✗ Branch 7 → 22 not taken.
|
6 | breakStmtNode->breakTimes = std::stoi(ctx->INT_LIT()->toString()); |
| 848 | |||
| 849 | // Visit children | ||
| 850 |
1/2✓ Branch 10 → 11 taken 125 times.
✗ Branch 10 → 25 not taken.
|
125 | visitChildren(ctx); |
| 851 | |||
| 852 |
1/2✓ Branch 18 → 19 taken 125 times.
✗ Branch 18 → 26 not taken.
|
125 | return concludeNode(breakStmtNode); |
| 853 | } | ||
| 854 | |||
| 855 | 209 | std::any ASTBuilder::visitContinueStmt(SpiceParser::ContinueStmtContext *ctx) { | |
| 856 | 209 | const auto continueStmtNode = createNode<ContinueStmtNode>(ctx); | |
| 857 | |||
| 858 | // Extract number of continues | ||
| 859 |
2/2✓ Branch 4 → 5 taken 208 times.
✓ Branch 4 → 10 taken 1 time.
|
209 | if (ctx->INT_LIT()) |
| 860 |
3/6✓ Branch 5 → 6 taken 208 times.
✗ Branch 5 → 24 not taken.
✓ Branch 6 → 7 taken 208 times.
✗ Branch 6 → 24 not taken.
✓ Branch 7 → 8 taken 208 times.
✗ Branch 7 → 22 not taken.
|
208 | continueStmtNode->continueTimes = std::stoi(ctx->INT_LIT()->toString()); |
| 861 | |||
| 862 | // Visit children | ||
| 863 |
1/2✓ Branch 10 → 11 taken 209 times.
✗ Branch 10 → 25 not taken.
|
209 | visitChildren(ctx); |
| 864 | |||
| 865 |
1/2✓ Branch 18 → 19 taken 209 times.
✗ Branch 18 → 26 not taken.
|
209 | return concludeNode(continueStmtNode); |
| 866 | } | ||
| 867 | |||
| 868 | 6 | std::any ASTBuilder::visitFallthroughStmt(SpiceParser::FallthroughStmtContext *ctx) { | |
| 869 | 6 | const auto fallthroughStmtNode = createNode<FallthroughStmtNode>(ctx); | |
| 870 | |||
| 871 | // Visit children | ||
| 872 |
1/2✓ Branch 3 → 4 taken 6 times.
✗ Branch 3 → 15 not taken.
|
6 | visitChildren(ctx); |
| 873 | |||
| 874 |
1/2✓ Branch 11 → 12 taken 6 times.
✗ Branch 11 → 16 not taken.
|
6 | return concludeNode(fallthroughStmtNode); |
| 875 | } | ||
| 876 | |||
| 877 | 775 | std::any ASTBuilder::visitAssertStmt(SpiceParser::AssertStmtContext *ctx) { | |
| 878 |
1/2✓ Branch 2 → 3 taken 775 times.
✗ Branch 2 → 30 not taken.
|
775 | const auto assertStmtNode = createNode<AssertStmtNode>(ctx); |
| 879 | |||
| 880 | // Enrich | ||
| 881 |
5/10✓ Branch 3 → 4 taken 775 times.
✗ Branch 3 → 30 not taken.
✓ Branch 4 → 5 taken 775 times.
✗ Branch 4 → 30 not taken.
✓ Branch 5 → 6 taken 775 times.
✗ Branch 5 → 30 not taken.
✓ Branch 6 → 7 taken 775 times.
✗ Branch 6 → 30 not taken.
✓ Branch 7 → 8 taken 775 times.
✗ Branch 7 → 30 not taken.
|
775 | const antlr4::misc::Interval interval(ctx->assignExpr()->start->getStartIndex(), ctx->assignExpr()->stop->getStopIndex()); |
| 882 |
1/2✓ Branch 8 → 9 taken 775 times.
✗ Branch 8 → 25 not taken.
|
775 | assertStmtNode->expressionString = inputStream->getText(interval); |
| 883 | |||
| 884 | // Visit children | ||
| 885 |
3/6✓ Branch 11 → 12 taken 775 times.
✗ Branch 11 → 28 not taken.
✓ Branch 12 → 13 taken 775 times.
✗ Branch 12 → 28 not taken.
✓ Branch 13 → 14 taken 775 times.
✗ Branch 13 → 26 not taken.
|
775 | assertStmtNode->assignExpr = std::any_cast<AssignExprNode *>(visit(ctx->assignExpr())); |
| 886 | |||
| 887 |
1/2✓ Branch 21 → 22 taken 775 times.
✗ Branch 21 → 29 not taken.
|
775 | return concludeNode(assertStmtNode); |
| 888 | } | ||
| 889 | |||
| 890 | 2317 | std::any ASTBuilder::visitBuiltinCall(SpiceParser::BuiltinCallContext *ctx) { | |
| 891 | 2317 | const auto builtinCallNode = createNode<BuiltinCallNode>(ctx); | |
| 892 | |||
| 893 |
2/2✓ Branch 4 → 5 taken 866 times.
✓ Branch 4 → 10 taken 1451 times.
|
2317 | if (ctx->printfCall()) { |
| 894 |
3/6✓ Branch 5 → 6 taken 866 times.
✗ Branch 5 → 65 not taken.
✓ Branch 6 → 7 taken 866 times.
✗ Branch 6 → 65 not taken.
✓ Branch 7 → 8 taken 866 times.
✗ Branch 7 → 63 not taken.
|
866 | builtinCallNode->printfCall = std::any_cast<PrintfCallNode *>(visit(ctx->printfCall())); |
| 895 |
2/2✓ Branch 11 → 12 taken 281 times.
✓ Branch 11 → 17 taken 1170 times.
|
1451 | } else if (ctx->sizeOfCall()) { |
| 896 |
3/6✓ Branch 12 → 13 taken 281 times.
✗ Branch 12 → 68 not taken.
✓ Branch 13 → 14 taken 281 times.
✗ Branch 13 → 68 not taken.
✓ Branch 14 → 15 taken 281 times.
✗ Branch 14 → 66 not taken.
|
281 | builtinCallNode->sizeofCall = std::any_cast<SizeofCallNode *>(visit(ctx->sizeOfCall())); |
| 897 |
2/2✓ Branch 18 → 19 taken 11 times.
✓ Branch 18 → 24 taken 1159 times.
|
1170 | } else if (ctx->alignOfCall()) { |
| 898 |
3/6✓ Branch 19 → 20 taken 11 times.
✗ Branch 19 → 71 not taken.
✓ Branch 20 → 21 taken 11 times.
✗ Branch 20 → 71 not taken.
✓ Branch 21 → 22 taken 11 times.
✗ Branch 21 → 69 not taken.
|
11 | builtinCallNode->alignofCall = std::any_cast<AlignofCallNode *>(visit(ctx->alignOfCall())); |
| 899 |
2/2✓ Branch 25 → 26 taken 4 times.
✓ Branch 25 → 31 taken 1155 times.
|
1159 | } else if (ctx->typeIdCall()) { |
| 900 |
3/6✓ Branch 26 → 27 taken 4 times.
✗ Branch 26 → 74 not taken.
✓ Branch 27 → 28 taken 4 times.
✗ Branch 27 → 74 not taken.
✓ Branch 28 → 29 taken 4 times.
✗ Branch 28 → 72 not taken.
|
4 | builtinCallNode->typeidCall = std::any_cast<TypeidCallNode *>(visit(ctx->typeIdCall())); |
| 901 |
2/2✓ Branch 32 → 33 taken 142 times.
✓ Branch 32 → 38 taken 1013 times.
|
1155 | } else if (ctx->lenCall()) { |
| 902 |
3/6✓ Branch 33 → 34 taken 142 times.
✗ Branch 33 → 77 not taken.
✓ Branch 34 → 35 taken 142 times.
✗ Branch 34 → 77 not taken.
✓ Branch 35 → 36 taken 142 times.
✗ Branch 35 → 75 not taken.
|
142 | builtinCallNode->lenCall = std::any_cast<LenCallNode *>(visit(ctx->lenCall())); |
| 903 |
2/2✓ Branch 39 → 40 taken 1012 times.
✓ Branch 39 → 45 taken 1 time.
|
1013 | } else if (ctx->panicCall()) { |
| 904 |
3/6✓ Branch 40 → 41 taken 1012 times.
✗ Branch 40 → 80 not taken.
✓ Branch 41 → 42 taken 1012 times.
✗ Branch 41 → 80 not taken.
✓ Branch 42 → 43 taken 1012 times.
✗ Branch 42 → 78 not taken.
|
1012 | builtinCallNode->panicCall = std::any_cast<PanicCallNode *>(visit(ctx->panicCall())); |
| 905 |
1/2✓ Branch 46 → 47 taken 1 time.
✗ Branch 46 → 52 not taken.
|
1 | } else if (ctx->sysCall()) { |
| 906 |
3/6✓ Branch 47 → 48 taken 1 time.
✗ Branch 47 → 83 not taken.
✓ Branch 48 → 49 taken 1 time.
✗ Branch 48 → 83 not taken.
✓ Branch 49 → 50 taken 1 time.
✗ Branch 49 → 81 not taken.
|
1 | builtinCallNode->sysCall = std::any_cast<SysCallNode *>(visit(ctx->sysCall())); |
| 907 | } else { | ||
| 908 | − | assert_fail("Unknown builtin call"); // GCOV_EXCL_LINE | |
| 909 | } | ||
| 910 | |||
| 911 |
1/2✓ Branch 59 → 60 taken 2317 times.
✗ Branch 59 → 84 not taken.
|
2317 | return concludeNode(builtinCallNode); |
| 912 | } | ||
| 913 | |||
| 914 | 866 | std::any ASTBuilder::visitPrintfCall(SpiceParser::PrintfCallContext *ctx) { | |
| 915 |
1/2✓ Branch 2 → 3 taken 866 times.
✗ Branch 2 → 32 not taken.
|
866 | const auto printfCallNode = createNode<PrintfCallNode>(ctx); |
| 916 | |||
| 917 | // Enrich | ||
| 918 |
2/4✓ Branch 3 → 4 taken 866 times.
✗ Branch 3 → 32 not taken.
✓ Branch 4 → 5 taken 866 times.
✗ Branch 4 → 32 not taken.
|
866 | std::string templatedString = ctx->STRING_LIT()->getText(); |
| 919 |
1/2✓ Branch 6 → 7 taken 866 times.
✗ Branch 6 → 25 not taken.
|
866 | templatedString = templatedString.substr(1, templatedString.size() - 2); |
| 920 |
1/2✓ Branch 9 → 10 taken 866 times.
✗ Branch 9 → 30 not taken.
|
866 | replaceEscapeChars(templatedString); |
| 921 |
1/2✓ Branch 10 → 11 taken 866 times.
✗ Branch 10 → 30 not taken.
|
866 | printfCallNode->templatedString = templatedString; |
| 922 | |||
| 923 | // Visit children | ||
| 924 |
2/4✓ Branch 11 → 12 taken 866 times.
✗ Branch 11 → 28 not taken.
✓ Branch 12 → 13 taken 866 times.
✗ Branch 12 → 26 not taken.
|
866 | fetchChildrenIntoVector(printfCallNode->args, ctx->assignExpr()); |
| 925 | |||
| 926 |
1/2✓ Branch 20 → 21 taken 866 times.
✗ Branch 20 → 29 not taken.
|
1732 | return concludeNode(printfCallNode); |
| 927 | 866 | } | |
| 928 | |||
| 929 | 281 | std::any ASTBuilder::visitSizeOfCall(SpiceParser::SizeOfCallContext *ctx) { | |
| 930 | 281 | const auto sizeofCallNode = createNode<SizeofCallNode>(ctx); | |
| 931 | |||
| 932 | // Visit children | ||
| 933 |
2/2✓ Branch 4 → 5 taken 20 times.
✓ Branch 4 → 10 taken 261 times.
|
281 | if (ctx->assignExpr()) { |
| 934 |
3/6✓ Branch 5 → 6 taken 20 times.
✗ Branch 5 → 27 not taken.
✓ Branch 6 → 7 taken 20 times.
✗ Branch 6 → 27 not taken.
✓ Branch 7 → 8 taken 20 times.
✗ Branch 7 → 25 not taken.
|
20 | sizeofCallNode->assignExpr = std::any_cast<AssignExprNode *>(visit(ctx->assignExpr())); |
| 935 | } else { | ||
| 936 | 261 | sizeofCallNode->isType = true; | |
| 937 |
3/6✓ Branch 10 → 11 taken 261 times.
✗ Branch 10 → 30 not taken.
✓ Branch 11 → 12 taken 261 times.
✗ Branch 11 → 30 not taken.
✓ Branch 12 → 13 taken 261 times.
✗ Branch 12 → 28 not taken.
|
261 | sizeofCallNode->dataType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 938 | } | ||
| 939 | |||
| 940 |
1/2✓ Branch 21 → 22 taken 281 times.
✗ Branch 21 → 31 not taken.
|
281 | return concludeNode(sizeofCallNode); |
| 941 | } | ||
| 942 | |||
| 943 | 11 | std::any ASTBuilder::visitAlignOfCall(SpiceParser::AlignOfCallContext *ctx) { | |
| 944 | 11 | const auto alignofCallNode = createNode<AlignofCallNode>(ctx); | |
| 945 | |||
| 946 | // Visit children | ||
| 947 |
2/2✓ Branch 4 → 5 taken 10 times.
✓ Branch 4 → 10 taken 1 time.
|
11 | if (ctx->assignExpr()) { |
| 948 |
3/6✓ Branch 5 → 6 taken 10 times.
✗ Branch 5 → 27 not taken.
✓ Branch 6 → 7 taken 10 times.
✗ Branch 6 → 27 not taken.
✓ Branch 7 → 8 taken 10 times.
✗ Branch 7 → 25 not taken.
|
10 | alignofCallNode->assignExpr = std::any_cast<AssignExprNode *>(visit(ctx->assignExpr())); |
| 949 | } else { | ||
| 950 | 1 | alignofCallNode->isType = true; | |
| 951 |
3/6✓ Branch 10 → 11 taken 1 time.
✗ Branch 10 → 30 not taken.
✓ Branch 11 → 12 taken 1 time.
✗ Branch 11 → 30 not taken.
✓ Branch 12 → 13 taken 1 time.
✗ Branch 12 → 28 not taken.
|
1 | alignofCallNode->dataType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 952 | } | ||
| 953 | |||
| 954 |
1/2✓ Branch 21 → 22 taken 11 times.
✗ Branch 21 → 31 not taken.
|
11 | return concludeNode(alignofCallNode); |
| 955 | } | ||
| 956 | |||
| 957 | 4 | std::any ASTBuilder::visitTypeIdCall(SpiceParser::TypeIdCallContext *ctx) { | |
| 958 | 4 | const auto typeidCallNode = createNode<TypeidCallNode>(ctx); | |
| 959 | |||
| 960 | // Visit children | ||
| 961 |
2/2✓ Branch 4 → 5 taken 1 time.
✓ Branch 4 → 10 taken 3 times.
|
4 | if (ctx->assignExpr()) { |
| 962 |
3/6✓ Branch 5 → 6 taken 1 time.
✗ Branch 5 → 27 not taken.
✓ Branch 6 → 7 taken 1 time.
✗ Branch 6 → 27 not taken.
✓ Branch 7 → 8 taken 1 time.
✗ Branch 7 → 25 not taken.
|
1 | typeidCallNode->assignExpr = std::any_cast<AssignExprNode *>(visit(ctx->assignExpr())); |
| 963 | } else { | ||
| 964 | 3 | typeidCallNode->isType = true; | |
| 965 |
3/6✓ Branch 10 → 11 taken 3 times.
✗ Branch 10 → 30 not taken.
✓ Branch 11 → 12 taken 3 times.
✗ Branch 11 → 30 not taken.
✓ Branch 12 → 13 taken 3 times.
✗ Branch 12 → 28 not taken.
|
3 | typeidCallNode->dataType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 966 | } | ||
| 967 | |||
| 968 |
1/2✓ Branch 21 → 22 taken 4 times.
✗ Branch 21 → 31 not taken.
|
4 | return concludeNode(typeidCallNode); |
| 969 | } | ||
| 970 | |||
| 971 | 142 | std::any ASTBuilder::visitLenCall(SpiceParser::LenCallContext *ctx) { | |
| 972 | 142 | const auto lenCallNode = createNode<LenCallNode>(ctx); | |
| 973 | |||
| 974 | // Visit children | ||
| 975 |
3/6✓ Branch 3 → 4 taken 142 times.
✗ Branch 3 → 19 not taken.
✓ Branch 4 → 5 taken 142 times.
✗ Branch 4 → 19 not taken.
✓ Branch 5 → 6 taken 142 times.
✗ Branch 5 → 17 not taken.
|
142 | lenCallNode->assignExpr = std::any_cast<AssignExprNode *>(visit(ctx->assignExpr())); |
| 976 | |||
| 977 |
1/2✓ Branch 13 → 14 taken 142 times.
✗ Branch 13 → 20 not taken.
|
142 | return concludeNode(lenCallNode); |
| 978 | } | ||
| 979 | |||
| 980 | 1012 | std::any ASTBuilder::visitPanicCall(SpiceParser::PanicCallContext *ctx) { | |
| 981 | 1012 | const auto panicCallNode = createNode<PanicCallNode>(ctx); | |
| 982 | |||
| 983 | // Visit children | ||
| 984 |
3/6✓ Branch 3 → 4 taken 1012 times.
✗ Branch 3 → 19 not taken.
✓ Branch 4 → 5 taken 1012 times.
✗ Branch 4 → 19 not taken.
✓ Branch 5 → 6 taken 1012 times.
✗ Branch 5 → 17 not taken.
|
1012 | panicCallNode->assignExpr = std::any_cast<AssignExprNode *>(visit(ctx->assignExpr())); |
| 985 | |||
| 986 |
1/2✓ Branch 13 → 14 taken 1012 times.
✗ Branch 13 → 20 not taken.
|
1012 | return concludeNode(panicCallNode); |
| 987 | } | ||
| 988 | |||
| 989 | 1 | std::any ASTBuilder::visitSysCall(SpiceParser::SysCallContext *ctx) { | |
| 990 | 1 | const auto sysCallNode = createNode<SysCallNode>(ctx); | |
| 991 | |||
| 992 | // Visit children | ||
| 993 |
2/4✓ Branch 3 → 4 taken 1 time.
✗ Branch 3 → 18 not taken.
✓ Branch 4 → 5 taken 1 time.
✗ Branch 4 → 16 not taken.
|
1 | fetchChildrenIntoVector(sysCallNode->args, ctx->assignExpr()); |
| 994 | |||
| 995 |
1/2✓ Branch 12 → 13 taken 1 time.
✗ Branch 12 → 19 not taken.
|
1 | return concludeNode(sysCallNode); |
| 996 | } | ||
| 997 | |||
| 998 | 82438 | std::any ASTBuilder::visitAssignExpr(SpiceParser::AssignExprContext *ctx) { | |
| 999 | 82438 | const auto assignExprNode = createNode<AssignExprNode>(ctx); | |
| 1000 | |||
| 1001 | // Visit children | ||
| 1002 |
2/2✓ Branch 4 → 5 taken 74352 times.
✓ Branch 4 → 10 taken 8086 times.
|
82438 | if (ctx->ternaryExpr()) { |
| 1003 |
4/6✓ Branch 5 → 6 taken 74352 times.
✗ Branch 5 → 37 not taken.
✓ Branch 6 → 7 taken 74350 times.
✓ Branch 6 → 37 taken 2 times.
✓ Branch 7 → 8 taken 74350 times.
✗ Branch 7 → 35 not taken.
|
74352 | assignExprNode->ternaryExpr = std::any_cast<TernaryExprNode *>(visit(ctx->ternaryExpr())); |
| 1004 |
1/2✓ Branch 11 → 12 taken 8086 times.
✗ Branch 11 → 24 not taken.
|
8086 | } else if (ctx->prefixUnaryExpr()) { |
| 1005 |
3/6✓ Branch 12 → 13 taken 8086 times.
✗ Branch 12 → 40 not taken.
✓ Branch 13 → 14 taken 8086 times.
✗ Branch 13 → 40 not taken.
✓ Branch 14 → 15 taken 8086 times.
✗ Branch 14 → 38 not taken.
|
8086 | assignExprNode->lhs = std::any_cast<PrefixUnaryExprNode *>(visit(ctx->prefixUnaryExpr())); |
| 1006 |
2/4✓ Branch 16 → 17 taken 8086 times.
✗ Branch 16 → 41 not taken.
✓ Branch 17 → 18 taken 8086 times.
✗ Branch 17 → 41 not taken.
|
8086 | visit(ctx->assignOp()); |
| 1007 |
3/6✓ Branch 19 → 20 taken 8086 times.
✗ Branch 19 → 44 not taken.
✓ Branch 20 → 21 taken 8086 times.
✗ Branch 20 → 44 not taken.
✓ Branch 21 → 22 taken 8086 times.
✗ Branch 21 → 42 not taken.
|
8086 | assignExprNode->rhs = std::any_cast<AssignExprNode *>(visit(ctx->assignExpr())); |
| 1008 | } else { | ||
| 1009 | − | assert_fail("Invalid assign expression"); // GCOV_EXCL_LINE | |
| 1010 | } | ||
| 1011 | |||
| 1012 |
1/2✓ Branch 31 → 32 taken 82436 times.
✗ Branch 31 → 45 not taken.
|
82436 | return concludeNode(assignExprNode); |
| 1013 | } | ||
| 1014 | |||
| 1015 | 74586 | std::any ASTBuilder::visitTernaryExpr(SpiceParser::TernaryExprContext *ctx) { | |
| 1016 | 74586 | const auto ternaryExprNode = createNode<TernaryExprNode>(ctx); | |
| 1017 | |||
| 1018 |
4/6✓ Branch 3 → 4 taken 74586 times.
✗ Branch 3 → 41 not taken.
✓ Branch 4 → 5 taken 74584 times.
✓ Branch 4 → 41 taken 2 times.
✓ Branch 5 → 6 taken 74584 times.
✗ Branch 5 → 39 not taken.
|
74586 | ternaryExprNode->condition = std::any_cast<LogicalOrExprNode *>(visit(ctx->logicalOrExpr(0))); |
| 1019 |
3/4✓ Branch 7 → 8 taken 74584 times.
✗ Branch 7 → 42 not taken.
✓ Branch 10 → 11 taken 473 times.
✓ Branch 10 → 20 taken 74111 times.
|
74584 | if (ctx->logicalOrExpr().size() == 3) { |
| 1020 |
3/6✓ Branch 11 → 12 taken 473 times.
✗ Branch 11 → 45 not taken.
✓ Branch 12 → 13 taken 473 times.
✗ Branch 12 → 45 not taken.
✓ Branch 13 → 14 taken 473 times.
✗ Branch 13 → 43 not taken.
|
473 | ternaryExprNode->trueExpr = std::any_cast<LogicalOrExprNode *>(visit(ctx->logicalOrExpr(1))); |
| 1021 |
3/6✓ Branch 15 → 16 taken 473 times.
✗ Branch 15 → 48 not taken.
✓ Branch 16 → 17 taken 473 times.
✗ Branch 16 → 48 not taken.
✓ Branch 17 → 18 taken 473 times.
✗ Branch 17 → 46 not taken.
|
473 | ternaryExprNode->falseExpr = std::any_cast<LogicalOrExprNode *>(visit(ctx->logicalOrExpr(2))); |
| 1022 |
3/4✓ Branch 20 → 21 taken 74111 times.
✗ Branch 20 → 49 not taken.
✓ Branch 23 → 24 taken 1 time.
✓ Branch 23 → 29 taken 74110 times.
|
74111 | } else if (ctx->logicalOrExpr().size() == 2) { |
| 1023 | 1 | ternaryExprNode->isShortened = true; | |
| 1024 |
3/6✓ Branch 24 → 25 taken 1 time.
✗ Branch 24 → 52 not taken.
✓ Branch 25 → 26 taken 1 time.
✗ Branch 25 → 52 not taken.
✓ Branch 26 → 27 taken 1 time.
✗ Branch 26 → 50 not taken.
|
1 | ternaryExprNode->falseExpr = std::any_cast<LogicalOrExprNode *>(visit(ctx->logicalOrExpr(1))); |
| 1025 | } | ||
| 1026 | |||
| 1027 |
1/2✓ Branch 35 → 36 taken 74584 times.
✗ Branch 35 → 53 not taken.
|
74584 | return concludeNode(ternaryExprNode); |
| 1028 | } | ||
| 1029 | |||
| 1030 | 75533 | std::any ASTBuilder::visitLogicalOrExpr(SpiceParser::LogicalOrExprContext *ctx) { | |
| 1031 | 75533 | const auto logicalOrExprNode = createNode<LogicalOrExprNode>(ctx); | |
| 1032 | |||
| 1033 | // Visit children | ||
| 1034 |
3/4✓ Branch 3 → 4 taken 75533 times.
✗ Branch 3 → 18 not taken.
✓ Branch 4 → 5 taken 75531 times.
✓ Branch 4 → 16 taken 2 times.
|
75535 | fetchChildrenIntoVector(logicalOrExprNode->operands, ctx->logicalAndExpr()); |
| 1035 | |||
| 1036 |
1/2✓ Branch 12 → 13 taken 75531 times.
✗ Branch 12 → 19 not taken.
|
75531 | return concludeNode(logicalOrExprNode); |
| 1037 | } | ||
| 1038 | |||
| 1039 | 76878 | std::any ASTBuilder::visitLogicalAndExpr(SpiceParser::LogicalAndExprContext *ctx) { | |
| 1040 | 76878 | const auto logicalAndExprNode = createNode<LogicalAndExprNode>(ctx); | |
| 1041 | |||
| 1042 | // Visit children | ||
| 1043 |
3/4✓ Branch 3 → 4 taken 76878 times.
✗ Branch 3 → 18 not taken.
✓ Branch 4 → 5 taken 76876 times.
✓ Branch 4 → 16 taken 2 times.
|
76880 | fetchChildrenIntoVector(logicalAndExprNode->operands, ctx->bitwiseOrExpr()); |
| 1044 | |||
| 1045 |
1/2✓ Branch 12 → 13 taken 76876 times.
✗ Branch 12 → 19 not taken.
|
76876 | return concludeNode(logicalAndExprNode); |
| 1046 | } | ||
| 1047 | |||
| 1048 | 77178 | std::any ASTBuilder::visitBitwiseOrExpr(SpiceParser::BitwiseOrExprContext *ctx) { | |
| 1049 | 77178 | const auto bitwiseOrExprNode = createNode<BitwiseOrExprNode>(ctx); | |
| 1050 | |||
| 1051 | // Visit children | ||
| 1052 |
3/4✓ Branch 3 → 4 taken 77178 times.
✗ Branch 3 → 18 not taken.
✓ Branch 4 → 5 taken 77176 times.
✓ Branch 4 → 16 taken 2 times.
|
77180 | fetchChildrenIntoVector(bitwiseOrExprNode->operands, ctx->bitwiseXorExpr()); |
| 1053 | |||
| 1054 |
1/2✓ Branch 12 → 13 taken 77176 times.
✗ Branch 12 → 19 not taken.
|
77176 | return concludeNode(bitwiseOrExprNode); |
| 1055 | } | ||
| 1056 | |||
| 1057 | 77267 | std::any ASTBuilder::visitBitwiseXorExpr(SpiceParser::BitwiseXorExprContext *ctx) { | |
| 1058 | 77267 | const auto bitwiseXorExprNode = createNode<BitwiseXorExprNode>(ctx); | |
| 1059 | |||
| 1060 | // Visit children | ||
| 1061 |
3/4✓ Branch 3 → 4 taken 77267 times.
✗ Branch 3 → 18 not taken.
✓ Branch 4 → 5 taken 77265 times.
✓ Branch 4 → 16 taken 2 times.
|
77269 | fetchChildrenIntoVector(bitwiseXorExprNode->operands, ctx->bitwiseAndExpr()); |
| 1062 | |||
| 1063 |
1/2✓ Branch 12 → 13 taken 77265 times.
✗ Branch 12 → 19 not taken.
|
77265 | return concludeNode(bitwiseXorExprNode); |
| 1064 | } | ||
| 1065 | |||
| 1066 | 77279 | std::any ASTBuilder::visitBitwiseAndExpr(SpiceParser::BitwiseAndExprContext *ctx) { | |
| 1067 | 77279 | const auto bitwiseAndExprNode = createNode<BitwiseAndExprNode>(ctx); | |
| 1068 | |||
| 1069 | // Visit children | ||
| 1070 |
3/4✓ Branch 3 → 4 taken 77279 times.
✗ Branch 3 → 18 not taken.
✓ Branch 4 → 5 taken 77277 times.
✓ Branch 4 → 16 taken 2 times.
|
77281 | fetchChildrenIntoVector(bitwiseAndExprNode->operands, ctx->equalityExpr()); |
| 1071 | |||
| 1072 |
1/2✓ Branch 12 → 13 taken 77277 times.
✗ Branch 12 → 19 not taken.
|
77277 | return concludeNode(bitwiseAndExprNode); |
| 1073 | } | ||
| 1074 | |||
| 1075 | 77316 | std::any ASTBuilder::visitEqualityExpr(SpiceParser::EqualityExprContext *ctx) { | |
| 1076 | 77316 | const auto equalityExprNode = createNode<EqualityExprNode>(ctx); | |
| 1077 | |||
| 1078 | // Visit children | ||
| 1079 |
3/4✓ Branch 3 → 4 taken 77316 times.
✗ Branch 3 → 24 not taken.
✓ Branch 4 → 5 taken 77314 times.
✓ Branch 4 → 22 taken 2 times.
|
77318 | fetchChildrenIntoVector(equalityExprNode->operands, ctx->relationalExpr()); |
| 1080 | |||
| 1081 | // Extract operator | ||
| 1082 |
2/2✓ Branch 7 → 8 taken 4048 times.
✓ Branch 7 → 9 taken 73266 times.
|
77314 | if (ctx->EQUAL()) |
| 1083 | 4048 | equalityExprNode->op = EqualityExprNode::EqualityOp::OP_EQUAL; | |
| 1084 |
2/2✓ Branch 10 → 11 taken 1428 times.
✓ Branch 10 → 12 taken 71838 times.
|
73266 | else if (ctx->NOT_EQUAL()) |
| 1085 | 1428 | equalityExprNode->op = EqualityExprNode::EqualityOp::OP_NOT_EQUAL; | |
| 1086 | |||
| 1087 |
1/2✓ Branch 18 → 19 taken 77314 times.
✗ Branch 18 → 25 not taken.
|
77314 | return concludeNode(equalityExprNode); |
| 1088 | } | ||
| 1089 | |||
| 1090 | 82792 | std::any ASTBuilder::visitRelationalExpr(SpiceParser::RelationalExprContext *ctx) { | |
| 1091 | 82792 | const auto relationalExprNode = createNode<RelationalExprNode>(ctx); | |
| 1092 | |||
| 1093 | // Visit children | ||
| 1094 |
3/4✓ Branch 3 → 4 taken 82792 times.
✗ Branch 3 → 30 not taken.
✓ Branch 4 → 5 taken 82790 times.
✓ Branch 4 → 28 taken 2 times.
|
82794 | fetchChildrenIntoVector(relationalExprNode->operands, ctx->shiftExpr()); |
| 1095 | |||
| 1096 | // Extract operator | ||
| 1097 |
2/2✓ Branch 7 → 8 taken 2181 times.
✓ Branch 7 → 9 taken 80609 times.
|
82790 | if (ctx->LESS()) |
| 1098 | 2181 | relationalExprNode->op = RelationalExprNode::RelationalOp::OP_LESS; | |
| 1099 |
2/2✓ Branch 10 → 11 taken 721 times.
✓ Branch 10 → 12 taken 79888 times.
|
80609 | else if (ctx->GREATER()) |
| 1100 | 721 | relationalExprNode->op = RelationalExprNode::RelationalOp::OP_GREATER; | |
| 1101 |
2/2✓ Branch 13 → 14 taken 360 times.
✓ Branch 13 → 15 taken 79528 times.
|
79888 | else if (ctx->LESS_EQUAL()) |
| 1102 | 360 | relationalExprNode->op = RelationalExprNode::RelationalOp::OP_LESS_EQUAL; | |
| 1103 |
2/2✓ Branch 16 → 17 taken 871 times.
✓ Branch 16 → 18 taken 78657 times.
|
79528 | else if (ctx->GREATER_EQUAL()) |
| 1104 | 871 | relationalExprNode->op = RelationalExprNode::RelationalOp::OP_GREATER_EQUAL; | |
| 1105 | |||
| 1106 |
1/2✓ Branch 24 → 25 taken 82790 times.
✗ Branch 24 → 31 not taken.
|
82790 | return concludeNode(relationalExprNode); |
| 1107 | } | ||
| 1108 | |||
| 1109 | 86925 | std::any ASTBuilder::visitShiftExpr(SpiceParser::ShiftExprContext *ctx) { | |
| 1110 | 86925 | const auto shiftExprNode = createNode<ShiftExprNode>(ctx); | |
| 1111 | |||
| 1112 | // Visit children | ||
| 1113 |
3/4✓ Branch 3 → 4 taken 86925 times.
✗ Branch 3 → 48 not taken.
✓ Branch 4 → 5 taken 86923 times.
✓ Branch 4 → 46 taken 2 times.
|
86927 | fetchChildrenIntoVector(shiftExprNode->operands, ctx->additiveExpr()); |
| 1114 | |||
| 1115 | 86923 | bool seenFirstLess = false; | |
| 1116 | 86923 | bool seenFirstGreater = false; | |
| 1117 |
2/2✓ Branch 31 → 8 taken 87322 times.
✓ Branch 31 → 32 taken 86923 times.
|
174245 | for (ParserRuleContext::ParseTree *subTree : ctx->children) { |
| 1118 |
1/2✓ Branch 9 → 10 taken 87322 times.
✗ Branch 9 → 11 not taken.
|
87322 | const auto terminal = dynamic_cast<TerminalNode *>(subTree); |
| 1119 |
2/2✓ Branch 12 → 13 taken 87056 times.
✓ Branch 12 → 14 taken 266 times.
|
87322 | if (!terminal) |
| 1120 | 87056 | continue; | |
| 1121 | |||
| 1122 |
4/6✓ Branch 14 → 15 taken 266 times.
✗ Branch 14 → 53 not taken.
✓ Branch 15 → 16 taken 266 times.
✗ Branch 15 → 53 not taken.
✓ Branch 16 → 17 taken 156 times.
✓ Branch 16 → 21 taken 110 times.
|
266 | if (terminal->getSymbol()->getType() == SpiceParser::LESS) { |
| 1123 |
2/2✓ Branch 17 → 18 taken 78 times.
✓ Branch 17 → 20 taken 78 times.
|
156 | if (seenFirstLess) |
| 1124 |
1/2✓ Branch 18 → 19 taken 78 times.
✗ Branch 18 → 49 not taken.
|
78 | shiftExprNode->opQueue.emplace(ShiftExprNode::ShiftOp::OP_SHIFT_LEFT, TY_INVALID); |
| 1125 | 156 | seenFirstLess = !seenFirstLess; | |
| 1126 | 156 | continue; | |
| 1127 | } | ||
| 1128 | |||
| 1129 |
3/6✓ Branch 21 → 22 taken 110 times.
✗ Branch 21 → 53 not taken.
✓ Branch 22 → 23 taken 110 times.
✗ Branch 22 → 53 not taken.
✓ Branch 23 → 24 taken 110 times.
✗ Branch 23 → 28 not taken.
|
110 | if (terminal->getSymbol()->getType() == SpiceParser::GREATER) { |
| 1130 |
2/2✓ Branch 24 → 25 taken 55 times.
✓ Branch 24 → 27 taken 55 times.
|
110 | if (seenFirstGreater) |
| 1131 |
1/2✓ Branch 25 → 26 taken 55 times.
✗ Branch 25 → 51 not taken.
|
55 | shiftExprNode->opQueue.emplace(ShiftExprNode::ShiftOp::OP_SHIFT_RIGHT, TY_INVALID); |
| 1132 | 110 | seenFirstGreater = !seenFirstGreater; | |
| 1133 | 110 | continue; | |
| 1134 | } | ||
| 1135 | |||
| 1136 | − | assert_fail("Invalid terminal symbol for additive expression"); // GCOV_EXCL_LINE | |
| 1137 | } | ||
| 1138 |
2/4✓ Branch 32 → 33 taken 86923 times.
✗ Branch 32 → 35 not taken.
✓ Branch 33 → 34 taken 86923 times.
✗ Branch 33 → 35 not taken.
|
86923 | assert(!seenFirstLess && !seenFirstGreater); |
| 1139 | |||
| 1140 |
1/2✓ Branch 42 → 43 taken 86923 times.
✗ Branch 42 → 54 not taken.
|
86923 | return concludeNode(shiftExprNode); |
| 1141 | } | ||
| 1142 | |||
| 1143 | 87058 | std::any ASTBuilder::visitAdditiveExpr(SpiceParser::AdditiveExprContext *ctx) { | |
| 1144 | 87058 | const auto additiveExprNode = createNode<AdditiveExprNode>(ctx); | |
| 1145 | |||
| 1146 | // Visit children | ||
| 1147 |
3/4✓ Branch 3 → 4 taken 87058 times.
✗ Branch 3 → 40 not taken.
✓ Branch 4 → 5 taken 87056 times.
✓ Branch 4 → 38 taken 2 times.
|
87060 | fetchChildrenIntoVector(additiveExprNode->operands, ctx->multiplicativeExpr()); |
| 1148 | |||
| 1149 |
2/2✓ Branch 27 → 8 taken 95718 times.
✓ Branch 27 → 28 taken 87056 times.
|
182774 | for (ParserRuleContext::ParseTree *subTree : ctx->children) { |
| 1150 |
1/2✓ Branch 9 → 10 taken 95718 times.
✗ Branch 9 → 11 not taken.
|
95718 | const auto terminal = dynamic_cast<TerminalNode *>(subTree); |
| 1151 |
2/2✓ Branch 12 → 13 taken 91387 times.
✓ Branch 12 → 14 taken 4331 times.
|
95718 | if (!terminal) |
| 1152 | 91387 | continue; | |
| 1153 | |||
| 1154 |
4/6✓ Branch 14 → 15 taken 4331 times.
✗ Branch 14 → 45 not taken.
✓ Branch 15 → 16 taken 4331 times.
✗ Branch 15 → 45 not taken.
✓ Branch 16 → 17 taken 2614 times.
✓ Branch 16 → 19 taken 1717 times.
|
4331 | if (terminal->getSymbol()->getType() == SpiceParser::PLUS) |
| 1155 |
1/2✓ Branch 17 → 18 taken 2614 times.
✗ Branch 17 → 41 not taken.
|
2614 | additiveExprNode->opQueue.emplace(AdditiveExprNode::AdditiveOp::OP_PLUS, TY_INVALID); |
| 1156 |
3/6✓ Branch 19 → 20 taken 1717 times.
✗ Branch 19 → 45 not taken.
✓ Branch 20 → 21 taken 1717 times.
✗ Branch 20 → 45 not taken.
✓ Branch 21 → 22 taken 1717 times.
✗ Branch 21 → 24 not taken.
|
1717 | else if (terminal->getSymbol()->getType() == SpiceParser::MINUS) |
| 1157 |
1/2✓ Branch 22 → 23 taken 1717 times.
✗ Branch 22 → 43 not taken.
|
1717 | additiveExprNode->opQueue.emplace(AdditiveExprNode::AdditiveOp::OP_MINUS, TY_INVALID); |
| 1158 | else | ||
| 1159 | − | assert_fail("Invalid terminal symbol for additive expression"); // GCOV_EXCL_LINE | |
| 1160 | } | ||
| 1161 | |||
| 1162 |
1/2✓ Branch 34 → 35 taken 87056 times.
✗ Branch 34 → 46 not taken.
|
87056 | return concludeNode(additiveExprNode); |
| 1163 | } | ||
| 1164 | |||
| 1165 | 91389 | std::any ASTBuilder::visitMultiplicativeExpr(SpiceParser::MultiplicativeExprContext *ctx) { | |
| 1166 | 91389 | const auto multiplicativeExprNode = createNode<MultiplicativeExprNode>(ctx); | |
| 1167 | |||
| 1168 | // Visit children | ||
| 1169 |
3/4✓ Branch 3 → 4 taken 91389 times.
✗ Branch 3 → 45 not taken.
✓ Branch 4 → 5 taken 91387 times.
✓ Branch 4 → 43 taken 2 times.
|
91391 | fetchChildrenIntoVector(multiplicativeExprNode->operands, ctx->castExpr()); |
| 1170 | |||
| 1171 |
2/2✓ Branch 32 → 8 taken 94179 times.
✓ Branch 32 → 33 taken 91387 times.
|
185566 | for (ParserRuleContext::ParseTree *subTree : ctx->children) { |
| 1172 |
1/2✓ Branch 9 → 10 taken 94179 times.
✗ Branch 9 → 11 not taken.
|
94179 | const auto terminal = dynamic_cast<TerminalNode *>(subTree); |
| 1173 |
2/2✓ Branch 12 → 13 taken 92783 times.
✓ Branch 12 → 14 taken 1396 times.
|
94179 | if (!terminal) |
| 1174 | 92783 | continue; | |
| 1175 | |||
| 1176 |
4/6✓ Branch 14 → 15 taken 1396 times.
✗ Branch 14 → 52 not taken.
✓ Branch 15 → 16 taken 1396 times.
✗ Branch 15 → 52 not taken.
✓ Branch 16 → 17 taken 1044 times.
✓ Branch 16 → 19 taken 352 times.
|
1396 | if (terminal->getSymbol()->getType() == SpiceParser::MUL) |
| 1177 |
1/2✓ Branch 17 → 18 taken 1044 times.
✗ Branch 17 → 46 not taken.
|
1044 | multiplicativeExprNode->opQueue.emplace(MultiplicativeExprNode::MultiplicativeOp::OP_MUL, TY_INVALID); |
| 1178 |
4/6✓ Branch 19 → 20 taken 352 times.
✗ Branch 19 → 52 not taken.
✓ Branch 20 → 21 taken 352 times.
✗ Branch 20 → 52 not taken.
✓ Branch 21 → 22 taken 141 times.
✓ Branch 21 → 24 taken 211 times.
|
352 | else if (terminal->getSymbol()->getType() == SpiceParser::DIV) |
| 1179 |
1/2✓ Branch 22 → 23 taken 141 times.
✗ Branch 22 → 48 not taken.
|
141 | multiplicativeExprNode->opQueue.emplace(MultiplicativeExprNode::MultiplicativeOp::OP_DIV, TY_INVALID); |
| 1180 |
3/6✓ Branch 24 → 25 taken 211 times.
✗ Branch 24 → 52 not taken.
✓ Branch 25 → 26 taken 211 times.
✗ Branch 25 → 52 not taken.
✓ Branch 26 → 27 taken 211 times.
✗ Branch 26 → 29 not taken.
|
211 | else if (terminal->getSymbol()->getType() == SpiceParser::REM) |
| 1181 |
1/2✓ Branch 27 → 28 taken 211 times.
✗ Branch 27 → 50 not taken.
|
211 | multiplicativeExprNode->opQueue.emplace(MultiplicativeExprNode::MultiplicativeOp::OP_REM, TY_INVALID); |
| 1182 | else | ||
| 1183 | − | assert_fail("Invalid terminal symbol for multiplicative expression"); // GCOV_EXCL_LINE | |
| 1184 | } | ||
| 1185 | |||
| 1186 |
1/2✓ Branch 39 → 40 taken 91387 times.
✗ Branch 39 → 53 not taken.
|
91387 | return concludeNode(multiplicativeExprNode); |
| 1187 | } | ||
| 1188 | |||
| 1189 | 92785 | std::any ASTBuilder::visitCastExpr(SpiceParser::CastExprContext *ctx) { | |
| 1190 | 92785 | const auto castExprNode = createNode<CastExprNode>(ctx); | |
| 1191 | |||
| 1192 |
2/2✓ Branch 4 → 5 taken 2879 times.
✓ Branch 4 → 14 taken 89906 times.
|
92785 | if (ctx->dataType()) { |
| 1193 |
3/6✓ Branch 5 → 6 taken 2879 times.
✗ Branch 5 → 31 not taken.
✓ Branch 6 → 7 taken 2879 times.
✗ Branch 6 → 31 not taken.
✓ Branch 7 → 8 taken 2879 times.
✗ Branch 7 → 29 not taken.
|
2879 | castExprNode->dataType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 1194 |
3/6✓ Branch 9 → 10 taken 2879 times.
✗ Branch 9 → 34 not taken.
✓ Branch 10 → 11 taken 2879 times.
✗ Branch 10 → 34 not taken.
✓ Branch 11 → 12 taken 2879 times.
✗ Branch 11 → 32 not taken.
|
2879 | castExprNode->assignExpr = std::any_cast<AssignExprNode *>(visit(ctx->assignExpr())); |
| 1195 | 2879 | castExprNode->isCast = true; | |
| 1196 | } else { | ||
| 1197 |
4/6✓ Branch 14 → 15 taken 89906 times.
✗ Branch 14 → 37 not taken.
✓ Branch 15 → 16 taken 89904 times.
✓ Branch 15 → 37 taken 2 times.
✓ Branch 16 → 17 taken 89904 times.
✗ Branch 16 → 35 not taken.
|
89906 | castExprNode->prefixUnaryExpr = std::any_cast<PrefixUnaryExprNode *>(visit(ctx->prefixUnaryExpr())); |
| 1198 | } | ||
| 1199 | |||
| 1200 |
1/2✓ Branch 25 → 26 taken 92783 times.
✗ Branch 25 → 38 not taken.
|
92783 | return concludeNode(castExprNode); |
| 1201 | } | ||
| 1202 | |||
| 1203 | 99487 | std::any ASTBuilder::visitPrefixUnaryExpr(SpiceParser::PrefixUnaryExprContext *ctx) { | |
| 1204 | 99487 | const auto prefixUnaryExprNode = createNode<PrefixUnaryExprNode>(ctx); | |
| 1205 | |||
| 1206 | // Visit children | ||
| 1207 |
2/2✓ Branch 4 → 5 taken 97992 times.
✓ Branch 4 → 10 taken 1495 times.
|
99487 | if (ctx->postfixUnaryExpr()) { |
| 1208 |
4/6✓ Branch 5 → 6 taken 97992 times.
✗ Branch 5 → 51 not taken.
✓ Branch 6 → 7 taken 97990 times.
✓ Branch 6 → 51 taken 2 times.
✓ Branch 7 → 8 taken 97990 times.
✗ Branch 7 → 49 not taken.
|
97992 | prefixUnaryExprNode->postfixUnaryExpr = std::any_cast<PostfixUnaryExprNode *>(visit(ctx->postfixUnaryExpr())); |
| 1209 |
1/2✓ Branch 11 → 12 taken 1495 times.
✗ Branch 11 → 38 not taken.
|
1495 | } else if (ctx->prefixUnaryExpr()) { |
| 1210 | // Extract operator | ||
| 1211 |
2/2✓ Branch 13 → 14 taken 78 times.
✓ Branch 13 → 15 taken 1417 times.
|
1495 | if (ctx->MINUS()) |
| 1212 | 78 | prefixUnaryExprNode->op = PrefixUnaryExprNode::PrefixUnaryOp::OP_MINUS; | |
| 1213 |
2/2✓ Branch 16 → 17 taken 22 times.
✓ Branch 16 → 18 taken 1395 times.
|
1417 | else if (ctx->PLUS_PLUS()) |
| 1214 | 22 | prefixUnaryExprNode->op = PrefixUnaryExprNode::PrefixUnaryOp::OP_PLUS_PLUS; | |
| 1215 |
2/2✓ Branch 19 → 20 taken 10 times.
✓ Branch 19 → 21 taken 1385 times.
|
1395 | else if (ctx->MINUS_MINUS()) |
| 1216 | 10 | prefixUnaryExprNode->op = PrefixUnaryExprNode::PrefixUnaryOp::OP_MINUS_MINUS; | |
| 1217 |
2/2✓ Branch 22 → 23 taken 871 times.
✓ Branch 22 → 24 taken 514 times.
|
1385 | else if (ctx->NOT()) |
| 1218 | 871 | prefixUnaryExprNode->op = PrefixUnaryExprNode::PrefixUnaryOp::OP_NOT; | |
| 1219 |
2/2✓ Branch 25 → 26 taken 2 times.
✓ Branch 25 → 27 taken 512 times.
|
514 | else if (ctx->BITWISE_NOT()) |
| 1220 | 2 | prefixUnaryExprNode->op = PrefixUnaryExprNode::PrefixUnaryOp::OP_BITWISE_NOT; | |
| 1221 |
2/2✓ Branch 28 → 29 taken 254 times.
✓ Branch 28 → 30 taken 258 times.
|
512 | else if (ctx->MUL()) |
| 1222 | 254 | prefixUnaryExprNode->op = PrefixUnaryExprNode::PrefixUnaryOp::OP_DEREFERENCE; | |
| 1223 |
1/2✓ Branch 31 → 32 taken 258 times.
✗ Branch 31 → 33 not taken.
|
258 | else if (ctx->BITWISE_AND()) |
| 1224 | 258 | prefixUnaryExprNode->op = PrefixUnaryExprNode::PrefixUnaryOp::OP_ADDRESS_OF; | |
| 1225 | |||
| 1226 |
3/6✓ Branch 33 → 34 taken 1495 times.
✗ Branch 33 → 54 not taken.
✓ Branch 34 → 35 taken 1495 times.
✗ Branch 34 → 54 not taken.
✓ Branch 35 → 36 taken 1495 times.
✗ Branch 35 → 52 not taken.
|
1495 | prefixUnaryExprNode->prefixUnaryExpr = std::any_cast<PrefixUnaryExprNode *>(visit(ctx->prefixUnaryExpr())); |
| 1227 | } else { | ||
| 1228 | − | assert_fail("Unknown prefix unary expression type"); // GCOV_EXCL_LINE | |
| 1229 | } | ||
| 1230 | |||
| 1231 |
1/2✓ Branch 45 → 46 taken 99485 times.
✗ Branch 45 → 55 not taken.
|
99485 | return concludeNode(prefixUnaryExprNode); |
| 1232 | } | ||
| 1233 | |||
| 1234 | 123878 | std::any ASTBuilder::visitPostfixUnaryExpr(SpiceParser::PostfixUnaryExprContext *ctx) { | |
| 1235 | 123878 | const auto postfixUnaryExprNode = createNode<PostfixUnaryExprNode>(ctx); | |
| 1236 | |||
| 1237 |
2/2✓ Branch 4 → 5 taken 97992 times.
✓ Branch 4 → 10 taken 25886 times.
|
123878 | if (ctx->atomicExpr()) { |
| 1238 |
4/6✓ Branch 5 → 6 taken 97992 times.
✗ Branch 5 → 49 not taken.
✓ Branch 6 → 7 taken 97990 times.
✓ Branch 6 → 49 taken 2 times.
✓ Branch 7 → 8 taken 97990 times.
✗ Branch 7 → 47 not taken.
|
97992 | postfixUnaryExprNode->atomicExpr = std::any_cast<AtomicExprNode *>(visit(ctx->atomicExpr())); |
| 1239 |
1/2✓ Branch 11 → 12 taken 25886 times.
✗ Branch 11 → 36 not taken.
|
25886 | } else if (ctx->postfixUnaryExpr()) { |
| 1240 |
3/6✓ Branch 12 → 13 taken 25886 times.
✗ Branch 12 → 52 not taken.
✓ Branch 13 → 14 taken 25886 times.
✗ Branch 13 → 52 not taken.
✓ Branch 14 → 15 taken 25886 times.
✗ Branch 14 → 50 not taken.
|
25886 | postfixUnaryExprNode->postfixUnaryExpr = std::any_cast<PostfixUnaryExprNode *>(visit(ctx->postfixUnaryExpr())); |
| 1241 | |||
| 1242 | // Extract operator | ||
| 1243 |
2/2✓ Branch 17 → 18 taken 4347 times.
✓ Branch 17 → 23 taken 21539 times.
|
25886 | if (ctx->assignExpr()) { |
| 1244 | 4347 | postfixUnaryExprNode->op = PostfixUnaryExprNode::PostfixUnaryOp::OP_SUBSCRIPT; | |
| 1245 |
3/6✓ Branch 18 → 19 taken 4347 times.
✗ Branch 18 → 55 not taken.
✓ Branch 19 → 20 taken 4347 times.
✗ Branch 19 → 55 not taken.
✓ Branch 20 → 21 taken 4347 times.
✗ Branch 20 → 53 not taken.
|
4347 | postfixUnaryExprNode->subscriptIndexExpr = std::any_cast<AssignExprNode *>(visit(ctx->assignExpr())); |
| 1246 |
2/2✓ Branch 24 → 25 taken 19016 times.
✓ Branch 24 → 30 taken 2523 times.
|
21539 | } else if (ctx->IDENTIFIER()) { |
| 1247 | 19016 | postfixUnaryExprNode->op = PostfixUnaryExprNode::PostfixUnaryOp::OP_MEMBER_ACCESS; | |
| 1248 |
2/4✓ Branch 25 → 26 taken 19016 times.
✗ Branch 25 → 56 not taken.
✓ Branch 26 → 27 taken 19016 times.
✗ Branch 26 → 56 not taken.
|
19016 | postfixUnaryExprNode->identifier = getIdentifier(ctx->IDENTIFIER(), false); |
| 1249 |
2/2✓ Branch 31 → 32 taken 1993 times.
✓ Branch 31 → 33 taken 530 times.
|
2523 | } else if (ctx->PLUS_PLUS()) { |
| 1250 | 1993 | postfixUnaryExprNode->op = PostfixUnaryExprNode::PostfixUnaryOp::OP_PLUS_PLUS; | |
| 1251 |
1/2✓ Branch 34 → 35 taken 530 times.
✗ Branch 34 → 37 not taken.
|
530 | } else if (ctx->MINUS_MINUS()) { |
| 1252 | 530 | postfixUnaryExprNode->op = PostfixUnaryExprNode::PostfixUnaryOp::OP_MINUS_MINUS; | |
| 1253 | } | ||
| 1254 | } else { | ||
| 1255 | − | assert_fail("Unknown postfix unary expression type"); // GCOV_EXCL_LINE | |
| 1256 | } | ||
| 1257 | |||
| 1258 |
1/2✓ Branch 43 → 44 taken 123876 times.
✗ Branch 43 → 57 not taken.
|
123876 | return concludeNode(postfixUnaryExprNode); |
| 1259 | } | ||
| 1260 | |||
| 1261 | 97992 | std::any ASTBuilder::visitAtomicExpr(SpiceParser::AtomicExprContext *ctx) { | |
| 1262 | 97992 | const auto atomicExprNode = createNode<AtomicExprNode>(ctx); | |
| 1263 | |||
| 1264 | // Visit children | ||
| 1265 |
2/2✓ Branch 4 → 5 taken 18478 times.
✓ Branch 4 → 10 taken 79514 times.
|
97992 | if (ctx->constant()) { |
| 1266 |
4/6✓ Branch 5 → 6 taken 18478 times.
✗ Branch 5 → 91 not taken.
✓ Branch 6 → 7 taken 18476 times.
✓ Branch 6 → 91 taken 2 times.
✓ Branch 7 → 8 taken 18476 times.
✗ Branch 7 → 89 not taken.
|
18478 | atomicExprNode->constant = std::any_cast<ConstantNode *>(visit(ctx->constant())); |
| 1267 |
2/2✓ Branch 11 → 12 taken 19357 times.
✓ Branch 11 → 17 taken 60157 times.
|
79514 | } else if (ctx->value()) { |
| 1268 |
3/6✓ Branch 12 → 13 taken 19357 times.
✗ Branch 12 → 94 not taken.
✓ Branch 13 → 14 taken 19357 times.
✗ Branch 13 → 94 not taken.
✓ Branch 14 → 15 taken 19357 times.
✗ Branch 14 → 92 not taken.
|
19357 | atomicExprNode->value = std::any_cast<ValueNode *>(visit(ctx->value())); |
| 1269 |
11/18✓ Branch 17 → 18 taken 60157 times.
✗ Branch 17 → 95 not taken.
✓ Branch 19 → 20 taken 4847 times.
✓ Branch 19 → 23 taken 55310 times.
✓ Branch 20 → 21 taken 4847 times.
✗ Branch 20 → 95 not taken.
✓ Branch 22 → 23 taken 1831 times.
✓ Branch 22 → 24 taken 3016 times.
✓ Branch 25 → 26 taken 4847 times.
✓ Branch 25 → 27 taken 55310 times.
✓ Branch 27 → 28 taken 60157 times.
✗ Branch 27 → 29 not taken.
✓ Branch 29 → 30 taken 57141 times.
✓ Branch 29 → 64 taken 3016 times.
✗ Branch 95 → 96 not taken.
✗ Branch 95 → 97 not taken.
✗ Branch 99 → 100 not taken.
✗ Branch 99 → 101 not taken.
|
60157 | } else if (!ctx->IDENTIFIER().empty() || !ctx->TYPE_IDENTIFIER().empty()) { |
| 1270 |
2/2✓ Branch 62 → 32 taken 57769 times.
✓ Branch 62 → 63 taken 57141 times.
|
114910 | for (ParserRuleContext::ParseTree *subTree : ctx->children) { |
| 1271 |
1/2✓ Branch 33 → 34 taken 57769 times.
✗ Branch 33 → 35 not taken.
|
57769 | const auto terminal = dynamic_cast<TerminalNode *>(subTree); |
| 1272 |
1/2✗ Branch 36 → 37 not taken.
✓ Branch 36 → 38 taken 57769 times.
|
57769 | if (!terminal) |
| 1273 | ✗ | continue; | |
| 1274 | |||
| 1275 |
4/6✓ Branch 38 → 39 taken 57769 times.
✗ Branch 38 → 109 not taken.
✓ Branch 39 → 40 taken 57769 times.
✗ Branch 39 → 109 not taken.
✓ Branch 40 → 41 taken 55310 times.
✓ Branch 40 → 49 taken 2459 times.
|
57769 | if (terminal->getSymbol()->getType() == SpiceParser::IDENTIFIER) { |
| 1276 |
1/2✓ Branch 41 → 42 taken 55310 times.
✗ Branch 41 → 105 not taken.
|
55310 | std::string fragment = getIdentifier(terminal, false); |
| 1277 |
1/2✓ Branch 42 → 43 taken 55310 times.
✗ Branch 42 → 103 not taken.
|
55310 | atomicExprNode->identifierFragments.push_back(fragment); |
| 1278 |
1/2✗ Branch 44 → 45 not taken.
✓ Branch 44 → 46 taken 55310 times.
|
55310 | if (!atomicExprNode->fqIdentifier.empty()) |
| 1279 | ✗ | atomicExprNode->fqIdentifier += SCOPE_ACCESS_TOKEN; | |
| 1280 |
1/2✓ Branch 46 → 47 taken 55310 times.
✗ Branch 46 → 103 not taken.
|
55310 | atomicExprNode->fqIdentifier += fragment; |
| 1281 |
4/6✓ Branch 49 → 50 taken 2459 times.
✗ Branch 49 → 109 not taken.
✓ Branch 50 → 51 taken 2459 times.
✗ Branch 50 → 109 not taken.
✓ Branch 51 → 52 taken 2145 times.
✓ Branch 51 → 60 taken 314 times.
|
57769 | } else if (terminal->getSymbol()->getType() == SpiceParser::TYPE_IDENTIFIER) { |
| 1282 |
1/2✓ Branch 52 → 53 taken 2145 times.
✗ Branch 52 → 108 not taken.
|
2145 | std::string fragment = getIdentifier(terminal, false); |
| 1283 |
1/2✓ Branch 53 → 54 taken 2145 times.
✗ Branch 53 → 106 not taken.
|
2145 | atomicExprNode->identifierFragments.push_back(fragment); |
| 1284 |
2/2✓ Branch 55 → 56 taken 314 times.
✓ Branch 55 → 57 taken 1831 times.
|
2145 | if (!atomicExprNode->fqIdentifier.empty()) |
| 1285 |
1/2✓ Branch 56 → 57 taken 314 times.
✗ Branch 56 → 106 not taken.
|
314 | atomicExprNode->fqIdentifier += SCOPE_ACCESS_TOKEN; |
| 1286 |
1/2✓ Branch 57 → 58 taken 2145 times.
✗ Branch 57 → 106 not taken.
|
2145 | atomicExprNode->fqIdentifier += fragment; |
| 1287 | 2145 | } | |
| 1288 | } | ||
| 1289 |
2/2✓ Branch 65 → 66 taken 2317 times.
✓ Branch 65 → 71 taken 699 times.
|
3016 | } else if (ctx->builtinCall()) { |
| 1290 |
3/6✓ Branch 66 → 67 taken 2317 times.
✗ Branch 66 → 112 not taken.
✓ Branch 67 → 68 taken 2317 times.
✗ Branch 67 → 112 not taken.
✓ Branch 68 → 69 taken 2317 times.
✗ Branch 68 → 110 not taken.
|
2317 | atomicExprNode->builtinCall = std::any_cast<BuiltinCallNode *>(visit(ctx->builtinCall())); |
| 1291 |
1/2✓ Branch 72 → 73 taken 699 times.
✗ Branch 72 → 78 not taken.
|
699 | } else if (ctx->assignExpr()) { |
| 1292 |
3/6✓ Branch 73 → 74 taken 699 times.
✗ Branch 73 → 115 not taken.
✓ Branch 74 → 75 taken 699 times.
✗ Branch 74 → 115 not taken.
✓ Branch 75 → 76 taken 699 times.
✗ Branch 75 → 113 not taken.
|
699 | atomicExprNode->assignExpr = std::any_cast<AssignExprNode *>(visit(ctx->assignExpr())); |
| 1293 | } else { | ||
| 1294 | − | assert_fail("Unknown atomic expression type"); // GCOV_EXCL_LINE | |
| 1295 | } | ||
| 1296 | |||
| 1297 |
1/2✓ Branch 85 → 86 taken 97990 times.
✗ Branch 85 → 116 not taken.
|
97990 | return concludeNode(atomicExprNode); |
| 1298 | } | ||
| 1299 | |||
| 1300 | 19357 | std::any ASTBuilder::visitValue(SpiceParser::ValueContext *ctx) { | |
| 1301 | 19357 | const auto valueNode = createNode<ValueNode>(ctx); | |
| 1302 | |||
| 1303 | // Visit children | ||
| 1304 |
2/2✓ Branch 4 → 5 taken 17469 times.
✓ Branch 4 → 10 taken 1888 times.
|
19357 | if (ctx->fctCall()) { |
| 1305 |
3/6✓ Branch 5 → 6 taken 17469 times.
✗ Branch 5 → 65 not taken.
✓ Branch 6 → 7 taken 17469 times.
✗ Branch 6 → 65 not taken.
✓ Branch 7 → 8 taken 17469 times.
✗ Branch 7 → 63 not taken.
|
17469 | valueNode->fctCall = std::any_cast<FctCallNode *>(visit(ctx->fctCall())); |
| 1306 |
2/2✓ Branch 11 → 12 taken 75 times.
✓ Branch 11 → 17 taken 1813 times.
|
1888 | } else if (ctx->arrayInitialization()) { |
| 1307 |
3/6✓ Branch 12 → 13 taken 75 times.
✗ Branch 12 → 68 not taken.
✓ Branch 13 → 14 taken 75 times.
✗ Branch 13 → 68 not taken.
✓ Branch 14 → 15 taken 75 times.
✗ Branch 14 → 66 not taken.
|
75 | valueNode->arrayInitialization = std::any_cast<ArrayInitializationNode *>(visit(ctx->arrayInitialization())); |
| 1308 |
2/2✓ Branch 18 → 19 taken 224 times.
✓ Branch 18 → 24 taken 1589 times.
|
1813 | } else if (ctx->structInstantiation()) { |
| 1309 |
3/6✓ Branch 19 → 20 taken 224 times.
✗ Branch 19 → 71 not taken.
✓ Branch 20 → 21 taken 224 times.
✗ Branch 20 → 71 not taken.
✓ Branch 21 → 22 taken 224 times.
✗ Branch 21 → 69 not taken.
|
224 | valueNode->structInstantiation = std::any_cast<StructInstantiationNode *>(visit(ctx->structInstantiation())); |
| 1310 |
2/2✓ Branch 25 → 26 taken 16 times.
✓ Branch 25 → 31 taken 1573 times.
|
1589 | } else if (ctx->lambdaFunc()) { |
| 1311 |
3/6✓ Branch 26 → 27 taken 16 times.
✗ Branch 26 → 74 not taken.
✓ Branch 27 → 28 taken 16 times.
✗ Branch 27 → 74 not taken.
✓ Branch 28 → 29 taken 16 times.
✗ Branch 28 → 72 not taken.
|
16 | valueNode->lambdaFunc = std::any_cast<LambdaFuncNode *>(visit(ctx->lambdaFunc())); |
| 1312 |
2/2✓ Branch 32 → 33 taken 31 times.
✓ Branch 32 → 38 taken 1542 times.
|
1573 | } else if (ctx->lambdaProc()) { |
| 1313 |
3/6✓ Branch 33 → 34 taken 31 times.
✗ Branch 33 → 77 not taken.
✓ Branch 34 → 35 taken 31 times.
✗ Branch 34 → 77 not taken.
✓ Branch 35 → 36 taken 31 times.
✗ Branch 35 → 75 not taken.
|
31 | valueNode->lambdaProc = std::any_cast<LambdaProcNode *>(visit(ctx->lambdaProc())); |
| 1314 |
2/2✓ Branch 39 → 40 taken 1 time.
✓ Branch 39 → 45 taken 1541 times.
|
1542 | } else if (ctx->lambdaExpr()) { |
| 1315 |
3/6✓ Branch 40 → 41 taken 1 time.
✗ Branch 40 → 80 not taken.
✓ Branch 41 → 42 taken 1 time.
✗ Branch 41 → 80 not taken.
✓ Branch 42 → 43 taken 1 time.
✗ Branch 42 → 78 not taken.
|
1 | valueNode->lambdaExpr = std::any_cast<LambdaExprNode *>(visit(ctx->lambdaExpr())); |
| 1316 |
1/2✓ Branch 46 → 47 taken 1541 times.
✗ Branch 46 → 52 not taken.
|
1541 | } else if (ctx->dataType()) { |
| 1317 | 1541 | valueNode->isNil = true; | |
| 1318 |
3/6✓ Branch 47 → 48 taken 1541 times.
✗ Branch 47 → 83 not taken.
✓ Branch 48 → 49 taken 1541 times.
✗ Branch 48 → 83 not taken.
✓ Branch 49 → 50 taken 1541 times.
✗ Branch 49 → 81 not taken.
|
1541 | valueNode->nilType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 1319 | } else { | ||
| 1320 | − | assert_fail("Unknown value type"); // GCOV_EXCL_LINE | |
| 1321 | } | ||
| 1322 | |||
| 1323 |
1/2✓ Branch 59 → 60 taken 19357 times.
✗ Branch 59 → 84 not taken.
|
19357 | return concludeNode(valueNode); |
| 1324 | } | ||
| 1325 | |||
| 1326 | 20498 | std::any ASTBuilder::visitConstant(SpiceParser::ConstantContext *ctx) { | |
| 1327 | 20498 | const auto constantNode = createNode<ConstantNode>(ctx); | |
| 1328 | |||
| 1329 | // Enrich | ||
| 1330 |
2/2✓ Branch 4 → 5 taken 652 times.
✓ Branch 4 → 10 taken 19846 times.
|
20498 | if (ctx->DOUBLE_LIT()) { |
| 1331 | 652 | constantNode->type = ConstantNode::PrimitiveValueType::TYPE_DOUBLE; | |
| 1332 |
3/6✓ Branch 5 → 6 taken 652 times.
✗ Branch 5 → 59 not taken.
✓ Branch 6 → 7 taken 652 times.
✗ Branch 6 → 59 not taken.
✓ Branch 7 → 8 taken 652 times.
✗ Branch 7 → 57 not taken.
|
652 | constantNode->compileTimeValue.doubleValue = std::stod(ctx->DOUBLE_LIT()->toString()); |
| 1333 |
2/2✓ Branch 11 → 12 taken 4594 times.
✓ Branch 11 → 15 taken 15252 times.
|
19846 | } else if (ctx->INT_LIT()) { |
| 1334 | 4594 | constantNode->type = ConstantNode::PrimitiveValueType::TYPE_INT; | |
| 1335 | 4594 | constantNode->compileTimeValue.intValue = parseInt(ctx->INT_LIT()); | |
| 1336 |
2/2✓ Branch 16 → 17 taken 872 times.
✓ Branch 16 → 20 taken 14380 times.
|
15252 | } else if (ctx->SHORT_LIT()) { |
| 1337 | 872 | constantNode->type = ConstantNode::PrimitiveValueType::TYPE_SHORT; | |
| 1338 | 872 | constantNode->compileTimeValue.shortValue = parseShort(ctx->SHORT_LIT()); | |
| 1339 |
2/2✓ Branch 21 → 22 taken 6400 times.
✓ Branch 21 → 25 taken 7980 times.
|
14380 | } else if (ctx->LONG_LIT()) { |
| 1340 | 6400 | constantNode->type = ConstantNode::PrimitiveValueType::TYPE_LONG; | |
| 1341 | 6400 | constantNode->compileTimeValue.longValue = parseLong(ctx->LONG_LIT()); | |
| 1342 |
2/2✓ Branch 26 → 27 taken 2968 times.
✓ Branch 26 → 30 taken 5012 times.
|
7980 | } else if (ctx->CHAR_LIT()) { |
| 1343 | 2968 | constantNode->type = ConstantNode::PrimitiveValueType::TYPE_CHAR; | |
| 1344 | 2968 | constantNode->compileTimeValue.charValue = parseChar(ctx->CHAR_LIT()); | |
| 1345 |
2/2✓ Branch 31 → 32 taken 2723 times.
✓ Branch 31 → 40 taken 2289 times.
|
5012 | } else if (ctx->STRING_LIT()) { |
| 1346 | // Save a pointer to the string in the compile time value | ||
| 1347 | 2723 | constantNode->type = ConstantNode::PrimitiveValueType::TYPE_STRING; | |
| 1348 | 2723 | constantNode->compileTimeValue.stringValueOffset = resourceManager.compileTimeStringValues.size(); | |
| 1349 | // Add the string to the global compile time string list | ||
| 1350 |
4/8✓ Branch 33 → 34 taken 2723 times.
✗ Branch 33 → 64 not taken.
✓ Branch 34 → 35 taken 2723 times.
✗ Branch 34 → 64 not taken.
✓ Branch 35 → 36 taken 2723 times.
✗ Branch 35 → 62 not taken.
✓ Branch 36 → 37 taken 2723 times.
✗ Branch 36 → 60 not taken.
|
2723 | resourceManager.compileTimeStringValues.push_back(parseString(ctx->STRING_LIT()->toString())); |
| 1351 |
2/2✓ Branch 41 → 42 taken 1174 times.
✓ Branch 41 → 43 taken 1115 times.
|
2289 | } else if (ctx->TRUE()) { |
| 1352 | 1174 | constantNode->type = ConstantNode::PrimitiveValueType::TYPE_BOOL; | |
| 1353 | 1174 | constantNode->compileTimeValue.boolValue = true; | |
| 1354 |
1/2✓ Branch 44 → 45 taken 1115 times.
✗ Branch 44 → 46 not taken.
|
1115 | } else if (ctx->FALSE()) { |
| 1355 | 1115 | constantNode->type = ConstantNode::PrimitiveValueType::TYPE_BOOL; | |
| 1356 | 1115 | constantNode->compileTimeValue.boolValue = false; | |
| 1357 | } else { | ||
| 1358 | − | assert_fail("Unknown constant type"); // GCOV_EXCL_LINE | |
| 1359 | } | ||
| 1360 | |||
| 1361 |
1/2✓ Branch 53 → 54 taken 20496 times.
✗ Branch 53 → 66 not taken.
|
20496 | return concludeNode(constantNode); |
| 1362 | } | ||
| 1363 | |||
| 1364 | 17469 | std::any ASTBuilder::visitFctCall(SpiceParser::FctCallContext *ctx) { | |
| 1365 | 17469 | const auto fctCallNode = createNode<FctCallNode>(ctx); | |
| 1366 | |||
| 1367 |
2/2✓ Branch 37 → 5 taken 85842 times.
✓ Branch 37 → 38 taken 17469 times.
|
103311 | for (antlr4::ParserRuleContext::ParseTree *subTree : ctx->children) { |
| 1368 |
1/2✓ Branch 6 → 7 taken 85842 times.
✗ Branch 6 → 8 not taken.
|
85842 | const auto terminal = dynamic_cast<antlr4::tree::TerminalNode *>(subTree); |
| 1369 |
2/2✓ Branch 9 → 10 taken 14583 times.
✓ Branch 9 → 11 taken 71259 times.
|
85842 | if (!terminal) |
| 1370 | 14583 | continue; | |
| 1371 | |||
| 1372 |
4/6✓ Branch 11 → 12 taken 71259 times.
✗ Branch 11 → 68 not taken.
✓ Branch 12 → 13 taken 71259 times.
✗ Branch 12 → 68 not taken.
✓ Branch 13 → 14 taken 22704 times.
✓ Branch 13 → 19 taken 48555 times.
|
71259 | if (terminal->getSymbol()->getType() == SpiceParser::IDENTIFIER) { |
| 1373 |
1/2✓ Branch 14 → 15 taken 22704 times.
✗ Branch 14 → 64 not taken.
|
22704 | const std::string fragment = terminal->toString(); |
| 1374 |
1/2✓ Branch 15 → 16 taken 22704 times.
✗ Branch 15 → 62 not taken.
|
22704 | fctCallNode->functionNameFragments.push_back(fragment); |
| 1375 |
1/2✓ Branch 16 → 17 taken 22704 times.
✗ Branch 16 → 62 not taken.
|
22704 | fctCallNode->fqFunctionName += fragment; |
| 1376 |
4/6✓ Branch 19 → 20 taken 48555 times.
✗ Branch 19 → 68 not taken.
✓ Branch 20 → 21 taken 48555 times.
✗ Branch 20 → 68 not taken.
✓ Branch 21 → 22 taken 3085 times.
✓ Branch 21 → 27 taken 45470 times.
|
71259 | } else if (terminal->getSymbol()->getType() == SpiceParser::TYPE_IDENTIFIER) { |
| 1377 |
1/2✓ Branch 22 → 23 taken 3085 times.
✗ Branch 22 → 67 not taken.
|
3085 | const std::string fragment = terminal->toString(); |
| 1378 |
1/2✓ Branch 23 → 24 taken 3085 times.
✗ Branch 23 → 65 not taken.
|
3085 | fctCallNode->functionNameFragments.push_back(fragment); |
| 1379 |
1/2✓ Branch 24 → 25 taken 3085 times.
✗ Branch 24 → 65 not taken.
|
3085 | fctCallNode->fqFunctionName += fragment; |
| 1380 |
4/6✓ Branch 27 → 28 taken 45470 times.
✗ Branch 27 → 68 not taken.
✓ Branch 28 → 29 taken 45470 times.
✗ Branch 28 → 68 not taken.
✓ Branch 29 → 30 taken 62 times.
✓ Branch 29 → 31 taken 45408 times.
|
48555 | } else if (terminal->getSymbol()->getType() == SpiceParser::SCOPE_ACCESS) { |
| 1381 |
1/2✓ Branch 30 → 35 taken 62 times.
✗ Branch 30 → 68 not taken.
|
62 | fctCallNode->fqFunctionName += SCOPE_ACCESS_TOKEN; |
| 1382 |
4/6✓ Branch 31 → 32 taken 45408 times.
✗ Branch 31 → 68 not taken.
✓ Branch 32 → 33 taken 45408 times.
✗ Branch 32 → 68 not taken.
✓ Branch 33 → 34 taken 8258 times.
✓ Branch 33 → 35 taken 37150 times.
|
45408 | } else if (terminal->getSymbol()->getType() == SpiceParser::DOT) { |
| 1383 |
1/2✓ Branch 34 → 35 taken 8258 times.
✗ Branch 34 → 68 not taken.
|
8258 | fctCallNode->fqFunctionName += MEMBER_ACCESS_TOKEN; |
| 1384 | } | ||
| 1385 | } | ||
| 1386 | |||
| 1387 | // Visit children | ||
| 1388 |
2/2✓ Branch 39 → 40 taken 1106 times.
✓ Branch 39 → 45 taken 16363 times.
|
17469 | if (ctx->typeLst()) { |
| 1389 | 1106 | fctCallNode->hasTemplateTypes = true; | |
| 1390 |
3/6✓ Branch 40 → 41 taken 1106 times.
✗ Branch 40 → 71 not taken.
✓ Branch 41 → 42 taken 1106 times.
✗ Branch 41 → 71 not taken.
✓ Branch 42 → 43 taken 1106 times.
✗ Branch 42 → 69 not taken.
|
1106 | fctCallNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst())); |
| 1391 | } | ||
| 1392 |
2/2✓ Branch 46 → 47 taken 13477 times.
✓ Branch 46 → 52 taken 3992 times.
|
17469 | if (ctx->argLst()) { |
| 1393 | 13477 | fctCallNode->hasArgs = true; | |
| 1394 |
3/6✓ Branch 47 → 48 taken 13477 times.
✗ Branch 47 → 74 not taken.
✓ Branch 48 → 49 taken 13477 times.
✗ Branch 48 → 74 not taken.
✓ Branch 49 → 50 taken 13477 times.
✗ Branch 49 → 72 not taken.
|
13477 | fctCallNode->argLst = std::any_cast<ArgLstNode *>(visit(ctx->argLst())); |
| 1395 | } | ||
| 1396 | |||
| 1397 |
1/2✓ Branch 58 → 59 taken 17469 times.
✗ Branch 58 → 75 not taken.
|
17469 | return concludeNode(fctCallNode); |
| 1398 | } | ||
| 1399 | |||
| 1400 | 75 | std::any ASTBuilder::visitArrayInitialization(SpiceParser::ArrayInitializationContext *ctx) { | |
| 1401 | 75 | const auto arrayInitializationNode = createNode<ArrayInitializationNode>(ctx); | |
| 1402 | |||
| 1403 | // Visit children | ||
| 1404 |
2/2✓ Branch 4 → 5 taken 74 times.
✓ Branch 4 → 10 taken 1 time.
|
75 | if (ctx->argLst()) |
| 1405 |
3/6✓ Branch 5 → 6 taken 74 times.
✗ Branch 5 → 22 not taken.
✓ Branch 6 → 7 taken 74 times.
✗ Branch 6 → 22 not taken.
✓ Branch 7 → 8 taken 74 times.
✗ Branch 7 → 20 not taken.
|
74 | arrayInitializationNode->itemLst = std::any_cast<ArgLstNode *>(visit(ctx->argLst())); |
| 1406 | |||
| 1407 |
1/2✓ Branch 16 → 17 taken 75 times.
✗ Branch 16 → 23 not taken.
|
75 | return concludeNode(arrayInitializationNode); |
| 1408 | } | ||
| 1409 | |||
| 1410 | 224 | std::any ASTBuilder::visitStructInstantiation(SpiceParser::StructInstantiationContext *ctx) { | |
| 1411 | 224 | const auto structInstantiationNode = createNode<StructInstantiationNode>(ctx); | |
| 1412 | |||
| 1413 | // Enrich | ||
| 1414 |
2/2✓ Branch 31 → 5 taken 945 times.
✓ Branch 31 → 32 taken 224 times.
|
1169 | for (antlr4::ParserRuleContext::ParseTree *subTree : ctx->children) { |
| 1415 |
1/2✓ Branch 6 → 7 taken 945 times.
✗ Branch 6 → 8 not taken.
|
945 | const auto terminal = dynamic_cast<antlr4::tree::TerminalNode *>(subTree); |
| 1416 |
2/2✓ Branch 9 → 10 taken 227 times.
✓ Branch 9 → 11 taken 718 times.
|
945 | if (!terminal) |
| 1417 | 227 | continue; | |
| 1418 | |||
| 1419 |
4/6✓ Branch 11 → 12 taken 718 times.
✗ Branch 11 → 65 not taken.
✓ Branch 12 → 13 taken 718 times.
✗ Branch 12 → 65 not taken.
✓ Branch 13 → 14 taken 3 times.
✓ Branch 13 → 21 taken 715 times.
|
718 | if (terminal->getSymbol()->getType() == SpiceParser::IDENTIFIER) { |
| 1420 |
1/2✓ Branch 14 → 15 taken 3 times.
✗ Branch 14 → 61 not taken.
|
3 | const std::string fragment = terminal->toString(); |
| 1421 |
1/2✓ Branch 15 → 16 taken 3 times.
✗ Branch 15 → 59 not taken.
|
3 | structInstantiationNode->structNameFragments.push_back(fragment); |
| 1422 |
2/4✓ Branch 16 → 17 taken 3 times.
✗ Branch 16 → 58 not taken.
✓ Branch 17 → 18 taken 3 times.
✗ Branch 17 → 56 not taken.
|
3 | structInstantiationNode->fqStructName += fragment + SCOPE_ACCESS_TOKEN; |
| 1423 |
4/6✓ Branch 21 → 22 taken 715 times.
✗ Branch 21 → 65 not taken.
✓ Branch 22 → 23 taken 715 times.
✗ Branch 22 → 65 not taken.
✓ Branch 23 → 24 taken 224 times.
✓ Branch 23 → 29 taken 491 times.
|
718 | } else if (terminal->getSymbol()->getType() == SpiceParser::TYPE_IDENTIFIER) { |
| 1424 |
1/2✓ Branch 24 → 25 taken 224 times.
✗ Branch 24 → 64 not taken.
|
224 | const std::string fragment = terminal->toString(); |
| 1425 |
1/2✓ Branch 25 → 26 taken 224 times.
✗ Branch 25 → 62 not taken.
|
224 | structInstantiationNode->structNameFragments.push_back(fragment); |
| 1426 |
1/2✓ Branch 26 → 27 taken 224 times.
✗ Branch 26 → 62 not taken.
|
224 | structInstantiationNode->fqStructName += fragment; |
| 1427 | 224 | } | |
| 1428 | } | ||
| 1429 | |||
| 1430 | // Visit children | ||
| 1431 |
2/2✓ Branch 33 → 34 taken 20 times.
✓ Branch 33 → 39 taken 204 times.
|
224 | if (ctx->typeLst()) { |
| 1432 | 20 | structInstantiationNode->hasTemplateTypes = true; | |
| 1433 |
3/6✓ Branch 34 → 35 taken 20 times.
✗ Branch 34 → 68 not taken.
✓ Branch 35 → 36 taken 20 times.
✗ Branch 35 → 68 not taken.
✓ Branch 36 → 37 taken 20 times.
✗ Branch 36 → 66 not taken.
|
20 | structInstantiationNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst())); |
| 1434 | } | ||
| 1435 |
2/2✓ Branch 40 → 41 taken 207 times.
✓ Branch 40 → 46 taken 17 times.
|
224 | if (ctx->argLst()) |
| 1436 |
3/6✓ Branch 41 → 42 taken 207 times.
✗ Branch 41 → 71 not taken.
✓ Branch 42 → 43 taken 207 times.
✗ Branch 42 → 71 not taken.
✓ Branch 43 → 44 taken 207 times.
✗ Branch 43 → 69 not taken.
|
207 | structInstantiationNode->fieldLst = std::any_cast<ArgLstNode *>(visit(ctx->argLst())); |
| 1437 | |||
| 1438 |
1/2✓ Branch 52 → 53 taken 224 times.
✗ Branch 52 → 72 not taken.
|
224 | return concludeNode(structInstantiationNode); |
| 1439 | } | ||
| 1440 | |||
| 1441 | 16 | std::any ASTBuilder::visitLambdaFunc(SpiceParser::LambdaFuncContext *ctx) { | |
| 1442 | 16 | const auto lambdaFuncNode = createNode<LambdaFuncNode>(ctx); | |
| 1443 | |||
| 1444 | // Visit children | ||
| 1445 |
3/6✓ Branch 3 → 4 taken 16 times.
✗ Branch 3 → 37 not taken.
✓ Branch 4 → 5 taken 16 times.
✗ Branch 4 → 37 not taken.
✓ Branch 5 → 6 taken 16 times.
✗ Branch 5 → 35 not taken.
|
16 | lambdaFuncNode->returnType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 1446 |
2/2✓ Branch 8 → 9 taken 12 times.
✓ Branch 8 → 14 taken 4 times.
|
16 | if (ctx->paramLst()) { |
| 1447 | 12 | lambdaFuncNode->hasParams = true; | |
| 1448 |
3/6✓ Branch 9 → 10 taken 12 times.
✗ Branch 9 → 40 not taken.
✓ Branch 10 → 11 taken 12 times.
✗ Branch 10 → 40 not taken.
✓ Branch 11 → 12 taken 12 times.
✗ Branch 11 → 38 not taken.
|
12 | lambdaFuncNode->paramLst = std::any_cast<ParamLstNode *>(visit(ctx->paramLst())); |
| 1449 | } | ||
| 1450 |
1/2✗ Branch 15 → 16 not taken.
✓ Branch 15 → 21 taken 16 times.
|
16 | if (ctx->lambdaAttr()) |
| 1451 | ✗ | lambdaFuncNode->lambdaAttr = std::any_cast<LambdaAttrNode *>(visit(ctx->lambdaAttr())); | |
| 1452 |
3/6✓ Branch 21 → 22 taken 16 times.
✗ Branch 21 → 46 not taken.
✓ Branch 22 → 23 taken 16 times.
✗ Branch 22 → 46 not taken.
✓ Branch 23 → 24 taken 16 times.
✗ Branch 23 → 44 not taken.
|
16 | lambdaFuncNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 1453 | |||
| 1454 |
1/2✓ Branch 31 → 32 taken 16 times.
✗ Branch 31 → 47 not taken.
|
16 | return concludeNode(lambdaFuncNode); |
| 1455 | } | ||
| 1456 | |||
| 1457 | 31 | std::any ASTBuilder::visitLambdaProc(SpiceParser::LambdaProcContext *ctx) { | |
| 1458 | 31 | const auto lambdaProcNode = createNode<LambdaProcNode>(ctx); | |
| 1459 | |||
| 1460 | // Visit children | ||
| 1461 |
2/2✓ Branch 4 → 5 taken 11 times.
✓ Branch 4 → 10 taken 20 times.
|
31 | if (ctx->paramLst()) { |
| 1462 | 11 | lambdaProcNode->hasParams = true; | |
| 1463 |
3/6✓ Branch 5 → 6 taken 11 times.
✗ Branch 5 → 33 not taken.
✓ Branch 6 → 7 taken 11 times.
✗ Branch 6 → 33 not taken.
✓ Branch 7 → 8 taken 11 times.
✗ Branch 7 → 31 not taken.
|
11 | lambdaProcNode->paramLst = std::any_cast<ParamLstNode *>(visit(ctx->paramLst())); |
| 1464 | } | ||
| 1465 |
2/2✓ Branch 11 → 12 taken 16 times.
✓ Branch 11 → 17 taken 15 times.
|
31 | if (ctx->lambdaAttr()) |
| 1466 |
3/6✓ Branch 12 → 13 taken 16 times.
✗ Branch 12 → 36 not taken.
✓ Branch 13 → 14 taken 16 times.
✗ Branch 13 → 36 not taken.
✓ Branch 14 → 15 taken 16 times.
✗ Branch 14 → 34 not taken.
|
16 | lambdaProcNode->lambdaAttr = std::any_cast<LambdaAttrNode *>(visit(ctx->lambdaAttr())); |
| 1467 |
3/6✓ Branch 17 → 18 taken 31 times.
✗ Branch 17 → 39 not taken.
✓ Branch 18 → 19 taken 31 times.
✗ Branch 18 → 39 not taken.
✓ Branch 19 → 20 taken 31 times.
✗ Branch 19 → 37 not taken.
|
31 | lambdaProcNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 1468 | |||
| 1469 |
1/2✓ Branch 27 → 28 taken 31 times.
✗ Branch 27 → 40 not taken.
|
31 | return concludeNode(lambdaProcNode); |
| 1470 | } | ||
| 1471 | |||
| 1472 | 1 | std::any ASTBuilder::visitLambdaExpr(SpiceParser::LambdaExprContext *ctx) { | |
| 1473 | 1 | const auto lambdaExprNode = createNode<LambdaExprNode>(ctx); | |
| 1474 | |||
| 1475 | // Visit children | ||
| 1476 |
1/2✓ Branch 4 → 5 taken 1 time.
✗ Branch 4 → 10 not taken.
|
1 | if (ctx->paramLst()) { |
| 1477 | 1 | lambdaExprNode->hasParams = true; | |
| 1478 |
3/6✓ Branch 5 → 6 taken 1 time.
✗ Branch 5 → 26 not taken.
✓ Branch 6 → 7 taken 1 time.
✗ Branch 6 → 26 not taken.
✓ Branch 7 → 8 taken 1 time.
✗ Branch 7 → 24 not taken.
|
1 | lambdaExprNode->paramLst = std::any_cast<ParamLstNode *>(visit(ctx->paramLst())); |
| 1479 | } | ||
| 1480 |
3/6✓ Branch 10 → 11 taken 1 time.
✗ Branch 10 → 29 not taken.
✓ Branch 11 → 12 taken 1 time.
✗ Branch 11 → 29 not taken.
✓ Branch 12 → 13 taken 1 time.
✗ Branch 12 → 27 not taken.
|
1 | lambdaExprNode->lambdaExpr = std::any_cast<AssignExprNode *>(visit(ctx->assignExpr())); |
| 1481 | |||
| 1482 |
1/2✓ Branch 20 → 21 taken 1 time.
✗ Branch 20 → 30 not taken.
|
1 | return concludeNode(lambdaExprNode); |
| 1483 | } | ||
| 1484 | |||
| 1485 | 51144 | std::any ASTBuilder::visitDataType(SpiceParser::DataTypeContext *ctx) { | |
| 1486 | 51144 | const auto dataTypeNode = createNode<DataTypeNode>(ctx); | |
| 1487 | |||
| 1488 | // Visit children | ||
| 1489 |
2/2✓ Branch 4 → 5 taken 20048 times.
✓ Branch 4 → 10 taken 31096 times.
|
51144 | if (ctx->qualifierLst()) |
| 1490 |
4/6✓ Branch 5 → 6 taken 20048 times.
✗ Branch 5 → 74 not taken.
✓ Branch 6 → 7 taken 20047 times.
✓ Branch 6 → 74 taken 1 time.
✓ Branch 7 → 8 taken 20047 times.
✗ Branch 7 → 72 not taken.
|
20048 | dataTypeNode->qualifierLst = std::any_cast<QualifierLstNode *>(visit(ctx->qualifierLst())); |
| 1491 |
3/6✓ Branch 10 → 11 taken 51143 times.
✗ Branch 10 → 77 not taken.
✓ Branch 11 → 12 taken 51143 times.
✗ Branch 11 → 77 not taken.
✓ Branch 12 → 13 taken 51143 times.
✗ Branch 12 → 75 not taken.
|
51143 | dataTypeNode->baseDataType = std::any_cast<BaseDataTypeNode *>(visit(ctx->baseDataType())); |
| 1492 | |||
| 1493 | // Enrich | ||
| 1494 |
2/2✓ Branch 61 → 15 taken 83523 times.
✓ Branch 61 → 62 taken 51143 times.
|
134666 | for (size_t i = 0; i < ctx->children.size(); i++) { |
| 1495 | 83523 | antlr4::tree::ParseTree *subTree = ctx->children.at(i); | |
| 1496 |
1/2✓ Branch 16 → 17 taken 83523 times.
✗ Branch 16 → 18 not taken.
|
83523 | auto terminal = dynamic_cast<TerminalNode *>(subTree); |
| 1497 |
2/2✓ Branch 19 → 20 taken 71190 times.
✓ Branch 19 → 21 taken 12333 times.
|
83523 | if (!terminal) |
| 1498 | 71190 | continue; | |
| 1499 | |||
| 1500 |
2/2✓ Branch 23 → 24 taken 6478 times.
✓ Branch 23 → 26 taken 5855 times.
|
12333 | if (terminal->getSymbol()->getType() == SpiceParser::MUL) { |
| 1501 |
1/2✓ Branch 24 → 25 taken 6478 times.
✗ Branch 24 → 78 not taken.
|
6478 | dataTypeNode->tmQueue.emplace(DataTypeNode::TypeModifierType::TYPE_PTR, false, 0); |
| 1502 |
2/2✓ Branch 28 → 29 taken 5750 times.
✓ Branch 28 → 31 taken 105 times.
|
5855 | } else if (terminal->getSymbol()->getType() == SpiceParser::BITWISE_AND) { |
| 1503 |
1/2✓ Branch 29 → 30 taken 5750 times.
✗ Branch 29 → 81 not taken.
|
5750 | dataTypeNode->tmQueue.emplace(DataTypeNode::TypeModifierType::TYPE_REF, false, 0); |
| 1504 |
1/2✓ Branch 33 → 34 taken 105 times.
✗ Branch 33 → 59 not taken.
|
105 | } else if (terminal->getSymbol()->getType() == SpiceParser::LBRACKET) { |
| 1505 | 105 | i++; // Consume LBRACKET | |
| 1506 |
1/2✓ Branch 34 → 35 taken 105 times.
✗ Branch 34 → 93 not taken.
|
105 | subTree = ctx->children.at(i); |
| 1507 |
1/2✓ Branch 35 → 36 taken 105 times.
✗ Branch 35 → 37 not taken.
|
105 | terminal = dynamic_cast<TerminalNode *>(subTree); |
| 1508 | 105 | bool hasSize = false; | |
| 1509 | 105 | unsigned int hardCodedSize = 0; | |
| 1510 | 105 | std::string sizeVarName; | |
| 1511 |
4/6✓ Branch 39 → 40 taken 105 times.
✗ Branch 39 → 91 not taken.
✓ Branch 40 → 41 taken 105 times.
✗ Branch 40 → 91 not taken.
✓ Branch 41 → 42 taken 51 times.
✓ Branch 41 → 47 taken 54 times.
|
105 | if (terminal->getSymbol()->getType() == SpiceParser::INT_LIT) { |
| 1512 | 51 | hasSize = true; | |
| 1513 |
3/6✓ Branch 42 → 43 taken 51 times.
✗ Branch 42 → 86 not taken.
✓ Branch 43 → 44 taken 51 times.
✗ Branch 43 → 86 not taken.
✓ Branch 44 → 45 taken 51 times.
✗ Branch 44 → 84 not taken.
|
51 | hardCodedSize = std::stoi(terminal->getSymbol()->getText()); |
| 1514 | 51 | i++; // Consume INT_LIT | |
| 1515 |
4/6✓ Branch 47 → 48 taken 54 times.
✗ Branch 47 → 91 not taken.
✓ Branch 48 → 49 taken 54 times.
✗ Branch 48 → 91 not taken.
✓ Branch 49 → 50 taken 24 times.
✓ Branch 49 → 54 taken 30 times.
|
54 | } else if (terminal->getSymbol()->getType() == SpiceParser::TYPE_IDENTIFIER) { |
| 1516 | 24 | hasSize = true; | |
| 1517 |
1/2✓ Branch 50 → 51 taken 24 times.
✗ Branch 50 → 87 not taken.
|
24 | sizeVarName = getIdentifier(terminal, true); |
| 1518 | 24 | i++; // Consume TYPE_IDENTIFIER | |
| 1519 | } | ||
| 1520 |
1/2✓ Branch 55 → 56 taken 105 times.
✗ Branch 55 → 88 not taken.
|
105 | dataTypeNode->tmQueue.push({DataTypeNode::TypeModifierType::TYPE_ARRAY, hasSize, hardCodedSize, sizeVarName}); |
| 1521 | 105 | } | |
| 1522 | } | ||
| 1523 | |||
| 1524 |
1/2✓ Branch 68 → 69 taken 51143 times.
✗ Branch 68 → 94 not taken.
|
51143 | return concludeNode(dataTypeNode); |
| 1525 |
1/2✓ Branch 54 → 55 taken 105 times.
✗ Branch 54 → 90 not taken.
|
105 | } |
| 1526 | |||
| 1527 | 51143 | std::any ASTBuilder::visitBaseDataType(SpiceParser::BaseDataTypeContext *ctx) { | |
| 1528 | 51143 | const auto baseDataTypeNode = createNode<BaseDataTypeNode>(ctx); | |
| 1529 | |||
| 1530 | // Enrich | ||
| 1531 |
2/2✓ Branch 4 → 5 taken 575 times.
✓ Branch 4 → 6 taken 50568 times.
|
51143 | if (ctx->TYPE_DOUBLE()) { |
| 1532 | 575 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_DOUBLE; | |
| 1533 |
2/2✓ Branch 7 → 8 taken 3374 times.
✓ Branch 7 → 9 taken 47194 times.
|
50568 | } else if (ctx->TYPE_INT()) { |
| 1534 | 3374 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_INT; | |
| 1535 |
2/2✓ Branch 10 → 11 taken 1182 times.
✓ Branch 10 → 12 taken 46012 times.
|
47194 | } else if (ctx->TYPE_SHORT()) { |
| 1536 | 1182 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_SHORT; | |
| 1537 |
2/2✓ Branch 13 → 14 taken 9700 times.
✓ Branch 13 → 15 taken 36312 times.
|
46012 | } else if (ctx->TYPE_LONG()) { |
| 1538 | 9700 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_LONG; | |
| 1539 |
2/2✓ Branch 16 → 17 taken 2906 times.
✓ Branch 16 → 18 taken 33406 times.
|
36312 | } else if (ctx->TYPE_BYTE()) { |
| 1540 | 2906 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_BYTE; | |
| 1541 |
2/2✓ Branch 19 → 20 taken 5475 times.
✓ Branch 19 → 21 taken 27931 times.
|
33406 | } else if (ctx->TYPE_CHAR()) { |
| 1542 | 5475 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_CHAR; | |
| 1543 |
2/2✓ Branch 22 → 23 taken 4222 times.
✓ Branch 22 → 24 taken 23709 times.
|
27931 | } else if (ctx->TYPE_STRING()) { |
| 1544 | 4222 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_STRING; | |
| 1545 |
2/2✓ Branch 25 → 26 taken 4135 times.
✓ Branch 25 → 27 taken 19574 times.
|
23709 | } else if (ctx->TYPE_BOOL()) { |
| 1546 | 4135 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_BOOL; | |
| 1547 |
2/2✓ Branch 28 → 29 taken 487 times.
✓ Branch 28 → 30 taken 19087 times.
|
19574 | } else if (ctx->TYPE_DYN()) { |
| 1548 | 487 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_DYN; | |
| 1549 |
2/2✓ Branch 31 → 32 taken 18983 times.
✓ Branch 31 → 37 taken 104 times.
|
19087 | } else if (ctx->customDataType()) { |
| 1550 | 18983 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_CUSTOM; | |
| 1551 |
3/6✓ Branch 32 → 33 taken 18983 times.
✗ Branch 32 → 57 not taken.
✓ Branch 33 → 34 taken 18983 times.
✗ Branch 33 → 57 not taken.
✓ Branch 34 → 35 taken 18983 times.
✗ Branch 34 → 55 not taken.
|
18983 | baseDataTypeNode->customDataType = std::any_cast<CustomDataTypeNode *>(visit(ctx->customDataType())); |
| 1552 |
1/2✓ Branch 38 → 39 taken 104 times.
✗ Branch 38 → 44 not taken.
|
104 | } else if (ctx->functionDataType()) { |
| 1553 | 104 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_FUNCTION; | |
| 1554 |
3/6✓ Branch 39 → 40 taken 104 times.
✗ Branch 39 → 60 not taken.
✓ Branch 40 → 41 taken 104 times.
✗ Branch 40 → 60 not taken.
✓ Branch 41 → 42 taken 104 times.
✗ Branch 41 → 58 not taken.
|
104 | baseDataTypeNode->functionDataType = std::any_cast<FunctionDataTypeNode *>(visit(ctx->functionDataType())); |
| 1555 | } else { | ||
| 1556 | ✗ | assert_fail("Unknown base data type"); | |
| 1557 | } | ||
| 1558 | |||
| 1559 |
1/2✓ Branch 51 → 52 taken 51143 times.
✗ Branch 51 → 61 not taken.
|
51143 | return concludeNode(baseDataTypeNode); |
| 1560 | } | ||
| 1561 | |||
| 1562 | 18983 | std::any ASTBuilder::visitCustomDataType(SpiceParser::CustomDataTypeContext *ctx) { | |
| 1563 | 18983 | const auto customDataTypeNode = createNode<CustomDataTypeNode>(ctx); | |
| 1564 | |||
| 1565 | // Enrich | ||
| 1566 |
2/2✓ Branch 31 → 5 taken 27005 times.
✓ Branch 31 → 32 taken 18983 times.
|
45988 | for (ParserRuleContext::ParseTree *subTree : ctx->children) { |
| 1567 |
1/2✓ Branch 6 → 7 taken 27005 times.
✗ Branch 6 → 8 not taken.
|
27005 | const auto terminal = dynamic_cast<TerminalNode *>(subTree); |
| 1568 |
2/2✓ Branch 9 → 10 taken 2656 times.
✓ Branch 9 → 11 taken 24349 times.
|
27005 | if (!terminal) |
| 1569 | 2656 | continue; | |
| 1570 | |||
| 1571 |
4/6✓ Branch 11 → 12 taken 24349 times.
✗ Branch 11 → 58 not taken.
✓ Branch 12 → 13 taken 24349 times.
✗ Branch 12 → 58 not taken.
✓ Branch 13 → 14 taken 27 times.
✓ Branch 13 → 21 taken 24322 times.
|
24349 | if (terminal->getSymbol()->getType() == SpiceParser::IDENTIFIER) { |
| 1572 |
1/2✓ Branch 14 → 15 taken 27 times.
✗ Branch 14 → 54 not taken.
|
27 | const std::string fragment = terminal->toString(); |
| 1573 |
1/2✓ Branch 15 → 16 taken 27 times.
✗ Branch 15 → 52 not taken.
|
27 | customDataTypeNode->typeNameFragments.push_back(fragment); |
| 1574 |
2/4✓ Branch 16 → 17 taken 27 times.
✗ Branch 16 → 51 not taken.
✓ Branch 17 → 18 taken 27 times.
✗ Branch 17 → 49 not taken.
|
27 | customDataTypeNode->fqTypeName += fragment + SCOPE_ACCESS_TOKEN; |
| 1575 |
4/6✓ Branch 21 → 22 taken 24322 times.
✗ Branch 21 → 58 not taken.
✓ Branch 22 → 23 taken 24322 times.
✗ Branch 22 → 58 not taken.
✓ Branch 23 → 24 taken 18983 times.
✓ Branch 23 → 29 taken 5339 times.
|
24349 | } else if (terminal->getSymbol()->getType() == SpiceParser::TYPE_IDENTIFIER) { |
| 1576 |
1/2✓ Branch 24 → 25 taken 18983 times.
✗ Branch 24 → 57 not taken.
|
18983 | const std::string fragment = terminal->toString(); |
| 1577 |
1/2✓ Branch 25 → 26 taken 18983 times.
✗ Branch 25 → 55 not taken.
|
18983 | customDataTypeNode->typeNameFragments.push_back(fragment); |
| 1578 |
1/2✓ Branch 26 → 27 taken 18983 times.
✗ Branch 26 → 55 not taken.
|
18983 | customDataTypeNode->fqTypeName += fragment; |
| 1579 | 18983 | } | |
| 1580 | } | ||
| 1581 | |||
| 1582 | // Visit children | ||
| 1583 |
2/2✓ Branch 33 → 34 taken 2656 times.
✓ Branch 33 → 39 taken 16327 times.
|
18983 | if (ctx->typeLst()) |
| 1584 |
3/6✓ Branch 34 → 35 taken 2656 times.
✗ Branch 34 → 61 not taken.
✓ Branch 35 → 36 taken 2656 times.
✗ Branch 35 → 61 not taken.
✓ Branch 36 → 37 taken 2656 times.
✗ Branch 36 → 59 not taken.
|
2656 | customDataTypeNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst())); |
| 1585 | |||
| 1586 |
1/2✓ Branch 45 → 46 taken 18983 times.
✗ Branch 45 → 62 not taken.
|
18983 | return concludeNode(customDataTypeNode); |
| 1587 | } | ||
| 1588 | |||
| 1589 | 104 | std::any ASTBuilder::visitFunctionDataType(SpiceParser::FunctionDataTypeContext *ctx) { | |
| 1590 | 104 | const auto functionDataTypeNode = createNode<FunctionDataTypeNode>(ctx); | |
| 1591 | |||
| 1592 | // Enrich | ||
| 1593 |
2/2✓ Branch 4 → 5 taken 32 times.
✓ Branch 4 → 11 taken 72 times.
|
104 | if (ctx->dataType()) { |
| 1594 | 32 | functionDataTypeNode->isFunction = ctx->dataType(); | |
| 1595 |
3/6✓ Branch 6 → 7 taken 32 times.
✗ Branch 6 → 30 not taken.
✓ Branch 7 → 8 taken 32 times.
✗ Branch 7 → 30 not taken.
✓ Branch 8 → 9 taken 32 times.
✗ Branch 8 → 28 not taken.
|
32 | functionDataTypeNode->returnType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 1596 | } | ||
| 1597 |
2/2✓ Branch 12 → 13 taken 66 times.
✓ Branch 12 → 18 taken 38 times.
|
104 | if (ctx->typeLst()) |
| 1598 |
3/6✓ Branch 13 → 14 taken 66 times.
✗ Branch 13 → 33 not taken.
✓ Branch 14 → 15 taken 66 times.
✗ Branch 14 → 33 not taken.
✓ Branch 15 → 16 taken 66 times.
✗ Branch 15 → 31 not taken.
|
66 | functionDataTypeNode->paramTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst())); |
| 1599 | |||
| 1600 |
1/2✓ Branch 24 → 25 taken 104 times.
✗ Branch 24 → 34 not taken.
|
104 | return concludeNode(functionDataTypeNode); |
| 1601 | } | ||
| 1602 | |||
| 1603 | 8086 | std::any ASTBuilder::visitAssignOp(SpiceParser::AssignOpContext *ctx) { | |
| 1604 | 8086 | const auto assignExprNode = resumeForExpansion<AssignExprNode>(); | |
| 1605 | |||
| 1606 | // Extract assign operator | ||
| 1607 |
2/2✓ Branch 13 → 14 taken 7169 times.
✓ Branch 13 → 15 taken 917 times.
|
8086 | if (ctx->ASSIGN()) |
| 1608 | 7169 | assignExprNode->op = AssignExprNode::AssignOp::OP_ASSIGN; | |
| 1609 |
2/2✓ Branch 16 → 17 taken 390 times.
✓ Branch 16 → 18 taken 527 times.
|
917 | else if (ctx->PLUS_EQUAL()) |
| 1610 | 390 | assignExprNode->op = AssignExprNode::AssignOp::OP_PLUS_EQUAL; | |
| 1611 |
2/2✓ Branch 19 → 20 taken 69 times.
✓ Branch 19 → 21 taken 458 times.
|
527 | else if (ctx->MINUS_EQUAL()) |
| 1612 | 69 | assignExprNode->op = AssignExprNode::AssignOp::OP_MINUS_EQUAL; | |
| 1613 |
2/2✓ Branch 22 → 23 taken 42 times.
✓ Branch 22 → 24 taken 416 times.
|
458 | else if (ctx->MUL_EQUAL()) |
| 1614 | 42 | assignExprNode->op = AssignExprNode::AssignOp::OP_MUL_EQUAL; | |
| 1615 |
2/2✓ Branch 25 → 26 taken 44 times.
✓ Branch 25 → 27 taken 372 times.
|
416 | else if (ctx->DIV_EQUAL()) |
| 1616 | 44 | assignExprNode->op = AssignExprNode::AssignOp::OP_DIV_EQUAL; | |
| 1617 |
2/2✓ Branch 28 → 29 taken 8 times.
✓ Branch 28 → 30 taken 364 times.
|
372 | else if (ctx->REM_EQUAL()) |
| 1618 | 8 | assignExprNode->op = AssignExprNode::AssignOp::OP_REM_EQUAL; | |
| 1619 |
2/2✓ Branch 31 → 32 taken 3 times.
✓ Branch 31 → 33 taken 361 times.
|
364 | else if (ctx->SHL_EQUAL()) |
| 1620 | 3 | assignExprNode->op = AssignExprNode::AssignOp::OP_SHL_EQUAL; | |
| 1621 |
2/2✓ Branch 34 → 35 taken 4 times.
✓ Branch 34 → 36 taken 357 times.
|
361 | else if (ctx->SHR_EQUAL()) |
| 1622 | 4 | assignExprNode->op = AssignExprNode::AssignOp::OP_SHR_EQUAL; | |
| 1623 |
2/2✓ Branch 37 → 38 taken 2 times.
✓ Branch 37 → 39 taken 355 times.
|
357 | else if (ctx->AND_EQUAL()) |
| 1624 | 2 | assignExprNode->op = AssignExprNode::AssignOp::OP_AND_EQUAL; | |
| 1625 |
2/2✓ Branch 40 → 41 taken 2 times.
✓ Branch 40 → 42 taken 353 times.
|
355 | else if (ctx->OR_EQUAL()) |
| 1626 | 2 | assignExprNode->op = AssignExprNode::AssignOp::OP_OR_EQUAL; | |
| 1627 |
1/2✓ Branch 43 → 44 taken 353 times.
✗ Branch 43 → 45 not taken.
|
353 | else if (ctx->XOR_EQUAL()) |
| 1628 | 353 | assignExprNode->op = AssignExprNode::AssignOp::OP_XOR_EQUAL; | |
| 1629 | else | ||
| 1630 | ✗ | assert_fail("Unknown assign operator"); | |
| 1631 | |||
| 1632 |
1/2✓ Branch 46 → 47 taken 8086 times.
✗ Branch 46 → 49 not taken.
|
8086 | return nullptr; |
| 1633 | } | ||
| 1634 | |||
| 1635 | 1843 | std::any ASTBuilder::visitOverloadableOp(SpiceParser::OverloadableOpContext *ctx) { | |
| 1636 | 1843 | const auto fctNameNode = resumeForExpansion<FctNameNode>(); | |
| 1637 | |||
| 1638 | // Enrich | ||
| 1639 |
2/2✓ Branch 13 → 14 taken 97 times.
✓ Branch 13 → 15 taken 1746 times.
|
1843 | if (ctx->PLUS()) |
| 1640 | 97 | fctNameNode->name = OP_FCT_PLUS; | |
| 1641 |
2/2✓ Branch 16 → 17 taken 1 time.
✓ Branch 16 → 18 taken 1745 times.
|
1746 | else if (ctx->MINUS()) |
| 1642 | 1 | fctNameNode->name = OP_FCT_MINUS; | |
| 1643 |
2/2✓ Branch 19 → 20 taken 193 times.
✓ Branch 19 → 21 taken 1552 times.
|
1745 | else if (ctx->MUL()) |
| 1644 | 193 | fctNameNode->name = OP_FCT_MUL; | |
| 1645 |
2/2✓ Branch 22 → 23 taken 22 times.
✓ Branch 22 → 24 taken 1530 times.
|
1552 | else if (ctx->DIV()) |
| 1646 | 22 | fctNameNode->name = OP_FCT_DIV; | |
| 1647 |
2/2✓ Branch 25 → 26 taken 439 times.
✓ Branch 25 → 27 taken 1091 times.
|
1530 | else if (ctx->EQUAL()) |
| 1648 | 439 | fctNameNode->name = OP_FCT_EQUAL; | |
| 1649 |
2/2✓ Branch 28 → 29 taken 436 times.
✓ Branch 28 → 30 taken 655 times.
|
1091 | else if (ctx->NOT_EQUAL()) |
| 1650 | 436 | fctNameNode->name = OP_FCT_NOT_EQUAL; | |
| 1651 |
3/4✓ Branch 30 → 31 taken 655 times.
✗ Branch 30 → 67 not taken.
✓ Branch 33 → 34 taken 13 times.
✓ Branch 33 → 35 taken 642 times.
|
655 | else if (ctx->LESS().size() == 2) |
| 1652 | 13 | fctNameNode->name = OP_FCT_SHL; | |
| 1653 |
3/4✓ Branch 35 → 36 taken 642 times.
✗ Branch 35 → 68 not taken.
✓ Branch 38 → 39 taken 1 time.
✓ Branch 38 → 40 taken 641 times.
|
642 | else if (ctx->GREATER().size() == 2) |
| 1654 | 1 | fctNameNode->name = OP_FCT_SHR; | |
| 1655 |
2/2✓ Branch 41 → 42 taken 139 times.
✓ Branch 41 → 43 taken 502 times.
|
641 | else if (ctx->PLUS_EQUAL()) |
| 1656 | 139 | fctNameNode->name = OP_FCT_PLUS_EQUAL; | |
| 1657 |
2/2✓ Branch 44 → 45 taken 43 times.
✓ Branch 44 → 46 taken 459 times.
|
502 | else if (ctx->MINUS_EQUAL()) |
| 1658 | 43 | fctNameNode->name = OP_FCT_MINUS_EQUAL; | |
| 1659 |
2/2✓ Branch 47 → 48 taken 97 times.
✓ Branch 47 → 49 taken 362 times.
|
459 | else if (ctx->MUL_EQUAL()) |
| 1660 | 97 | fctNameNode->name = OP_FCT_MUL_EQUAL; | |
| 1661 |
2/2✓ Branch 50 → 51 taken 22 times.
✓ Branch 50 → 52 taken 340 times.
|
362 | else if (ctx->DIV_EQUAL()) |
| 1662 | 22 | fctNameNode->name = OP_FCT_DIV_EQUAL; | |
| 1663 |
2/2✓ Branch 53 → 54 taken 53 times.
✓ Branch 53 → 55 taken 287 times.
|
340 | else if (ctx->PLUS_PLUS()) |
| 1664 | 53 | fctNameNode->name = OP_FCT_POSTFIX_PLUS_PLUS; | |
| 1665 |
2/2✓ Branch 56 → 57 taken 43 times.
✓ Branch 56 → 58 taken 244 times.
|
287 | else if (ctx->MINUS_MINUS()) |
| 1666 | 43 | fctNameNode->name = OP_FCT_POSTFIX_MINUS_MINUS; | |
| 1667 |
1/2✓ Branch 59 → 60 taken 244 times.
✗ Branch 59 → 61 not taken.
|
244 | else if (ctx->LBRACKET()) |
| 1668 | 244 | fctNameNode->name = OP_FCT_SUBSCRIPT; | |
| 1669 | else | ||
| 1670 | − | assert_fail("Unsupported overloadable operator"); // GCOV_EXCL_LINE | |
| 1671 | |||
| 1672 | 1843 | fctNameNode->fqName = fctNameNode->name; | |
| 1673 | 1843 | fctNameNode->nameFragments.push_back(fctNameNode->name); | |
| 1674 | |||
| 1675 |
1/2✓ Branch 64 → 65 taken 1843 times.
✗ Branch 64 → 69 not taken.
|
1843 | return nullptr; |
| 1676 | } | ||
| 1677 | |||
| 1678 | 5003 | int32_t ASTBuilder::parseInt(TerminalNode *terminal) { | |
| 1679 | 10006 | const NumericParserCallback<int32_t> cb = [](const std::string &substr, short base, bool isSigned) -> int32_t { | |
| 1680 | // Prepare limits | ||
| 1681 |
2/2✓ Branch 2 → 3 taken 4996 times.
✓ Branch 2 → 4 taken 7 times.
|
5003 | const int64_t upperLimit = isSigned ? INT32_MAX : UINT32_MAX; |
| 1682 |
2/2✓ Branch 5 → 6 taken 4996 times.
✓ Branch 5 → 7 taken 7 times.
|
5003 | const int64_t lowerLimit = isSigned ? INT32_MIN : 0; |
| 1683 | // Parse number and check for limits | ||
| 1684 | 5003 | const int64_t number = std::stoll(substr, nullptr, base); | |
| 1685 |
2/4✓ Branch 9 → 10 taken 5002 times.
✗ Branch 9 → 11 not taken.
✗ Branch 10 → 11 not taken.
✓ Branch 10 → 14 taken 5002 times.
|
5002 | if (number < lowerLimit || number > upperLimit) |
| 1686 | ✗ | throw std::out_of_range("Number out of range"); | |
| 1687 | 5002 | return static_cast<int32_t>(number); | |
| 1688 | 5003 | }; | |
| 1689 |
2/2✓ Branch 3 → 4 taken 5002 times.
✓ Branch 3 → 8 taken 1 time.
|
10005 | return parseNumeric(terminal, cb); |
| 1690 | 5003 | } | |
| 1691 | |||
| 1692 | 872 | int16_t ASTBuilder::parseShort(TerminalNode *terminal) { | |
| 1693 | 1744 | const NumericParserCallback<int16_t> cb = [](const std::string &substr, short base, bool isSigned) -> int16_t { | |
| 1694 | // Prepare limits | ||
| 1695 |
2/2✓ Branch 2 → 3 taken 538 times.
✓ Branch 2 → 4 taken 334 times.
|
872 | const int64_t upperLimit = isSigned ? INT16_MAX : UINT16_MAX; |
| 1696 |
2/2✓ Branch 5 → 6 taken 538 times.
✓ Branch 5 → 7 taken 334 times.
|
872 | const int64_t lowerLimit = isSigned ? INT16_MIN : 0; |
| 1697 | // Parse number and check for limits | ||
| 1698 | 872 | const int64_t number = std::stoll(substr, nullptr, base); | |
| 1699 |
2/4✓ Branch 9 → 10 taken 872 times.
✗ Branch 9 → 11 not taken.
✗ Branch 10 → 11 not taken.
✓ Branch 10 → 14 taken 872 times.
|
872 | if (number < lowerLimit || number > upperLimit) |
| 1700 | ✗ | throw std::out_of_range("Number out of range"); | |
| 1701 | 872 | return static_cast<int16_t>(number); | |
| 1702 | 872 | }; | |
| 1703 |
1/2✓ Branch 3 → 4 taken 872 times.
✗ Branch 3 → 8 not taken.
|
1744 | return parseNumeric(terminal, cb); |
| 1704 | 872 | } | |
| 1705 | |||
| 1706 | 6400 | int64_t ASTBuilder::parseLong(TerminalNode *terminal) { | |
| 1707 | 12800 | const NumericParserCallback<int64_t> cb = [](const std::string &substr, short base, bool isSigned) -> int64_t { | |
| 1708 |
2/2✓ Branch 2 → 3 taken 6254 times.
✓ Branch 2 → 5 taken 146 times.
|
6400 | return isSigned ? std::stoll(substr, nullptr, base) : static_cast<int64_t>(std::stoull(substr, nullptr, base)); |
| 1709 | 6400 | }; | |
| 1710 |
1/2✓ Branch 3 → 4 taken 6400 times.
✗ Branch 3 → 8 not taken.
|
12800 | return parseNumeric(terminal, cb); |
| 1711 | 6400 | } | |
| 1712 | |||
| 1713 | 2968 | int8_t ASTBuilder::parseChar(TerminalNode *terminal) const { | |
| 1714 |
1/2✓ Branch 2 → 3 taken 2968 times.
✗ Branch 2 → 59 not taken.
|
2968 | const std::string input = terminal->toString(); |
| 1715 |
2/2✓ Branch 4 → 5 taken 1877 times.
✓ Branch 4 → 7 taken 1091 times.
|
2968 | if (input.length() == 3) // Normal char literals |
| 1716 | 1877 | return input[1]; | |
| 1717 | |||
| 1718 |
3/6✓ Branch 8 → 9 taken 1091 times.
✗ Branch 8 → 12 not taken.
✓ Branch 10 → 11 taken 1091 times.
✗ Branch 10 → 12 not taken.
✓ Branch 13 → 14 taken 1091 times.
✗ Branch 13 → 34 not taken.
|
1091 | if (input.length() == 4 && input[1] == '\\') { // Char literals with escape sequence |
| 1719 |
7/11✓ Branch 15 → 16 taken 5 times.
✗ Branch 15 → 17 not taken.
✓ Branch 15 → 18 taken 11 times.
✓ Branch 15 → 19 taken 112 times.
✓ Branch 15 → 20 taken 96 times.
✓ Branch 15 → 21 taken 96 times.
✗ Branch 15 → 22 not taken.
✗ Branch 15 → 23 not taken.
✗ Branch 15 → 24 not taken.
✓ Branch 15 → 25 taken 770 times.
✓ Branch 15 → 26 taken 1 time.
|
1091 | switch (input[2]) { |
| 1720 | 5 | case '\'': | |
| 1721 | 5 | return '\''; | |
| 1722 | ✗ | case '"': | |
| 1723 | ✗ | return '\"'; | |
| 1724 | 11 | case '\\': | |
| 1725 | 11 | return '\\'; | |
| 1726 | 112 | case 'n': | |
| 1727 | 112 | return '\n'; | |
| 1728 | 96 | case 'r': | |
| 1729 | 96 | return '\r'; | |
| 1730 | 96 | case 't': | |
| 1731 | 96 | return '\t'; | |
| 1732 | ✗ | case 'b': | |
| 1733 | ✗ | return '\b'; | |
| 1734 | ✗ | case 'f': | |
| 1735 | ✗ | return '\f'; | |
| 1736 | ✗ | case 'v': | |
| 1737 | ✗ | return '\v'; | |
| 1738 | 770 | case '0': | |
| 1739 | 770 | return '\0'; | |
| 1740 | 1 | default: | |
| 1741 |
2/4✓ Branch 26 → 27 taken 1 time.
✗ Branch 26 → 50 not taken.
✓ Branch 27 → 28 taken 1 time.
✗ Branch 27 → 50 not taken.
|
1 | const CodeLoc codeLoc(terminal->getSymbol(), sourceFile); |
| 1742 |
2/4✓ Branch 29 → 30 taken 1 time.
✗ Branch 29 → 47 not taken.
✓ Branch 30 → 31 taken 1 time.
✗ Branch 30 → 44 not taken.
|
1 | throw ParserError(codeLoc, INVALID_CHAR_LITERAL, "Invalid escape sequence " + input); |
| 1743 | } | ||
| 1744 | } | ||
| 1745 | |||
| 1746 | ✗ | const CodeLoc codeLoc(terminal->getSymbol(), sourceFile); | |
| 1747 | ✗ | throw ParserError(codeLoc, INVALID_CHAR_LITERAL, "Invalid char literal " + input); | |
| 1748 | 2968 | } | |
| 1749 | |||
| 1750 | 2723 | std::string ASTBuilder::parseString(std::string input) { | |
| 1751 |
1/2✓ Branch 3 → 4 taken 2723 times.
✗ Branch 3 → 9 not taken.
|
2723 | input = input.substr(1, input.size() - 2); |
| 1752 | 2723 | replaceEscapeChars(input); | |
| 1753 | 2723 | return input; | |
| 1754 | } | ||
| 1755 | |||
| 1756 | 12275 | template <typename T> T ASTBuilder::parseNumeric(TerminalNode *terminal, const NumericParserCallback<T> &cb) { | |
| 1757 |
3/6int spice::compiler::ASTBuilder::parseNumeric<int>(antlr4::tree::TerminalNode*, std::function<int (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✓ Branch 2 → 3 taken 5003 times.
✗ Branch 2 → 87 not taken.
long spice::compiler::ASTBuilder::parseNumeric<long>(antlr4::tree::TerminalNode*, std::function<long (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✓ Branch 2 → 3 taken 6400 times.
✗ Branch 2 → 87 not taken.
short spice::compiler::ASTBuilder::parseNumeric<short>(antlr4::tree::TerminalNode*, std::function<short (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✓ Branch 2 → 3 taken 872 times.
✗ Branch 2 → 87 not taken.
|
12275 | const std::string input = terminal->toString(); |
| 1758 | |||
| 1759 | // Set to signed if the input string does not end with 'u' | ||
| 1760 |
12/18int spice::compiler::ASTBuilder::parseNumeric<int>(antlr4::tree::TerminalNode*, std::function<int (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✓ Branch 4 → 5 taken 4996 times.
✓ Branch 4 → 9 taken 7 times.
✓ Branch 6 → 7 taken 4996 times.
✗ Branch 6 → 9 not taken.
✗ Branch 8 → 9 not taken.
✓ Branch 8 → 10 taken 4996 times.
long spice::compiler::ASTBuilder::parseNumeric<long>(antlr4::tree::TerminalNode*, std::function<long (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✓ Branch 4 → 5 taken 6400 times.
✗ Branch 4 → 9 not taken.
✓ Branch 6 → 7 taken 6400 times.
✗ Branch 6 → 9 not taken.
✓ Branch 8 → 9 taken 146 times.
✓ Branch 8 → 10 taken 6254 times.
short spice::compiler::ASTBuilder::parseNumeric<short>(antlr4::tree::TerminalNode*, std::function<short (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✓ Branch 4 → 5 taken 872 times.
✗ Branch 4 → 9 not taken.
✓ Branch 6 → 7 taken 538 times.
✓ Branch 6 → 9 taken 334 times.
✗ Branch 8 → 9 not taken.
✓ Branch 8 → 10 taken 538 times.
|
12275 | const bool isUnsigned = input.ends_with('u') || input.ends_with("us") || input.ends_with("ul"); |
| 1761 | |||
| 1762 | try { | ||
| 1763 |
6/6int spice::compiler::ASTBuilder::parseNumeric<int>(antlr4::tree::TerminalNode*, std::function<int (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✓ Branch 12 → 13 taken 677 times.
✓ Branch 12 → 30 taken 4326 times.
long spice::compiler::ASTBuilder::parseNumeric<long>(antlr4::tree::TerminalNode*, std::function<long (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✓ Branch 12 → 13 taken 1588 times.
✓ Branch 12 → 30 taken 4812 times.
short spice::compiler::ASTBuilder::parseNumeric<short>(antlr4::tree::TerminalNode*, std::function<short (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✓ Branch 12 → 13 taken 670 times.
✓ Branch 12 → 30 taken 202 times.
|
12275 | if (input.length() >= 3) { |
| 1764 |
6/6int spice::compiler::ASTBuilder::parseNumeric<int>(antlr4::tree::TerminalNode*, std::function<int (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✓ Branch 14 → 15 taken 199 times.
✓ Branch 14 → 30 taken 478 times.
long spice::compiler::ASTBuilder::parseNumeric<long>(antlr4::tree::TerminalNode*, std::function<long (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✓ Branch 14 → 15 taken 50 times.
✓ Branch 14 → 30 taken 1538 times.
short spice::compiler::ASTBuilder::parseNumeric<short>(antlr4::tree::TerminalNode*, std::function<short (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✓ Branch 14 → 15 taken 109 times.
✓ Branch 14 → 30 taken 561 times.
|
2935 | if (input[0] == '0') { |
| 1765 |
3/6int spice::compiler::ASTBuilder::parseNumeric<int>(antlr4::tree::TerminalNode*, std::function<int (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✓ Branch 15 → 16 taken 199 times.
✗ Branch 15 → 37 not taken.
long spice::compiler::ASTBuilder::parseNumeric<long>(antlr4::tree::TerminalNode*, std::function<long (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✓ Branch 15 → 16 taken 50 times.
✗ Branch 15 → 37 not taken.
short spice::compiler::ASTBuilder::parseNumeric<short>(antlr4::tree::TerminalNode*, std::function<short (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✓ Branch 15 → 16 taken 109 times.
✗ Branch 15 → 37 not taken.
|
358 | const std::string subStr = input.substr(2); |
| 1766 |
5/15int spice::compiler::ASTBuilder::parseNumeric<int>(antlr4::tree::TerminalNode*, std::function<int (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✗ Branch 17 → 18 not taken.
✗ Branch 17 → 20 not taken.
✗ Branch 17 → 22 not taken.
✓ Branch 17 → 24 taken 199 times.
✗ Branch 17 → 26 not taken.
long spice::compiler::ASTBuilder::parseNumeric<long>(antlr4::tree::TerminalNode*, std::function<long (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✗ Branch 17 → 18 not taken.
✗ Branch 17 → 20 not taken.
✓ Branch 17 → 22 taken 38 times.
✗ Branch 17 → 24 not taken.
✓ Branch 17 → 26 taken 12 times.
short spice::compiler::ASTBuilder::parseNumeric<short>(antlr4::tree::TerminalNode*, std::function<short (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✗ Branch 17 → 18 not taken.
✗ Branch 17 → 20 not taken.
✗ Branch 17 → 22 not taken.
✓ Branch 17 → 24 taken 108 times.
✓ Branch 17 → 26 taken 1 time.
|
358 | switch (input[1]) { |
| 1767 | ✗ | case 'd': // fall-through | |
| 1768 | case 'D': | ||
| 1769 | ✗ | return cb(subStr, 10, !isUnsigned); | |
| 1770 | ✗ | case 'b': // fall-through | |
| 1771 | case 'B': | ||
| 1772 | ✗ | return cb(subStr, 2, !isUnsigned); | |
| 1773 | 38 | case 'h': // fall-through | |
| 1774 | case 'H': // fall-through | ||
| 1775 | case 'x': // fall-through | ||
| 1776 | case 'X': | ||
| 1777 |
1/6int spice::compiler::ASTBuilder::parseNumeric<int>(antlr4::tree::TerminalNode*, std::function<int (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✗ Branch 22 → 23 not taken.
✗ Branch 22 → 35 not taken.
long spice::compiler::ASTBuilder::parseNumeric<long>(antlr4::tree::TerminalNode*, std::function<long (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✓ Branch 22 → 23 taken 38 times.
✗ Branch 22 → 35 not taken.
short spice::compiler::ASTBuilder::parseNumeric<short>(antlr4::tree::TerminalNode*, std::function<short (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✗ Branch 22 → 23 not taken.
✗ Branch 22 → 35 not taken.
|
38 | return cb(subStr, 16, !isUnsigned); |
| 1778 | 307 | case 'o': // fall-through | |
| 1779 | case 'O': | ||
| 1780 |
2/6int spice::compiler::ASTBuilder::parseNumeric<int>(antlr4::tree::TerminalNode*, std::function<int (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✓ Branch 24 → 25 taken 199 times.
✗ Branch 24 → 35 not taken.
long spice::compiler::ASTBuilder::parseNumeric<long>(antlr4::tree::TerminalNode*, std::function<long (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✗ Branch 24 → 25 not taken.
✗ Branch 24 → 35 not taken.
short spice::compiler::ASTBuilder::parseNumeric<short>(antlr4::tree::TerminalNode*, std::function<short (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✓ Branch 24 → 25 taken 108 times.
✗ Branch 24 → 35 not taken.
|
307 | return cb(subStr, 8, !isUnsigned); |
| 1781 | 13 | default: // default is decimal | |
| 1782 |
2/6int spice::compiler::ASTBuilder::parseNumeric<int>(antlr4::tree::TerminalNode*, std::function<int (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✗ Branch 26 → 27 not taken.
✗ Branch 26 → 35 not taken.
long spice::compiler::ASTBuilder::parseNumeric<long>(antlr4::tree::TerminalNode*, std::function<long (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✓ Branch 26 → 27 taken 12 times.
✗ Branch 26 → 35 not taken.
short spice::compiler::ASTBuilder::parseNumeric<short>(antlr4::tree::TerminalNode*, std::function<short (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✓ Branch 26 → 27 taken 1 time.
✗ Branch 26 → 35 not taken.
|
13 | return cb(input, 10, !isUnsigned); |
| 1783 | } | ||
| 1784 | 358 | } | |
| 1785 | } | ||
| 1786 |
4/6int spice::compiler::ASTBuilder::parseNumeric<int>(antlr4::tree::TerminalNode*, std::function<int (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✓ Branch 30 → 31 taken 4803 times.
✓ Branch 30 → 38 taken 1 time.
long spice::compiler::ASTBuilder::parseNumeric<long>(antlr4::tree::TerminalNode*, std::function<long (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✓ Branch 30 → 31 taken 6350 times.
✗ Branch 30 → 38 not taken.
short spice::compiler::ASTBuilder::parseNumeric<short>(antlr4::tree::TerminalNode*, std::function<short (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✓ Branch 30 → 31 taken 763 times.
✗ Branch 30 → 38 not taken.
|
11917 | return cb(input, 10, !isUnsigned); |
| 1787 |
1/9int spice::compiler::ASTBuilder::parseNumeric<int>(antlr4::tree::TerminalNode*, std::function<int (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✗ Branch 38 → 39 not taken.
✓ Branch 38 → 40 taken 1 time.
✗ Branch 38 → 51 not taken.
long spice::compiler::ASTBuilder::parseNumeric<long>(antlr4::tree::TerminalNode*, std::function<long (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✗ Branch 38 → 39 not taken.
✗ Branch 38 → 40 not taken.
✗ Branch 38 → 51 not taken.
short spice::compiler::ASTBuilder::parseNumeric<short>(antlr4::tree::TerminalNode*, std::function<short (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✗ Branch 38 → 39 not taken.
✗ Branch 38 → 40 not taken.
✗ Branch 38 → 51 not taken.
|
2 | } catch (std::out_of_range &) { |
| 1788 |
2/12int spice::compiler::ASTBuilder::parseNumeric<int>(antlr4::tree::TerminalNode*, std::function<int (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✓ Branch 41 → 42 taken 1 time.
✗ Branch 41 → 70 not taken.
✓ Branch 42 → 43 taken 1 time.
✗ Branch 42 → 70 not taken.
long spice::compiler::ASTBuilder::parseNumeric<long>(antlr4::tree::TerminalNode*, std::function<long (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✗ Branch 41 → 42 not taken.
✗ Branch 41 → 70 not taken.
✗ Branch 42 → 43 not taken.
✗ Branch 42 → 70 not taken.
short spice::compiler::ASTBuilder::parseNumeric<short>(antlr4::tree::TerminalNode*, std::function<short (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✗ Branch 41 → 42 not taken.
✗ Branch 41 → 70 not taken.
✗ Branch 42 → 43 not taken.
✗ Branch 42 → 70 not taken.
|
1 | const CodeLoc codeLoc(terminal->getSymbol(), sourceFile); |
| 1789 |
2/12int spice::compiler::ASTBuilder::parseNumeric<int>(antlr4::tree::TerminalNode*, std::function<int (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✓ Branch 46 → 47 taken 1 time.
✗ Branch 46 → 64 not taken.
✓ Branch 47 → 48 taken 1 time.
✗ Branch 47 → 61 not taken.
long spice::compiler::ASTBuilder::parseNumeric<long>(antlr4::tree::TerminalNode*, std::function<long (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✗ Branch 46 → 47 not taken.
✗ Branch 46 → 64 not taken.
✗ Branch 47 → 48 not taken.
✗ Branch 47 → 61 not taken.
short spice::compiler::ASTBuilder::parseNumeric<short>(antlr4::tree::TerminalNode*, std::function<short (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✗ Branch 46 → 47 not taken.
✗ Branch 46 → 64 not taken.
✗ Branch 47 → 48 not taken.
✗ Branch 47 → 61 not taken.
|
3 | throw ParserError(codeLoc, NUMBER_OUT_OF_RANGE, "The provided number is out of range"); |
| 1790 | ✗ | } catch (std::invalid_argument &) { | |
| 1791 | ✗ | const CodeLoc codeLoc(terminal->getSymbol(), sourceFile); | |
| 1792 | ✗ | throw ParserError(codeLoc, NUMBER_OUT_OF_RANGE, "You tried to parse '" + input + "' as an integer, but it was no integer"); | |
| 1793 | } | ||
| 1794 | 12275 | } | |
| 1795 | |||
| 1796 | 3589 | void ASTBuilder::replaceEscapeChars(std::string &input) { | |
| 1797 | const std::unordered_map<char, char> escapeMap = { | ||
| 1798 | {'a', '\a'}, {'b', '\b'}, {'f', '\f'}, {'n', '\n'}, {'r', '\r'}, {'t', '\t'}, | ||
| 1799 | {'v', '\v'}, {'\\', '\\'}, {'?', '\?'}, {'\'', '\''}, {'"', '\"'}, | ||
| 1800 |
1/2✓ Branch 4 → 5 taken 3589 times.
✗ Branch 4 → 40 not taken.
|
7178 | }; |
| 1801 | |||
| 1802 | 3589 | size_t writeIndex = 0; | |
| 1803 | 3589 | size_t readIndex = 0; | |
| 1804 | 3589 | const size_t len = input.length(); | |
| 1805 | |||
| 1806 |
2/2✓ Branch 36 → 8 taken 54907 times.
✓ Branch 36 → 37 taken 3589 times.
|
58496 | while (readIndex < len) { |
| 1807 | 54907 | const char c = input[readIndex]; | |
| 1808 |
3/4✓ Branch 9 → 10 taken 703 times.
✓ Branch 9 → 33 taken 54204 times.
✓ Branch 10 → 11 taken 703 times.
✗ Branch 10 → 33 not taken.
|
54907 | if (c == '\\' && readIndex + 1 < len) { |
| 1809 | 703 | char next = input[readIndex + 1]; | |
| 1810 |
1/2✓ Branch 12 → 13 taken 703 times.
✗ Branch 12 → 45 not taken.
|
703 | auto it = escapeMap.find(next); |
| 1811 |
2/2✓ Branch 15 → 16 taken 694 times.
✓ Branch 15 → 19 taken 9 times.
|
703 | if (it != escapeMap.end()) { |
| 1812 | 694 | input[writeIndex++] = it->second; | |
| 1813 | 694 | readIndex += 2; | |
| 1814 | 700 | continue; | |
| 1815 | } | ||
| 1816 | |||
| 1817 | // Handle octal escape sequences (up to 3 digits) | ||
| 1818 |
3/4✓ Branch 19 → 20 taken 9 times.
✗ Branch 19 → 31 not taken.
✓ Branch 20 → 21 taken 6 times.
✓ Branch 20 → 31 taken 3 times.
|
9 | if (next >= '0' && next <= '7') { |
| 1819 | 6 | int value = 0; | |
| 1820 | 6 | size_t octalDigits = 0; | |
| 1821 | |||
| 1822 | // Look ahead up to 3 digits | ||
| 1823 |
3/4✓ Branch 26 → 27 taken 18 times.
✓ Branch 26 → 28 taken 6 times.
✓ Branch 27 → 22 taken 18 times.
✗ Branch 27 → 28 not taken.
|
24 | for (size_t i = 1; i <= 3 && readIndex + i < len; ++i) { |
| 1824 | 18 | const char oc = input[readIndex + i]; | |
| 1825 |
2/4✓ Branch 23 → 24 taken 18 times.
✗ Branch 23 → 28 not taken.
✓ Branch 24 → 25 taken 18 times.
✗ Branch 24 → 28 not taken.
|
18 | if (oc >= '0' && oc <= '7') { |
| 1826 | 18 | value = value << 3 | (oc - '0'); // multiply by 8 and add digit | |
| 1827 | 18 | octalDigits++; | |
| 1828 | } else { | ||
| 1829 | break; | ||
| 1830 | } | ||
| 1831 | } | ||
| 1832 | |||
| 1833 |
1/2✓ Branch 28 → 29 taken 6 times.
✗ Branch 28 → 31 not taken.
|
6 | if (octalDigits > 0) { |
| 1834 | 6 | input[writeIndex++] = static_cast<char>(value); | |
| 1835 | 6 | readIndex += 1 + octalDigits; // backslash + octal digits | |
| 1836 | 6 | continue; | |
| 1837 | } | ||
| 1838 | } | ||
| 1839 | } | ||
| 1840 | |||
| 1841 | // Copy current character | ||
| 1842 | 54207 | input[writeIndex++] = c; | |
| 1843 | 54207 | readIndex++; | |
| 1844 | } | ||
| 1845 | |||
| 1846 |
1/2✓ Branch 37 → 38 taken 3589 times.
✗ Branch 37 → 46 not taken.
|
3589 | input.resize(writeIndex); |
| 1847 | 3589 | } | |
| 1848 | |||
| 1849 | 122614 | std::string ASTBuilder::getIdentifier(TerminalNode *terminal, bool isTypeIdentifier) const { | |
| 1850 | 122614 | const std::string identifier = terminal->getText(); | |
| 1851 | |||
| 1852 | // Check if the list of reserved keywords contains the given identifier | ||
| 1853 |
3/4✓ Branch 3 → 4 taken 122614 times.
✗ Branch 3 → 56 not taken.
✓ Branch 6 → 7 taken 1 time.
✓ Branch 6 → 16 taken 122613 times.
|
245228 | if (std::ranges::find(RESERVED_KEYWORDS, identifier) != std::end(RESERVED_KEYWORDS)) { |
| 1854 |
2/4✓ Branch 7 → 8 taken 1 time.
✗ Branch 7 → 45 not taken.
✓ Branch 8 → 9 taken 1 time.
✗ Branch 8 → 45 not taken.
|
1 | const CodeLoc codeLoc(terminal->getSymbol(), sourceFile); |
| 1855 |
3/6✓ Branch 10 → 11 taken 1 time.
✗ Branch 10 → 41 not taken.
✓ Branch 11 → 12 taken 1 time.
✗ Branch 11 → 39 not taken.
✓ Branch 12 → 13 taken 1 time.
✗ Branch 12 → 36 not taken.
|
1 | throw ParserError(codeLoc, RESERVED_KEYWORD, "'" + identifier + "' is a reserved keyword. Please use another name instead"); |
| 1856 | } | ||
| 1857 | |||
| 1858 | // Check if the identifier is a type identifier and is reserved | ||
| 1859 |
6/6✓ Branch 16 → 17 taken 10034 times.
✓ Branch 16 → 23 taken 112579 times.
✓ Branch 17 → 18 taken 836 times.
✓ Branch 17 → 23 taken 9198 times.
✓ Branch 24 → 25 taken 1 time.
✓ Branch 24 → 34 taken 122612 times.
|
123449 | if (isTypeIdentifier && !sourceFile->isStdFile && |
| 1860 |
3/4✓ Branch 18 → 19 taken 836 times.
✗ Branch 18 → 56 not taken.
✓ Branch 21 → 22 taken 1 time.
✓ Branch 21 → 23 taken 835 times.
|
1672 | std::ranges::find(RESERVED_TYPE_NAMES, identifier) != std::end(RESERVED_TYPE_NAMES)) { |
| 1861 |
2/4✓ Branch 25 → 26 taken 1 time.
✗ Branch 25 → 55 not taken.
✓ Branch 26 → 27 taken 1 time.
✗ Branch 26 → 55 not taken.
|
1 | const CodeLoc codeLoc(terminal->getSymbol(), sourceFile); |
| 1862 |
3/6✓ Branch 28 → 29 taken 1 time.
✗ Branch 28 → 51 not taken.
✓ Branch 29 → 30 taken 1 time.
✗ Branch 29 → 49 not taken.
✓ Branch 30 → 31 taken 1 time.
✗ Branch 30 → 46 not taken.
|
1 | throw ParserError(codeLoc, RESERVED_TYPENAME, "'" + identifier + "' is a reserved type name. Please use another one instead"); |
| 1863 | } | ||
| 1864 | |||
| 1865 | 122612 | return identifier; | |
| 1866 | 2 | } | |
| 1867 | |||
| 1868 | } // namespace spice::compiler | ||
| 1869 |