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 | 10728 | ASTBuilder::ASTBuilder(GlobalResourceManager &resourceManager, SourceFile *sourceFile, antlr4::ANTLRInputStream *inputStream) | |
| 17 |
1/2✓ Branch 4 → 5 taken 10728 times.
✗ Branch 4 → 6 not taken.
|
10728 | : CompilerPass(resourceManager, sourceFile), inputStream(inputStream) {} |
| 18 | |||
| 19 | 10724 | std::any ASTBuilder::visitEntry(SpiceParser::EntryContext *ctx) { | |
| 20 | 10724 | const auto entryNode = createNode<EntryNode>(ctx); | |
| 21 | |||
| 22 | // Visit children | ||
| 23 |
2/2✓ Branch 144 → 5 taken 293925 times.
✓ Branch 144 → 145 taken 10712 times.
|
315361 | for (ParserRuleContext::ParseTree *child : ctx->children) { |
| 24 |
3/4✓ Branch 7 → 8 taken 293925 times.
✗ Branch 7 → 9 not taken.
✓ Branch 10 → 11 taken 1351 times.
✓ Branch 10 → 16 taken 292574 times.
|
293925 | if (auto *mainFctDefCtx = dynamic_cast<SpiceParser::MainFunctionDefContext *>(child)) |
| 25 |
4/6✓ Branch 11 → 12 taken 1343 times.
✓ Branch 11 → 157 taken 8 times.
✓ Branch 12 → 13 taken 1343 times.
✗ Branch 12 → 155 not taken.
✓ Branch 13 → 14 taken 1343 times.
✗ Branch 13 → 155 not taken.
|
1351 | entryNode->topLevelDefs.push_back(std::any_cast<MainFctDefNode *>(visit(mainFctDefCtx))); |
| 26 |
3/4✓ Branch 16 → 17 taken 292574 times.
✗ Branch 16 → 18 not taken.
✓ Branch 19 → 20 taken 125240 times.
✓ Branch 19 → 25 taken 167334 times.
|
292574 | else if (auto *fctDefCtx = dynamic_cast<SpiceParser::FunctionDefContext *>(child)) |
| 27 |
3/6✓ Branch 20 → 21 taken 125240 times.
✗ Branch 20 → 161 not taken.
✓ Branch 21 → 22 taken 125240 times.
✗ Branch 21 → 159 not taken.
✓ Branch 22 → 23 taken 125240 times.
✗ Branch 22 → 159 not taken.
|
125240 | entryNode->topLevelDefs.push_back(std::any_cast<FctDefNode *>(visit(fctDefCtx))); |
| 28 |
3/4✓ Branch 25 → 26 taken 167334 times.
✗ Branch 25 → 27 not taken.
✓ Branch 28 → 29 taken 55829 times.
✓ Branch 28 → 34 taken 111505 times.
|
167334 | else if (auto *procDefCtx = dynamic_cast<SpiceParser::ProcedureDefContext *>(child)) |
| 29 |
3/6✓ Branch 29 → 30 taken 55829 times.
✗ Branch 29 → 165 not taken.
✓ Branch 30 → 31 taken 55829 times.
✗ Branch 30 → 163 not taken.
✓ Branch 31 → 32 taken 55829 times.
✗ Branch 31 → 163 not taken.
|
55829 | entryNode->topLevelDefs.push_back(std::any_cast<ProcDefNode *>(visit(procDefCtx))); |
| 30 |
3/4✓ Branch 34 → 35 taken 111505 times.
✗ Branch 34 → 36 not taken.
✓ Branch 37 → 38 taken 14843 times.
✓ Branch 37 → 43 taken 96662 times.
|
111505 | else if (auto *structDefCtx = dynamic_cast<SpiceParser::StructDefContext *>(child)) |
| 31 |
4/6✓ Branch 38 → 39 taken 14841 times.
✓ Branch 38 → 169 taken 2 times.
✓ Branch 39 → 40 taken 14841 times.
✗ Branch 39 → 167 not taken.
✓ Branch 40 → 41 taken 14841 times.
✗ Branch 40 → 167 not taken.
|
14843 | entryNode->topLevelDefs.push_back(std::any_cast<StructDefNode *>(visit(structDefCtx))); |
| 32 |
3/4✓ Branch 43 → 44 taken 96662 times.
✗ Branch 43 → 45 not taken.
✓ Branch 46 → 47 taken 775 times.
✓ Branch 46 → 52 taken 95887 times.
|
96662 | else if (auto *interfaceDefCtx = dynamic_cast<SpiceParser::InterfaceDefContext *>(child)) |
| 33 |
3/6✓ Branch 47 → 48 taken 775 times.
✗ Branch 47 → 173 not taken.
✓ Branch 48 → 49 taken 775 times.
✗ Branch 48 → 171 not taken.
✓ Branch 49 → 50 taken 775 times.
✗ Branch 49 → 171 not taken.
|
775 | entryNode->topLevelDefs.push_back(std::any_cast<InterfaceDefNode *>(visit(interfaceDefCtx))); |
| 34 |
3/4✓ Branch 52 → 53 taken 95887 times.
✗ Branch 52 → 54 not taken.
✓ Branch 55 → 56 taken 86 times.
✓ Branch 55 → 61 taken 95801 times.
|
95887 | else if (auto *unionDefCtx = dynamic_cast<SpiceParser::UnionDefContext *>(child)) |
| 35 |
3/6✓ Branch 56 → 57 taken 86 times.
✗ Branch 56 → 177 not taken.
✓ Branch 57 → 58 taken 86 times.
✗ Branch 57 → 175 not taken.
✓ Branch 58 → 59 taken 86 times.
✗ Branch 58 → 175 not taken.
|
86 | entryNode->topLevelDefs.push_back(std::any_cast<UnionDefNode *>(visit(unionDefCtx))); |
| 36 |
3/4✓ Branch 61 → 62 taken 95801 times.
✗ Branch 61 → 63 not taken.
✓ Branch 64 → 65 taken 4254 times.
✓ Branch 64 → 70 taken 91547 times.
|
95801 | else if (auto *enumDefCtx = dynamic_cast<SpiceParser::EnumDefContext *>(child)) |
| 37 |
3/6✓ Branch 65 → 66 taken 4254 times.
✗ Branch 65 → 181 not taken.
✓ Branch 66 → 67 taken 4254 times.
✗ Branch 66 → 179 not taken.
✓ Branch 67 → 68 taken 4254 times.
✗ Branch 67 → 179 not taken.
|
4254 | entryNode->topLevelDefs.push_back(std::any_cast<EnumDefNode *>(visit(enumDefCtx))); |
| 38 |
3/4✓ Branch 70 → 71 taken 91547 times.
✗ Branch 70 → 72 not taken.
✓ Branch 73 → 74 taken 7047 times.
✓ Branch 73 → 79 taken 84500 times.
|
91547 | else if (auto *genericTypeDefCtx = dynamic_cast<SpiceParser::GenericTypeDefContext *>(child)) |
| 39 |
3/6✓ Branch 74 → 75 taken 7047 times.
✗ Branch 74 → 185 not taken.
✓ Branch 75 → 76 taken 7047 times.
✗ Branch 75 → 183 not taken.
✓ Branch 76 → 77 taken 7047 times.
✗ Branch 76 → 183 not taken.
|
7047 | entryNode->topLevelDefs.push_back(std::any_cast<GenericTypeDefNode *>(visit(genericTypeDefCtx))); |
| 40 |
3/4✓ Branch 79 → 80 taken 84500 times.
✗ Branch 79 → 81 not taken.
✓ Branch 82 → 83 taken 2893 times.
✓ Branch 82 → 88 taken 81607 times.
|
84500 | else if (auto *aliasDefCtx = dynamic_cast<SpiceParser::AliasDefContext *>(child)) |
| 41 |
3/6✓ Branch 83 → 84 taken 2893 times.
✗ Branch 83 → 189 not taken.
✓ Branch 84 → 85 taken 2893 times.
✗ Branch 84 → 187 not taken.
✓ Branch 85 → 86 taken 2893 times.
✗ Branch 85 → 187 not taken.
|
2893 | entryNode->topLevelDefs.push_back(std::any_cast<AliasDefNode *>(visit(aliasDefCtx))); |
| 42 |
3/4✓ Branch 88 → 89 taken 81607 times.
✗ Branch 88 → 90 not taken.
✓ Branch 91 → 92 taken 19515 times.
✓ Branch 91 → 97 taken 62092 times.
|
81607 | else if (auto *globalVarDefCtx = dynamic_cast<SpiceParser::GlobalVarDefContext *>(child)) |
| 43 |
3/6✓ Branch 92 → 93 taken 19515 times.
✗ Branch 92 → 193 not taken.
✓ Branch 93 → 94 taken 19515 times.
✗ Branch 93 → 191 not taken.
✓ Branch 94 → 95 taken 19515 times.
✗ Branch 94 → 191 not taken.
|
19515 | entryNode->topLevelDefs.push_back(std::any_cast<GlobalVarDefNode *>(visit(globalVarDefCtx))); |
| 44 |
3/4✓ Branch 97 → 98 taken 62092 times.
✗ Branch 97 → 99 not taken.
✓ Branch 100 → 101 taken 32858 times.
✓ Branch 100 → 106 taken 29234 times.
|
62092 | else if (auto *importDefCtx = dynamic_cast<SpiceParser::ImportDefContext *>(child)) |
| 45 |
3/6✓ Branch 101 → 102 taken 32858 times.
✗ Branch 101 → 197 not taken.
✓ Branch 102 → 103 taken 32858 times.
✗ Branch 102 → 195 not taken.
✓ Branch 103 → 104 taken 32858 times.
✗ Branch 103 → 195 not taken.
|
32858 | entryNode->importDefs.push_back(std::any_cast<ImportDefNode *>(visit(importDefCtx))); |
| 46 |
3/4✓ Branch 106 → 107 taken 29234 times.
✗ Branch 106 → 108 not taken.
✓ Branch 109 → 110 taken 16020 times.
✓ Branch 109 → 115 taken 13214 times.
|
29234 | else if (auto *extDeclCtx = dynamic_cast<SpiceParser::ExtDeclContext *>(child)) |
| 47 |
3/6✓ Branch 110 → 111 taken 16020 times.
✗ Branch 110 → 201 not taken.
✓ Branch 111 → 112 taken 16020 times.
✗ Branch 111 → 199 not taken.
✓ Branch 112 → 113 taken 16020 times.
✗ Branch 112 → 199 not taken.
|
16020 | entryNode->topLevelDefs.push_back(std::any_cast<ExtDeclNode *>(visit(extDeclCtx))); |
| 48 |
3/4✓ Branch 115 → 116 taken 13214 times.
✗ Branch 115 → 117 not taken.
✓ Branch 118 → 119 taken 2502 times.
✓ Branch 118 → 124 taken 10712 times.
|
13214 | else if (auto *modAttrCtx = dynamic_cast<SpiceParser::ModAttrContext *>(child)) |
| 49 |
4/6✓ Branch 119 → 120 taken 2500 times.
✓ Branch 119 → 205 taken 2 times.
✓ Branch 120 → 121 taken 2500 times.
✗ Branch 120 → 203 not taken.
✓ Branch 121 → 122 taken 2500 times.
✗ Branch 121 → 203 not taken.
|
2502 | entryNode->modAttrs.push_back(std::any_cast<ModAttrNode *>(visit(modAttrCtx))); |
| 50 |
1/2✓ Branch 124 → 125 taken 10712 times.
✗ Branch 124 → 126 not taken.
|
10712 | else if (const auto *eofCtx = dynamic_cast<TerminalNode *>(child); |
| 51 |
5/10✓ Branch 127 → 128 taken 10712 times.
✗ Branch 127 → 131 not taken.
✓ Branch 128 → 129 taken 10712 times.
✗ Branch 128 → 207 not taken.
✓ Branch 129 → 130 taken 10712 times.
✗ Branch 129 → 207 not taken.
✗ Branch 130 → 131 not taken.
✓ Branch 130 → 132 taken 10712 times.
✗ Branch 133 → 134 not taken.
✓ Branch 133 → 135 taken 10712 times.
|
10712 | !eofCtx || eofCtx->getSymbol()->getType() != SpiceParser::EOF) |
| 52 | − | assert_fail("Unknown top level definition type"); // GCOV_EXCL_LINE | |
| 53 | } | ||
| 54 | |||
| 55 |
1/2✓ Branch 151 → 152 taken 10712 times.
✗ Branch 151 → 208 not taken.
|
21424 | return concludeNode(entryNode); |
| 56 | } | ||
| 57 | |||
| 58 | 1351 | std::any ASTBuilder::visitMainFunctionDef(SpiceParser::MainFunctionDefContext *ctx) { | |
| 59 | 1351 | const auto mainFctDefNode = createNode<MainFctDefNode>(ctx); | |
| 60 | |||
| 61 | // Visit children | ||
| 62 |
2/2✓ Branch 4 → 5 taken 2 times.
✓ Branch 4 → 10 taken 1349 times.
|
1351 | if (ctx->topLevelDefAttr()) |
| 63 |
3/6✓ Branch 5 → 6 taken 2 times.
✗ Branch 5 → 33 not taken.
✓ Branch 6 → 7 taken 2 times.
✗ Branch 6 → 33 not taken.
✓ Branch 7 → 8 taken 2 times.
✗ Branch 7 → 31 not taken.
|
2 | mainFctDefNode->attrs = std::any_cast<TopLevelDefAttrNode *>(visit(ctx->topLevelDefAttr())); |
| 64 |
2/2✓ Branch 11 → 12 taken 14 times.
✓ Branch 11 → 17 taken 1337 times.
|
1351 | if (ctx->paramLst()) { |
| 65 | 14 | mainFctDefNode->takesArgs = true; | |
| 66 |
3/6✓ Branch 12 → 13 taken 14 times.
✗ Branch 12 → 36 not taken.
✓ Branch 13 → 14 taken 14 times.
✗ Branch 13 → 36 not taken.
✓ Branch 14 → 15 taken 14 times.
✗ Branch 14 → 34 not taken.
|
14 | mainFctDefNode->paramLst = std::any_cast<ParamLstNode *>(visit(ctx->paramLst())); |
| 67 | } | ||
| 68 |
5/8✓ Branch 17 → 18 taken 1351 times.
✗ Branch 17 → 39 not taken.
✓ Branch 18 → 19 taken 1343 times.
✓ Branch 18 → 39 taken 8 times.
✓ Branch 19 → 20 taken 1343 times.
✗ Branch 19 → 37 not taken.
✓ Branch 21 → 22 taken 1343 times.
✗ Branch 21 → 40 not taken.
|
1351 | mainFctDefNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 69 | |||
| 70 |
1/2✓ Branch 27 → 28 taken 1343 times.
✗ Branch 27 → 40 not taken.
|
2686 | return concludeNode(mainFctDefNode); |
| 71 | } | ||
| 72 | |||
| 73 | 125240 | std::any ASTBuilder::visitFunctionDef(SpiceParser::FunctionDefContext *ctx) { | |
| 74 | 125240 | const auto fctDefNode = createNode<FctDefNode>(ctx); | |
| 75 | |||
| 76 | // Visit children | ||
| 77 |
2/2✓ Branch 4 → 5 taken 3600 times.
✓ Branch 4 → 24 taken 121640 times.
|
125240 | if (ctx->topLevelDefAttr()) { |
| 78 |
3/6✓ Branch 5 → 6 taken 3600 times.
✗ Branch 5 → 70 not taken.
✓ Branch 6 → 7 taken 3600 times.
✗ Branch 6 → 70 not taken.
✓ Branch 7 → 8 taken 3600 times.
✗ Branch 7 → 68 not taken.
|
3600 | fctDefNode->attrs = std::any_cast<TopLevelDefAttrNode *>(visit(ctx->topLevelDefAttr())); |
| 79 | // Tell the attributes that they are function attributes | ||
| 80 |
2/2✓ Branch 22 → 11 taken 4956 times.
✓ Branch 22 → 23 taken 3600 times.
|
12156 | for (AttrNode *attr : fctDefNode->attrs->attrLst->attributes) |
| 81 | 4956 | attr->target = AttrNode::TARGET_FCT_PROC; | |
| 82 | } | ||
| 83 |
2/2✓ Branch 25 → 26 taken 111330 times.
✓ Branch 25 → 31 taken 13910 times.
|
125240 | if (ctx->qualifierLst()) |
| 84 |
3/6✓ Branch 26 → 27 taken 111330 times.
✗ Branch 26 → 73 not taken.
✓ Branch 27 → 28 taken 111330 times.
✗ Branch 27 → 73 not taken.
✓ Branch 28 → 29 taken 111330 times.
✗ Branch 28 → 71 not taken.
|
111330 | fctDefNode->qualifierLst = std::any_cast<QualifierLstNode *>(visit(ctx->qualifierLst())); |
| 85 |
3/6✓ Branch 31 → 32 taken 125240 times.
✗ Branch 31 → 76 not taken.
✓ Branch 32 → 33 taken 125240 times.
✗ Branch 32 → 76 not taken.
✓ Branch 33 → 34 taken 125240 times.
✗ Branch 33 → 74 not taken.
|
125240 | fctDefNode->returnType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 86 | 125240 | fctDefNode->returnType->isReturnType = true; | |
| 87 |
3/6✓ Branch 35 → 36 taken 125240 times.
✗ Branch 35 → 79 not taken.
✓ Branch 36 → 37 taken 125240 times.
✗ Branch 36 → 79 not taken.
✓ Branch 37 → 38 taken 125240 times.
✗ Branch 37 → 77 not taken.
|
125240 | fctDefNode->name = std::any_cast<FctNameNode *>(visit(ctx->fctName())); |
| 88 | 125240 | fctDefNode->isMethod = fctDefNode->name->nameFragments.size() > 1; | |
| 89 |
2/2✓ Branch 41 → 42 taken 8411 times.
✓ Branch 41 → 47 taken 116829 times.
|
125240 | if (ctx->typeLst()) { |
| 90 | 8411 | fctDefNode->hasTemplateTypes = true; | |
| 91 |
3/6✓ Branch 42 → 43 taken 8411 times.
✗ Branch 42 → 82 not taken.
✓ Branch 43 → 44 taken 8411 times.
✗ Branch 43 → 82 not taken.
✓ Branch 44 → 45 taken 8411 times.
✗ Branch 44 → 80 not taken.
|
8411 | fctDefNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst())); |
| 92 | } | ||
| 93 |
2/2✓ Branch 48 → 49 taken 83436 times.
✓ Branch 48 → 54 taken 41804 times.
|
125240 | if (ctx->paramLst()) { |
| 94 | 83436 | fctDefNode->hasParams = true; | |
| 95 |
3/6✓ Branch 49 → 50 taken 83436 times.
✗ Branch 49 → 85 not taken.
✓ Branch 50 → 51 taken 83436 times.
✗ Branch 50 → 85 not taken.
✓ Branch 51 → 52 taken 83436 times.
✗ Branch 51 → 83 not taken.
|
83436 | fctDefNode->paramLst = std::any_cast<ParamLstNode *>(visit(ctx->paramLst())); |
| 96 | } | ||
| 97 |
4/8✓ Branch 54 → 55 taken 125240 times.
✗ Branch 54 → 88 not taken.
✓ Branch 55 → 56 taken 125240 times.
✗ Branch 55 → 88 not taken.
✓ Branch 56 → 57 taken 125240 times.
✗ Branch 56 → 86 not taken.
✓ Branch 58 → 59 taken 125240 times.
✗ Branch 58 → 89 not taken.
|
125240 | fctDefNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 98 | |||
| 99 |
1/2✓ Branch 64 → 65 taken 125240 times.
✗ Branch 64 → 89 not taken.
|
250480 | return concludeNode(fctDefNode); |
| 100 | } | ||
| 101 | |||
| 102 | 55829 | std::any ASTBuilder::visitProcedureDef(SpiceParser::ProcedureDefContext *ctx) { | |
| 103 | 55829 | const auto procDefNode = createNode<ProcDefNode>(ctx); | |
| 104 | |||
| 105 | // Visit children | ||
| 106 |
2/2✓ Branch 4 → 5 taken 2 times.
✓ Branch 4 → 24 taken 55827 times.
|
55829 | if (ctx->topLevelDefAttr()) { |
| 107 |
3/6✓ Branch 5 → 6 taken 2 times.
✗ Branch 5 → 66 not taken.
✓ Branch 6 → 7 taken 2 times.
✗ Branch 6 → 66 not taken.
✓ Branch 7 → 8 taken 2 times.
✗ Branch 7 → 64 not taken.
|
2 | procDefNode->attrs = std::any_cast<TopLevelDefAttrNode *>(visit(ctx->topLevelDefAttr())); |
| 108 | // Tell the attributes that they are function attributes | ||
| 109 |
2/2✓ Branch 22 → 11 taken 2 times.
✓ Branch 22 → 23 taken 2 times.
|
6 | for (AttrNode *attr : procDefNode->attrs->attrLst->attributes) |
| 110 | 2 | attr->target = AttrNode::TARGET_FCT_PROC; | |
| 111 | } | ||
| 112 |
2/2✓ Branch 25 → 26 taken 46019 times.
✓ Branch 25 → 31 taken 9810 times.
|
55829 | if (ctx->qualifierLst()) |
| 113 |
3/6✓ Branch 26 → 27 taken 46019 times.
✗ Branch 26 → 69 not taken.
✓ Branch 27 → 28 taken 46019 times.
✗ Branch 27 → 69 not taken.
✓ Branch 28 → 29 taken 46019 times.
✗ Branch 28 → 67 not taken.
|
46019 | procDefNode->qualifierLst = std::any_cast<QualifierLstNode *>(visit(ctx->qualifierLst())); |
| 114 |
3/6✓ Branch 31 → 32 taken 55829 times.
✗ Branch 31 → 72 not taken.
✓ Branch 32 → 33 taken 55829 times.
✗ Branch 32 → 72 not taken.
✓ Branch 33 → 34 taken 55829 times.
✗ Branch 33 → 70 not taken.
|
55829 | procDefNode->name = std::any_cast<FctNameNode *>(visit(ctx->fctName())); |
| 115 | 55829 | procDefNode->isMethod = procDefNode->name->nameFragments.size() > 1; | |
| 116 |
2/2✓ Branch 37 → 38 taken 7018 times.
✓ Branch 37 → 43 taken 48811 times.
|
55829 | if (ctx->typeLst()) { |
| 117 | 7018 | procDefNode->hasTemplateTypes = true; | |
| 118 |
3/6✓ Branch 38 → 39 taken 7018 times.
✗ Branch 38 → 75 not taken.
✓ Branch 39 → 40 taken 7018 times.
✗ Branch 39 → 75 not taken.
✓ Branch 40 → 41 taken 7018 times.
✗ Branch 40 → 73 not taken.
|
7018 | procDefNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst())); |
| 119 | } | ||
| 120 |
2/2✓ Branch 44 → 45 taken 40981 times.
✓ Branch 44 → 50 taken 14848 times.
|
55829 | if (ctx->paramLst()) { |
| 121 | 40981 | procDefNode->hasParams = true; | |
| 122 |
3/6✓ Branch 45 → 46 taken 40981 times.
✗ Branch 45 → 78 not taken.
✓ Branch 46 → 47 taken 40981 times.
✗ Branch 46 → 78 not taken.
✓ Branch 47 → 48 taken 40981 times.
✗ Branch 47 → 76 not taken.
|
40981 | procDefNode->paramLst = std::any_cast<ParamLstNode *>(visit(ctx->paramLst())); |
| 123 | } | ||
| 124 |
4/8✓ Branch 50 → 51 taken 55829 times.
✗ Branch 50 → 81 not taken.
✓ Branch 51 → 52 taken 55829 times.
✗ Branch 51 → 81 not taken.
✓ Branch 52 → 53 taken 55829 times.
✗ Branch 52 → 79 not taken.
✓ Branch 54 → 55 taken 55829 times.
✗ Branch 54 → 82 not taken.
|
55829 | procDefNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 125 | |||
| 126 |
1/2✓ Branch 60 → 61 taken 55829 times.
✗ Branch 60 → 82 not taken.
|
111658 | return concludeNode(procDefNode); |
| 127 | } | ||
| 128 | |||
| 129 | 181069 | std::any ASTBuilder::visitFctName(SpiceParser::FctNameContext *ctx) { | |
| 130 |
1/2✓ Branch 2 → 3 taken 181069 times.
✗ Branch 2 → 54 not taken.
|
181069 | const auto fctNameNode = createNode<FctNameNode>(ctx); |
| 131 | |||
| 132 | // Extract function name | ||
| 133 |
1/2✓ Branch 3 → 4 taken 181069 times.
✗ Branch 3 → 54 not taken.
|
181069 | std::stringstream fqName; |
| 134 |
3/4✓ Branch 4 → 5 taken 181069 times.
✗ Branch 4 → 52 not taken.
✓ Branch 5 → 6 taken 130574 times.
✓ Branch 5 → 14 taken 50495 times.
|
181069 | if (ctx->TYPE_IDENTIFIER()) { |
| 135 |
2/4✓ Branch 6 → 7 taken 130574 times.
✗ Branch 6 → 45 not taken.
✓ Branch 7 → 8 taken 130574 times.
✗ Branch 7 → 45 not taken.
|
130574 | const std::string typeIdentifier = getIdentifier(ctx->TYPE_IDENTIFIER(), true); |
| 136 |
1/2✓ Branch 8 → 9 taken 130574 times.
✗ Branch 8 → 43 not taken.
|
130574 | fctNameNode->structName = typeIdentifier; |
| 137 |
2/4✓ Branch 9 → 10 taken 130574 times.
✗ Branch 9 → 43 not taken.
✓ Branch 10 → 11 taken 130574 times.
✗ Branch 10 → 43 not taken.
|
130574 | fqName << typeIdentifier << MEMBER_ACCESS_TOKEN; |
| 138 |
1/2✓ Branch 11 → 12 taken 130574 times.
✗ Branch 11 → 43 not taken.
|
130574 | fctNameNode->nameFragments.push_back(typeIdentifier); |
| 139 | 130574 | } | |
| 140 |
3/4✓ Branch 14 → 15 taken 181069 times.
✗ Branch 14 → 52 not taken.
✓ Branch 15 → 16 taken 169787 times.
✓ Branch 15 → 23 taken 11282 times.
|
181069 | if (ctx->IDENTIFIER()) { |
| 141 |
2/4✓ Branch 16 → 17 taken 169787 times.
✗ Branch 16 → 48 not taken.
✓ Branch 17 → 18 taken 169787 times.
✗ Branch 17 → 48 not taken.
|
169787 | const std::string fctIdentifier = getIdentifier(ctx->IDENTIFIER(), false); |
| 142 |
1/2✓ Branch 18 → 19 taken 169787 times.
✗ Branch 18 → 46 not taken.
|
169787 | fctNameNode->name = fctIdentifier; |
| 143 |
1/2✓ Branch 19 → 20 taken 169787 times.
✗ Branch 19 → 46 not taken.
|
169787 | fqName << fctIdentifier; |
| 144 |
1/2✓ Branch 20 → 21 taken 169787 times.
✗ Branch 20 → 46 not taken.
|
169787 | fctNameNode->nameFragments.push_back(fctIdentifier); |
| 145 | 169787 | } | |
| 146 |
1/2✓ Branch 23 → 24 taken 181069 times.
✗ Branch 23 → 49 not taken.
|
181069 | fctNameNode->fqName = fqName.str(); |
| 147 | |||
| 148 | // Visit children | ||
| 149 |
3/4✓ Branch 26 → 27 taken 181069 times.
✗ Branch 26 → 52 not taken.
✓ Branch 27 → 28 taken 11282 times.
✓ Branch 27 → 32 taken 169787 times.
|
181069 | if (ctx->overloadableOp()) |
| 150 |
2/4✓ Branch 28 → 29 taken 11282 times.
✗ Branch 28 → 50 not taken.
✓ Branch 29 → 30 taken 11282 times.
✗ Branch 29 → 50 not taken.
|
11282 | visit(ctx->overloadableOp()); |
| 151 | |||
| 152 |
1/2✓ Branch 38 → 39 taken 181069 times.
✗ Branch 38 → 51 not taken.
|
362138 | return concludeNode(fctNameNode); |
| 153 | 181069 | } | |
| 154 | |||
| 155 | 14843 | std::any ASTBuilder::visitStructDef(SpiceParser::StructDefContext *ctx) { | |
| 156 | 14843 | const auto structDefNode = createNode<StructDefNode>(ctx); | |
| 157 | |||
| 158 | // Enrich | ||
| 159 |
3/4✓ Branch 3 → 4 taken 14843 times.
✗ Branch 3 → 103 not taken.
✓ Branch 4 → 5 taken 14841 times.
✓ Branch 4 → 103 taken 2 times.
|
14843 | structDefNode->structName = getIdentifier(ctx->TYPE_IDENTIFIER(), true); |
| 160 | 14841 | structDefNode->typeId = resourceManager.getNextCustomTypeId(); | |
| 161 | |||
| 162 | // Visit children | ||
| 163 |
2/2✓ Branch 9 → 10 taken 282 times.
✓ Branch 9 → 49 taken 14559 times.
|
14841 | if (ctx->topLevelDefAttr()) { |
| 164 |
3/6✓ Branch 10 → 11 taken 282 times.
✗ Branch 10 → 106 not taken.
✓ Branch 11 → 12 taken 282 times.
✗ Branch 11 → 106 not taken.
✓ Branch 12 → 13 taken 282 times.
✗ Branch 12 → 104 not taken.
|
282 | structDefNode->attrs = std::any_cast<TopLevelDefAttrNode *>(visit(ctx->topLevelDefAttr())); |
| 165 | |||
| 166 | // Tell the attributes that they are struct attributes | ||
| 167 |
2/2✓ Branch 27 → 16 taken 282 times.
✓ Branch 27 → 28 taken 282 times.
|
846 | for (AttrNode *attr : structDefNode->attrs->attrLst->attributes) |
| 168 | 282 | attr->target = AttrNode::TARGET_STRUCT; | |
| 169 | |||
| 170 | // Check if a custom type id was set | ||
| 171 |
7/18✓ Branch 28 → 29 taken 282 times.
✗ Branch 28 → 35 not taken.
✓ Branch 31 → 32 taken 282 times.
✗ Branch 31 → 107 not taken.
✓ Branch 32 → 33 taken 282 times.
✗ Branch 32 → 107 not taken.
✗ Branch 33 → 34 not taken.
✓ Branch 33 → 35 taken 282 times.
✓ Branch 36 → 37 taken 282 times.
✗ Branch 36 → 38 not taken.
✓ Branch 38 → 39 taken 282 times.
✗ Branch 38 → 41 not taken.
✗ Branch 41 → 42 not taken.
✓ Branch 41 → 49 taken 282 times.
✗ Branch 107 → 108 not taken.
✗ Branch 107 → 109 not taken.
✗ Branch 111 → 112 not taken.
✗ Branch 111 → 114 not taken.
|
846 | if (structDefNode->attrs && structDefNode->attrs->attrLst->hasAttr(ATTR_CORE_COMPILER_FIXED_TYPE_ID)) |
| 172 | ✗ | structDefNode->typeId = structDefNode->attrs->attrLst->getAttrValueByName(ATTR_CORE_COMPILER_FIXED_TYPE_ID)->intValue; | |
| 173 | } | ||
| 174 |
2/2✓ Branch 50 → 51 taken 12649 times.
✓ Branch 50 → 56 taken 2192 times.
|
14841 | if (ctx->qualifierLst()) |
| 175 |
3/6✓ Branch 51 → 52 taken 12649 times.
✗ Branch 51 → 124 not taken.
✓ Branch 52 → 53 taken 12649 times.
✗ Branch 52 → 124 not taken.
✓ Branch 53 → 54 taken 12649 times.
✗ Branch 53 → 122 not taken.
|
12649 | structDefNode->qualifierLst = std::any_cast<QualifierLstNode *>(visit(ctx->qualifierLst())); |
| 176 |
2/2✓ Branch 57 → 58 taken 2682 times.
✓ Branch 57 → 63 taken 12159 times.
|
14841 | if (ctx->LESS()) { |
| 177 | 2682 | structDefNode->hasTemplateTypes = true; | |
| 178 |
3/6✓ Branch 58 → 59 taken 2682 times.
✗ Branch 58 → 127 not taken.
✓ Branch 59 → 60 taken 2682 times.
✗ Branch 59 → 127 not taken.
✓ Branch 60 → 61 taken 2682 times.
✗ Branch 60 → 125 not taken.
|
2682 | structDefNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst(0))); |
| 179 | } | ||
| 180 |
2/2✓ Branch 64 → 65 taken 5370 times.
✓ Branch 64 → 73 taken 9471 times.
|
14841 | if (ctx->COLON()) { |
| 181 | 5370 | structDefNode->hasInterfaces = true; | |
| 182 |
5/8✓ Branch 65 → 66 taken 1268 times.
✓ Branch 65 → 67 taken 4102 times.
✓ Branch 68 → 69 taken 5370 times.
✗ Branch 68 → 130 not taken.
✓ Branch 69 → 70 taken 5370 times.
✗ Branch 69 → 130 not taken.
✓ Branch 70 → 71 taken 5370 times.
✗ Branch 70 → 128 not taken.
|
5370 | structDefNode->interfaceTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst(structDefNode->hasTemplateTypes ? 1 : 0))); |
| 183 | } | ||
| 184 |
3/4✓ Branch 73 → 74 taken 14841 times.
✗ Branch 73 → 137 not taken.
✓ Branch 91 → 76 taken 58532 times.
✓ Branch 91 → 92 taken 14841 times.
|
88214 | for (SpiceParser::FieldContext *field : ctx->field()) |
| 185 |
3/6✓ Branch 78 → 79 taken 58532 times.
✗ Branch 78 → 133 not taken.
✓ Branch 79 → 80 taken 58532 times.
✗ Branch 79 → 131 not taken.
✓ Branch 80 → 81 taken 58532 times.
✗ Branch 80 → 131 not taken.
|
73373 | structDefNode->fields.push_back(std::any_cast<FieldNode *>(visit(field))); |
| 186 | |||
| 187 |
1/2✓ Branch 99 → 100 taken 14841 times.
✗ Branch 99 → 138 not taken.
|
29682 | return concludeNode(structDefNode); |
| 188 | } | ||
| 189 | |||
| 190 | 775 | std::any ASTBuilder::visitInterfaceDef(SpiceParser::InterfaceDefContext *ctx) { | |
| 191 | 775 | const auto interfaceDefNode = createNode<InterfaceDefNode>(ctx); | |
| 192 | |||
| 193 | // Enrich | ||
| 194 |
2/4✓ Branch 3 → 4 taken 775 times.
✗ Branch 3 → 93 not taken.
✓ Branch 4 → 5 taken 775 times.
✗ Branch 4 → 93 not taken.
|
775 | interfaceDefNode->interfaceName = getIdentifier(ctx->TYPE_IDENTIFIER(), true); |
| 195 | 775 | interfaceDefNode->typeId = resourceManager.getNextCustomTypeId(); | |
| 196 | |||
| 197 | // Visit children | ||
| 198 |
2/2✓ Branch 9 → 10 taken 440 times.
✓ Branch 9 → 49 taken 335 times.
|
775 | if (ctx->topLevelDefAttr()) { |
| 199 |
3/6✓ Branch 10 → 11 taken 440 times.
✗ Branch 10 → 96 not taken.
✓ Branch 11 → 12 taken 440 times.
✗ Branch 11 → 96 not taken.
✓ Branch 12 → 13 taken 440 times.
✗ Branch 12 → 94 not taken.
|
440 | interfaceDefNode->attrs = std::any_cast<TopLevelDefAttrNode *>(visit(ctx->topLevelDefAttr())); |
| 200 | |||
| 201 | // Tell the attributes that they are struct attributes | ||
| 202 |
2/2✓ Branch 27 → 16 taken 440 times.
✓ Branch 27 → 28 taken 440 times.
|
1320 | for (AttrNode *attr : interfaceDefNode->attrs->attrLst->attributes) |
| 203 | 440 | attr->target = AttrNode::TARGET_INTERFACE; | |
| 204 | |||
| 205 | // Check if a custom type id was set | ||
| 206 |
7/18✓ Branch 28 → 29 taken 440 times.
✗ Branch 28 → 35 not taken.
✓ Branch 31 → 32 taken 440 times.
✗ Branch 31 → 97 not taken.
✓ Branch 32 → 33 taken 440 times.
✗ Branch 32 → 97 not taken.
✓ Branch 33 → 34 taken 440 times.
✗ Branch 33 → 35 not taken.
✓ Branch 36 → 37 taken 440 times.
✗ Branch 36 → 38 not taken.
✓ Branch 38 → 39 taken 440 times.
✗ Branch 38 → 41 not taken.
✓ Branch 41 → 42 taken 440 times.
✗ Branch 41 → 49 not taken.
✗ Branch 97 → 98 not taken.
✗ Branch 97 → 99 not taken.
✗ Branch 101 → 102 not taken.
✗ Branch 101 → 104 not taken.
|
1320 | if (interfaceDefNode->attrs && interfaceDefNode->attrs->attrLst->hasAttr(ATTR_CORE_COMPILER_FIXED_TYPE_ID)) |
| 207 |
2/4✓ Branch 44 → 45 taken 440 times.
✗ Branch 44 → 108 not taken.
✓ Branch 45 → 46 taken 440 times.
✗ Branch 45 → 106 not taken.
|
1320 | interfaceDefNode->typeId = interfaceDefNode->attrs->attrLst->getAttrValueByName(ATTR_CORE_COMPILER_FIXED_TYPE_ID)->intValue; |
| 208 | } | ||
| 209 |
2/2✓ Branch 50 → 51 taken 733 times.
✓ Branch 50 → 56 taken 42 times.
|
775 | if (ctx->qualifierLst()) |
| 210 |
3/6✓ Branch 51 → 52 taken 733 times.
✗ Branch 51 → 114 not taken.
✓ Branch 52 → 53 taken 733 times.
✗ Branch 52 → 114 not taken.
✓ Branch 53 → 54 taken 733 times.
✗ Branch 53 → 112 not taken.
|
733 | interfaceDefNode->qualifierLst = std::any_cast<QualifierLstNode *>(visit(ctx->qualifierLst())); |
| 211 |
2/2✓ Branch 57 → 58 taken 448 times.
✓ Branch 57 → 63 taken 327 times.
|
775 | if (ctx->LESS()) { |
| 212 | 448 | interfaceDefNode->hasTemplateTypes = true; | |
| 213 |
3/6✓ Branch 58 → 59 taken 448 times.
✗ Branch 58 → 117 not taken.
✓ Branch 59 → 60 taken 448 times.
✗ Branch 59 → 117 not taken.
✓ Branch 60 → 61 taken 448 times.
✗ Branch 60 → 115 not taken.
|
448 | interfaceDefNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst())); |
| 214 | } | ||
| 215 |
3/4✓ Branch 63 → 64 taken 775 times.
✗ Branch 63 → 124 not taken.
✓ Branch 81 → 66 taken 5361 times.
✓ Branch 81 → 82 taken 775 times.
|
6911 | for (SpiceParser::SignatureContext *signature : ctx->signature()) |
| 216 |
3/6✓ Branch 68 → 69 taken 5361 times.
✗ Branch 68 → 120 not taken.
✓ Branch 69 → 70 taken 5361 times.
✗ Branch 69 → 118 not taken.
✓ Branch 70 → 71 taken 5361 times.
✗ Branch 70 → 118 not taken.
|
6136 | interfaceDefNode->signatures.push_back(std::any_cast<SignatureNode *>(visit(signature))); |
| 217 | |||
| 218 |
1/2✓ Branch 89 → 90 taken 775 times.
✗ Branch 89 → 125 not taken.
|
1550 | return concludeNode(interfaceDefNode); |
| 219 | } | ||
| 220 | |||
| 221 | 86 | std::any ASTBuilder::visitUnionDef(SpiceParser::UnionDefContext *ctx) { | |
| 222 | 86 | const auto unionDefNode = createNode<UnionDefNode>(ctx); | |
| 223 | |||
| 224 | // Enrich | ||
| 225 |
2/4✓ Branch 3 → 4 taken 86 times.
✗ Branch 3 → 93 not taken.
✓ Branch 4 → 5 taken 86 times.
✗ Branch 4 → 93 not taken.
|
86 | unionDefNode->unionName = getIdentifier(ctx->TYPE_IDENTIFIER(), true); |
| 226 | 86 | unionDefNode->typeId = resourceManager.getNextCustomTypeId(); | |
| 227 | |||
| 228 | // Visit children | ||
| 229 |
1/2✗ Branch 9 → 10 not taken.
✓ Branch 9 → 49 taken 86 times.
|
86 | if (ctx->topLevelDefAttr()) { |
| 230 | ✗ | unionDefNode->attrs = std::any_cast<TopLevelDefAttrNode *>(visit(ctx->topLevelDefAttr())); | |
| 231 | |||
| 232 | // Tell the attributes that they are union attributes | ||
| 233 | ✗ | for (AttrNode *attr : unionDefNode->attrs->attrLst->attributes) | |
| 234 | ✗ | attr->target = AttrNode::TARGET_UNION; | |
| 235 | |||
| 236 | // Check if a custom type id was set | ||
| 237 | ✗ | if (unionDefNode->attrs && unionDefNode->attrs->attrLst->hasAttr(ATTR_CORE_COMPILER_FIXED_TYPE_ID)) | |
| 238 | ✗ | unionDefNode->typeId = unionDefNode->attrs->attrLst->getAttrValueByName(ATTR_CORE_COMPILER_FIXED_TYPE_ID)->intValue; | |
| 239 | } | ||
| 240 |
2/2✓ Branch 50 → 51 taken 50 times.
✓ Branch 50 → 56 taken 36 times.
|
86 | if (ctx->qualifierLst()) |
| 241 |
3/6✓ Branch 51 → 52 taken 50 times.
✗ Branch 51 → 114 not taken.
✓ Branch 52 → 53 taken 50 times.
✗ Branch 52 → 114 not taken.
✓ Branch 53 → 54 taken 50 times.
✗ Branch 53 → 112 not taken.
|
50 | unionDefNode->qualifierLst = std::any_cast<QualifierLstNode *>(visit(ctx->qualifierLst())); |
| 242 |
2/2✓ Branch 57 → 58 taken 4 times.
✓ Branch 57 → 63 taken 82 times.
|
86 | if (ctx->LESS()) { |
| 243 | 4 | unionDefNode->hasTemplateTypes = true; | |
| 244 |
3/6✓ Branch 58 → 59 taken 4 times.
✗ Branch 58 → 117 not taken.
✓ Branch 59 → 60 taken 4 times.
✗ Branch 59 → 117 not taken.
✓ Branch 60 → 61 taken 4 times.
✗ Branch 60 → 115 not taken.
|
4 | unionDefNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst())); |
| 245 | } | ||
| 246 |
3/4✓ Branch 63 → 64 taken 86 times.
✗ Branch 63 → 124 not taken.
✓ Branch 81 → 66 taken 462 times.
✓ Branch 81 → 82 taken 86 times.
|
634 | for (SpiceParser::FieldContext *field : ctx->field()) |
| 247 |
3/6✓ Branch 68 → 69 taken 462 times.
✗ Branch 68 → 120 not taken.
✓ Branch 69 → 70 taken 462 times.
✗ Branch 69 → 118 not taken.
✓ Branch 70 → 71 taken 462 times.
✗ Branch 70 → 118 not taken.
|
548 | unionDefNode->fields.push_back(std::any_cast<FieldNode *>(visit(field))); |
| 248 | |||
| 249 |
1/2✓ Branch 89 → 90 taken 86 times.
✗ Branch 89 → 125 not taken.
|
172 | return concludeNode(unionDefNode); |
| 250 | } | ||
| 251 | |||
| 252 | 4254 | std::any ASTBuilder::visitEnumDef(SpiceParser::EnumDefContext *ctx) { | |
| 253 | 4254 | const auto enumDefNode = createNode<EnumDefNode>(ctx); | |
| 254 | |||
| 255 | // Enrich | ||
| 256 |
2/4✓ Branch 3 → 4 taken 4254 times.
✗ Branch 3 → 43 not taken.
✓ Branch 4 → 5 taken 4254 times.
✗ Branch 4 → 43 not taken.
|
4254 | enumDefNode->enumName = getIdentifier(ctx->TYPE_IDENTIFIER(), true); |
| 257 | 4254 | enumDefNode->typeId = resourceManager.getNextCustomTypeId(); | |
| 258 | |||
| 259 | // Visit children | ||
| 260 |
2/2✓ Branch 9 → 10 taken 3905 times.
✓ Branch 9 → 15 taken 349 times.
|
4254 | if (ctx->qualifierLst()) |
| 261 |
3/6✓ Branch 10 → 11 taken 3905 times.
✗ Branch 10 → 46 not taken.
✓ Branch 11 → 12 taken 3905 times.
✗ Branch 11 → 46 not taken.
✓ Branch 12 → 13 taken 3905 times.
✗ Branch 12 → 44 not taken.
|
3905 | enumDefNode->qualifierLst = std::any_cast<QualifierLstNode *>(visit(ctx->qualifierLst())); |
| 262 |
3/6✓ Branch 15 → 16 taken 4254 times.
✗ Branch 15 → 49 not taken.
✓ Branch 16 → 17 taken 4254 times.
✗ Branch 16 → 49 not taken.
✓ Branch 17 → 18 taken 4254 times.
✗ Branch 17 → 47 not taken.
|
4254 | enumDefNode->itemLst = std::any_cast<EnumItemLstNode *>(visit(ctx->enumItemLst())); |
| 263 | |||
| 264 | // Tell all items about the enum def | ||
| 265 |
2/2✓ Branch 32 → 21 taken 47138 times.
✓ Branch 32 → 33 taken 4254 times.
|
55646 | for (EnumItemNode *enumItem : enumDefNode->itemLst->items) |
| 266 | 47138 | enumItem->enumDef = enumDefNode; | |
| 267 | |||
| 268 |
1/2✓ Branch 39 → 40 taken 4254 times.
✗ Branch 39 → 50 not taken.
|
8508 | return concludeNode(enumDefNode); |
| 269 | } | ||
| 270 | |||
| 271 | 7047 | std::any ASTBuilder::visitGenericTypeDef(SpiceParser::GenericTypeDefContext *ctx) { | |
| 272 | 7047 | const auto genericTypeDefNode = createNode<GenericTypeDefNode>(ctx); | |
| 273 | |||
| 274 | // Enrich | ||
| 275 |
2/4✓ Branch 3 → 4 taken 7047 times.
✗ Branch 3 → 21 not taken.
✓ Branch 4 → 5 taken 7047 times.
✗ Branch 4 → 21 not taken.
|
7047 | genericTypeDefNode->typeName = getIdentifier(ctx->TYPE_IDENTIFIER(), true); |
| 276 | |||
| 277 | // Visit children | ||
| 278 |
4/8✓ Branch 7 → 8 taken 7047 times.
✗ Branch 7 → 24 not taken.
✓ Branch 8 → 9 taken 7047 times.
✗ Branch 8 → 24 not taken.
✓ Branch 9 → 10 taken 7047 times.
✗ Branch 9 → 22 not taken.
✓ Branch 11 → 12 taken 7047 times.
✗ Branch 11 → 25 not taken.
|
7047 | genericTypeDefNode->typeAltsLst = std::any_cast<TypeAltsLstNode *>(visit(ctx->typeAltsLst())); |
| 279 | |||
| 280 |
1/2✓ Branch 17 → 18 taken 7047 times.
✗ Branch 17 → 25 not taken.
|
14094 | return concludeNode(genericTypeDefNode); |
| 281 | } | ||
| 282 | |||
| 283 | 2893 | std::any ASTBuilder::visitAliasDef(SpiceParser::AliasDefContext *ctx) { | |
| 284 | 2893 | const auto aliasDefNode = createNode<AliasDefNode>(ctx); | |
| 285 | |||
| 286 | // Enrich | ||
| 287 |
2/4✓ Branch 3 → 4 taken 2893 times.
✗ Branch 3 → 33 not taken.
✓ Branch 4 → 5 taken 2893 times.
✗ Branch 4 → 33 not taken.
|
2893 | aliasDefNode->aliasName = getIdentifier(ctx->TYPE_IDENTIFIER(), true); |
| 288 |
2/4✓ Branch 7 → 8 taken 2893 times.
✗ Branch 7 → 34 not taken.
✓ Branch 8 → 9 taken 2893 times.
✗ Branch 8 → 34 not taken.
|
2893 | aliasDefNode->dataTypeString = ctx->dataType()->getText(); |
| 289 | 2893 | aliasDefNode->typeId = resourceManager.getNextCustomTypeId(); | |
| 290 | |||
| 291 | // Visit children | ||
| 292 |
2/2✓ Branch 13 → 14 taken 1837 times.
✓ Branch 13 → 19 taken 1056 times.
|
2893 | if (ctx->qualifierLst()) |
| 293 |
3/6✓ Branch 14 → 15 taken 1837 times.
✗ Branch 14 → 37 not taken.
✓ Branch 15 → 16 taken 1837 times.
✗ Branch 15 → 37 not taken.
✓ Branch 16 → 17 taken 1837 times.
✗ Branch 16 → 35 not taken.
|
1837 | aliasDefNode->qualifierLst = std::any_cast<QualifierLstNode *>(visit(ctx->qualifierLst())); |
| 294 |
4/8✓ Branch 19 → 20 taken 2893 times.
✗ Branch 19 → 40 not taken.
✓ Branch 20 → 21 taken 2893 times.
✗ Branch 20 → 40 not taken.
✓ Branch 21 → 22 taken 2893 times.
✗ Branch 21 → 38 not taken.
✓ Branch 23 → 24 taken 2893 times.
✗ Branch 23 → 41 not taken.
|
2893 | aliasDefNode->dataType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 295 | |||
| 296 |
1/2✓ Branch 29 → 30 taken 2893 times.
✗ Branch 29 → 41 not taken.
|
5786 | return concludeNode(aliasDefNode); |
| 297 | } | ||
| 298 | |||
| 299 | 19515 | std::any ASTBuilder::visitGlobalVarDef(SpiceParser::GlobalVarDefContext *ctx) { | |
| 300 | 19515 | const auto globalVarDefNode = createNode<GlobalVarDefNode>(ctx); | |
| 301 | |||
| 302 | // Enrich | ||
| 303 |
2/4✓ Branch 3 → 4 taken 19515 times.
✗ Branch 3 → 28 not taken.
✓ Branch 4 → 5 taken 19515 times.
✗ Branch 4 → 28 not taken.
|
19515 | globalVarDefNode->varName = getIdentifier(ctx->TYPE_IDENTIFIER(), true); |
| 304 | |||
| 305 | // Visit children | ||
| 306 |
3/6✓ Branch 7 → 8 taken 19515 times.
✗ Branch 7 → 31 not taken.
✓ Branch 8 → 9 taken 19515 times.
✗ Branch 8 → 31 not taken.
✓ Branch 9 → 10 taken 19515 times.
✗ Branch 9 → 29 not taken.
|
19515 | globalVarDefNode->dataType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 307 | 19515 | globalVarDefNode->dataType->isGlobalType = true; | |
| 308 |
2/2✓ Branch 12 → 13 taken 19511 times.
✓ Branch 12 → 18 taken 4 times.
|
19515 | if (ctx->constant()) { |
| 309 | 19511 | globalVarDefNode->hasValue = true; | |
| 310 |
3/6✓ Branch 13 → 14 taken 19511 times.
✗ Branch 13 → 34 not taken.
✓ Branch 14 → 15 taken 19511 times.
✗ Branch 14 → 34 not taken.
✓ Branch 15 → 16 taken 19511 times.
✗ Branch 15 → 32 not taken.
|
19511 | globalVarDefNode->constant = std::any_cast<ConstantNode *>(visit(ctx->constant())); |
| 311 | } | ||
| 312 | |||
| 313 |
1/2✓ Branch 24 → 25 taken 19515 times.
✗ Branch 24 → 35 not taken.
|
39030 | return concludeNode(globalVarDefNode); |
| 314 | } | ||
| 315 | |||
| 316 | 16020 | std::any ASTBuilder::visitExtDecl(SpiceParser::ExtDeclContext *ctx) { | |
| 317 | 16020 | const auto extDeclNode = createNode<ExtDeclNode>(ctx); | |
| 318 | |||
| 319 | // Enrich | ||
| 320 |
6/10✓ Branch 3 → 4 taken 16020 times.
✗ Branch 3 → 57 not taken.
✓ Branch 4 → 5 taken 8400 times.
✓ Branch 4 → 7 taken 7620 times.
✓ Branch 5 → 6 taken 8400 times.
✗ Branch 5 → 57 not taken.
✓ Branch 7 → 8 taken 7620 times.
✗ Branch 7 → 57 not taken.
✓ Branch 9 → 10 taken 16020 times.
✗ Branch 9 → 57 not taken.
|
16020 | extDeclNode->extFunctionName = getIdentifier(ctx->IDENTIFIER() ? ctx->IDENTIFIER() : ctx->TYPE_IDENTIFIER(), false); |
| 321 | |||
| 322 | // Visit children | ||
| 323 |
2/2✓ Branch 13 → 14 taken 2 times.
✓ Branch 13 → 33 taken 16018 times.
|
16020 | if (ctx->topLevelDefAttr()) { |
| 324 |
3/6✓ Branch 14 → 15 taken 2 times.
✗ Branch 14 → 60 not taken.
✓ Branch 15 → 16 taken 2 times.
✗ Branch 15 → 60 not taken.
✓ Branch 16 → 17 taken 2 times.
✗ Branch 16 → 58 not taken.
|
2 | extDeclNode->attrs = std::any_cast<TopLevelDefAttrNode *>(visit(ctx->topLevelDefAttr())); |
| 325 | |||
| 326 | // Tell the attributes that they are ext decl attributes | ||
| 327 |
2/2✓ Branch 31 → 20 taken 2 times.
✓ Branch 31 → 32 taken 2 times.
|
6 | for (AttrNode *attr : extDeclNode->attrs->attrLst->attributes) |
| 328 | 2 | attr->target = AttrNode::TARGET_EXT_DECL; | |
| 329 | } | ||
| 330 |
2/2✓ Branch 34 → 35 taken 12675 times.
✓ Branch 34 → 40 taken 3345 times.
|
16020 | if (ctx->F()) { |
| 331 |
3/6✓ Branch 35 → 36 taken 12675 times.
✗ Branch 35 → 63 not taken.
✓ Branch 36 → 37 taken 12675 times.
✗ Branch 36 → 63 not taken.
✓ Branch 37 → 38 taken 12675 times.
✗ Branch 37 → 61 not taken.
|
12675 | extDeclNode->returnType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 332 | 12675 | extDeclNode->returnType->isReturnType = true; | |
| 333 | } | ||
| 334 |
2/2✓ Branch 41 → 42 taken 14884 times.
✓ Branch 41 → 47 taken 1136 times.
|
16020 | if (ctx->typeLstWithEllipsis()) { |
| 335 | 14884 | extDeclNode->hasArgs = true; | |
| 336 |
3/6✓ Branch 42 → 43 taken 14884 times.
✗ Branch 42 → 66 not taken.
✓ Branch 43 → 44 taken 14884 times.
✗ Branch 43 → 66 not taken.
✓ Branch 44 → 45 taken 14884 times.
✗ Branch 44 → 64 not taken.
|
14884 | extDeclNode->argTypeLst = std::any_cast<TypeLstWithEllipsisNode *>(visit(ctx->typeLstWithEllipsis())); |
| 337 | } | ||
| 338 | |||
| 339 |
1/2✓ Branch 53 → 54 taken 16020 times.
✗ Branch 53 → 67 not taken.
|
32040 | return concludeNode(extDeclNode); |
| 340 | } | ||
| 341 | |||
| 342 | 32858 | std::any ASTBuilder::visitImportDef(SpiceParser::ImportDefContext *ctx) { | |
| 343 |
1/2✓ Branch 2 → 3 taken 32858 times.
✗ Branch 2 → 32 not taken.
|
32858 | const auto importDefNode = createNode<ImportDefNode>(ctx); |
| 344 | |||
| 345 | // Extract path | ||
| 346 |
2/4✓ Branch 3 → 4 taken 32858 times.
✗ Branch 3 → 32 not taken.
✓ Branch 4 → 5 taken 32858 times.
✗ Branch 4 → 32 not taken.
|
32858 | const std::string pathStr = ctx->STRING_LIT()->getText(); |
| 347 |
1/2✓ Branch 6 → 7 taken 32858 times.
✗ Branch 6 → 27 not taken.
|
32858 | importDefNode->importPath = pathStr.substr(1, pathStr.size() - 2); |
| 348 | |||
| 349 | // If no name is given, use the path as name | ||
| 350 |
7/12✓ Branch 9 → 10 taken 32858 times.
✗ Branch 9 → 28 not taken.
✓ Branch 10 → 11 taken 640 times.
✓ Branch 10 → 13 taken 32218 times.
✓ Branch 11 → 12 taken 640 times.
✗ Branch 11 → 28 not taken.
✓ Branch 12 → 14 taken 640 times.
✗ Branch 12 → 28 not taken.
✓ Branch 13 → 14 taken 32218 times.
✗ Branch 13 → 28 not taken.
✓ Branch 16 → 17 taken 32858 times.
✗ Branch 16 → 29 not taken.
|
32858 | importDefNode->importName = ctx->AS() ? getIdentifier(ctx->IDENTIFIER(), false) : importDefNode->importPath; |
| 351 | |||
| 352 |
1/2✓ Branch 22 → 23 taken 32858 times.
✗ Branch 22 → 29 not taken.
|
65716 | return concludeNode(importDefNode); |
| 353 | 32858 | } | |
| 354 | |||
| 355 | 27003 | std::any ASTBuilder::visitUnsafeBlock(SpiceParser::UnsafeBlockContext *ctx) { | |
| 356 | 27003 | const auto unsafeBlockDefNode = createNode<UnsafeBlockNode>(ctx); | |
| 357 | |||
| 358 | // Visit children | ||
| 359 |
4/8✓ Branch 3 → 4 taken 27003 times.
✗ Branch 3 → 19 not taken.
✓ Branch 4 → 5 taken 27003 times.
✗ Branch 4 → 19 not taken.
✓ Branch 5 → 6 taken 27003 times.
✗ Branch 5 → 17 not taken.
✓ Branch 7 → 8 taken 27003 times.
✗ Branch 7 → 20 not taken.
|
27003 | unsafeBlockDefNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 360 | |||
| 361 |
1/2✓ Branch 13 → 14 taken 27003 times.
✗ Branch 13 → 20 not taken.
|
54006 | return concludeNode(unsafeBlockDefNode); |
| 362 | } | ||
| 363 | |||
| 364 | 11224 | std::any ASTBuilder::visitForLoop(SpiceParser::ForLoopContext *ctx) { | |
| 365 | 11224 | const auto forLoopNode = createNode<ForLoopNode>(ctx); | |
| 366 | |||
| 367 |
2/4✓ Branch 3 → 4 taken 11224 times.
✗ Branch 3 → 20 not taken.
✓ Branch 4 → 5 taken 11224 times.
✗ Branch 4 → 20 not taken.
|
11224 | visit(ctx->forHead()); |
| 368 |
4/8✓ Branch 6 → 7 taken 11224 times.
✗ Branch 6 → 23 not taken.
✓ Branch 7 → 8 taken 11224 times.
✗ Branch 7 → 23 not taken.
✓ Branch 8 → 9 taken 11224 times.
✗ Branch 8 → 21 not taken.
✓ Branch 10 → 11 taken 11224 times.
✗ Branch 10 → 24 not taken.
|
11224 | forLoopNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 369 | |||
| 370 |
1/2✓ Branch 16 → 17 taken 11224 times.
✗ Branch 16 → 24 not taken.
|
22448 | return concludeNode(forLoopNode); |
| 371 | } | ||
| 372 | |||
| 373 | 11224 | std::any ASTBuilder::visitForHead(SpiceParser::ForHeadContext *ctx) { | |
| 374 | 11224 | const auto forLoopNode = resumeForExpansion<ForLoopNode>(); | |
| 375 | |||
| 376 | // Visit children | ||
| 377 |
3/6✓ Branch 14 → 15 taken 11224 times.
✗ Branch 14 → 32 not taken.
✓ Branch 15 → 16 taken 11224 times.
✗ Branch 15 → 32 not taken.
✓ Branch 16 → 17 taken 11224 times.
✗ Branch 16 → 30 not taken.
|
11224 | forLoopNode->initDecl = std::any_cast<DeclStmtNode *>(visit(ctx->declStmt())); |
| 378 |
3/6✓ Branch 18 → 19 taken 11224 times.
✗ Branch 18 → 35 not taken.
✓ Branch 19 → 20 taken 11224 times.
✗ Branch 19 → 35 not taken.
✓ Branch 20 → 21 taken 11224 times.
✗ Branch 20 → 33 not taken.
|
11224 | forLoopNode->condAssign = std::any_cast<ExprNode *>(visit(ctx->assignExpr(0))); |
| 379 |
3/6✓ Branch 22 → 23 taken 11224 times.
✗ Branch 22 → 38 not taken.
✓ Branch 23 → 24 taken 11224 times.
✗ Branch 23 → 38 not taken.
✓ Branch 24 → 25 taken 11224 times.
✗ Branch 24 → 36 not taken.
|
11224 | forLoopNode->incAssign = std::any_cast<ExprNode *>(visit(ctx->assignExpr(1))); |
| 380 | |||
| 381 |
1/2✓ Branch 26 → 27 taken 11224 times.
✗ Branch 26 → 39 not taken.
|
22448 | return nullptr; |
| 382 | } | ||
| 383 | |||
| 384 | 12983 | std::any ASTBuilder::visitForeachLoop(SpiceParser::ForeachLoopContext *ctx) { | |
| 385 | 12983 | const auto foreachLoopNode = createNode<ForeachLoopNode>(ctx); | |
| 386 | |||
| 387 | // Visit children | ||
| 388 |
2/4✓ Branch 3 → 4 taken 12983 times.
✗ Branch 3 → 20 not taken.
✓ Branch 4 → 5 taken 12983 times.
✗ Branch 4 → 20 not taken.
|
12983 | visit(ctx->foreachHead()); |
| 389 |
3/6✓ Branch 6 → 7 taken 12983 times.
✗ Branch 6 → 23 not taken.
✓ Branch 7 → 8 taken 12983 times.
✗ Branch 7 → 23 not taken.
✓ Branch 8 → 9 taken 12983 times.
✗ Branch 8 → 21 not taken.
|
12983 | foreachLoopNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 390 | |||
| 391 | // Tell the foreach item that it is one | ||
| 392 |
1/2✓ Branch 10 → 11 taken 12983 times.
✗ Branch 10 → 24 not taken.
|
12983 | foreachLoopNode->itemVarDecl->isForEachItem = true; |
| 393 | |||
| 394 |
1/2✓ Branch 16 → 17 taken 12983 times.
✗ Branch 16 → 24 not taken.
|
25966 | return concludeNode(foreachLoopNode); |
| 395 | } | ||
| 396 | |||
| 397 | 12983 | std::any ASTBuilder::visitForeachHead(SpiceParser::ForeachHeadContext *ctx) { | |
| 398 | 12983 | const auto foreachLoopNode = resumeForExpansion<ForeachLoopNode>(); | |
| 399 | |||
| 400 | // Visit children | ||
| 401 |
3/4✓ Branch 14 → 15 taken 12983 times.
✗ Branch 14 → 45 not taken.
✓ Branch 17 → 18 taken 11945 times.
✓ Branch 17 → 23 taken 1038 times.
|
12983 | if (ctx->declStmt().size() == 1) { |
| 402 |
3/6✓ Branch 18 → 19 taken 11945 times.
✗ Branch 18 → 48 not taken.
✓ Branch 19 → 20 taken 11945 times.
✗ Branch 19 → 48 not taken.
✓ Branch 20 → 21 taken 11945 times.
✗ Branch 20 → 46 not taken.
|
11945 | foreachLoopNode->itemVarDecl = std::any_cast<DeclStmtNode *>(visit(ctx->declStmt(0))); |
| 403 |
2/4✓ Branch 23 → 24 taken 1038 times.
✗ Branch 23 → 49 not taken.
✓ Branch 26 → 27 taken 1038 times.
✗ Branch 26 → 36 not taken.
|
1038 | } else if (ctx->declStmt().size() == 2) { |
| 404 |
3/6✓ Branch 27 → 28 taken 1038 times.
✗ Branch 27 → 52 not taken.
✓ Branch 28 → 29 taken 1038 times.
✗ Branch 28 → 52 not taken.
✓ Branch 29 → 30 taken 1038 times.
✗ Branch 29 → 50 not taken.
|
1038 | foreachLoopNode->idxVarDecl = std::any_cast<DeclStmtNode *>(visit(ctx->declStmt(0))); |
| 405 |
3/6✓ Branch 31 → 32 taken 1038 times.
✗ Branch 31 → 55 not taken.
✓ Branch 32 → 33 taken 1038 times.
✗ Branch 32 → 55 not taken.
✓ Branch 33 → 34 taken 1038 times.
✗ Branch 33 → 53 not taken.
|
1038 | foreachLoopNode->itemVarDecl = std::any_cast<DeclStmtNode *>(visit(ctx->declStmt(1))); |
| 406 | } else { | ||
| 407 | − | assert_fail("Invalid number of decl statements in foreach loop"); // GCOV_EXCL_LINE | |
| 408 | } | ||
| 409 |
3/6✓ Branch 37 → 38 taken 12983 times.
✗ Branch 37 → 58 not taken.
✓ Branch 38 → 39 taken 12983 times.
✗ Branch 38 → 58 not taken.
✓ Branch 39 → 40 taken 12983 times.
✗ Branch 39 → 56 not taken.
|
12983 | foreachLoopNode->iteratorAssign = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 410 | |||
| 411 |
1/2✓ Branch 41 → 42 taken 12983 times.
✗ Branch 41 → 59 not taken.
|
25966 | return nullptr; |
| 412 | } | ||
| 413 | |||
| 414 | 8815 | std::any ASTBuilder::visitWhileLoop(SpiceParser::WhileLoopContext *ctx) { | |
| 415 | 8815 | const auto whileLoopNode = createNode<WhileLoopNode>(ctx); | |
| 416 | |||
| 417 | // Visit children | ||
| 418 |
3/6✓ Branch 3 → 4 taken 8815 times.
✗ Branch 3 → 23 not taken.
✓ Branch 4 → 5 taken 8815 times.
✗ Branch 4 → 23 not taken.
✓ Branch 5 → 6 taken 8815 times.
✗ Branch 5 → 21 not taken.
|
8815 | whileLoopNode->condition = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 419 |
4/8✓ Branch 7 → 8 taken 8815 times.
✗ Branch 7 → 26 not taken.
✓ Branch 8 → 9 taken 8815 times.
✗ Branch 8 → 26 not taken.
✓ Branch 9 → 10 taken 8815 times.
✗ Branch 9 → 24 not taken.
✓ Branch 11 → 12 taken 8815 times.
✗ Branch 11 → 27 not taken.
|
8815 | whileLoopNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 420 | |||
| 421 |
1/2✓ Branch 17 → 18 taken 8815 times.
✗ Branch 17 → 27 not taken.
|
17630 | return concludeNode(whileLoopNode); |
| 422 | } | ||
| 423 | |||
| 424 | 169 | std::any ASTBuilder::visitDoWhileLoop(SpiceParser::DoWhileLoopContext *ctx) { | |
| 425 | 169 | const auto doWhileLoopNode = createNode<DoWhileLoopNode>(ctx); | |
| 426 | |||
| 427 | // Visit children | ||
| 428 |
3/6✓ Branch 3 → 4 taken 169 times.
✗ Branch 3 → 23 not taken.
✓ Branch 4 → 5 taken 169 times.
✗ Branch 4 → 23 not taken.
✓ Branch 5 → 6 taken 169 times.
✗ Branch 5 → 21 not taken.
|
169 | doWhileLoopNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 429 |
4/8✓ Branch 7 → 8 taken 169 times.
✗ Branch 7 → 26 not taken.
✓ Branch 8 → 9 taken 169 times.
✗ Branch 8 → 26 not taken.
✓ Branch 9 → 10 taken 169 times.
✗ Branch 9 → 24 not taken.
✓ Branch 11 → 12 taken 169 times.
✗ Branch 11 → 27 not taken.
|
169 | doWhileLoopNode->condition = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 430 | |||
| 431 |
1/2✓ Branch 17 → 18 taken 169 times.
✗ Branch 17 → 27 not taken.
|
338 | return concludeNode(doWhileLoopNode); |
| 432 | } | ||
| 433 | |||
| 434 | 138582 | std::any ASTBuilder::visitIfStmt(SpiceParser::IfStmtContext *ctx) { | |
| 435 | 138582 | const auto ifStmtNode = createNode<IfStmtNode>(ctx); | |
| 436 | |||
| 437 | // Visit children | ||
| 438 |
3/6✓ Branch 3 → 4 taken 138582 times.
✗ Branch 3 → 30 not taken.
✓ Branch 4 → 5 taken 138582 times.
✗ Branch 4 → 30 not taken.
✓ Branch 5 → 6 taken 138582 times.
✗ Branch 5 → 28 not taken.
|
138582 | ifStmtNode->condition = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 439 |
3/6✓ Branch 7 → 8 taken 138582 times.
✗ Branch 7 → 33 not taken.
✓ Branch 8 → 9 taken 138582 times.
✗ Branch 8 → 33 not taken.
✓ Branch 9 → 10 taken 138582 times.
✗ Branch 9 → 31 not taken.
|
138582 | ifStmtNode->thenBody = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 440 |
2/2✓ Branch 12 → 13 taken 21501 times.
✓ Branch 12 → 18 taken 117081 times.
|
138582 | if (ctx->elseStmt()) |
| 441 |
3/6✓ Branch 13 → 14 taken 21501 times.
✗ Branch 13 → 36 not taken.
✓ Branch 14 → 15 taken 21501 times.
✗ Branch 14 → 36 not taken.
✓ Branch 15 → 16 taken 21501 times.
✗ Branch 15 → 34 not taken.
|
21501 | ifStmtNode->elseStmt = std::any_cast<ElseStmtNode *>(visit(ctx->elseStmt())); |
| 442 | |||
| 443 |
1/2✓ Branch 24 → 25 taken 138582 times.
✗ Branch 24 → 37 not taken.
|
277164 | return concludeNode(ifStmtNode); |
| 444 | } | ||
| 445 | |||
| 446 | 21501 | std::any ASTBuilder::visitElseStmt(SpiceParser::ElseStmtContext *ctx) { | |
| 447 | 21501 | const auto elseStmtNode = createNode<ElseStmtNode>(ctx); | |
| 448 | |||
| 449 | // Visit children | ||
| 450 |
2/2✓ Branch 4 → 5 taken 12145 times.
✓ Branch 4 → 10 taken 9356 times.
|
21501 | if (ctx->ifStmt()) { |
| 451 | 12145 | elseStmtNode->isElseIf = true; | |
| 452 |
3/6✓ Branch 5 → 6 taken 12145 times.
✗ Branch 5 → 27 not taken.
✓ Branch 6 → 7 taken 12145 times.
✗ Branch 6 → 27 not taken.
✓ Branch 7 → 8 taken 12145 times.
✗ Branch 7 → 25 not taken.
|
12145 | elseStmtNode->ifStmt = std::any_cast<IfStmtNode *>(visit(ctx->ifStmt())); |
| 453 | } else { | ||
| 454 |
3/6✓ Branch 10 → 11 taken 9356 times.
✗ Branch 10 → 30 not taken.
✓ Branch 11 → 12 taken 9356 times.
✗ Branch 11 → 30 not taken.
✓ Branch 12 → 13 taken 9356 times.
✗ Branch 12 → 28 not taken.
|
9356 | elseStmtNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 455 | } | ||
| 456 | |||
| 457 |
1/2✓ Branch 21 → 22 taken 21501 times.
✗ Branch 21 → 31 not taken.
|
43002 | return concludeNode(elseStmtNode); |
| 458 | } | ||
| 459 | |||
| 460 | 1715 | std::any ASTBuilder::visitSwitchStmt(SpiceParser::SwitchStmtContext *ctx) { | |
| 461 | 1715 | const auto switchStmtNode = createNode<SwitchStmtNode>(ctx); | |
| 462 | |||
| 463 | // Visit children | ||
| 464 |
3/6✓ Branch 3 → 4 taken 1715 times.
✗ Branch 3 → 29 not taken.
✓ Branch 4 → 5 taken 1715 times.
✗ Branch 4 → 29 not taken.
✓ Branch 5 → 6 taken 1715 times.
✗ Branch 5 → 27 not taken.
|
1715 | switchStmtNode->assignExpr = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 465 |
2/4✓ Branch 7 → 8 taken 1715 times.
✗ Branch 7 → 32 not taken.
✓ Branch 8 → 9 taken 1715 times.
✗ Branch 8 → 30 not taken.
|
1715 | fetchChildrenIntoVector(switchStmtNode->caseBranches, ctx->caseBranch()); |
| 466 |
2/2✓ Branch 11 → 12 taken 1165 times.
✓ Branch 11 → 17 taken 550 times.
|
1715 | if (ctx->defaultBranch()) { |
| 467 | 1165 | switchStmtNode->hasDefaultBranch = true; | |
| 468 |
3/6✓ Branch 12 → 13 taken 1165 times.
✗ Branch 12 → 35 not taken.
✓ Branch 13 → 14 taken 1165 times.
✗ Branch 13 → 35 not taken.
✓ Branch 14 → 15 taken 1165 times.
✗ Branch 14 → 33 not taken.
|
1165 | switchStmtNode->defaultBranch = std::any_cast<DefaultBranchNode *>(visit(ctx->defaultBranch())); |
| 469 | } | ||
| 470 | |||
| 471 |
1/2✓ Branch 23 → 24 taken 1715 times.
✗ Branch 23 → 36 not taken.
|
3430 | return concludeNode(switchStmtNode); |
| 472 | } | ||
| 473 | |||
| 474 | 22245 | std::any ASTBuilder::visitCaseBranch(SpiceParser::CaseBranchContext *ctx) { | |
| 475 | 22245 | const auto caseBranchNode = createNode<CaseBranchNode>(ctx); | |
| 476 | |||
| 477 | // Visit children | ||
| 478 |
2/4✓ Branch 3 → 4 taken 22245 times.
✗ Branch 3 → 22 not taken.
✓ Branch 4 → 5 taken 22245 times.
✗ Branch 4 → 20 not taken.
|
22245 | fetchChildrenIntoVector(caseBranchNode->caseConstants, ctx->caseConstant()); |
| 479 |
4/8✓ Branch 6 → 7 taken 22245 times.
✗ Branch 6 → 25 not taken.
✓ Branch 7 → 8 taken 22245 times.
✗ Branch 7 → 25 not taken.
✓ Branch 8 → 9 taken 22245 times.
✗ Branch 8 → 23 not taken.
✓ Branch 10 → 11 taken 22245 times.
✗ Branch 10 → 26 not taken.
|
22245 | caseBranchNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 480 | |||
| 481 |
1/2✓ Branch 16 → 17 taken 22245 times.
✗ Branch 16 → 26 not taken.
|
44490 | return concludeNode(caseBranchNode); |
| 482 | } | ||
| 483 | |||
| 484 | 1165 | std::any ASTBuilder::visitDefaultBranch(SpiceParser::DefaultBranchContext *ctx) { | |
| 485 | 1165 | const auto defaultBranchNode = createNode<DefaultBranchNode>(ctx); | |
| 486 | |||
| 487 | // Visit children | ||
| 488 |
4/8✓ Branch 3 → 4 taken 1165 times.
✗ Branch 3 → 19 not taken.
✓ Branch 4 → 5 taken 1165 times.
✗ Branch 4 → 19 not taken.
✓ Branch 5 → 6 taken 1165 times.
✗ Branch 5 → 17 not taken.
✓ Branch 7 → 8 taken 1165 times.
✗ Branch 7 → 20 not taken.
|
1165 | defaultBranchNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 489 | |||
| 490 |
1/2✓ Branch 13 → 14 taken 1165 times.
✗ Branch 13 → 20 not taken.
|
2330 | return concludeNode(defaultBranchNode); |
| 491 | } | ||
| 492 | |||
| 493 | 337 | std::any ASTBuilder::visitAnonymousBlockStmt(SpiceParser::AnonymousBlockStmtContext *ctx) { | |
| 494 | 337 | const auto anonymousBlockStmtNode = createNode<AnonymousBlockStmtNode>(ctx); | |
| 495 | |||
| 496 | // Visit children | ||
| 497 |
4/8✓ Branch 3 → 4 taken 337 times.
✗ Branch 3 → 19 not taken.
✓ Branch 4 → 5 taken 337 times.
✗ Branch 4 → 19 not taken.
✓ Branch 5 → 6 taken 337 times.
✗ Branch 5 → 17 not taken.
✓ Branch 7 → 8 taken 337 times.
✗ Branch 7 → 20 not taken.
|
337 | anonymousBlockStmtNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 498 | |||
| 499 |
1/2✓ Branch 13 → 14 taken 337 times.
✗ Branch 13 → 20 not taken.
|
674 | return concludeNode(anonymousBlockStmtNode); |
| 500 | } | ||
| 501 | |||
| 502 | 415812 | std::any ASTBuilder::visitStmtLst(SpiceParser::StmtLstContext *ctx) { | |
| 503 | 415812 | const auto stmtLstNode = createNode<StmtLstNode>(ctx); | |
| 504 | |||
| 505 | // Enrich | ||
| 506 |
2/4✓ Branch 3 → 4 taken 415812 times.
✗ Branch 3 → 126 not taken.
✓ Branch 4 → 5 taken 415812 times.
✗ Branch 4 → 126 not taken.
|
415812 | stmtLstNode->closingBraceCodeLoc = CodeLoc(ctx->getStop(), sourceFile); |
| 507 | |||
| 508 | // Visit children | ||
| 509 |
2/2✓ Branch 115 → 7 taken 1787961 times.
✓ Branch 115 → 116 taken 415804 times.
|
2619577 | for (ParserRuleContext::ParseTree *stmt : ctx->children) { |
| 510 |
3/4✓ Branch 9 → 10 taken 1787961 times.
✗ Branch 9 → 11 not taken.
✓ Branch 12 → 13 taken 721309 times.
✓ Branch 12 → 18 taken 1066652 times.
|
1787961 | if (auto *stmtCtx = dynamic_cast<SpiceParser::StmtContext *>(stmt)) |
| 511 |
4/6✓ Branch 13 → 14 taken 721301 times.
✓ Branch 13 → 129 taken 8 times.
✓ Branch 14 → 15 taken 721301 times.
✗ Branch 14 → 127 not taken.
✓ Branch 15 → 16 taken 721301 times.
✗ Branch 15 → 127 not taken.
|
721309 | stmtLstNode->statements.push_back(std::any_cast<StmtNode *>(visit(stmtCtx))); |
| 512 |
3/4✓ Branch 18 → 19 taken 1066652 times.
✗ Branch 18 → 20 not taken.
✓ Branch 21 → 22 taken 11224 times.
✓ Branch 21 → 27 taken 1055428 times.
|
1066652 | else if (auto *forLoopCtx = dynamic_cast<SpiceParser::ForLoopContext *>(stmt)) |
| 513 |
3/6✓ Branch 22 → 23 taken 11224 times.
✗ Branch 22 → 133 not taken.
✓ Branch 23 → 24 taken 11224 times.
✗ Branch 23 → 131 not taken.
✓ Branch 24 → 25 taken 11224 times.
✗ Branch 24 → 131 not taken.
|
11224 | stmtLstNode->statements.push_back(std::any_cast<ForLoopNode *>(visit(forLoopCtx))); |
| 514 |
3/4✓ Branch 27 → 28 taken 1055428 times.
✗ Branch 27 → 29 not taken.
✓ Branch 30 → 31 taken 12983 times.
✓ Branch 30 → 36 taken 1042445 times.
|
1055428 | else if (auto *foreachLoopCtx = dynamic_cast<SpiceParser::ForeachLoopContext *>(stmt)) |
| 515 |
3/6✓ Branch 31 → 32 taken 12983 times.
✗ Branch 31 → 137 not taken.
✓ Branch 32 → 33 taken 12983 times.
✗ Branch 32 → 135 not taken.
✓ Branch 33 → 34 taken 12983 times.
✗ Branch 33 → 135 not taken.
|
12983 | stmtLstNode->statements.push_back(std::any_cast<ForeachLoopNode *>(visit(foreachLoopCtx))); |
| 516 |
3/4✓ Branch 36 → 37 taken 1042445 times.
✗ Branch 36 → 38 not taken.
✓ Branch 39 → 40 taken 8815 times.
✓ Branch 39 → 45 taken 1033630 times.
|
1042445 | else if (auto *whileLoopCtx = dynamic_cast<SpiceParser::WhileLoopContext *>(stmt)) |
| 517 |
3/6✓ Branch 40 → 41 taken 8815 times.
✗ Branch 40 → 141 not taken.
✓ Branch 41 → 42 taken 8815 times.
✗ Branch 41 → 139 not taken.
✓ Branch 42 → 43 taken 8815 times.
✗ Branch 42 → 139 not taken.
|
8815 | stmtLstNode->statements.push_back(std::any_cast<WhileLoopNode *>(visit(whileLoopCtx))); |
| 518 |
3/4✓ Branch 45 → 46 taken 1033630 times.
✗ Branch 45 → 47 not taken.
✓ Branch 48 → 49 taken 169 times.
✓ Branch 48 → 54 taken 1033461 times.
|
1033630 | else if (auto *doWhileLoopCtx = dynamic_cast<SpiceParser::DoWhileLoopContext *>(stmt)) |
| 519 |
3/6✓ Branch 49 → 50 taken 169 times.
✗ Branch 49 → 145 not taken.
✓ Branch 50 → 51 taken 169 times.
✗ Branch 50 → 143 not taken.
✓ Branch 51 → 52 taken 169 times.
✗ Branch 51 → 143 not taken.
|
169 | stmtLstNode->statements.push_back(std::any_cast<DoWhileLoopNode *>(visit(doWhileLoopCtx))); |
| 520 |
3/4✓ Branch 54 → 55 taken 1033461 times.
✗ Branch 54 → 56 not taken.
✓ Branch 57 → 58 taken 126437 times.
✓ Branch 57 → 63 taken 907024 times.
|
1033461 | else if (auto *ifStmtCtx = dynamic_cast<SpiceParser::IfStmtContext *>(stmt)) |
| 521 |
3/6✓ Branch 58 → 59 taken 126437 times.
✗ Branch 58 → 149 not taken.
✓ Branch 59 → 60 taken 126437 times.
✗ Branch 59 → 147 not taken.
✓ Branch 60 → 61 taken 126437 times.
✗ Branch 60 → 147 not taken.
|
126437 | stmtLstNode->statements.push_back(std::any_cast<IfStmtNode *>(visit(ifStmtCtx))); |
| 522 |
3/4✓ Branch 63 → 64 taken 907024 times.
✗ Branch 63 → 65 not taken.
✓ Branch 66 → 67 taken 1715 times.
✓ Branch 66 → 72 taken 905309 times.
|
907024 | else if (auto *switchStmtCtx = dynamic_cast<SpiceParser::SwitchStmtContext *>(stmt)) |
| 523 |
3/6✓ Branch 67 → 68 taken 1715 times.
✗ Branch 67 → 153 not taken.
✓ Branch 68 → 69 taken 1715 times.
✗ Branch 68 → 151 not taken.
✓ Branch 69 → 70 taken 1715 times.
✗ Branch 69 → 151 not taken.
|
1715 | stmtLstNode->statements.push_back(std::any_cast<SwitchStmtNode *>(visit(switchStmtCtx))); |
| 524 |
3/4✓ Branch 72 → 73 taken 905309 times.
✗ Branch 72 → 74 not taken.
✓ Branch 75 → 76 taken 46353 times.
✓ Branch 75 → 81 taken 858956 times.
|
905309 | else if (auto *assetStmtCtx = dynamic_cast<SpiceParser::AssertStmtContext *>(stmt)) |
| 525 |
3/6✓ Branch 76 → 77 taken 46353 times.
✗ Branch 76 → 157 not taken.
✓ Branch 77 → 78 taken 46353 times.
✗ Branch 77 → 155 not taken.
✓ Branch 78 → 79 taken 46353 times.
✗ Branch 78 → 155 not taken.
|
46353 | stmtLstNode->statements.push_back(std::any_cast<AssertStmtNode *>(visit(assetStmtCtx))); |
| 526 |
3/4✓ Branch 81 → 82 taken 858956 times.
✗ Branch 81 → 83 not taken.
✓ Branch 84 → 85 taken 27003 times.
✓ Branch 84 → 90 taken 831953 times.
|
858956 | else if (auto *unsafeBlockCtx = dynamic_cast<SpiceParser::UnsafeBlockContext *>(stmt)) |
| 527 |
3/6✓ Branch 85 → 86 taken 27003 times.
✗ Branch 85 → 161 not taken.
✓ Branch 86 → 87 taken 27003 times.
✗ Branch 86 → 159 not taken.
✓ Branch 87 → 88 taken 27003 times.
✗ Branch 87 → 159 not taken.
|
27003 | stmtLstNode->statements.push_back(std::any_cast<UnsafeBlockNode *>(visit(unsafeBlockCtx))); |
| 528 |
3/4✓ Branch 90 → 91 taken 831953 times.
✗ Branch 90 → 92 not taken.
✓ Branch 93 → 94 taken 337 times.
✓ Branch 93 → 99 taken 831616 times.
|
831953 | else if (auto *anonymousScopeCtx = dynamic_cast<SpiceParser::AnonymousBlockStmtContext *>(stmt)) |
| 529 |
3/6✓ Branch 94 → 95 taken 337 times.
✗ Branch 94 → 165 not taken.
✓ Branch 95 → 96 taken 337 times.
✗ Branch 95 → 163 not taken.
✓ Branch 96 → 97 taken 337 times.
✗ Branch 96 → 163 not taken.
|
337 | stmtLstNode->statements.push_back(std::any_cast<AnonymousBlockStmtNode *>(visit(anonymousScopeCtx))); |
| 530 | else | ||
| 531 | − | assert(is<TerminalNode *>(stmt)); // GCOV_EXCL_LINE | |
| 532 | } | ||
| 533 | |||
| 534 |
1/2✓ Branch 122 → 123 taken 415804 times.
✗ Branch 122 → 168 not taken.
|
831608 | return concludeNode(stmtLstNode); |
| 535 | } | ||
| 536 | |||
| 537 | 126095 | std::any ASTBuilder::visitTypeLst(SpiceParser::TypeLstContext *ctx) { | |
| 538 | 126095 | const auto typeLstNode = createNode<TypeLstNode>(ctx); | |
| 539 | |||
| 540 | // Visit children | ||
| 541 |
3/6✓ Branch 3 → 4 taken 126095 times.
✗ Branch 3 → 18 not taken.
✓ Branch 4 → 5 taken 126095 times.
✗ Branch 4 → 16 not taken.
✓ Branch 6 → 7 taken 126095 times.
✗ Branch 6 → 19 not taken.
|
126095 | fetchChildrenIntoVector(typeLstNode->dataTypes, ctx->dataType()); |
| 542 | |||
| 543 |
1/2✓ Branch 12 → 13 taken 126095 times.
✗ Branch 12 → 19 not taken.
|
252190 | return concludeNode(typeLstNode); |
| 544 | } | ||
| 545 | |||
| 546 | 14884 | std::any ASTBuilder::visitTypeLstWithEllipsis(SpiceParser::TypeLstWithEllipsisContext *ctx) { | |
| 547 | 14884 | const auto typeLstWithEllipsisNode = createNode<TypeLstWithEllipsisNode>(ctx); | |
| 548 | |||
| 549 | // Visit children | ||
| 550 |
3/6✓ Branch 3 → 4 taken 14884 times.
✗ Branch 3 → 20 not taken.
✓ Branch 4 → 5 taken 14884 times.
✗ Branch 4 → 20 not taken.
✓ Branch 5 → 6 taken 14884 times.
✗ Branch 5 → 18 not taken.
|
14884 | typeLstWithEllipsisNode->typeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst())); |
| 551 | |||
| 552 | // Set some flags | ||
| 553 |
1/2✓ Branch 8 → 9 taken 14884 times.
✗ Branch 8 → 21 not taken.
|
14884 | typeLstWithEllipsisNode->hasEllipsis = ctx->ELLIPSIS() != nullptr; |
| 554 | |||
| 555 |
1/2✓ Branch 14 → 15 taken 14884 times.
✗ Branch 14 → 21 not taken.
|
29768 | return concludeNode(typeLstWithEllipsisNode); |
| 556 | } | ||
| 557 | |||
| 558 | 7047 | std::any ASTBuilder::visitTypeAltsLst(SpiceParser::TypeAltsLstContext *ctx) { | |
| 559 | 7047 | const auto typeAltsLstNode = createNode<TypeAltsLstNode>(ctx); | |
| 560 | |||
| 561 | // Visit children | ||
| 562 |
3/6✓ Branch 3 → 4 taken 7047 times.
✗ Branch 3 → 18 not taken.
✓ Branch 4 → 5 taken 7047 times.
✗ Branch 4 → 16 not taken.
✓ Branch 6 → 7 taken 7047 times.
✗ Branch 6 → 19 not taken.
|
7047 | fetchChildrenIntoVector(typeAltsLstNode->dataTypes, ctx->dataType()); |
| 563 | |||
| 564 |
1/2✓ Branch 12 → 13 taken 7047 times.
✗ Branch 12 → 19 not taken.
|
14094 | return concludeNode(typeAltsLstNode); |
| 565 | } | ||
| 566 | |||
| 567 | 125584 | std::any ASTBuilder::visitParamLst(SpiceParser::ParamLstContext *ctx) { | |
| 568 | 125584 | const auto paramLstNode = createNode<ParamLstNode>(ctx); | |
| 569 | |||
| 570 | // Visit children | ||
| 571 |
2/4✓ Branch 3 → 4 taken 125584 times.
✗ Branch 3 → 32 not taken.
✓ Branch 4 → 5 taken 125584 times.
✗ Branch 4 → 30 not taken.
|
125584 | fetchChildrenIntoVector(paramLstNode->params, ctx->declStmt()); |
| 572 | |||
| 573 | // Set some flags to later detect that the decl statements are parameters | ||
| 574 |
2/2✓ Branch 19 → 8 taken 197645 times.
✓ Branch 19 → 20 taken 125584 times.
|
448813 | for (DeclStmtNode *declStmt : paramLstNode->params) { |
| 575 | 197645 | declStmt->isFctParam = true; | |
| 576 | 197645 | declStmt->dataType->isParamType = true; | |
| 577 | } | ||
| 578 | |||
| 579 |
1/2✓ Branch 26 → 27 taken 125584 times.
✗ Branch 26 → 33 not taken.
|
251168 | return concludeNode(paramLstNode); |
| 580 | } | ||
| 581 | |||
| 582 | 464548 | std::any ASTBuilder::visitArgLst(SpiceParser::ArgLstContext *ctx) { | |
| 583 | 464548 | const auto argLstNode = createNode<ArgLstNode>(ctx); | |
| 584 | |||
| 585 | // Visit children | ||
| 586 |
2/4✓ Branch 3 → 4 taken 464548 times.
✗ Branch 3 → 20 not taken.
✓ Branch 4 → 5 taken 464548 times.
✗ Branch 4 → 18 not taken.
|
464548 | fetchChildrenIntoVector(argLstNode->args, ctx->assignExpr()); |
| 587 | 464548 | argLstNode->argInfos.reserve(argLstNode->args.size()); | |
| 588 | |||
| 589 |
1/2✓ Branch 14 → 15 taken 464548 times.
✗ Branch 14 → 21 not taken.
|
929096 | return concludeNode(argLstNode); |
| 590 | } | ||
| 591 | |||
| 592 | 4254 | std::any ASTBuilder::visitEnumItemLst(SpiceParser::EnumItemLstContext *ctx) { | |
| 593 | 4254 | const auto enumItemLstNode = createNode<EnumItemLstNode>(ctx); | |
| 594 | |||
| 595 | // Visit children | ||
| 596 |
3/6✓ Branch 3 → 4 taken 4254 times.
✗ Branch 3 → 18 not taken.
✓ Branch 4 → 5 taken 4254 times.
✗ Branch 4 → 16 not taken.
✓ Branch 6 → 7 taken 4254 times.
✗ Branch 6 → 19 not taken.
|
4254 | fetchChildrenIntoVector(enumItemLstNode->items, ctx->enumItem()); |
| 597 | |||
| 598 |
1/2✓ Branch 12 → 13 taken 4254 times.
✗ Branch 12 → 19 not taken.
|
8508 | return concludeNode(enumItemLstNode); |
| 599 | } | ||
| 600 | |||
| 601 | 47138 | std::any ASTBuilder::visitEnumItem(SpiceParser::EnumItemContext *ctx) { | |
| 602 | 47138 | const auto enumItemNode = createNode<EnumItemNode>(ctx); | |
| 603 | |||
| 604 | // Enrich | ||
| 605 |
2/4✓ Branch 3 → 4 taken 47138 times.
✗ Branch 3 → 22 not taken.
✓ Branch 4 → 5 taken 47138 times.
✗ Branch 4 → 22 not taken.
|
47138 | enumItemNode->itemName = getIdentifier(ctx->TYPE_IDENTIFIER(), false); |
| 606 |
2/2✓ Branch 8 → 9 taken 18836 times.
✓ Branch 8 → 12 taken 28302 times.
|
47138 | if (ctx->ASSIGN()) { |
| 607 | 18836 | enumItemNode->itemValue = parseInt(ctx->INT_LIT()); | |
| 608 | 18836 | enumItemNode->hasValue = true; | |
| 609 | } | ||
| 610 | |||
| 611 |
1/2✓ Branch 18 → 19 taken 47138 times.
✗ Branch 18 → 23 not taken.
|
94276 | return concludeNode(enumItemNode); |
| 612 | } | ||
| 613 | |||
| 614 | 58994 | std::any ASTBuilder::visitField(SpiceParser::FieldContext *ctx) { | |
| 615 | 58994 | const auto fieldNode = createNode<FieldNode>(ctx); | |
| 616 | |||
| 617 | // Enrich | ||
| 618 |
2/4✓ Branch 3 → 4 taken 58994 times.
✗ Branch 3 → 29 not taken.
✓ Branch 4 → 5 taken 58994 times.
✗ Branch 4 → 29 not taken.
|
58994 | fieldNode->fieldName = getIdentifier(ctx->IDENTIFIER(), false); |
| 619 | |||
| 620 | // Visit children | ||
| 621 |
3/6✓ Branch 7 → 8 taken 58994 times.
✗ Branch 7 → 32 not taken.
✓ Branch 8 → 9 taken 58994 times.
✗ Branch 8 → 32 not taken.
✓ Branch 9 → 10 taken 58994 times.
✗ Branch 9 → 30 not taken.
|
58994 | fieldNode->dataType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 622 | 58994 | fieldNode->dataType->setFieldTypeRecursive(); | |
| 623 |
2/2✓ Branch 13 → 14 taken 23441 times.
✓ Branch 13 → 19 taken 35553 times.
|
58994 | if (ctx->ternaryExpr()) |
| 624 |
3/6✓ Branch 14 → 15 taken 23441 times.
✗ Branch 14 → 35 not taken.
✓ Branch 15 → 16 taken 23441 times.
✗ Branch 15 → 35 not taken.
✓ Branch 16 → 17 taken 23441 times.
✗ Branch 16 → 33 not taken.
|
23441 | fieldNode->defaultValue = std::any_cast<ExprNode *>(visit(ctx->ternaryExpr())); |
| 625 | |||
| 626 |
1/2✓ Branch 25 → 26 taken 58994 times.
✗ Branch 25 → 36 not taken.
|
117988 | return concludeNode(fieldNode); |
| 627 | } | ||
| 628 | |||
| 629 | 5361 | std::any ASTBuilder::visitSignature(SpiceParser::SignatureContext *ctx) { | |
| 630 | 5361 | const auto signatureNode = createNode<SignatureNode>(ctx); | |
| 631 | |||
| 632 | // Extract method name | ||
| 633 |
2/4✓ Branch 3 → 4 taken 5361 times.
✗ Branch 3 → 73 not taken.
✓ Branch 4 → 5 taken 5361 times.
✗ Branch 4 → 73 not taken.
|
5361 | signatureNode->methodName = getIdentifier(ctx->IDENTIFIER(), false); |
| 634 | |||
| 635 | // Visit children | ||
| 636 |
2/2✓ Branch 8 → 9 taken 5259 times.
✓ Branch 8 → 14 taken 102 times.
|
5361 | if (ctx->qualifierLst()) { |
| 637 |
3/6✓ Branch 9 → 10 taken 5259 times.
✗ Branch 9 → 76 not taken.
✓ Branch 10 → 11 taken 5259 times.
✗ Branch 10 → 76 not taken.
✓ Branch 11 → 12 taken 5259 times.
✗ Branch 11 → 74 not taken.
|
5259 | signatureNode->qualifierLst = std::any_cast<QualifierLstNode *>(visit(ctx->qualifierLst())); |
| 638 | } | ||
| 639 |
2/2✓ Branch 15 → 16 taken 5059 times.
✓ Branch 15 → 22 taken 302 times.
|
5361 | if (ctx->F()) { |
| 640 | 5059 | signatureNode->hasReturnType = true; | |
| 641 | 5059 | signatureNode->signatureType = SignatureNode::SignatureType::TYPE_FUNCTION; | |
| 642 | 5059 | signatureNode->signatureQualifiers = TypeQualifiers::of(TY_FUNCTION); | |
| 643 |
3/6✓ Branch 17 → 18 taken 5059 times.
✗ Branch 17 → 79 not taken.
✓ Branch 18 → 19 taken 5059 times.
✗ Branch 18 → 79 not taken.
✓ Branch 19 → 20 taken 5059 times.
✗ Branch 19 → 77 not taken.
|
5059 | signatureNode->returnType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 644 | } else { | ||
| 645 | 302 | signatureNode->signatureType = SignatureNode::SignatureType::TYPE_PROCEDURE; | |
| 646 | 302 | signatureNode->signatureQualifiers = TypeQualifiers::of(TY_PROCEDURE); | |
| 647 | } | ||
| 648 |
10/16✓ Branch 24 → 25 taken 5059 times.
✓ Branch 24 → 28 taken 302 times.
✓ Branch 25 → 26 taken 5059 times.
✗ Branch 25 → 80 not taken.
✓ Branch 28 → 29 taken 302 times.
✗ Branch 28 → 80 not taken.
✓ Branch 31 → 32 taken 302 times.
✓ Branch 31 → 33 taken 5059 times.
✓ Branch 33 → 34 taken 5059 times.
✓ Branch 33 → 35 taken 302 times.
✓ Branch 35 → 36 taken 676 times.
✓ Branch 35 → 41 taken 4685 times.
✗ Branch 80 → 81 not taken.
✗ Branch 80 → 82 not taken.
✗ Branch 84 → 85 not taken.
✗ Branch 84 → 86 not taken.
|
5361 | if (ctx->F() ? ctx->LESS().size() == 2 : ctx->LESS().size() == 1) { |
| 649 | 676 | signatureNode->hasTemplateTypes = true; | |
| 650 |
3/6✓ Branch 36 → 37 taken 676 times.
✗ Branch 36 → 90 not taken.
✓ Branch 37 → 38 taken 676 times.
✗ Branch 37 → 90 not taken.
✓ Branch 38 → 39 taken 676 times.
✗ Branch 38 → 88 not taken.
|
676 | signatureNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst(0))); |
| 651 | } | ||
| 652 |
13/20✓ Branch 41 → 42 taken 5361 times.
✗ Branch 41 → 91 not taken.
✓ Branch 43 → 44 taken 5357 times.
✓ Branch 43 → 48 taken 4 times.
✓ Branch 44 → 45 taken 5357 times.
✗ Branch 44 → 91 not taken.
✓ Branch 46 → 47 taken 4624 times.
✓ Branch 46 → 49 taken 733 times.
✓ Branch 47 → 48 taken 3952 times.
✓ Branch 47 → 49 taken 672 times.
✓ Branch 50 → 51 taken 5357 times.
✓ Branch 50 → 52 taken 4 times.
✓ Branch 52 → 53 taken 5361 times.
✗ Branch 52 → 54 not taken.
✓ Branch 54 → 55 taken 3956 times.
✓ Branch 54 → 63 taken 1405 times.
✗ Branch 91 → 92 not taken.
✗ Branch 91 → 93 not taken.
✗ Branch 95 → 96 not taken.
✗ Branch 95 → 97 not taken.
|
5361 | if (ctx->typeLst().size() == 2 || (ctx->typeLst().size() == 1 && !signatureNode->hasTemplateTypes)) { |
| 653 | 3956 | signatureNode->hasParams = true; | |
| 654 |
5/8✓ Branch 55 → 56 taken 4 times.
✓ Branch 55 → 57 taken 3952 times.
✓ Branch 58 → 59 taken 3956 times.
✗ Branch 58 → 101 not taken.
✓ Branch 59 → 60 taken 3956 times.
✗ Branch 59 → 101 not taken.
✓ Branch 60 → 61 taken 3956 times.
✗ Branch 60 → 99 not taken.
|
3956 | signatureNode->paramTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst(signatureNode->hasTemplateTypes ? 1 : 0))); |
| 655 | } | ||
| 656 | |||
| 657 |
1/2✓ Branch 69 → 70 taken 5361 times.
✗ Branch 69 → 102 not taken.
|
10722 | return concludeNode(signatureNode); |
| 658 | } | ||
| 659 | |||
| 660 | 721309 | std::any ASTBuilder::visitStmt(SpiceParser::StmtContext *ctx) { | |
| 661 |
2/2✓ Branch 3 → 4 taken 181254 times.
✓ Branch 3 → 11 taken 540055 times.
|
721309 | if (ctx->declStmt()) |
| 662 |
5/8✓ Branch 4 → 5 taken 181254 times.
✗ Branch 4 → 60 not taken.
✓ Branch 5 → 6 taken 181246 times.
✓ Branch 5 → 60 taken 8 times.
✓ Branch 6 → 7 taken 181246 times.
✗ Branch 6 → 58 not taken.
✓ Branch 7 → 8 taken 181246 times.
✗ Branch 7 → 58 not taken.
|
362500 | return static_cast<StmtNode *>(std::any_cast<DeclStmtNode *>(visit(ctx->declStmt()))); |
| 663 |
2/2✓ Branch 12 → 13 taken 333801 times.
✓ Branch 12 → 20 taken 206254 times.
|
540055 | if (ctx->exprStmt()) |
| 664 |
4/8✓ Branch 13 → 14 taken 333801 times.
✗ Branch 13 → 64 not taken.
✓ Branch 14 → 15 taken 333801 times.
✗ Branch 14 → 64 not taken.
✓ Branch 15 → 16 taken 333801 times.
✗ Branch 15 → 62 not taken.
✓ Branch 16 → 17 taken 333801 times.
✗ Branch 16 → 62 not taken.
|
667602 | return static_cast<StmtNode *>(std::any_cast<ExprStmtNode *>(visit(ctx->exprStmt()))); |
| 665 |
2/2✓ Branch 21 → 22 taken 198458 times.
✓ Branch 21 → 29 taken 7796 times.
|
206254 | if (ctx->returnStmt()) |
| 666 |
4/8✓ Branch 22 → 23 taken 198458 times.
✗ Branch 22 → 68 not taken.
✓ Branch 23 → 24 taken 198458 times.
✗ Branch 23 → 68 not taken.
✓ Branch 24 → 25 taken 198458 times.
✗ Branch 24 → 66 not taken.
✓ Branch 25 → 26 taken 198458 times.
✗ Branch 25 → 66 not taken.
|
396916 | return static_cast<StmtNode *>(std::any_cast<ReturnStmtNode *>(visit(ctx->returnStmt()))); |
| 667 |
2/2✓ Branch 30 → 31 taken 2664 times.
✓ Branch 30 → 38 taken 5132 times.
|
7796 | if (ctx->breakStmt()) |
| 668 |
4/8✓ Branch 31 → 32 taken 2664 times.
✗ Branch 31 → 72 not taken.
✓ Branch 32 → 33 taken 2664 times.
✗ Branch 32 → 72 not taken.
✓ Branch 33 → 34 taken 2664 times.
✗ Branch 33 → 70 not taken.
✓ Branch 34 → 35 taken 2664 times.
✗ Branch 34 → 70 not taken.
|
5328 | return static_cast<StmtNode *>(std::any_cast<BreakStmtNode *>(visit(ctx->breakStmt()))); |
| 669 |
2/2✓ Branch 39 → 40 taken 5120 times.
✓ Branch 39 → 47 taken 12 times.
|
5132 | if (ctx->continueStmt()) |
| 670 |
4/8✓ Branch 40 → 41 taken 5120 times.
✗ Branch 40 → 76 not taken.
✓ Branch 41 → 42 taken 5120 times.
✗ Branch 41 → 76 not taken.
✓ Branch 42 → 43 taken 5120 times.
✗ Branch 42 → 74 not taken.
✓ Branch 43 → 44 taken 5120 times.
✗ Branch 43 → 74 not taken.
|
10240 | return static_cast<StmtNode *>(std::any_cast<ContinueStmtNode *>(visit(ctx->continueStmt()))); |
| 671 |
1/2✓ Branch 48 → 49 taken 12 times.
✗ Branch 48 → 56 not taken.
|
12 | if (ctx->fallthroughStmt()) |
| 672 |
4/8✓ Branch 49 → 50 taken 12 times.
✗ Branch 49 → 80 not taken.
✓ Branch 50 → 51 taken 12 times.
✗ Branch 50 → 80 not taken.
✓ Branch 51 → 52 taken 12 times.
✗ Branch 51 → 78 not taken.
✓ Branch 52 → 53 taken 12 times.
✗ Branch 52 → 78 not taken.
|
24 | return static_cast<StmtNode *>(std::any_cast<FallthroughStmtNode *>(visit(ctx->fallthroughStmt()))); |
| 673 | − | assert_fail("Unknown statement type"); // GCOV_EXCL_LINE | |
| 674 | return nullptr; // GCOV_EXCL_LINE | ||
| 675 | } | ||
| 676 | |||
| 677 | 404144 | std::any ASTBuilder::visitDeclStmt(SpiceParser::DeclStmtContext *ctx) { | |
| 678 | 404144 | const auto declStmtNode = createNode<DeclStmtNode>(ctx); | |
| 679 | |||
| 680 | // Enrich | ||
| 681 |
3/4✓ Branch 3 → 4 taken 404144 times.
✗ Branch 3 → 28 not taken.
✓ Branch 4 → 5 taken 404142 times.
✓ Branch 4 → 28 taken 2 times.
|
404144 | declStmtNode->varName = getIdentifier(ctx->IDENTIFIER(), false); |
| 682 | |||
| 683 | // Visit children | ||
| 684 |
4/6✓ Branch 7 → 8 taken 404142 times.
✗ Branch 7 → 31 not taken.
✓ Branch 8 → 9 taken 404140 times.
✓ Branch 8 → 31 taken 2 times.
✓ Branch 9 → 10 taken 404140 times.
✗ Branch 9 → 29 not taken.
|
404142 | declStmtNode->dataType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 685 |
2/2✓ Branch 12 → 13 taken 187811 times.
✓ Branch 12 → 18 taken 216329 times.
|
404140 | if (ctx->assignExpr()) { |
| 686 | 187811 | declStmtNode->hasAssignment = true; | |
| 687 |
4/6✓ Branch 13 → 14 taken 187811 times.
✗ Branch 13 → 34 not taken.
✓ Branch 14 → 15 taken 187807 times.
✓ Branch 14 → 34 taken 4 times.
✓ Branch 15 → 16 taken 187807 times.
✗ Branch 15 → 32 not taken.
|
187811 | declStmtNode->assignExpr = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 688 | } | ||
| 689 | |||
| 690 |
1/2✓ Branch 24 → 25 taken 404136 times.
✗ Branch 24 → 35 not taken.
|
808272 | return concludeNode(declStmtNode); |
| 691 | } | ||
| 692 | |||
| 693 | 333801 | std::any ASTBuilder::visitExprStmt(SpiceParser::ExprStmtContext *ctx) { | |
| 694 | 333801 | const auto exprStmtNode = createNode<ExprStmtNode>(ctx); | |
| 695 | |||
| 696 | // Enrich | ||
| 697 |
4/8✓ Branch 3 → 4 taken 333801 times.
✗ Branch 3 → 19 not taken.
✓ Branch 4 → 5 taken 333801 times.
✗ Branch 4 → 19 not taken.
✓ Branch 5 → 6 taken 333801 times.
✗ Branch 5 → 17 not taken.
✓ Branch 7 → 8 taken 333801 times.
✗ Branch 7 → 20 not taken.
|
333801 | exprStmtNode->expr = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 698 | |||
| 699 |
1/2✓ Branch 13 → 14 taken 333801 times.
✗ Branch 13 → 20 not taken.
|
667602 | return concludeNode(exprStmtNode); |
| 700 | } | ||
| 701 | |||
| 702 | 506711 | std::any ASTBuilder::visitQualifierLst(SpiceParser::QualifierLstContext *ctx) { | |
| 703 | 506711 | const auto qualifierLstNode = createNode<QualifierLstNode>(ctx); | |
| 704 | |||
| 705 | // Visit children | ||
| 706 |
2/4✓ Branch 3 → 4 taken 506711 times.
✗ Branch 3 → 45 not taken.
✓ Branch 4 → 5 taken 506711 times.
✗ Branch 4 → 43 not taken.
|
506711 | fetchChildrenIntoVector(qualifierLstNode->qualifiers, ctx->qualifier()); |
| 707 | |||
| 708 | // Check if qualifier combination is invalid | ||
| 709 | 506711 | bool seenSignedOrUnsigned = false; | |
| 710 |
2/2✓ Branch 32 → 8 taken 575523 times.
✓ Branch 32 → 33 taken 506709 times.
|
1588943 | for (const QualifierNode *qualifier : qualifierLstNode->qualifiers) { |
| 711 | // Check if we have both, signed and unsigned qualifier | ||
| 712 |
2/2✓ Branch 10 → 11 taken 575317 times.
✓ Branch 10 → 13 taken 206 times.
|
575523 | if (qualifier->type != QualifierNode::QualifierType::TY_SIGNED && |
| 713 |
2/2✓ Branch 11 → 12 taken 482471 times.
✓ Branch 11 → 13 taken 92846 times.
|
575317 | qualifier->type != QualifierNode::QualifierType::TY_UNSIGNED) |
| 714 | 482471 | continue; | |
| 715 |
2/2✓ Branch 13 → 14 taken 2 times.
✓ Branch 13 → 22 taken 93050 times.
|
93052 | if (seenSignedOrUnsigned) |
| 716 |
2/4✓ Branch 17 → 18 taken 2 times.
✗ Branch 17 → 49 not taken.
✓ Branch 18 → 19 taken 2 times.
✗ Branch 18 → 46 not taken.
|
6 | throw ParserError(qualifier->codeLoc, INVALID_QUALIFIER_COMBINATION, "A variable can not be signed and unsigned"); |
| 717 | 93050 | seenSignedOrUnsigned = true; | |
| 718 | } | ||
| 719 | |||
| 720 |
1/2✓ Branch 39 → 40 taken 506709 times.
✗ Branch 39 → 56 not taken.
|
1013418 | return concludeNode(qualifierLstNode); |
| 721 | } | ||
| 722 | |||
| 723 | 575523 | std::any ASTBuilder::visitQualifier(SpiceParser::QualifierContext *ctx) { | |
| 724 | 575523 | const auto qualifierNode = createNode<QualifierNode>(ctx); | |
| 725 | |||
| 726 |
3/4✓ Branch 7 → 8 taken 575523 times.
✗ Branch 7 → 9 not taken.
✓ Branch 42 → 5 taken 575523 times.
✓ Branch 42 → 43 taken 575523 times.
|
2302092 | for (ParserRuleContext::ParseTree *subTree : ctx->children) { |
| 727 | 575523 | const auto token = spice_pointer_cast<TerminalNode *>(subTree); | |
| 728 |
2/4✓ Branch 16 → 17 taken 575523 times.
✗ Branch 16 → 53 not taken.
✓ Branch 17 → 18 taken 575523 times.
✗ Branch 17 → 53 not taken.
|
575523 | const size_t symbolType = token->getSymbol()->getType(); |
| 729 |
2/2✓ Branch 18 → 19 taken 189287 times.
✓ Branch 18 → 20 taken 386236 times.
|
575523 | if (symbolType == SpiceParser::CONST) |
| 730 | 189287 | qualifierNode->type = QualifierNode::QualifierType::TY_CONST; | |
| 731 |
2/2✓ Branch 20 → 21 taken 206 times.
✓ Branch 20 → 22 taken 386030 times.
|
386236 | else if (symbolType == SpiceParser::SIGNED) |
| 732 | 206 | qualifierNode->type = QualifierNode::QualifierType::TY_SIGNED; | |
| 733 |
2/2✓ Branch 22 → 23 taken 92846 times.
✓ Branch 22 → 24 taken 293184 times.
|
386030 | else if (symbolType == SpiceParser::UNSIGNED) |
| 734 | 92846 | qualifierNode->type = QualifierNode::QualifierType::TY_UNSIGNED; | |
| 735 |
2/2✓ Branch 24 → 25 taken 28497 times.
✓ Branch 24 → 26 taken 264687 times.
|
293184 | else if (symbolType == SpiceParser::INLINE) |
| 736 | 28497 | qualifierNode->type = QualifierNode::QualifierType::TY_INLINE; | |
| 737 |
2/2✓ Branch 26 → 27 taken 225469 times.
✓ Branch 26 → 28 taken 39218 times.
|
264687 | else if (symbolType == SpiceParser::PUBLIC) |
| 738 | 225469 | qualifierNode->type = QualifierNode::QualifierType::TY_PUBLIC; | |
| 739 |
2/2✓ Branch 28 → 29 taken 34816 times.
✓ Branch 28 → 30 taken 4402 times.
|
39218 | else if (symbolType == SpiceParser::HEAP) |
| 740 | 34816 | qualifierNode->type = QualifierNode::QualifierType::TY_HEAP; | |
| 741 |
1/2✓ Branch 30 → 31 taken 4402 times.
✗ Branch 30 → 32 not taken.
|
4402 | else if (symbolType == SpiceParser::COMPOSE) |
| 742 | 4402 | qualifierNode->type = QualifierNode::QualifierType::TY_COMPOSITION; | |
| 743 | else | ||
| 744 | − | assert_fail("Unknown qualifier type"); // GCOV_EXCL_LINE | |
| 745 | } | ||
| 746 | |||
| 747 |
1/2✓ Branch 49 → 50 taken 575523 times.
✗ Branch 49 → 54 not taken.
|
1151046 | return concludeNode(qualifierNode); |
| 748 | } | ||
| 749 | |||
| 750 | 2502 | std::any ASTBuilder::visitModAttr(SpiceParser::ModAttrContext *ctx) { | |
| 751 | 2502 | const auto modAttrNode = createNode<ModAttrNode>(ctx); | |
| 752 | |||
| 753 | // Visit children | ||
| 754 |
4/6✓ Branch 3 → 4 taken 2502 times.
✗ Branch 3 → 33 not taken.
✓ Branch 4 → 5 taken 2500 times.
✓ Branch 4 → 33 taken 2 times.
✓ Branch 5 → 6 taken 2500 times.
✗ Branch 5 → 31 not taken.
|
2502 | modAttrNode->attrLst = std::any_cast<AttrLstNode *>(visit(ctx->attrLst())); |
| 755 | |||
| 756 | // Tell the attributes that they are module attributes | ||
| 757 |
2/2✓ Branch 20 → 9 taken 11396 times.
✓ Branch 20 → 21 taken 2500 times.
|
16396 | for (AttrNode *attr : modAttrNode->attrLst->attributes) |
| 758 | 11396 | attr->target = AttrNode::TARGET_MODULE; | |
| 759 | |||
| 760 |
1/2✓ Branch 27 → 28 taken 2500 times.
✗ Branch 27 → 34 not taken.
|
5000 | return concludeNode(modAttrNode); |
| 761 | } | ||
| 762 | |||
| 763 | 4328 | std::any ASTBuilder::visitTopLevelDefAttr(SpiceParser::TopLevelDefAttrContext *ctx) { | |
| 764 | 4328 | const auto fctAttrNode = createNode<TopLevelDefAttrNode>(ctx); | |
| 765 | |||
| 766 | // Visit children | ||
| 767 |
4/8✓ Branch 3 → 4 taken 4328 times.
✗ Branch 3 → 19 not taken.
✓ Branch 4 → 5 taken 4328 times.
✗ Branch 4 → 19 not taken.
✓ Branch 5 → 6 taken 4328 times.
✗ Branch 5 → 17 not taken.
✓ Branch 7 → 8 taken 4328 times.
✗ Branch 7 → 20 not taken.
|
4328 | fctAttrNode->attrLst = std::any_cast<AttrLstNode *>(visit(ctx->attrLst())); |
| 768 | |||
| 769 |
1/2✓ Branch 13 → 14 taken 4328 times.
✗ Branch 13 → 20 not taken.
|
8656 | return concludeNode(fctAttrNode); |
| 770 | } | ||
| 771 | |||
| 772 | 16 | std::any ASTBuilder::visitLambdaAttr(SpiceParser::LambdaAttrContext *ctx) { | |
| 773 | 16 | const auto lambdaAttrNode = createNode<LambdaAttrNode>(ctx); | |
| 774 | |||
| 775 | // Visit children | ||
| 776 |
3/6✓ Branch 3 → 4 taken 16 times.
✗ Branch 3 → 33 not taken.
✓ Branch 4 → 5 taken 16 times.
✗ Branch 4 → 33 not taken.
✓ Branch 5 → 6 taken 16 times.
✗ Branch 5 → 31 not taken.
|
16 | lambdaAttrNode->attrLst = std::any_cast<AttrLstNode *>(visit(ctx->attrLst())); |
| 777 | |||
| 778 | // Tell the attributes that they are module attributes | ||
| 779 |
2/2✓ Branch 20 → 9 taken 16 times.
✓ Branch 20 → 21 taken 16 times.
|
48 | for (AttrNode *attr : lambdaAttrNode->attrLst->attributes) |
| 780 | 16 | attr->target = AttrNode::TARGET_LAMBDA; | |
| 781 | |||
| 782 |
1/2✓ Branch 27 → 28 taken 16 times.
✗ Branch 27 → 34 not taken.
|
32 | return concludeNode(lambdaAttrNode); |
| 783 | } | ||
| 784 | |||
| 785 | 6846 | std::any ASTBuilder::visitAttrLst(SpiceParser::AttrLstContext *ctx) { | |
| 786 | 6846 | const auto attrLstNode = createNode<AttrLstNode>(ctx); | |
| 787 | |||
| 788 | // Visit children | ||
| 789 |
4/6✓ Branch 3 → 4 taken 6846 times.
✗ Branch 3 → 18 not taken.
✓ Branch 4 → 5 taken 6844 times.
✓ Branch 4 → 16 taken 2 times.
✓ Branch 6 → 7 taken 6844 times.
✗ Branch 6 → 19 not taken.
|
6848 | fetchChildrenIntoVector(attrLstNode->attributes, ctx->attr()); |
| 790 | |||
| 791 |
1/2✓ Branch 12 → 13 taken 6844 times.
✗ Branch 12 → 19 not taken.
|
13688 | return concludeNode(attrLstNode); |
| 792 | } | ||
| 793 | |||
| 794 | 17098 | std::any ASTBuilder::visitAttr(SpiceParser::AttrContext *ctx) { | |
| 795 |
1/2✓ Branch 2 → 3 taken 17098 times.
✗ Branch 2 → 83 not taken.
|
17098 | const auto attrNode = createNode<AttrNode>(ctx); |
| 796 | |||
| 797 | // Extract key | ||
| 798 |
1/2✓ Branch 3 → 4 taken 17098 times.
✗ Branch 3 → 83 not taken.
|
17098 | std::stringstream key; |
| 799 |
3/4✓ Branch 12 → 13 taken 61100 times.
✗ Branch 12 → 66 not taken.
✓ Branch 15 → 5 taken 44002 times.
✓ Branch 15 → 16 taken 17098 times.
|
61100 | for (size_t i = 0; i < ctx->IDENTIFIER().size(); i++) { |
| 800 |
2/2✓ Branch 5 → 6 taken 26904 times.
✓ Branch 5 → 7 taken 17098 times.
|
44002 | if (i > 0) |
| 801 |
1/2✓ Branch 6 → 7 taken 26904 times.
✗ Branch 6 → 81 not taken.
|
26904 | key << MEMBER_ACCESS_TOKEN; |
| 802 |
3/6✓ Branch 7 → 8 taken 44002 times.
✗ Branch 7 → 65 not taken.
✓ Branch 8 → 9 taken 44002 times.
✗ Branch 8 → 65 not taken.
✓ Branch 9 → 10 taken 44002 times.
✗ Branch 9 → 63 not taken.
|
44002 | key << ctx->IDENTIFIER(i)->getText(); |
| 803 | } | ||
| 804 |
1/2✓ Branch 16 → 17 taken 17098 times.
✗ Branch 16 → 67 not taken.
|
17098 | attrNode->key = key.str(); |
| 805 | |||
| 806 | // Visit children | ||
| 807 |
3/4✓ Branch 19 → 20 taken 17098 times.
✗ Branch 19 → 81 not taken.
✓ Branch 20 → 21 taken 13416 times.
✓ Branch 20 → 51 taken 3682 times.
|
17098 | if (ctx->constant()) { |
| 808 |
3/6✓ Branch 21 → 22 taken 13416 times.
✗ Branch 21 → 70 not taken.
✓ Branch 22 → 23 taken 13416 times.
✗ Branch 22 → 70 not taken.
✓ Branch 23 → 24 taken 13416 times.
✗ Branch 23 → 68 not taken.
|
13416 | attrNode->value = std::any_cast<ConstantNode *>(visit(ctx->constant())); |
| 809 | |||
| 810 |
4/6✓ Branch 25 → 26 taken 13416 times.
✗ Branch 25 → 81 not taken.
✓ Branch 26 → 27 taken 13416 times.
✗ Branch 26 → 81 not taken.
✓ Branch 27 → 28 taken 10342 times.
✓ Branch 27 → 29 taken 3074 times.
|
13416 | if (ctx->constant()->STRING_LIT()) |
| 811 | 10342 | attrNode->type = AttrNode::AttrType::TYPE_STRING; | |
| 812 |
4/6✓ Branch 29 → 30 taken 3074 times.
✗ Branch 29 → 81 not taken.
✓ Branch 30 → 31 taken 3074 times.
✗ Branch 30 → 81 not taken.
✓ Branch 31 → 32 taken 442 times.
✓ Branch 31 → 33 taken 2632 times.
|
3074 | else if (ctx->constant()->INT_LIT()) |
| 813 | 442 | attrNode->type = AttrNode::AttrType::TYPE_INT; | |
| 814 |
10/14✓ Branch 33 → 34 taken 2632 times.
✗ Branch 33 → 81 not taken.
✓ Branch 34 → 35 taken 2632 times.
✗ Branch 34 → 81 not taken.
✓ Branch 35 → 36 taken 10 times.
✓ Branch 35 → 39 taken 2622 times.
✓ Branch 36 → 37 taken 10 times.
✗ Branch 36 → 81 not taken.
✓ Branch 37 → 38 taken 10 times.
✗ Branch 37 → 81 not taken.
✓ Branch 38 → 39 taken 8 times.
✓ Branch 38 → 40 taken 2 times.
✓ Branch 41 → 42 taken 2630 times.
✓ Branch 41 → 43 taken 2 times.
|
2632 | else if (ctx->constant()->TRUE() || ctx->constant()->FALSE()) |
| 815 | 2630 | attrNode->type = AttrNode::AttrType::TYPE_BOOL; | |
| 816 | else | ||
| 817 |
2/4✓ Branch 46 → 47 taken 2 times.
✗ Branch 46 → 74 not taken.
✓ Branch 47 → 48 taken 2 times.
✗ Branch 47 → 71 not taken.
|
6 | throw ParserError(attrNode->value->codeLoc, INVALID_ATTR_VALUE_TYPE, "Invalid attribute value type"); |
| 818 | } else { | ||
| 819 | // If no value is given, use the bool type | ||
| 820 | 3682 | attrNode->type = AttrNode::AttrType::TYPE_BOOL; | |
| 821 | } | ||
| 822 | |||
| 823 |
1/2✓ Branch 58 → 59 taken 17096 times.
✗ Branch 58 → 80 not taken.
|
34192 | return concludeNode(attrNode); |
| 824 | 17098 | } | |
| 825 | |||
| 826 | 24543 | std::any ASTBuilder::visitCaseConstant(SpiceParser::CaseConstantContext *ctx) { | |
| 827 | 24543 | const auto caseConstantNode = createNode<CaseConstantNode>(ctx); | |
| 828 | |||
| 829 | // Visit children | ||
| 830 |
2/2✓ Branch 4 → 5 taken 1145 times.
✓ Branch 4 → 10 taken 23398 times.
|
24543 | if (ctx->constant()) { |
| 831 |
3/6✓ Branch 5 → 6 taken 1145 times.
✗ Branch 5 → 65 not taken.
✓ Branch 6 → 7 taken 1145 times.
✗ Branch 6 → 65 not taken.
✓ Branch 7 → 8 taken 1145 times.
✗ Branch 7 → 63 not taken.
|
1145 | caseConstantNode->constant = std::any_cast<ConstantNode *>(visit(ctx->constant())); |
| 832 |
2/4✓ Branch 10 → 11 taken 23398 times.
✗ Branch 10 → 66 not taken.
✓ Branch 13 → 14 taken 23398 times.
✗ Branch 13 → 52 not taken.
|
23398 | } else if (!ctx->TYPE_IDENTIFIER().empty()) { |
| 833 |
1/2✓ Branch 14 → 15 taken 23398 times.
✗ Branch 14 → 75 not taken.
|
23398 | std::stringstream fqIdentifier; |
| 834 |
2/2✓ Branch 46 → 17 taken 68790 times.
✓ Branch 46 → 47 taken 23398 times.
|
115586 | for (antlr4::tree::ParseTree *parseTree : ctx->children) { |
| 835 |
1/2✓ Branch 19 → 20 taken 68790 times.
✗ Branch 19 → 21 not taken.
|
68790 | const auto terminal = dynamic_cast<TerminalNode *>(parseTree); |
| 836 |
1/2✗ Branch 22 → 23 not taken.
✓ Branch 22 → 24 taken 68790 times.
|
68790 | if (!terminal) |
| 837 | ✗ | continue; | |
| 838 | |||
| 839 |
2/4✓ Branch 24 → 25 taken 68790 times.
✗ Branch 24 → 71 not taken.
✓ Branch 25 → 26 taken 68790 times.
✗ Branch 25 → 71 not taken.
|
68790 | const size_t terminalType = terminal->getSymbol()->getType(); |
| 840 |
3/4✓ Branch 26 → 27 taken 68790 times.
✗ Branch 26 → 28 not taken.
✓ Branch 27 → 28 taken 46094 times.
✓ Branch 27 → 37 taken 22696 times.
|
68790 | if (terminalType == SpiceParser::IDENTIFIER || terminalType == SpiceParser::TYPE_IDENTIFIER) { |
| 841 |
1/2✓ Branch 28 → 29 taken 46094 times.
✗ Branch 28 → 70 not taken.
|
46094 | const std::string fragment = getIdentifier(terminal, false); |
| 842 |
1/2✓ Branch 29 → 30 taken 46094 times.
✗ Branch 29 → 68 not taken.
|
46094 | caseConstantNode->identifierFragments.push_back(fragment); |
| 843 |
3/4✓ Branch 30 → 31 taken 46094 times.
✗ Branch 30 → 67 not taken.
✓ Branch 32 → 33 taken 22696 times.
✓ Branch 32 → 34 taken 23398 times.
|
46094 | if (fqIdentifier.tellp() != 0) |
| 844 |
1/2✓ Branch 33 → 34 taken 22696 times.
✗ Branch 33 → 68 not taken.
|
22696 | fqIdentifier << SCOPE_ACCESS_TOKEN; |
| 845 |
1/2✓ Branch 34 → 35 taken 46094 times.
✗ Branch 34 → 68 not taken.
|
46094 | fqIdentifier << fragment; |
| 846 | 46094 | } | |
| 847 | } | ||
| 848 |
1/2✓ Branch 47 → 48 taken 23398 times.
✗ Branch 47 → 72 not taken.
|
23398 | caseConstantNode->fqIdentifier = fqIdentifier.str(); |
| 849 | 23398 | } else { | |
| 850 | − | assert_fail("Unknown case constant type"); // GCOV_EXCL_LINE | |
| 851 | } | ||
| 852 | |||
| 853 |
1/2✓ Branch 59 → 60 taken 24543 times.
✗ Branch 59 → 76 not taken.
|
49086 | return concludeNode(caseConstantNode); |
| 854 | } | ||
| 855 | |||
| 856 | 198458 | std::any ASTBuilder::visitReturnStmt(SpiceParser::ReturnStmtContext *ctx) { | |
| 857 | 198458 | const auto returnStmtNode = createNode<ReturnStmtNode>(ctx); | |
| 858 | |||
| 859 | // Visit children | ||
| 860 |
2/2✓ Branch 4 → 5 taken 187350 times.
✓ Branch 4 → 10 taken 11108 times.
|
198458 | if (ctx->assignExpr()) { |
| 861 | 187350 | returnStmtNode->hasReturnValue = true; | |
| 862 |
3/6✓ Branch 5 → 6 taken 187350 times.
✗ Branch 5 → 22 not taken.
✓ Branch 6 → 7 taken 187350 times.
✗ Branch 6 → 22 not taken.
✓ Branch 7 → 8 taken 187350 times.
✗ Branch 7 → 20 not taken.
|
187350 | returnStmtNode->assignExpr = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 863 | } | ||
| 864 | |||
| 865 |
1/2✓ Branch 16 → 17 taken 198458 times.
✗ Branch 16 → 23 not taken.
|
396916 | return concludeNode(returnStmtNode); |
| 866 | } | ||
| 867 | |||
| 868 | 2664 | std::any ASTBuilder::visitBreakStmt(SpiceParser::BreakStmtContext *ctx) { | |
| 869 | 2664 | const auto breakStmtNode = createNode<BreakStmtNode>(ctx); | |
| 870 | |||
| 871 | // Extract number of breaks | ||
| 872 |
2/2✓ Branch 4 → 5 taken 13 times.
✓ Branch 4 → 10 taken 2651 times.
|
2664 | if (ctx->INT_LIT()) |
| 873 |
3/6✓ Branch 5 → 6 taken 13 times.
✗ Branch 5 → 24 not taken.
✓ Branch 6 → 7 taken 13 times.
✗ Branch 6 → 24 not taken.
✓ Branch 7 → 8 taken 13 times.
✗ Branch 7 → 22 not taken.
|
13 | breakStmtNode->breakTimes = std::stoi(ctx->INT_LIT()->toString()); |
| 874 | |||
| 875 | // Visit children | ||
| 876 |
2/4✓ Branch 10 → 11 taken 2664 times.
✗ Branch 10 → 25 not taken.
✓ Branch 12 → 13 taken 2664 times.
✗ Branch 12 → 26 not taken.
|
2664 | visitChildren(ctx); |
| 877 | |||
| 878 |
1/2✓ Branch 18 → 19 taken 2664 times.
✗ Branch 18 → 26 not taken.
|
5328 | return concludeNode(breakStmtNode); |
| 879 | } | ||
| 880 | |||
| 881 | 5120 | std::any ASTBuilder::visitContinueStmt(SpiceParser::ContinueStmtContext *ctx) { | |
| 882 | 5120 | const auto continueStmtNode = createNode<ContinueStmtNode>(ctx); | |
| 883 | |||
| 884 | // Extract number of continues | ||
| 885 |
2/2✓ Branch 4 → 5 taken 1134 times.
✓ Branch 4 → 10 taken 3986 times.
|
5120 | if (ctx->INT_LIT()) |
| 886 |
3/6✓ Branch 5 → 6 taken 1134 times.
✗ Branch 5 → 24 not taken.
✓ Branch 6 → 7 taken 1134 times.
✗ Branch 6 → 24 not taken.
✓ Branch 7 → 8 taken 1134 times.
✗ Branch 7 → 22 not taken.
|
1134 | continueStmtNode->continueTimes = std::stoi(ctx->INT_LIT()->toString()); |
| 887 | |||
| 888 | // Visit children | ||
| 889 |
2/4✓ Branch 10 → 11 taken 5120 times.
✗ Branch 10 → 25 not taken.
✓ Branch 12 → 13 taken 5120 times.
✗ Branch 12 → 26 not taken.
|
5120 | visitChildren(ctx); |
| 890 | |||
| 891 |
1/2✓ Branch 18 → 19 taken 5120 times.
✗ Branch 18 → 26 not taken.
|
10240 | return concludeNode(continueStmtNode); |
| 892 | } | ||
| 893 | |||
| 894 | 12 | std::any ASTBuilder::visitFallthroughStmt(SpiceParser::FallthroughStmtContext *ctx) { | |
| 895 | 12 | const auto fallthroughStmtNode = createNode<FallthroughStmtNode>(ctx); | |
| 896 | |||
| 897 | // Visit children | ||
| 898 |
2/4✓ Branch 3 → 4 taken 12 times.
✗ Branch 3 → 15 not taken.
✓ Branch 5 → 6 taken 12 times.
✗ Branch 5 → 16 not taken.
|
12 | visitChildren(ctx); |
| 899 | |||
| 900 |
1/2✓ Branch 11 → 12 taken 12 times.
✗ Branch 11 → 16 not taken.
|
24 | return concludeNode(fallthroughStmtNode); |
| 901 | } | ||
| 902 | |||
| 903 | 46353 | std::any ASTBuilder::visitAssertStmt(SpiceParser::AssertStmtContext *ctx) { | |
| 904 |
1/2✓ Branch 2 → 3 taken 46353 times.
✗ Branch 2 → 30 not taken.
|
46353 | const auto assertStmtNode = createNode<AssertStmtNode>(ctx); |
| 905 | |||
| 906 | // Enrich | ||
| 907 |
5/10✓ Branch 3 → 4 taken 46353 times.
✗ Branch 3 → 30 not taken.
✓ Branch 4 → 5 taken 46353 times.
✗ Branch 4 → 30 not taken.
✓ Branch 5 → 6 taken 46353 times.
✗ Branch 5 → 30 not taken.
✓ Branch 6 → 7 taken 46353 times.
✗ Branch 6 → 30 not taken.
✓ Branch 7 → 8 taken 46353 times.
✗ Branch 7 → 30 not taken.
|
46353 | const antlr4::misc::Interval interval(ctx->assignExpr()->start->getStartIndex(), ctx->assignExpr()->stop->getStopIndex()); |
| 908 |
1/2✓ Branch 8 → 9 taken 46353 times.
✗ Branch 8 → 25 not taken.
|
46353 | assertStmtNode->expressionString = inputStream->getText(interval); |
| 909 | |||
| 910 | // Visit children | ||
| 911 |
4/8✓ Branch 11 → 12 taken 46353 times.
✗ Branch 11 → 28 not taken.
✓ Branch 12 → 13 taken 46353 times.
✗ Branch 12 → 28 not taken.
✓ Branch 13 → 14 taken 46353 times.
✗ Branch 13 → 26 not taken.
✓ Branch 15 → 16 taken 46353 times.
✗ Branch 15 → 29 not taken.
|
46353 | assertStmtNode->assignExpr = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 912 | |||
| 913 |
1/2✓ Branch 21 → 22 taken 46353 times.
✗ Branch 21 → 29 not taken.
|
92706 | return concludeNode(assertStmtNode); |
| 914 | } | ||
| 915 | |||
| 916 | 1971145 | std::any ASTBuilder::visitAssignExpr(SpiceParser::AssignExprContext *ctx) { | |
| 917 |
2/2✓ Branch 3 → 4 taken 1817595 times.
✓ Branch 3 → 6 taken 153550 times.
|
1971145 | if (!ctx->assignOp()) |
| 918 | 1817595 | return visit(ctx->ternaryExpr()); | |
| 919 | |||
| 920 | 153550 | const auto assignExprNode = createNode<AssignExprNode>(ctx); | |
| 921 | |||
| 922 | // Visit children | ||
| 923 |
1/2✗ Branch 8 → 9 not taken.
✓ Branch 8 → 14 taken 153550 times.
|
153550 | if (ctx->ternaryExpr()) { |
| 924 | ✗ | assignExprNode->ternaryExpr = std::any_cast<ExprNode *>(visit(ctx->ternaryExpr())); | |
| 925 |
1/2✓ Branch 15 → 16 taken 153550 times.
✗ Branch 15 → 28 not taken.
|
153550 | } else if (ctx->prefixUnaryExpr()) { |
| 926 |
3/6✓ Branch 16 → 17 taken 153550 times.
✗ Branch 16 → 44 not taken.
✓ Branch 17 → 18 taken 153550 times.
✗ Branch 17 → 44 not taken.
✓ Branch 18 → 19 taken 153550 times.
✗ Branch 18 → 42 not taken.
|
153550 | assignExprNode->lhs = std::any_cast<ExprNode *>(visit(ctx->prefixUnaryExpr())); |
| 927 |
2/4✓ Branch 20 → 21 taken 153550 times.
✗ Branch 20 → 45 not taken.
✓ Branch 21 → 22 taken 153550 times.
✗ Branch 21 → 45 not taken.
|
153550 | visit(ctx->assignOp()); |
| 928 |
3/6✓ Branch 23 → 24 taken 153550 times.
✗ Branch 23 → 48 not taken.
✓ Branch 24 → 25 taken 153550 times.
✗ Branch 24 → 48 not taken.
✓ Branch 25 → 26 taken 153550 times.
✗ Branch 25 → 46 not taken.
|
153550 | assignExprNode->rhs = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 929 | } else { | ||
| 930 | − | assert_fail("Invalid assign expression"); // GCOV_EXCL_LINE | |
| 931 | } | ||
| 932 | |||
| 933 |
1/2✓ Branch 35 → 36 taken 153550 times.
✗ Branch 35 → 49 not taken.
|
307100 | return concludeExprNode(assignExprNode); |
| 934 | } | ||
| 935 | |||
| 936 | 1841036 | std::any ASTBuilder::visitTernaryExpr(SpiceParser::TernaryExprContext *ctx) { | |
| 937 |
3/4✓ Branch 2 → 3 taken 1841036 times.
✗ Branch 2 → 45 not taken.
✓ Branch 5 → 6 taken 1832501 times.
✓ Branch 5 → 8 taken 8535 times.
|
1841036 | if (ctx->logicalOrExpr().size() == 1) |
| 938 | 1832501 | return visit(ctx->logicalOrExpr(0)); | |
| 939 | |||
| 940 | 8535 | const auto ternaryExprNode = createNode<TernaryExprNode>(ctx); | |
| 941 | |||
| 942 |
3/6✓ Branch 9 → 10 taken 8535 times.
✗ Branch 9 → 48 not taken.
✓ Branch 10 → 11 taken 8535 times.
✗ Branch 10 → 48 not taken.
✓ Branch 11 → 12 taken 8535 times.
✗ Branch 11 → 46 not taken.
|
8535 | ternaryExprNode->condition = std::any_cast<ExprNode *>(visit(ctx->logicalOrExpr(0))); |
| 943 |
3/4✓ Branch 13 → 14 taken 8535 times.
✗ Branch 13 → 49 not taken.
✓ Branch 16 → 17 taken 8533 times.
✓ Branch 16 → 26 taken 2 times.
|
8535 | if (ctx->logicalOrExpr().size() == 3) { |
| 944 |
3/6✓ Branch 17 → 18 taken 8533 times.
✗ Branch 17 → 52 not taken.
✓ Branch 18 → 19 taken 8533 times.
✗ Branch 18 → 52 not taken.
✓ Branch 19 → 20 taken 8533 times.
✗ Branch 19 → 50 not taken.
|
8533 | ternaryExprNode->trueExpr = std::any_cast<ExprNode *>(visit(ctx->logicalOrExpr(1))); |
| 945 |
3/6✓ Branch 21 → 22 taken 8533 times.
✗ Branch 21 → 55 not taken.
✓ Branch 22 → 23 taken 8533 times.
✗ Branch 22 → 55 not taken.
✓ Branch 23 → 24 taken 8533 times.
✗ Branch 23 → 53 not taken.
|
8533 | ternaryExprNode->falseExpr = std::any_cast<ExprNode *>(visit(ctx->logicalOrExpr(2))); |
| 946 |
2/4✓ Branch 26 → 27 taken 2 times.
✗ Branch 26 → 56 not taken.
✓ Branch 29 → 30 taken 2 times.
✗ Branch 29 → 35 not taken.
|
2 | } else if (ctx->logicalOrExpr().size() == 2) { |
| 947 | 2 | ternaryExprNode->isShortened = true; | |
| 948 |
3/6✓ Branch 30 → 31 taken 2 times.
✗ Branch 30 → 59 not taken.
✓ Branch 31 → 32 taken 2 times.
✗ Branch 31 → 59 not taken.
✓ Branch 32 → 33 taken 2 times.
✗ Branch 32 → 57 not taken.
|
2 | ternaryExprNode->falseExpr = std::any_cast<ExprNode *>(visit(ctx->logicalOrExpr(1))); |
| 949 | } | ||
| 950 | |||
| 951 |
1/2✓ Branch 41 → 42 taken 8535 times.
✗ Branch 41 → 60 not taken.
|
17070 | return concludeExprNode(ternaryExprNode); |
| 952 | } | ||
| 953 | |||
| 954 | 1858104 | std::any ASTBuilder::visitLogicalOrExpr(SpiceParser::LogicalOrExprContext *ctx) { | |
| 955 |
3/4✓ Branch 2 → 3 taken 1858104 times.
✗ Branch 2 → 22 not taken.
✓ Branch 5 → 6 taken 1843377 times.
✓ Branch 5 → 8 taken 14727 times.
|
1858104 | if (ctx->logicalAndExpr().size() == 1) |
| 956 | 1843377 | return visit(ctx->logicalAndExpr(0)); | |
| 957 | |||
| 958 | 14727 | const auto logicalOrExprNode = createNode<LogicalOrExprNode>(ctx); | |
| 959 | |||
| 960 | // Visit children | ||
| 961 |
3/6✓ Branch 9 → 10 taken 14727 times.
✗ Branch 9 → 25 not taken.
✓ Branch 10 → 11 taken 14727 times.
✗ Branch 10 → 23 not taken.
✓ Branch 12 → 13 taken 14727 times.
✗ Branch 12 → 26 not taken.
|
14727 | fetchChildrenIntoVector(logicalOrExprNode->operands, ctx->logicalAndExpr()); |
| 962 | |||
| 963 |
1/2✓ Branch 18 → 19 taken 14727 times.
✗ Branch 18 → 26 not taken.
|
29454 | return concludeExprNode(logicalOrExprNode); |
| 964 | } | ||
| 965 | |||
| 966 | 1878945 | std::any ASTBuilder::visitLogicalAndExpr(SpiceParser::LogicalAndExprContext *ctx) { | |
| 967 |
3/4✓ Branch 2 → 3 taken 1878945 times.
✗ Branch 2 → 22 not taken.
✓ Branch 5 → 6 taken 1859614 times.
✓ Branch 5 → 8 taken 19331 times.
|
1878945 | if (ctx->bitwiseOrExpr().size() == 1) |
| 968 | 1859614 | return visit(ctx->bitwiseOrExpr(0)); | |
| 969 | |||
| 970 | 19331 | const auto logicalAndExprNode = createNode<LogicalAndExprNode>(ctx); | |
| 971 | |||
| 972 | // Visit children | ||
| 973 |
3/6✓ Branch 9 → 10 taken 19331 times.
✗ Branch 9 → 25 not taken.
✓ Branch 10 → 11 taken 19331 times.
✗ Branch 10 → 23 not taken.
✓ Branch 12 → 13 taken 19331 times.
✗ Branch 12 → 26 not taken.
|
19331 | fetchChildrenIntoVector(logicalAndExprNode->operands, ctx->bitwiseOrExpr()); |
| 974 | |||
| 975 |
1/2✓ Branch 18 → 19 taken 19331 times.
✗ Branch 18 → 26 not taken.
|
38662 | return concludeExprNode(logicalAndExprNode); |
| 976 | } | ||
| 977 | |||
| 978 | 1902694 | std::any ASTBuilder::visitBitwiseOrExpr(SpiceParser::BitwiseOrExprContext *ctx) { | |
| 979 |
3/4✓ Branch 2 → 3 taken 1902694 times.
✗ Branch 2 → 22 not taken.
✓ Branch 5 → 6 taken 1901302 times.
✓ Branch 5 → 8 taken 1392 times.
|
1902694 | if (ctx->bitwiseXorExpr().size() == 1) |
| 980 | 1901302 | return visit(ctx->bitwiseXorExpr(0)); | |
| 981 | |||
| 982 | 1392 | const auto bitwiseOrExprNode = createNode<BitwiseOrExprNode>(ctx); | |
| 983 | |||
| 984 | // Visit children | ||
| 985 |
3/6✓ Branch 9 → 10 taken 1392 times.
✗ Branch 9 → 25 not taken.
✓ Branch 10 → 11 taken 1392 times.
✗ Branch 10 → 23 not taken.
✓ Branch 12 → 13 taken 1392 times.
✗ Branch 12 → 26 not taken.
|
1392 | fetchChildrenIntoVector(bitwiseOrExprNode->operands, ctx->bitwiseXorExpr()); |
| 986 | |||
| 987 |
1/2✓ Branch 18 → 19 taken 1392 times.
✗ Branch 18 → 26 not taken.
|
2784 | return concludeExprNode(bitwiseOrExprNode); |
| 988 | } | ||
| 989 | |||
| 990 | 1904184 | std::any ASTBuilder::visitBitwiseXorExpr(SpiceParser::BitwiseXorExprContext *ctx) { | |
| 991 |
3/4✓ Branch 2 → 3 taken 1904184 times.
✗ Branch 2 → 22 not taken.
✓ Branch 5 → 6 taken 1904015 times.
✓ Branch 5 → 8 taken 169 times.
|
1904184 | if (ctx->bitwiseAndExpr().size() == 1) |
| 992 | 1904015 | return visit(ctx->bitwiseAndExpr(0)); | |
| 993 | |||
| 994 | 169 | const auto bitwiseXorExprNode = createNode<BitwiseXorExprNode>(ctx); | |
| 995 | |||
| 996 | // Visit children | ||
| 997 |
3/6✓ Branch 9 → 10 taken 169 times.
✗ Branch 9 → 25 not taken.
✓ Branch 10 → 11 taken 169 times.
✗ Branch 10 → 23 not taken.
✓ Branch 12 → 13 taken 169 times.
✗ Branch 12 → 26 not taken.
|
169 | fetchChildrenIntoVector(bitwiseXorExprNode->operands, ctx->bitwiseAndExpr()); |
| 998 | |||
| 999 |
1/2✓ Branch 18 → 19 taken 169 times.
✗ Branch 18 → 26 not taken.
|
338 | return concludeExprNode(bitwiseXorExprNode); |
| 1000 | } | ||
| 1001 | |||
| 1002 | 1904355 | std::any ASTBuilder::visitBitwiseAndExpr(SpiceParser::BitwiseAndExprContext *ctx) { | |
| 1003 |
3/4✓ Branch 2 → 3 taken 1904355 times.
✗ Branch 2 → 22 not taken.
✓ Branch 5 → 6 taken 1903223 times.
✓ Branch 5 → 8 taken 1132 times.
|
1904355 | if (ctx->equalityExpr().size() == 1) |
| 1004 | 1903223 | return visit(ctx->equalityExpr(0)); | |
| 1005 | |||
| 1006 | 1132 | const auto bitwiseAndExprNode = createNode<BitwiseAndExprNode>(ctx); | |
| 1007 | |||
| 1008 | // Visit children | ||
| 1009 |
3/6✓ Branch 9 → 10 taken 1132 times.
✗ Branch 9 → 25 not taken.
✓ Branch 10 → 11 taken 1132 times.
✗ Branch 10 → 23 not taken.
✓ Branch 12 → 13 taken 1132 times.
✗ Branch 12 → 26 not taken.
|
1132 | fetchChildrenIntoVector(bitwiseAndExprNode->operands, ctx->equalityExpr()); |
| 1010 | |||
| 1011 |
1/2✓ Branch 18 → 19 taken 1132 times.
✗ Branch 18 → 26 not taken.
|
2264 | return concludeExprNode(bitwiseAndExprNode); |
| 1012 | } | ||
| 1013 | |||
| 1014 | 1905489 | std::any ASTBuilder::visitEqualityExpr(SpiceParser::EqualityExprContext *ctx) { | |
| 1015 |
3/4✓ Branch 2 → 3 taken 1905489 times.
✗ Branch 2 → 28 not taken.
✓ Branch 5 → 6 taken 1781066 times.
✓ Branch 5 → 8 taken 124423 times.
|
1905489 | if (ctx->relationalExpr().size() == 1) |
| 1016 | 1781066 | return visit(ctx->relationalExpr(0)); | |
| 1017 | |||
| 1018 | 124423 | const auto equalityExprNode = createNode<EqualityExprNode>(ctx); | |
| 1019 | |||
| 1020 | // Visit children | ||
| 1021 |
2/4✓ Branch 9 → 10 taken 124423 times.
✗ Branch 9 → 31 not taken.
✓ Branch 10 → 11 taken 124423 times.
✗ Branch 10 → 29 not taken.
|
124423 | fetchChildrenIntoVector(equalityExprNode->operands, ctx->relationalExpr()); |
| 1022 | |||
| 1023 | // Extract operator | ||
| 1024 |
2/2✓ Branch 13 → 14 taken 94688 times.
✓ Branch 13 → 15 taken 29735 times.
|
124423 | if (ctx->EQUAL()) |
| 1025 | 94688 | equalityExprNode->op = EqualityExprNode::EqualityOp::OP_EQUAL; | |
| 1026 |
1/2✓ Branch 16 → 17 taken 29735 times.
✗ Branch 16 → 18 not taken.
|
29735 | else if (ctx->NOT_EQUAL()) |
| 1027 | 29735 | equalityExprNode->op = EqualityExprNode::EqualityOp::OP_NOT_EQUAL; | |
| 1028 | |||
| 1029 |
1/2✓ Branch 24 → 25 taken 124423 times.
✗ Branch 24 → 32 not taken.
|
248846 | return concludeExprNode(equalityExprNode); |
| 1030 | } | ||
| 1031 | |||
| 1032 | 2029912 | std::any ASTBuilder::visitRelationalExpr(SpiceParser::RelationalExprContext *ctx) { | |
| 1033 |
3/4✓ Branch 2 → 3 taken 2029912 times.
✗ Branch 2 → 34 not taken.
✓ Branch 5 → 6 taken 1989014 times.
✓ Branch 5 → 8 taken 40898 times.
|
2029912 | if (ctx->shiftExpr().size() == 1) |
| 1034 | 1989014 | return visit(ctx->shiftExpr(0)); | |
| 1035 | |||
| 1036 | 40898 | const auto relationalExprNode = createNode<RelationalExprNode>(ctx); | |
| 1037 | |||
| 1038 | // Visit children | ||
| 1039 |
2/4✓ Branch 9 → 10 taken 40898 times.
✗ Branch 9 → 37 not taken.
✓ Branch 10 → 11 taken 40898 times.
✗ Branch 10 → 35 not taken.
|
40898 | fetchChildrenIntoVector(relationalExprNode->operands, ctx->shiftExpr()); |
| 1040 | |||
| 1041 | // Extract operator | ||
| 1042 |
2/2✓ Branch 13 → 14 taken 19222 times.
✓ Branch 13 → 15 taken 21676 times.
|
40898 | if (ctx->LESS()) |
| 1043 | 19222 | relationalExprNode->op = RelationalExprNode::RelationalOp::OP_LESS; | |
| 1044 |
2/2✓ Branch 16 → 17 taken 10381 times.
✓ Branch 16 → 18 taken 11295 times.
|
21676 | else if (ctx->GREATER()) |
| 1045 | 10381 | relationalExprNode->op = RelationalExprNode::RelationalOp::OP_GREATER; | |
| 1046 |
2/2✓ Branch 19 → 20 taken 3710 times.
✓ Branch 19 → 21 taken 7585 times.
|
11295 | else if (ctx->LESS_EQUAL()) |
| 1047 | 3710 | relationalExprNode->op = RelationalExprNode::RelationalOp::OP_LESS_EQUAL; | |
| 1048 |
1/2✓ Branch 22 → 23 taken 7585 times.
✗ Branch 22 → 24 not taken.
|
7585 | else if (ctx->GREATER_EQUAL()) |
| 1049 | 7585 | relationalExprNode->op = RelationalExprNode::RelationalOp::OP_GREATER_EQUAL; | |
| 1050 | |||
| 1051 |
1/2✓ Branch 30 → 31 taken 40898 times.
✗ Branch 30 → 38 not taken.
|
81796 | return concludeExprNode(relationalExprNode); |
| 1052 | } | ||
| 1053 | |||
| 1054 | 2070810 | std::any ASTBuilder::visitShiftExpr(SpiceParser::ShiftExprContext *ctx) { | |
| 1055 |
3/4✓ Branch 2 → 3 taken 2070810 times.
✗ Branch 2 → 60 not taken.
✓ Branch 5 → 6 taken 2063560 times.
✓ Branch 5 → 8 taken 7250 times.
|
2070810 | if (ctx->additiveExpr().size() == 1) |
| 1056 | 2063560 | return visit(ctx->additiveExpr(0)); | |
| 1057 | |||
| 1058 | 7250 | const auto shiftExprNode = createNode<ShiftExprNode>(ctx); | |
| 1059 | |||
| 1060 | // Visit children | ||
| 1061 |
2/4✓ Branch 9 → 10 taken 7250 times.
✗ Branch 9 → 63 not taken.
✓ Branch 10 → 11 taken 7250 times.
✗ Branch 10 → 61 not taken.
|
7250 | fetchChildrenIntoVector(shiftExprNode->operands, ctx->additiveExpr()); |
| 1062 | |||
| 1063 | 7250 | bool seenFirstLess = false; | |
| 1064 | 7250 | bool seenFirstGreater = false; | |
| 1065 |
2/2✓ Branch 45 → 14 taken 43406 times.
✓ Branch 45 → 46 taken 7250 times.
|
57906 | for (ParserRuleContext::ParseTree *subTree : ctx->children) { |
| 1066 |
1/2✓ Branch 16 → 17 taken 43406 times.
✗ Branch 16 → 18 not taken.
|
43406 | const auto terminal = dynamic_cast<TerminalNode *>(subTree); |
| 1067 |
2/2✓ Branch 19 → 20 taken 19302 times.
✓ Branch 19 → 21 taken 24104 times.
|
43406 | if (!terminal) |
| 1068 | 19302 | continue; | |
| 1069 | |||
| 1070 |
4/6✓ Branch 21 → 22 taken 24104 times.
✗ Branch 21 → 68 not taken.
✓ Branch 22 → 23 taken 24104 times.
✗ Branch 22 → 68 not taken.
✓ Branch 23 → 24 taken 22154 times.
✓ Branch 23 → 28 taken 1950 times.
|
24104 | if (terminal->getSymbol()->getType() == SpiceParser::LESS) { |
| 1071 |
2/2✓ Branch 24 → 25 taken 11077 times.
✓ Branch 24 → 27 taken 11077 times.
|
22154 | if (seenFirstLess) |
| 1072 |
1/2✓ Branch 25 → 26 taken 11077 times.
✗ Branch 25 → 64 not taken.
|
11077 | shiftExprNode->opQueue.emplace(ShiftExprNode::ShiftOp::OP_SHIFT_LEFT, TY_INVALID); |
| 1073 | 22154 | seenFirstLess = !seenFirstLess; | |
| 1074 | 22154 | continue; | |
| 1075 | } | ||
| 1076 | |||
| 1077 |
3/6✓ Branch 28 → 29 taken 1950 times.
✗ Branch 28 → 68 not taken.
✓ Branch 29 → 30 taken 1950 times.
✗ Branch 29 → 68 not taken.
✓ Branch 30 → 31 taken 1950 times.
✗ Branch 30 → 35 not taken.
|
1950 | if (terminal->getSymbol()->getType() == SpiceParser::GREATER) { |
| 1078 |
2/2✓ Branch 31 → 32 taken 975 times.
✓ Branch 31 → 34 taken 975 times.
|
1950 | if (seenFirstGreater) |
| 1079 |
1/2✓ Branch 32 → 33 taken 975 times.
✗ Branch 32 → 66 not taken.
|
975 | shiftExprNode->opQueue.emplace(ShiftExprNode::ShiftOp::OP_SHIFT_RIGHT, TY_INVALID); |
| 1080 | 1950 | seenFirstGreater = !seenFirstGreater; | |
| 1081 | 1950 | continue; | |
| 1082 | } | ||
| 1083 | |||
| 1084 | − | assert_fail("Invalid terminal symbol for additive expression"); // GCOV_EXCL_LINE | |
| 1085 | } | ||
| 1086 |
2/4✓ Branch 46 → 47 taken 7250 times.
✗ Branch 46 → 49 not taken.
✓ Branch 47 → 48 taken 7250 times.
✗ Branch 47 → 49 not taken.
|
7250 | assert(!seenFirstLess && !seenFirstGreater); |
| 1087 | |||
| 1088 |
1/2✓ Branch 56 → 57 taken 7250 times.
✗ Branch 56 → 69 not taken.
|
14500 | return concludeExprNode(shiftExprNode); |
| 1089 | } | ||
| 1090 | |||
| 1091 | 2082862 | std::any ASTBuilder::visitAdditiveExpr(SpiceParser::AdditiveExprContext *ctx) { | |
| 1092 |
3/4✓ Branch 2 → 3 taken 2082862 times.
✗ Branch 2 → 52 not taken.
✓ Branch 5 → 6 taken 2041893 times.
✓ Branch 5 → 8 taken 40969 times.
|
2082862 | if (ctx->multiplicativeExpr().size() == 1) |
| 1093 | 2041893 | return visit(ctx->multiplicativeExpr(0)); | |
| 1094 | |||
| 1095 | 40969 | const auto additiveExprNode = createNode<AdditiveExprNode>(ctx); | |
| 1096 | |||
| 1097 | // Visit children | ||
| 1098 |
2/4✓ Branch 9 → 10 taken 40969 times.
✗ Branch 9 → 55 not taken.
✓ Branch 10 → 11 taken 40969 times.
✗ Branch 10 → 53 not taken.
|
40969 | fetchChildrenIntoVector(additiveExprNode->operands, ctx->multiplicativeExpr()); |
| 1099 | |||
| 1100 |
2/2✓ Branch 41 → 14 taken 145183 times.
✓ Branch 41 → 42 taken 40969 times.
|
227121 | for (ParserRuleContext::ParseTree *subTree : ctx->children) { |
| 1101 |
1/2✓ Branch 16 → 17 taken 145183 times.
✗ Branch 16 → 18 not taken.
|
145183 | const auto terminal = dynamic_cast<TerminalNode *>(subTree); |
| 1102 |
2/2✓ Branch 19 → 20 taken 93076 times.
✓ Branch 19 → 21 taken 52107 times.
|
145183 | if (!terminal) |
| 1103 | 93076 | continue; | |
| 1104 | |||
| 1105 |
4/6✓ Branch 21 → 22 taken 52107 times.
✗ Branch 21 → 60 not taken.
✓ Branch 22 → 23 taken 52107 times.
✗ Branch 22 → 60 not taken.
✓ Branch 23 → 24 taken 39735 times.
✓ Branch 23 → 26 taken 12372 times.
|
52107 | if (terminal->getSymbol()->getType() == SpiceParser::PLUS) |
| 1106 |
1/2✓ Branch 24 → 25 taken 39735 times.
✗ Branch 24 → 56 not taken.
|
39735 | additiveExprNode->opQueue.emplace(AdditiveExprNode::AdditiveOp::OP_PLUS, TY_INVALID); |
| 1107 |
3/6✓ Branch 26 → 27 taken 12372 times.
✗ Branch 26 → 60 not taken.
✓ Branch 27 → 28 taken 12372 times.
✗ Branch 27 → 60 not taken.
✓ Branch 28 → 29 taken 12372 times.
✗ Branch 28 → 31 not taken.
|
12372 | else if (terminal->getSymbol()->getType() == SpiceParser::MINUS) |
| 1108 |
1/2✓ Branch 29 → 30 taken 12372 times.
✗ Branch 29 → 58 not taken.
|
12372 | additiveExprNode->opQueue.emplace(AdditiveExprNode::AdditiveOp::OP_MINUS, TY_INVALID); |
| 1109 | else | ||
| 1110 | − | assert_fail("Invalid terminal symbol for additive expression"); // GCOV_EXCL_LINE | |
| 1111 | } | ||
| 1112 | |||
| 1113 |
1/2✓ Branch 48 → 49 taken 40969 times.
✗ Branch 48 → 61 not taken.
|
81938 | return concludeExprNode(additiveExprNode); |
| 1114 | } | ||
| 1115 | |||
| 1116 | 2134969 | std::any ASTBuilder::visitMultiplicativeExpr(SpiceParser::MultiplicativeExprContext *ctx) { | |
| 1117 |
3/4✓ Branch 2 → 3 taken 2134969 times.
✗ Branch 2 → 57 not taken.
✓ Branch 5 → 6 taken 2123804 times.
✓ Branch 5 → 8 taken 11165 times.
|
2134969 | if (ctx->castExpr().size() == 1) |
| 1118 | 2123804 | return visit(ctx->castExpr(0)); | |
| 1119 | |||
| 1120 | 11165 | const auto multiplicativeExprNode = createNode<MultiplicativeExprNode>(ctx); | |
| 1121 | |||
| 1122 | // Visit children | ||
| 1123 |
2/4✓ Branch 9 → 10 taken 11165 times.
✗ Branch 9 → 60 not taken.
✓ Branch 10 → 11 taken 11165 times.
✗ Branch 10 → 58 not taken.
|
11165 | fetchChildrenIntoVector(multiplicativeExprNode->operands, ctx->castExpr()); |
| 1124 | |||
| 1125 |
2/2✓ Branch 46 → 14 taken 35193 times.
✓ Branch 46 → 47 taken 11165 times.
|
57523 | for (ParserRuleContext::ParseTree *subTree : ctx->children) { |
| 1126 |
1/2✓ Branch 16 → 17 taken 35193 times.
✗ Branch 16 → 18 not taken.
|
35193 | const auto terminal = dynamic_cast<TerminalNode *>(subTree); |
| 1127 |
2/2✓ Branch 19 → 20 taken 23179 times.
✓ Branch 19 → 21 taken 12014 times.
|
35193 | if (!terminal) |
| 1128 | 23179 | continue; | |
| 1129 | |||
| 1130 |
4/6✓ Branch 21 → 22 taken 12014 times.
✗ Branch 21 → 67 not taken.
✓ Branch 22 → 23 taken 12014 times.
✗ Branch 22 → 67 not taken.
✓ Branch 23 → 24 taken 6899 times.
✓ Branch 23 → 26 taken 5115 times.
|
12014 | if (terminal->getSymbol()->getType() == SpiceParser::MUL) |
| 1131 |
1/2✓ Branch 24 → 25 taken 6899 times.
✗ Branch 24 → 61 not taken.
|
6899 | multiplicativeExprNode->opQueue.emplace(MultiplicativeExprNode::MultiplicativeOp::OP_MUL, TY_INVALID); |
| 1132 |
4/6✓ Branch 26 → 27 taken 5115 times.
✗ Branch 26 → 67 not taken.
✓ Branch 27 → 28 taken 5115 times.
✗ Branch 27 → 67 not taken.
✓ Branch 28 → 29 taken 4091 times.
✓ Branch 28 → 31 taken 1024 times.
|
5115 | else if (terminal->getSymbol()->getType() == SpiceParser::DIV) |
| 1133 |
1/2✓ Branch 29 → 30 taken 4091 times.
✗ Branch 29 → 63 not taken.
|
4091 | multiplicativeExprNode->opQueue.emplace(MultiplicativeExprNode::MultiplicativeOp::OP_DIV, TY_INVALID); |
| 1134 |
3/6✓ Branch 31 → 32 taken 1024 times.
✗ Branch 31 → 67 not taken.
✓ Branch 32 → 33 taken 1024 times.
✗ Branch 32 → 67 not taken.
✓ Branch 33 → 34 taken 1024 times.
✗ Branch 33 → 36 not taken.
|
1024 | else if (terminal->getSymbol()->getType() == SpiceParser::REM) |
| 1135 |
1/2✓ Branch 34 → 35 taken 1024 times.
✗ Branch 34 → 65 not taken.
|
1024 | multiplicativeExprNode->opQueue.emplace(MultiplicativeExprNode::MultiplicativeOp::OP_REM, TY_INVALID); |
| 1136 | else | ||
| 1137 | − | assert_fail("Invalid terminal symbol for multiplicative expression"); // GCOV_EXCL_LINE | |
| 1138 | } | ||
| 1139 | |||
| 1140 |
1/2✓ Branch 53 → 54 taken 11165 times.
✗ Branch 53 → 68 not taken.
|
22330 | return concludeExprNode(multiplicativeExprNode); |
| 1141 | } | ||
| 1142 | |||
| 1143 | 2146983 | std::any ASTBuilder::visitCastExpr(SpiceParser::CastExprContext *ctx) { | |
| 1144 |
2/2✓ Branch 3 → 4 taken 2091214 times.
✓ Branch 3 → 6 taken 55769 times.
|
2146983 | if (!ctx->CAST()) |
| 1145 | 2091214 | return visit(ctx->prefixUnaryExpr()); | |
| 1146 | |||
| 1147 | 55769 | const auto castExprNode = createNode<CastExprNode>(ctx); | |
| 1148 | |||
| 1149 | // Visit children | ||
| 1150 |
1/2✓ Branch 8 → 9 taken 55769 times.
✗ Branch 8 → 18 not taken.
|
55769 | if (ctx->dataType()) { |
| 1151 |
3/6✓ Branch 9 → 10 taken 55769 times.
✗ Branch 9 → 35 not taken.
✓ Branch 10 → 11 taken 55769 times.
✗ Branch 10 → 35 not taken.
✓ Branch 11 → 12 taken 55769 times.
✗ Branch 11 → 33 not taken.
|
55769 | castExprNode->dataType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 1152 |
3/6✓ Branch 13 → 14 taken 55769 times.
✗ Branch 13 → 38 not taken.
✓ Branch 14 → 15 taken 55769 times.
✗ Branch 14 → 38 not taken.
✓ Branch 15 → 16 taken 55769 times.
✗ Branch 15 → 36 not taken.
|
55769 | castExprNode->assignExpr = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 1153 | 55769 | castExprNode->isCast = true; | |
| 1154 | } else { | ||
| 1155 | ✗ | castExprNode->prefixUnaryExpr = std::any_cast<ExprNode *>(visit(ctx->prefixUnaryExpr())); | |
| 1156 | } | ||
| 1157 | |||
| 1158 |
1/2✓ Branch 29 → 30 taken 55769 times.
✗ Branch 29 → 42 not taken.
|
111538 | return concludeExprNode(castExprNode); |
| 1159 | } | ||
| 1160 | |||
| 1161 | 2301072 | std::any ASTBuilder::visitPrefixUnaryExpr(SpiceParser::PrefixUnaryExprContext *ctx) { | |
| 1162 |
2/2✓ Branch 3 → 4 taken 2244764 times.
✓ Branch 3 → 6 taken 56308 times.
|
2301072 | if (!ctx->prefixUnaryExpr()) |
| 1163 | 2244764 | return visit(ctx->postfixUnaryExpr()); | |
| 1164 | |||
| 1165 | 56308 | const auto prefixUnaryExprNode = createNode<PrefixUnaryExprNode>(ctx); | |
| 1166 | |||
| 1167 | // Visit children | ||
| 1168 |
1/2✗ Branch 8 → 9 not taken.
✓ Branch 8 → 14 taken 56308 times.
|
56308 | if (ctx->postfixUnaryExpr()) { |
| 1169 | ✗ | prefixUnaryExprNode->postfixUnaryExpr = std::any_cast<ExprNode *>(visit(ctx->postfixUnaryExpr())); | |
| 1170 |
1/2✓ Branch 15 → 16 taken 56308 times.
✗ Branch 15 → 42 not taken.
|
56308 | } else if (ctx->prefixUnaryExpr()) { |
| 1171 | // Extract operator | ||
| 1172 |
2/2✓ Branch 17 → 18 taken 1387 times.
✓ Branch 17 → 19 taken 54921 times.
|
56308 | if (ctx->MINUS()) |
| 1173 | 1387 | prefixUnaryExprNode->op = PrefixUnaryExprNode::PrefixUnaryOp::OP_MINUS; | |
| 1174 |
2/2✓ Branch 20 → 21 taken 24 times.
✓ Branch 20 → 22 taken 54897 times.
|
54921 | else if (ctx->PLUS_PLUS()) |
| 1175 | 24 | prefixUnaryExprNode->op = PrefixUnaryExprNode::PrefixUnaryOp::OP_PLUS_PLUS; | |
| 1176 |
2/2✓ Branch 23 → 24 taken 228 times.
✓ Branch 23 → 25 taken 54669 times.
|
54897 | else if (ctx->MINUS_MINUS()) |
| 1177 | 228 | prefixUnaryExprNode->op = PrefixUnaryExprNode::PrefixUnaryOp::OP_MINUS_MINUS; | |
| 1178 |
2/2✓ Branch 26 → 27 taken 37359 times.
✓ Branch 26 → 28 taken 17310 times.
|
54669 | else if (ctx->NOT()) |
| 1179 | 37359 | prefixUnaryExprNode->op = PrefixUnaryExprNode::PrefixUnaryOp::OP_NOT; | |
| 1180 |
2/2✓ Branch 29 → 30 taken 102 times.
✓ Branch 29 → 31 taken 17208 times.
|
17310 | else if (ctx->BITWISE_NOT()) |
| 1181 | 102 | prefixUnaryExprNode->op = PrefixUnaryExprNode::PrefixUnaryOp::OP_BITWISE_NOT; | |
| 1182 |
2/2✓ Branch 32 → 33 taken 3720 times.
✓ Branch 32 → 34 taken 13488 times.
|
17208 | else if (ctx->MUL()) |
| 1183 | 3720 | prefixUnaryExprNode->op = PrefixUnaryExprNode::PrefixUnaryOp::OP_DEREFERENCE; | |
| 1184 |
1/2✓ Branch 35 → 36 taken 13488 times.
✗ Branch 35 → 37 not taken.
|
13488 | else if (ctx->BITWISE_AND()) |
| 1185 | 13488 | prefixUnaryExprNode->op = PrefixUnaryExprNode::PrefixUnaryOp::OP_ADDRESS_OF; | |
| 1186 | |||
| 1187 |
3/6✓ Branch 37 → 38 taken 56308 times.
✗ Branch 37 → 58 not taken.
✓ Branch 38 → 39 taken 56308 times.
✗ Branch 38 → 58 not taken.
✓ Branch 39 → 40 taken 56308 times.
✗ Branch 39 → 56 not taken.
|
56308 | prefixUnaryExprNode->prefixUnaryExpr = std::any_cast<ExprNode *>(visit(ctx->prefixUnaryExpr())); |
| 1188 | } else { | ||
| 1189 | − | assert_fail("Unknown prefix unary expression type"); // GCOV_EXCL_LINE | |
| 1190 | } | ||
| 1191 | |||
| 1192 |
1/2✓ Branch 49 → 50 taken 56308 times.
✗ Branch 49 → 59 not taken.
|
112616 | return concludeExprNode(prefixUnaryExprNode); |
| 1193 | } | ||
| 1194 | |||
| 1195 | 2697327 | std::any ASTBuilder::visitPostfixUnaryExpr(SpiceParser::PostfixUnaryExprContext *ctx) { | |
| 1196 |
2/2✓ Branch 3 → 4 taken 2244764 times.
✓ Branch 3 → 6 taken 452563 times.
|
2697327 | if (!ctx->postfixUnaryExpr()) |
| 1197 | 2244764 | return visit(ctx->atomicExpr()); | |
| 1198 | |||
| 1199 | 452563 | const auto postfixUnaryExprNode = createNode<PostfixUnaryExprNode>(ctx); | |
| 1200 | |||
| 1201 |
1/2✗ Branch 8 → 9 not taken.
✓ Branch 8 → 14 taken 452563 times.
|
452563 | if (ctx->atomicExpr()) { |
| 1202 | ✗ | postfixUnaryExprNode->atomicExpr = std::any_cast<ExprNode *>(visit(ctx->atomicExpr())); | |
| 1203 |
1/2✓ Branch 15 → 16 taken 452563 times.
✗ Branch 15 → 43 not taken.
|
452563 | } else if (ctx->postfixUnaryExpr()) { |
| 1204 |
3/6✓ Branch 16 → 17 taken 452563 times.
✗ Branch 16 → 59 not taken.
✓ Branch 17 → 18 taken 452563 times.
✗ Branch 17 → 59 not taken.
✓ Branch 18 → 19 taken 452563 times.
✗ Branch 18 → 57 not taken.
|
452563 | postfixUnaryExprNode->postfixUnaryExpr = std::any_cast<ExprNode *>(visit(ctx->postfixUnaryExpr())); |
| 1205 | |||
| 1206 | // Extract operator | ||
| 1207 |
2/2✓ Branch 21 → 22 taken 23212 times.
✓ Branch 21 → 27 taken 429351 times.
|
452563 | if (ctx->assignExpr()) { |
| 1208 | 23212 | postfixUnaryExprNode->op = PostfixUnaryExprNode::PostfixUnaryOp::OP_SUBSCRIPT; | |
| 1209 |
3/6✓ Branch 22 → 23 taken 23212 times.
✗ Branch 22 → 62 not taken.
✓ Branch 23 → 24 taken 23212 times.
✗ Branch 23 → 62 not taken.
✓ Branch 24 → 25 taken 23212 times.
✗ Branch 24 → 60 not taken.
|
23212 | postfixUnaryExprNode->subscriptIndexExpr = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 1210 |
2/2✓ Branch 28 → 29 taken 407684 times.
✓ Branch 28 → 34 taken 21667 times.
|
429351 | } else if (ctx->IDENTIFIER()) { |
| 1211 | 407684 | postfixUnaryExprNode->op = PostfixUnaryExprNode::PostfixUnaryOp::OP_MEMBER_ACCESS; | |
| 1212 |
2/4✓ Branch 29 → 30 taken 407684 times.
✗ Branch 29 → 63 not taken.
✓ Branch 30 → 31 taken 407684 times.
✗ Branch 30 → 63 not taken.
|
407684 | postfixUnaryExprNode->identifier = getIdentifier(ctx->IDENTIFIER(), false); |
| 1213 |
2/2✓ Branch 35 → 36 taken 18830 times.
✓ Branch 35 → 37 taken 2837 times.
|
21667 | } else if (ctx->PLUS_PLUS()) { |
| 1214 | 18830 | postfixUnaryExprNode->op = PostfixUnaryExprNode::PostfixUnaryOp::OP_PLUS_PLUS; | |
| 1215 |
2/2✓ Branch 38 → 39 taken 2541 times.
✓ Branch 38 → 40 taken 296 times.
|
2837 | } else if (ctx->MINUS_MINUS()) { |
| 1216 | 2541 | postfixUnaryExprNode->op = PostfixUnaryExprNode::PostfixUnaryOp::OP_MINUS_MINUS; | |
| 1217 |
1/2✓ Branch 41 → 42 taken 296 times.
✗ Branch 41 → 44 not taken.
|
296 | } else if (ctx->NOT()) { |
| 1218 | 296 | postfixUnaryExprNode->op = PostfixUnaryExprNode::PostfixUnaryOp::OP_ERR_PROPAGATION; | |
| 1219 | } | ||
| 1220 | } else { | ||
| 1221 | − | assert_fail("Unknown postfix unary expression type"); // GCOV_EXCL_LINE | |
| 1222 | } | ||
| 1223 | |||
| 1224 |
1/2✓ Branch 50 → 51 taken 452563 times.
✗ Branch 50 → 64 not taken.
|
905126 | return concludeExprNode(postfixUnaryExprNode); |
| 1225 | } | ||
| 1226 | |||
| 1227 | 2244764 | std::any ASTBuilder::visitAtomicExpr(SpiceParser::AtomicExprContext *ctx) { | |
| 1228 | 2244764 | const auto atomicExprNode = createNode<AtomicExprNode>(ctx); | |
| 1229 | |||
| 1230 | // Visit children | ||
| 1231 |
2/2✓ Branch 4 → 5 taken 354185 times.
✓ Branch 4 → 10 taken 1890579 times.
|
2244764 | if (ctx->constant()) { |
| 1232 |
4/6✓ Branch 5 → 6 taken 354185 times.
✗ Branch 5 → 88 not taken.
✓ Branch 6 → 7 taken 354181 times.
✓ Branch 6 → 88 taken 4 times.
✓ Branch 7 → 8 taken 354181 times.
✗ Branch 7 → 86 not taken.
|
354185 | atomicExprNode->constant = std::any_cast<ConstantNode *>(visit(ctx->constant())); |
| 1233 |
2/2✓ Branch 11 → 12 taken 697460 times.
✓ Branch 11 → 17 taken 1193119 times.
|
1890579 | } else if (ctx->value()) { |
| 1234 |
3/6✓ Branch 12 → 13 taken 697460 times.
✗ Branch 12 → 91 not taken.
✓ Branch 13 → 14 taken 697460 times.
✗ Branch 13 → 91 not taken.
✓ Branch 14 → 15 taken 697460 times.
✗ Branch 14 → 89 not taken.
|
697460 | atomicExprNode->value = std::any_cast<ValueNode *>(visit(ctx->value())); |
| 1235 |
11/18✓ Branch 17 → 18 taken 1193119 times.
✗ Branch 17 → 92 not taken.
✓ Branch 19 → 20 taken 212654 times.
✓ Branch 19 → 23 taken 980465 times.
✓ Branch 20 → 21 taken 212654 times.
✗ Branch 20 → 92 not taken.
✓ Branch 22 → 23 taken 204726 times.
✓ Branch 22 → 24 taken 7928 times.
✓ Branch 25 → 26 taken 212654 times.
✓ Branch 25 → 27 taken 980465 times.
✓ Branch 27 → 28 taken 1193119 times.
✗ Branch 27 → 29 not taken.
✓ Branch 29 → 30 taken 1185191 times.
✓ Branch 29 → 68 taken 7928 times.
✗ Branch 92 → 93 not taken.
✗ Branch 92 → 94 not taken.
✗ Branch 96 → 97 not taken.
✗ Branch 96 → 98 not taken.
|
1193119 | } else if (!ctx->IDENTIFIER().empty() || !ctx->TYPE_IDENTIFIER().empty()) { |
| 1236 |
1/2✓ Branch 30 → 31 taken 1185191 times.
✗ Branch 30 → 108 not taken.
|
1185191 | std::stringstream fqIdentifier; |
| 1237 |
2/2✓ Branch 62 → 33 taken 1536677 times.
✓ Branch 62 → 63 taken 1185191 times.
|
3907059 | for (ParserRuleContext::ParseTree *subTree : ctx->children) { |
| 1238 |
1/2✓ Branch 35 → 36 taken 1536677 times.
✗ Branch 35 → 37 not taken.
|
1536677 | const auto terminal = dynamic_cast<TerminalNode *>(subTree); |
| 1239 |
1/2✗ Branch 38 → 39 not taken.
✓ Branch 38 → 40 taken 1536677 times.
|
1536677 | if (!terminal) |
| 1240 | ✗ | continue; | |
| 1241 | |||
| 1242 |
2/4✓ Branch 40 → 41 taken 1536677 times.
✗ Branch 40 → 104 not taken.
✓ Branch 41 → 42 taken 1536677 times.
✗ Branch 41 → 104 not taken.
|
1536677 | const size_t terminalType = terminal->getSymbol()->getType(); |
| 1243 |
4/4✓ Branch 42 → 43 taken 556212 times.
✓ Branch 42 → 44 taken 980465 times.
✓ Branch 43 → 44 taken 380469 times.
✓ Branch 43 → 53 taken 175743 times.
|
1536677 | if (terminalType == SpiceParser::IDENTIFIER || terminalType == SpiceParser::TYPE_IDENTIFIER) { |
| 1244 |
1/2✓ Branch 44 → 45 taken 1360934 times.
✗ Branch 44 → 103 not taken.
|
1360934 | const std::string fragment = getIdentifier(terminal, false); |
| 1245 |
1/2✓ Branch 45 → 46 taken 1360934 times.
✗ Branch 45 → 101 not taken.
|
1360934 | atomicExprNode->identifierFragments.push_back(fragment); |
| 1246 |
3/4✓ Branch 46 → 47 taken 1360934 times.
✗ Branch 46 → 100 not taken.
✓ Branch 48 → 49 taken 175743 times.
✓ Branch 48 → 50 taken 1185191 times.
|
1360934 | if (fqIdentifier.tellp() != 0) |
| 1247 |
1/2✓ Branch 49 → 50 taken 175743 times.
✗ Branch 49 → 101 not taken.
|
175743 | fqIdentifier << SCOPE_ACCESS_TOKEN; |
| 1248 |
1/2✓ Branch 50 → 51 taken 1360934 times.
✗ Branch 50 → 101 not taken.
|
1360934 | fqIdentifier << fragment; |
| 1249 | 1360934 | } | |
| 1250 | } | ||
| 1251 |
1/2✓ Branch 63 → 64 taken 1185191 times.
✗ Branch 63 → 105 not taken.
|
1185191 | atomicExprNode->fqIdentifier = fqIdentifier.str(); |
| 1252 |
1/2✓ Branch 69 → 70 taken 7928 times.
✗ Branch 69 → 75 not taken.
|
1193119 | } else if (ctx->assignExpr()) { |
| 1253 |
3/6✓ Branch 70 → 71 taken 7928 times.
✗ Branch 70 → 111 not taken.
✓ Branch 71 → 72 taken 7928 times.
✗ Branch 71 → 111 not taken.
✓ Branch 72 → 73 taken 7928 times.
✗ Branch 72 → 109 not taken.
|
7928 | atomicExprNode->assignExpr = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 1254 | } else { | ||
| 1255 | − | assert_fail("Unknown atomic expression type"); // GCOV_EXCL_LINE | |
| 1256 | } | ||
| 1257 | |||
| 1258 |
1/2✓ Branch 82 → 83 taken 2244760 times.
✗ Branch 82 → 112 not taken.
|
4489520 | return concludeExprNode(atomicExprNode); |
| 1259 | } | ||
| 1260 | |||
| 1261 | 697460 | std::any ASTBuilder::visitValue(SpiceParser::ValueContext *ctx) { | |
| 1262 | 697460 | const auto valueNode = createNode<ValueNode>(ctx); | |
| 1263 | |||
| 1264 | // Visit children | ||
| 1265 |
2/2✓ Branch 4 → 5 taken 607315 times.
✓ Branch 4 → 10 taken 90145 times.
|
697460 | if (ctx->fctCall()) { |
| 1266 |
3/6✓ Branch 5 → 6 taken 607315 times.
✗ Branch 5 → 65 not taken.
✓ Branch 6 → 7 taken 607315 times.
✗ Branch 6 → 65 not taken.
✓ Branch 7 → 8 taken 607315 times.
✗ Branch 7 → 63 not taken.
|
607315 | valueNode->fctCall = std::any_cast<FctCallNode *>(visit(ctx->fctCall())); |
| 1267 |
2/2✓ Branch 11 → 12 taken 5564 times.
✓ Branch 11 → 17 taken 84581 times.
|
90145 | } else if (ctx->arrayInitialization()) { |
| 1268 |
3/6✓ Branch 12 → 13 taken 5564 times.
✗ Branch 12 → 68 not taken.
✓ Branch 13 → 14 taken 5564 times.
✗ Branch 13 → 68 not taken.
✓ Branch 14 → 15 taken 5564 times.
✗ Branch 14 → 66 not taken.
|
5564 | valueNode->arrayInitialization = std::any_cast<ArrayInitializationNode *>(visit(ctx->arrayInitialization())); |
| 1269 |
2/2✓ Branch 18 → 19 taken 29185 times.
✓ Branch 18 → 24 taken 55396 times.
|
84581 | } else if (ctx->structInstantiation()) { |
| 1270 |
3/6✓ Branch 19 → 20 taken 29185 times.
✗ Branch 19 → 71 not taken.
✓ Branch 20 → 21 taken 29185 times.
✗ Branch 20 → 71 not taken.
✓ Branch 21 → 22 taken 29185 times.
✗ Branch 21 → 69 not taken.
|
29185 | valueNode->structInstantiation = std::any_cast<StructInstantiationNode *>(visit(ctx->structInstantiation())); |
| 1271 |
2/2✓ Branch 25 → 26 taken 109 times.
✓ Branch 25 → 31 taken 55287 times.
|
55396 | } else if (ctx->lambdaFunc()) { |
| 1272 |
3/6✓ Branch 26 → 27 taken 109 times.
✗ Branch 26 → 74 not taken.
✓ Branch 27 → 28 taken 109 times.
✗ Branch 27 → 74 not taken.
✓ Branch 28 → 29 taken 109 times.
✗ Branch 28 → 72 not taken.
|
109 | valueNode->lambdaFunc = std::any_cast<LambdaFuncNode *>(visit(ctx->lambdaFunc())); |
| 1273 |
2/2✓ Branch 32 → 33 taken 1404 times.
✓ Branch 32 → 38 taken 53883 times.
|
55287 | } else if (ctx->lambdaProc()) { |
| 1274 |
3/6✓ Branch 33 → 34 taken 1404 times.
✗ Branch 33 → 77 not taken.
✓ Branch 34 → 35 taken 1404 times.
✗ Branch 34 → 77 not taken.
✓ Branch 35 → 36 taken 1404 times.
✗ Branch 35 → 75 not taken.
|
1404 | valueNode->lambdaProc = std::any_cast<LambdaProcNode *>(visit(ctx->lambdaProc())); |
| 1275 |
2/2✓ Branch 39 → 40 taken 2 times.
✓ Branch 39 → 45 taken 53881 times.
|
53883 | } else if (ctx->lambdaExpr()) { |
| 1276 |
3/6✓ Branch 40 → 41 taken 2 times.
✗ Branch 40 → 80 not taken.
✓ Branch 41 → 42 taken 2 times.
✗ Branch 41 → 80 not taken.
✓ Branch 42 → 43 taken 2 times.
✗ Branch 42 → 78 not taken.
|
2 | valueNode->lambdaExpr = std::any_cast<LambdaExprNode *>(visit(ctx->lambdaExpr())); |
| 1277 |
1/2✓ Branch 46 → 47 taken 53881 times.
✗ Branch 46 → 52 not taken.
|
53881 | } else if (ctx->dataType()) { |
| 1278 | 53881 | valueNode->isNil = true; | |
| 1279 |
3/6✓ Branch 47 → 48 taken 53881 times.
✗ Branch 47 → 83 not taken.
✓ Branch 48 → 49 taken 53881 times.
✗ Branch 48 → 83 not taken.
✓ Branch 49 → 50 taken 53881 times.
✗ Branch 49 → 81 not taken.
|
53881 | valueNode->nilType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 1280 | } else { | ||
| 1281 | − | assert_fail("Unknown value type"); // GCOV_EXCL_LINE | |
| 1282 | } | ||
| 1283 | |||
| 1284 |
1/2✓ Branch 59 → 60 taken 697460 times.
✗ Branch 59 → 84 not taken.
|
1394920 | return concludeNode(valueNode); |
| 1285 | } | ||
| 1286 | |||
| 1287 | 388257 | std::any ASTBuilder::visitConstant(SpiceParser::ConstantContext *ctx) { | |
| 1288 | 388257 | const auto constantNode = createNode<ConstantNode>(ctx); | |
| 1289 | |||
| 1290 | // Detect an optional leading minus sign for numeric literals | ||
| 1291 | 388257 | const bool isNegative = ctx->MINUS() != nullptr; | |
| 1292 | |||
| 1293 | // Enrich | ||
| 1294 |
2/2✓ Branch 5 → 6 taken 9552 times.
✓ Branch 5 → 14 taken 378705 times.
|
388257 | if (ctx->DOUBLE_LIT()) { |
| 1295 | 9552 | constantNode->type = ConstantNode::PrimitiveValueType::TYPE_DOUBLE; | |
| 1296 |
3/6✓ Branch 6 → 7 taken 9552 times.
✗ Branch 6 → 63 not taken.
✓ Branch 7 → 8 taken 9552 times.
✗ Branch 7 → 63 not taken.
✓ Branch 8 → 9 taken 9552 times.
✗ Branch 8 → 61 not taken.
|
9552 | const double value = std::stod(ctx->DOUBLE_LIT()->toString()); |
| 1297 |
2/2✓ Branch 10 → 11 taken 616 times.
✓ Branch 10 → 12 taken 8936 times.
|
9552 | constantNode->compileTimeValue.doubleValue = isNegative ? -value : value; |
| 1298 |
2/2✓ Branch 15 → 16 taken 43468 times.
✓ Branch 15 → 19 taken 335237 times.
|
378705 | } else if (ctx->INT_LIT()) { |
| 1299 | 43468 | constantNode->type = ConstantNode::PrimitiveValueType::TYPE_INT; | |
| 1300 | 43468 | constantNode->compileTimeValue.intValue = parseInt(ctx->INT_LIT(), isNegative); | |
| 1301 |
2/2✓ Branch 20 → 21 taken 4486 times.
✓ Branch 20 → 24 taken 330751 times.
|
335237 | } else if (ctx->SHORT_LIT()) { |
| 1302 | 4486 | constantNode->type = ConstantNode::PrimitiveValueType::TYPE_SHORT; | |
| 1303 | 4486 | constantNode->compileTimeValue.shortValue = parseShort(ctx->SHORT_LIT(), isNegative); | |
| 1304 |
2/2✓ Branch 25 → 26 taken 84027 times.
✓ Branch 25 → 29 taken 246724 times.
|
330751 | } else if (ctx->LONG_LIT()) { |
| 1305 | 84027 | constantNode->type = ConstantNode::PrimitiveValueType::TYPE_LONG; | |
| 1306 | 84027 | constantNode->compileTimeValue.longValue = parseLong(ctx->LONG_LIT(), isNegative); | |
| 1307 |
2/2✓ Branch 30 → 31 taken 24821 times.
✓ Branch 30 → 34 taken 221903 times.
|
246724 | } else if (ctx->CHAR_LIT()) { |
| 1308 | 24821 | constantNode->type = ConstantNode::PrimitiveValueType::TYPE_CHAR; | |
| 1309 | 24821 | constantNode->compileTimeValue.charValue = parseChar(ctx->CHAR_LIT()); | |
| 1310 |
2/2✓ Branch 35 → 36 taken 135433 times.
✓ Branch 35 → 44 taken 86470 times.
|
221903 | } else if (ctx->STRING_LIT()) { |
| 1311 | // Save a pointer to the string in the compile time value | ||
| 1312 | 135433 | constantNode->type = ConstantNode::PrimitiveValueType::TYPE_STRING; | |
| 1313 | 135433 | constantNode->compileTimeValue.stringValueOffset = resourceManager.compileTimeStringValues.size(); | |
| 1314 | // Add the string to the global compile time string list | ||
| 1315 |
4/8✓ Branch 37 → 38 taken 135433 times.
✗ Branch 37 → 68 not taken.
✓ Branch 38 → 39 taken 135433 times.
✗ Branch 38 → 68 not taken.
✓ Branch 39 → 40 taken 135433 times.
✗ Branch 39 → 66 not taken.
✓ Branch 40 → 41 taken 135433 times.
✗ Branch 40 → 64 not taken.
|
135433 | resourceManager.compileTimeStringValues.push_back(parseString(ctx->STRING_LIT()->toString())); |
| 1316 |
2/2✓ Branch 45 → 46 taken 32251 times.
✓ Branch 45 → 47 taken 54219 times.
|
86470 | } else if (ctx->TRUE()) { |
| 1317 | 32251 | constantNode->type = ConstantNode::PrimitiveValueType::TYPE_BOOL; | |
| 1318 | 32251 | constantNode->compileTimeValue.boolValue = true; | |
| 1319 |
1/2✓ Branch 48 → 49 taken 54219 times.
✗ Branch 48 → 50 not taken.
|
54219 | } else if (ctx->FALSE()) { |
| 1320 | 54219 | constantNode->type = ConstantNode::PrimitiveValueType::TYPE_BOOL; | |
| 1321 | 54219 | constantNode->compileTimeValue.boolValue = false; | |
| 1322 | } else { | ||
| 1323 | − | assert_fail("Unknown constant type"); // GCOV_EXCL_LINE | |
| 1324 | } | ||
| 1325 | |||
| 1326 |
1/2✓ Branch 57 → 58 taken 388253 times.
✗ Branch 57 → 70 not taken.
|
776506 | return concludeNode(constantNode); |
| 1327 | } | ||
| 1328 | |||
| 1329 | 607315 | std::any ASTBuilder::visitFctCall(SpiceParser::FctCallContext *ctx) { | |
| 1330 |
1/2✓ Branch 2 → 3 taken 607315 times.
✗ Branch 2 → 92 not taken.
|
607315 | const auto fctCallNode = createNode<FctCallNode>(ctx); |
| 1331 | |||
| 1332 |
1/2✓ Branch 3 → 4 taken 607315 times.
✗ Branch 3 → 92 not taken.
|
607315 | std::stringstream fqFunctionName; |
| 1333 |
2/2✓ Branch 46 → 6 taken 3328279 times.
✓ Branch 46 → 47 taken 607315 times.
|
4542909 | for (antlr4::ParserRuleContext::ParseTree *subTree : ctx->children) { |
| 1334 |
1/2✓ Branch 8 → 9 taken 3328279 times.
✗ Branch 8 → 10 not taken.
|
3328279 | const auto terminal = dynamic_cast<antlr4::tree::TerminalNode *>(subTree); |
| 1335 |
2/2✓ Branch 11 → 12 taken 457832 times.
✓ Branch 11 → 13 taken 2870447 times.
|
3328279 | if (!terminal) |
| 1336 | 457832 | continue; | |
| 1337 | |||
| 1338 |
4/6✓ Branch 13 → 14 taken 2870447 times.
✗ Branch 13 → 81 not taken.
✓ Branch 14 → 15 taken 2870447 times.
✗ Branch 14 → 81 not taken.
✓ Branch 15 → 16 taken 992578 times.
✓ Branch 15 → 21 taken 1877869 times.
|
2870447 | if (terminal->getSymbol()->getType() == SpiceParser::IDENTIFIER) { |
| 1339 |
1/2✓ Branch 16 → 17 taken 992578 times.
✗ Branch 16 → 77 not taken.
|
992578 | const std::string fragment = terminal->toString(); |
| 1340 |
1/2✓ Branch 17 → 18 taken 992578 times.
✗ Branch 17 → 75 not taken.
|
992578 | fctCallNode->functionNameFragments.push_back(fragment); |
| 1341 |
1/2✓ Branch 18 → 19 taken 992578 times.
✗ Branch 18 → 75 not taken.
|
992578 | fqFunctionName << fragment; |
| 1342 |
4/6✓ Branch 21 → 22 taken 1877869 times.
✗ Branch 21 → 81 not taken.
✓ Branch 22 → 23 taken 1877869 times.
✗ Branch 22 → 81 not taken.
✓ Branch 23 → 24 taken 111423 times.
✓ Branch 23 → 29 taken 1766446 times.
|
2870447 | } else if (terminal->getSymbol()->getType() == SpiceParser::TYPE_IDENTIFIER) { |
| 1343 |
1/2✓ Branch 24 → 25 taken 111423 times.
✗ Branch 24 → 80 not taken.
|
111423 | const std::string fragment = terminal->toString(); |
| 1344 |
1/2✓ Branch 25 → 26 taken 111423 times.
✗ Branch 25 → 78 not taken.
|
111423 | fctCallNode->functionNameFragments.push_back(fragment); |
| 1345 |
1/2✓ Branch 26 → 27 taken 111423 times.
✗ Branch 26 → 78 not taken.
|
111423 | fqFunctionName << fragment; |
| 1346 |
4/6✓ Branch 29 → 30 taken 1766446 times.
✗ Branch 29 → 81 not taken.
✓ Branch 30 → 31 taken 1766446 times.
✗ Branch 30 → 81 not taken.
✓ Branch 31 → 32 taken 1888 times.
✓ Branch 31 → 33 taken 1764558 times.
|
1877869 | } else if (terminal->getSymbol()->getType() == SpiceParser::SCOPE_ACCESS) { |
| 1347 |
1/2✓ Branch 32 → 37 taken 1888 times.
✗ Branch 32 → 81 not taken.
|
1888 | fqFunctionName << SCOPE_ACCESS_TOKEN; |
| 1348 |
4/6✓ Branch 33 → 34 taken 1764558 times.
✗ Branch 33 → 81 not taken.
✓ Branch 34 → 35 taken 1764558 times.
✗ Branch 34 → 81 not taken.
✓ Branch 35 → 36 taken 494798 times.
✓ Branch 35 → 37 taken 1269760 times.
|
1764558 | } else if (terminal->getSymbol()->getType() == SpiceParser::DOT) { |
| 1349 |
1/2✓ Branch 36 → 37 taken 494798 times.
✗ Branch 36 → 81 not taken.
|
494798 | fqFunctionName << MEMBER_ACCESS_TOKEN; |
| 1350 | } | ||
| 1351 | } | ||
| 1352 |
1/2✓ Branch 47 → 48 taken 607315 times.
✗ Branch 47 → 82 not taken.
|
607315 | fctCallNode->fqFunctionName = fqFunctionName.str(); |
| 1353 | |||
| 1354 | // Visit children | ||
| 1355 |
3/4✓ Branch 50 → 51 taken 607315 times.
✗ Branch 50 → 90 not taken.
✓ Branch 51 → 52 taken 27565 times.
✓ Branch 51 → 57 taken 579750 times.
|
607315 | if (ctx->typeLst()) { |
| 1356 | 27565 | fctCallNode->hasTemplateTypes = true; | |
| 1357 |
3/6✓ Branch 52 → 53 taken 27565 times.
✗ Branch 52 → 85 not taken.
✓ Branch 53 → 54 taken 27565 times.
✗ Branch 53 → 85 not taken.
✓ Branch 54 → 55 taken 27565 times.
✗ Branch 54 → 83 not taken.
|
27565 | fctCallNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst())); |
| 1358 | } | ||
| 1359 |
3/4✓ Branch 57 → 58 taken 607315 times.
✗ Branch 57 → 90 not taken.
✓ Branch 58 → 59 taken 430267 times.
✓ Branch 58 → 64 taken 177048 times.
|
607315 | if (ctx->argLst()) { |
| 1360 | 430267 | fctCallNode->hasArgs = true; | |
| 1361 |
3/6✓ Branch 59 → 60 taken 430267 times.
✗ Branch 59 → 88 not taken.
✓ Branch 60 → 61 taken 430267 times.
✗ Branch 60 → 88 not taken.
✓ Branch 61 → 62 taken 430267 times.
✗ Branch 61 → 86 not taken.
|
430267 | fctCallNode->argLst = std::any_cast<ArgLstNode *>(visit(ctx->argLst())); |
| 1362 | } | ||
| 1363 | |||
| 1364 |
1/2✓ Branch 70 → 71 taken 607315 times.
✗ Branch 70 → 89 not taken.
|
1214630 | return concludeNode(fctCallNode); |
| 1365 | 607315 | } | |
| 1366 | |||
| 1367 | 5564 | std::any ASTBuilder::visitArrayInitialization(SpiceParser::ArrayInitializationContext *ctx) { | |
| 1368 | 5564 | const auto arrayInitializationNode = createNode<ArrayInitializationNode>(ctx); | |
| 1369 | |||
| 1370 | // Visit children | ||
| 1371 |
2/2✓ Branch 4 → 5 taken 5562 times.
✓ Branch 4 → 10 taken 2 times.
|
5564 | if (ctx->argLst()) |
| 1372 |
3/6✓ Branch 5 → 6 taken 5562 times.
✗ Branch 5 → 22 not taken.
✓ Branch 6 → 7 taken 5562 times.
✗ Branch 6 → 22 not taken.
✓ Branch 7 → 8 taken 5562 times.
✗ Branch 7 → 20 not taken.
|
5562 | arrayInitializationNode->itemLst = std::any_cast<ArgLstNode *>(visit(ctx->argLst())); |
| 1373 | |||
| 1374 |
1/2✓ Branch 16 → 17 taken 5564 times.
✗ Branch 16 → 23 not taken.
|
11128 | return concludeNode(arrayInitializationNode); |
| 1375 | } | ||
| 1376 | |||
| 1377 | 29185 | std::any ASTBuilder::visitStructInstantiation(SpiceParser::StructInstantiationContext *ctx) { | |
| 1378 |
1/2✓ Branch 2 → 3 taken 29185 times.
✗ Branch 2 → 85 not taken.
|
29185 | const auto structInstantiationNode = createNode<StructInstantiationNode>(ctx); |
| 1379 | |||
| 1380 | // Enrich | ||
| 1381 |
1/2✓ Branch 3 → 4 taken 29185 times.
✗ Branch 3 → 85 not taken.
|
29185 | std::stringstream fqStructName; |
| 1382 |
2/2✓ Branch 39 → 6 taken 116349 times.
✓ Branch 39 → 40 taken 29185 times.
|
174719 | for (antlr4::ParserRuleContext::ParseTree *subTree : ctx->children) { |
| 1383 |
1/2✓ Branch 8 → 9 taken 116349 times.
✗ Branch 8 → 10 not taken.
|
116349 | const auto terminal = dynamic_cast<antlr4::tree::TerminalNode *>(subTree); |
| 1384 |
2/2✓ Branch 11 → 12 taken 28740 times.
✓ Branch 11 → 13 taken 87609 times.
|
116349 | if (!terminal) |
| 1385 | 28740 | continue; | |
| 1386 | |||
| 1387 |
4/6✓ Branch 13 → 14 taken 87609 times.
✗ Branch 13 → 74 not taken.
✓ Branch 14 → 15 taken 87609 times.
✗ Branch 14 → 74 not taken.
✓ Branch 15 → 16 taken 6 times.
✓ Branch 15 → 22 taken 87603 times.
|
87609 | if (terminal->getSymbol()->getType() == SpiceParser::IDENTIFIER) { |
| 1388 |
1/2✓ Branch 16 → 17 taken 6 times.
✗ Branch 16 → 70 not taken.
|
6 | const std::string fragment = terminal->toString(); |
| 1389 |
1/2✓ Branch 17 → 18 taken 6 times.
✗ Branch 17 → 68 not taken.
|
6 | structInstantiationNode->structNameFragments.push_back(fragment); |
| 1390 |
2/4✓ Branch 18 → 19 taken 6 times.
✗ Branch 18 → 68 not taken.
✓ Branch 19 → 20 taken 6 times.
✗ Branch 19 → 68 not taken.
|
6 | fqStructName << fragment << SCOPE_ACCESS_TOKEN; |
| 1391 |
4/6✓ Branch 22 → 23 taken 87603 times.
✗ Branch 22 → 74 not taken.
✓ Branch 23 → 24 taken 87603 times.
✗ Branch 23 → 74 not taken.
✓ Branch 24 → 25 taken 29185 times.
✓ Branch 24 → 30 taken 58418 times.
|
87609 | } else if (terminal->getSymbol()->getType() == SpiceParser::TYPE_IDENTIFIER) { |
| 1392 |
1/2✓ Branch 25 → 26 taken 29185 times.
✗ Branch 25 → 73 not taken.
|
29185 | const std::string fragment = terminal->toString(); |
| 1393 |
1/2✓ Branch 26 → 27 taken 29185 times.
✗ Branch 26 → 71 not taken.
|
29185 | structInstantiationNode->structNameFragments.push_back(fragment); |
| 1394 |
1/2✓ Branch 27 → 28 taken 29185 times.
✗ Branch 27 → 71 not taken.
|
29185 | fqStructName << fragment; |
| 1395 | 29185 | } | |
| 1396 | } | ||
| 1397 |
1/2✓ Branch 40 → 41 taken 29185 times.
✗ Branch 40 → 75 not taken.
|
29185 | structInstantiationNode->fqStructName = fqStructName.str(); |
| 1398 | |||
| 1399 | // Visit children | ||
| 1400 |
3/4✓ Branch 43 → 44 taken 29185 times.
✗ Branch 43 → 83 not taken.
✓ Branch 44 → 45 taken 21 times.
✓ Branch 44 → 50 taken 29164 times.
|
29185 | if (ctx->typeLst()) { |
| 1401 | 21 | structInstantiationNode->hasTemplateTypes = true; | |
| 1402 |
3/6✓ Branch 45 → 46 taken 21 times.
✗ Branch 45 → 78 not taken.
✓ Branch 46 → 47 taken 21 times.
✗ Branch 46 → 78 not taken.
✓ Branch 47 → 48 taken 21 times.
✗ Branch 47 → 76 not taken.
|
21 | structInstantiationNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst())); |
| 1403 | } | ||
| 1404 |
3/4✓ Branch 50 → 51 taken 29185 times.
✗ Branch 50 → 83 not taken.
✓ Branch 51 → 52 taken 28719 times.
✓ Branch 51 → 57 taken 466 times.
|
29185 | if (ctx->argLst()) |
| 1405 |
3/6✓ Branch 52 → 53 taken 28719 times.
✗ Branch 52 → 81 not taken.
✓ Branch 53 → 54 taken 28719 times.
✗ Branch 53 → 81 not taken.
✓ Branch 54 → 55 taken 28719 times.
✗ Branch 54 → 79 not taken.
|
28719 | structInstantiationNode->fieldLst = std::any_cast<ArgLstNode *>(visit(ctx->argLst())); |
| 1406 | |||
| 1407 |
1/2✓ Branch 63 → 64 taken 29185 times.
✗ Branch 63 → 82 not taken.
|
58370 | return concludeNode(structInstantiationNode); |
| 1408 | 29185 | } | |
| 1409 | |||
| 1410 | 109 | std::any ASTBuilder::visitLambdaFunc(SpiceParser::LambdaFuncContext *ctx) { | |
| 1411 | 109 | const auto lambdaFuncNode = createNode<LambdaFuncNode>(ctx); | |
| 1412 | |||
| 1413 | // Visit children | ||
| 1414 |
3/6✓ Branch 3 → 4 taken 109 times.
✗ Branch 3 → 37 not taken.
✓ Branch 4 → 5 taken 109 times.
✗ Branch 4 → 37 not taken.
✓ Branch 5 → 6 taken 109 times.
✗ Branch 5 → 35 not taken.
|
109 | lambdaFuncNode->returnType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 1415 |
2/2✓ Branch 8 → 9 taken 99 times.
✓ Branch 8 → 14 taken 10 times.
|
109 | if (ctx->paramLst()) { |
| 1416 | 99 | lambdaFuncNode->hasParams = true; | |
| 1417 |
3/6✓ Branch 9 → 10 taken 99 times.
✗ Branch 9 → 40 not taken.
✓ Branch 10 → 11 taken 99 times.
✗ Branch 10 → 40 not taken.
✓ Branch 11 → 12 taken 99 times.
✗ Branch 11 → 38 not taken.
|
99 | lambdaFuncNode->paramLst = std::any_cast<ParamLstNode *>(visit(ctx->paramLst())); |
| 1418 | } | ||
| 1419 |
1/2✗ Branch 15 → 16 not taken.
✓ Branch 15 → 21 taken 109 times.
|
109 | if (ctx->lambdaAttr()) |
| 1420 | ✗ | lambdaFuncNode->lambdaAttr = std::any_cast<LambdaAttrNode *>(visit(ctx->lambdaAttr())); | |
| 1421 |
4/8✓ Branch 21 → 22 taken 109 times.
✗ Branch 21 → 46 not taken.
✓ Branch 22 → 23 taken 109 times.
✗ Branch 22 → 46 not taken.
✓ Branch 23 → 24 taken 109 times.
✗ Branch 23 → 44 not taken.
✓ Branch 25 → 26 taken 109 times.
✗ Branch 25 → 47 not taken.
|
109 | lambdaFuncNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 1422 | |||
| 1423 |
1/2✓ Branch 31 → 32 taken 109 times.
✗ Branch 31 → 47 not taken.
|
218 | return concludeNode(lambdaFuncNode); |
| 1424 | } | ||
| 1425 | |||
| 1426 | 1404 | std::any ASTBuilder::visitLambdaProc(SpiceParser::LambdaProcContext *ctx) { | |
| 1427 | 1404 | const auto lambdaProcNode = createNode<LambdaProcNode>(ctx); | |
| 1428 | |||
| 1429 | // Visit children | ||
| 1430 |
2/2✓ Branch 4 → 5 taken 1052 times.
✓ Branch 4 → 10 taken 352 times.
|
1404 | if (ctx->paramLst()) { |
| 1431 | 1052 | lambdaProcNode->hasParams = true; | |
| 1432 |
3/6✓ Branch 5 → 6 taken 1052 times.
✗ Branch 5 → 33 not taken.
✓ Branch 6 → 7 taken 1052 times.
✗ Branch 6 → 33 not taken.
✓ Branch 7 → 8 taken 1052 times.
✗ Branch 7 → 31 not taken.
|
1052 | lambdaProcNode->paramLst = std::any_cast<ParamLstNode *>(visit(ctx->paramLst())); |
| 1433 | } | ||
| 1434 |
2/2✓ Branch 11 → 12 taken 16 times.
✓ Branch 11 → 17 taken 1388 times.
|
1404 | if (ctx->lambdaAttr()) |
| 1435 |
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())); |
| 1436 |
4/8✓ Branch 17 → 18 taken 1404 times.
✗ Branch 17 → 39 not taken.
✓ Branch 18 → 19 taken 1404 times.
✗ Branch 18 → 39 not taken.
✓ Branch 19 → 20 taken 1404 times.
✗ Branch 19 → 37 not taken.
✓ Branch 21 → 22 taken 1404 times.
✗ Branch 21 → 40 not taken.
|
1404 | lambdaProcNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 1437 | |||
| 1438 |
1/2✓ Branch 27 → 28 taken 1404 times.
✗ Branch 27 → 40 not taken.
|
2808 | return concludeNode(lambdaProcNode); |
| 1439 | } | ||
| 1440 | |||
| 1441 | 2 | std::any ASTBuilder::visitLambdaExpr(SpiceParser::LambdaExprContext *ctx) { | |
| 1442 | 2 | const auto lambdaExprNode = createNode<LambdaExprNode>(ctx); | |
| 1443 | |||
| 1444 | // Visit children | ||
| 1445 |
1/2✓ Branch 4 → 5 taken 2 times.
✗ Branch 4 → 10 not taken.
|
2 | if (ctx->paramLst()) { |
| 1446 | 2 | lambdaExprNode->hasParams = true; | |
| 1447 |
3/6✓ Branch 5 → 6 taken 2 times.
✗ Branch 5 → 26 not taken.
✓ Branch 6 → 7 taken 2 times.
✗ Branch 6 → 26 not taken.
✓ Branch 7 → 8 taken 2 times.
✗ Branch 7 → 24 not taken.
|
2 | lambdaExprNode->paramLst = std::any_cast<ParamLstNode *>(visit(ctx->paramLst())); |
| 1448 | } | ||
| 1449 |
4/8✓ Branch 10 → 11 taken 2 times.
✗ Branch 10 → 29 not taken.
✓ Branch 11 → 12 taken 2 times.
✗ Branch 11 → 29 not taken.
✓ Branch 12 → 13 taken 2 times.
✗ Branch 12 → 27 not taken.
✓ Branch 14 → 15 taken 2 times.
✗ Branch 14 → 30 not taken.
|
2 | lambdaExprNode->lambdaExpr = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 1450 | |||
| 1451 |
1/2✓ Branch 20 → 21 taken 2 times.
✗ Branch 20 → 30 not taken.
|
4 | return concludeNode(lambdaExprNode); |
| 1452 | } | ||
| 1453 | |||
| 1454 | 923150 | std::any ASTBuilder::visitDataType(SpiceParser::DataTypeContext *ctx) { | |
| 1455 | 923150 | const auto dataTypeNode = createNode<DataTypeNode>(ctx); | |
| 1456 | |||
| 1457 | // Visit children | ||
| 1458 |
2/2✓ Branch 4 → 5 taken 324929 times.
✓ Branch 4 → 10 taken 598221 times.
|
923150 | if (ctx->qualifierLst()) |
| 1459 |
4/6✓ Branch 5 → 6 taken 324929 times.
✗ Branch 5 → 73 not taken.
✓ Branch 6 → 7 taken 324927 times.
✓ Branch 6 → 73 taken 2 times.
✓ Branch 7 → 8 taken 324927 times.
✗ Branch 7 → 71 not taken.
|
324929 | dataTypeNode->qualifierLst = std::any_cast<QualifierLstNode *>(visit(ctx->qualifierLst())); |
| 1460 |
3/6✓ Branch 10 → 11 taken 923148 times.
✗ Branch 10 → 76 not taken.
✓ Branch 11 → 12 taken 923148 times.
✗ Branch 11 → 76 not taken.
✓ Branch 12 → 13 taken 923148 times.
✗ Branch 12 → 74 not taken.
|
923148 | dataTypeNode->baseDataType = std::any_cast<BaseDataTypeNode *>(visit(ctx->baseDataType())); |
| 1461 | |||
| 1462 | // Enrich | ||
| 1463 |
2/2✓ Branch 60 → 15 taken 1585065 times.
✓ Branch 60 → 61 taken 923148 times.
|
2508213 | for (size_t i = 0; i < ctx->children.size(); i++) { |
| 1464 | 1585065 | antlr4::tree::ParseTree *subTree = ctx->children.at(i); | |
| 1465 |
1/2✓ Branch 16 → 17 taken 1585065 times.
✗ Branch 16 → 18 not taken.
|
1585065 | auto terminal = dynamic_cast<TerminalNode *>(subTree); |
| 1466 |
2/2✓ Branch 19 → 20 taken 1248075 times.
✓ Branch 19 → 21 taken 336990 times.
|
1585065 | if (!terminal) |
| 1467 | 1248075 | continue; | |
| 1468 | |||
| 1469 |
2/2✓ Branch 23 → 24 taken 226652 times.
✓ Branch 23 → 26 taken 110338 times.
|
336990 | if (terminal->getSymbol()->getType() == SpiceParser::MUL) { |
| 1470 |
1/2✓ Branch 24 → 25 taken 226652 times.
✗ Branch 24 → 77 not taken.
|
226652 | dataTypeNode->tmQueue.emplace(DataTypeNode::TypeModifierType::TYPE_PTR, false, 0); |
| 1471 |
2/2✓ Branch 28 → 29 taken 106947 times.
✓ Branch 28 → 31 taken 3391 times.
|
110338 | } else if (terminal->getSymbol()->getType() == SpiceParser::BITWISE_AND) { |
| 1472 |
1/2✓ Branch 29 → 30 taken 106947 times.
✗ Branch 29 → 80 not taken.
|
106947 | dataTypeNode->tmQueue.emplace(DataTypeNode::TypeModifierType::TYPE_REF, false, 0); |
| 1473 |
1/2✓ Branch 33 → 34 taken 3391 times.
✗ Branch 33 → 58 not taken.
|
3391 | } else if (terminal->getSymbol()->getType() == SpiceParser::LBRACKET) { |
| 1474 | 3391 | i++; // Consume LBRACKET | |
| 1475 |
1/2✓ Branch 34 → 35 taken 3391 times.
✗ Branch 34 → 92 not taken.
|
3391 | subTree = ctx->children.at(i); |
| 1476 |
1/2✓ Branch 35 → 36 taken 3391 times.
✗ Branch 35 → 37 not taken.
|
3391 | terminal = dynamic_cast<TerminalNode *>(subTree); |
| 1477 | 3391 | bool hasSize = false; | |
| 1478 | 3391 | unsigned int hardCodedSize = 0; | |
| 1479 | 3391 | std::string sizeVarName; | |
| 1480 |
4/6✓ Branch 39 → 40 taken 3391 times.
✗ Branch 39 → 90 not taken.
✓ Branch 40 → 41 taken 3391 times.
✗ Branch 40 → 90 not taken.
✓ Branch 41 → 42 taken 1960 times.
✓ Branch 41 → 46 taken 1431 times.
|
3391 | if (terminal->getSymbol()->getType() == SpiceParser::INT_LIT) { |
| 1481 | 1960 | hasSize = true; | |
| 1482 |
2/4✓ Branch 42 → 43 taken 1960 times.
✗ Branch 42 → 85 not taken.
✓ Branch 43 → 44 taken 1960 times.
✗ Branch 43 → 83 not taken.
|
1960 | hardCodedSize = std::stoi(terminal->getText()); |
| 1483 | 1960 | i++; // Consume INT_LIT | |
| 1484 |
4/6✓ Branch 46 → 47 taken 1431 times.
✗ Branch 46 → 90 not taken.
✓ Branch 47 → 48 taken 1431 times.
✗ Branch 47 → 90 not taken.
✓ Branch 48 → 49 taken 733 times.
✓ Branch 48 → 53 taken 698 times.
|
1431 | } else if (terminal->getSymbol()->getType() == SpiceParser::TYPE_IDENTIFIER) { |
| 1485 | 733 | hasSize = true; | |
| 1486 |
1/2✓ Branch 49 → 50 taken 733 times.
✗ Branch 49 → 86 not taken.
|
733 | sizeVarName = getIdentifier(terminal, true); |
| 1487 | 733 | i++; // Consume TYPE_IDENTIFIER | |
| 1488 | } | ||
| 1489 |
1/2✓ Branch 54 → 55 taken 3391 times.
✗ Branch 54 → 87 not taken.
|
3391 | dataTypeNode->tmQueue.push({DataTypeNode::TypeModifierType::TYPE_ARRAY, hasSize, hardCodedSize, sizeVarName}); |
| 1490 | 3391 | } | |
| 1491 | } | ||
| 1492 | |||
| 1493 |
1/2✓ Branch 67 → 68 taken 923148 times.
✗ Branch 67 → 93 not taken.
|
1846296 | return concludeNode(dataTypeNode); |
| 1494 |
1/2✓ Branch 53 → 54 taken 3391 times.
✗ Branch 53 → 89 not taken.
|
3391 | } |
| 1495 | |||
| 1496 | 923148 | std::any ASTBuilder::visitBaseDataType(SpiceParser::BaseDataTypeContext *ctx) { | |
| 1497 | 923148 | const auto baseDataTypeNode = createNode<BaseDataTypeNode>(ctx); | |
| 1498 | |||
| 1499 | // Enrich | ||
| 1500 |
2/2✓ Branch 4 → 5 taken 10693 times.
✓ Branch 4 → 6 taken 912455 times.
|
923148 | if (ctx->TYPE_DOUBLE()) { |
| 1501 | 10693 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_DOUBLE; | |
| 1502 |
2/2✓ Branch 7 → 8 taken 45264 times.
✓ Branch 7 → 9 taken 867191 times.
|
912455 | } else if (ctx->TYPE_INT()) { |
| 1503 | 45264 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_INT; | |
| 1504 |
2/2✓ Branch 10 → 11 taken 7886 times.
✓ Branch 10 → 12 taken 859305 times.
|
867191 | } else if (ctx->TYPE_SHORT()) { |
| 1505 | 7886 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_SHORT; | |
| 1506 |
2/2✓ Branch 13 → 14 taken 84185 times.
✓ Branch 13 → 15 taken 775120 times.
|
859305 | } else if (ctx->TYPE_LONG()) { |
| 1507 | 84185 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_LONG; | |
| 1508 |
2/2✓ Branch 16 → 17 taken 33617 times.
✓ Branch 16 → 18 taken 741503 times.
|
775120 | } else if (ctx->TYPE_BYTE()) { |
| 1509 | 33617 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_BYTE; | |
| 1510 |
2/2✓ Branch 19 → 20 taken 38407 times.
✓ Branch 19 → 21 taken 703096 times.
|
741503 | } else if (ctx->TYPE_CHAR()) { |
| 1511 | 38407 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_CHAR; | |
| 1512 |
2/2✓ Branch 22 → 23 taken 54070 times.
✓ Branch 22 → 24 taken 649026 times.
|
703096 | } else if (ctx->TYPE_STRING()) { |
| 1513 | 54070 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_STRING; | |
| 1514 |
2/2✓ Branch 25 → 26 taken 60862 times.
✓ Branch 25 → 27 taken 588164 times.
|
649026 | } else if (ctx->TYPE_BOOL()) { |
| 1515 | 60862 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_BOOL; | |
| 1516 |
2/2✓ Branch 28 → 29 taken 11984 times.
✓ Branch 28 → 30 taken 576180 times.
|
588164 | } else if (ctx->TYPE_DYN()) { |
| 1517 | 11984 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_DYN; | |
| 1518 |
2/2✓ Branch 31 → 32 taken 573178 times.
✓ Branch 31 → 37 taken 3002 times.
|
576180 | } else if (ctx->customDataType()) { |
| 1519 | 573178 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_CUSTOM; | |
| 1520 |
3/6✓ Branch 32 → 33 taken 573178 times.
✗ Branch 32 → 57 not taken.
✓ Branch 33 → 34 taken 573178 times.
✗ Branch 33 → 57 not taken.
✓ Branch 34 → 35 taken 573178 times.
✗ Branch 34 → 55 not taken.
|
573178 | baseDataTypeNode->customDataType = std::any_cast<CustomDataTypeNode *>(visit(ctx->customDataType())); |
| 1521 |
1/2✓ Branch 38 → 39 taken 3002 times.
✗ Branch 38 → 44 not taken.
|
3002 | } else if (ctx->functionDataType()) { |
| 1522 | 3002 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_FUNCTION; | |
| 1523 |
3/6✓ Branch 39 → 40 taken 3002 times.
✗ Branch 39 → 60 not taken.
✓ Branch 40 → 41 taken 3002 times.
✗ Branch 40 → 60 not taken.
✓ Branch 41 → 42 taken 3002 times.
✗ Branch 41 → 58 not taken.
|
3002 | baseDataTypeNode->functionDataType = std::any_cast<FunctionDataTypeNode *>(visit(ctx->functionDataType())); |
| 1524 | } else { | ||
| 1525 | ✗ | assert_fail("Unknown base data type"); | |
| 1526 | } | ||
| 1527 | |||
| 1528 |
1/2✓ Branch 51 → 52 taken 923148 times.
✗ Branch 51 → 61 not taken.
|
1846296 | return concludeNode(baseDataTypeNode); |
| 1529 | } | ||
| 1530 | |||
| 1531 | 573178 | std::any ASTBuilder::visitCustomDataType(SpiceParser::CustomDataTypeContext *ctx) { | |
| 1532 |
1/2✓ Branch 2 → 3 taken 573178 times.
✗ Branch 2 → 75 not taken.
|
573178 | const auto customDataTypeNode = createNode<CustomDataTypeNode>(ctx); |
| 1533 | |||
| 1534 | // Enrich | ||
| 1535 |
1/2✓ Branch 3 → 4 taken 573178 times.
✗ Branch 3 → 75 not taken.
|
573178 | std::stringstream fqTypeName; |
| 1536 |
2/2✓ Branch 39 → 6 taken 733556 times.
✓ Branch 39 → 40 taken 573178 times.
|
1879912 | for (ParserRuleContext::ParseTree *subTree : ctx->children) { |
| 1537 |
1/2✓ Branch 8 → 9 taken 733556 times.
✗ Branch 8 → 10 not taken.
|
733556 | const auto terminal = dynamic_cast<TerminalNode *>(subTree); |
| 1538 |
2/2✓ Branch 11 → 12 taken 52586 times.
✓ Branch 11 → 13 taken 680970 times.
|
733556 | if (!terminal) |
| 1539 | 52586 | continue; | |
| 1540 | |||
| 1541 |
4/6✓ Branch 13 → 14 taken 680970 times.
✗ Branch 13 → 67 not taken.
✓ Branch 14 → 15 taken 680970 times.
✗ Branch 14 → 67 not taken.
✓ Branch 15 → 16 taken 1310 times.
✓ Branch 15 → 22 taken 679660 times.
|
680970 | if (terminal->getSymbol()->getType() == SpiceParser::IDENTIFIER) { |
| 1542 |
1/2✓ Branch 16 → 17 taken 1310 times.
✗ Branch 16 → 63 not taken.
|
1310 | const std::string fragment = terminal->toString(); |
| 1543 |
1/2✓ Branch 17 → 18 taken 1310 times.
✗ Branch 17 → 61 not taken.
|
1310 | customDataTypeNode->typeNameFragments.push_back(fragment); |
| 1544 |
2/4✓ Branch 18 → 19 taken 1310 times.
✗ Branch 18 → 61 not taken.
✓ Branch 19 → 20 taken 1310 times.
✗ Branch 19 → 61 not taken.
|
1310 | fqTypeName << fragment << SCOPE_ACCESS_TOKEN; |
| 1545 |
4/6✓ Branch 22 → 23 taken 679660 times.
✗ Branch 22 → 67 not taken.
✓ Branch 23 → 24 taken 679660 times.
✗ Branch 23 → 67 not taken.
✓ Branch 24 → 25 taken 573178 times.
✓ Branch 24 → 30 taken 106482 times.
|
680970 | } else if (terminal->getSymbol()->getType() == SpiceParser::TYPE_IDENTIFIER) { |
| 1546 |
1/2✓ Branch 25 → 26 taken 573178 times.
✗ Branch 25 → 66 not taken.
|
573178 | const std::string fragment = terminal->toString(); |
| 1547 |
1/2✓ Branch 26 → 27 taken 573178 times.
✗ Branch 26 → 64 not taken.
|
573178 | customDataTypeNode->typeNameFragments.push_back(fragment); |
| 1548 |
1/2✓ Branch 27 → 28 taken 573178 times.
✗ Branch 27 → 64 not taken.
|
573178 | fqTypeName << fragment; |
| 1549 | 573178 | } | |
| 1550 | } | ||
| 1551 |
1/2✓ Branch 40 → 41 taken 573178 times.
✗ Branch 40 → 68 not taken.
|
573178 | customDataTypeNode->fqTypeName = fqTypeName.str(); |
| 1552 | |||
| 1553 | // Visit children | ||
| 1554 |
3/4✓ Branch 43 → 44 taken 573178 times.
✗ Branch 43 → 73 not taken.
✓ Branch 44 → 45 taken 52586 times.
✓ Branch 44 → 50 taken 520592 times.
|
573178 | if (ctx->typeLst()) |
| 1555 |
3/6✓ Branch 45 → 46 taken 52586 times.
✗ Branch 45 → 71 not taken.
✓ Branch 46 → 47 taken 52586 times.
✗ Branch 46 → 71 not taken.
✓ Branch 47 → 48 taken 52586 times.
✗ Branch 47 → 69 not taken.
|
52586 | customDataTypeNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst())); |
| 1556 | |||
| 1557 |
1/2✓ Branch 56 → 57 taken 573178 times.
✗ Branch 56 → 72 not taken.
|
1146356 | return concludeNode(customDataTypeNode); |
| 1558 | 573178 | } | |
| 1559 | |||
| 1560 | 3002 | std::any ASTBuilder::visitFunctionDataType(SpiceParser::FunctionDataTypeContext *ctx) { | |
| 1561 | 3002 | const auto functionDataTypeNode = createNode<FunctionDataTypeNode>(ctx); | |
| 1562 | |||
| 1563 | // Enrich | ||
| 1564 |
2/2✓ Branch 4 → 5 taken 1210 times.
✓ Branch 4 → 11 taken 1792 times.
|
3002 | if (ctx->dataType()) { |
| 1565 | 1210 | functionDataTypeNode->isFunction = ctx->dataType(); | |
| 1566 |
3/6✓ Branch 6 → 7 taken 1210 times.
✗ Branch 6 → 30 not taken.
✓ Branch 7 → 8 taken 1210 times.
✗ Branch 7 → 30 not taken.
✓ Branch 8 → 9 taken 1210 times.
✗ Branch 8 → 28 not taken.
|
1210 | functionDataTypeNode->returnType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 1567 | } | ||
| 1568 |
2/2✓ Branch 12 → 13 taken 2474 times.
✓ Branch 12 → 18 taken 528 times.
|
3002 | if (ctx->typeLst()) |
| 1569 |
3/6✓ Branch 13 → 14 taken 2474 times.
✗ Branch 13 → 33 not taken.
✓ Branch 14 → 15 taken 2474 times.
✗ Branch 14 → 33 not taken.
✓ Branch 15 → 16 taken 2474 times.
✗ Branch 15 → 31 not taken.
|
2474 | functionDataTypeNode->paramTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst())); |
| 1570 | |||
| 1571 |
1/2✓ Branch 24 → 25 taken 3002 times.
✗ Branch 24 → 34 not taken.
|
6004 | return concludeNode(functionDataTypeNode); |
| 1572 | } | ||
| 1573 | |||
| 1574 | 153550 | std::any ASTBuilder::visitAssignOp(SpiceParser::AssignOpContext *ctx) { | |
| 1575 | 153550 | const auto assignExprNode = resumeForExpansion<AssignExprNode>(); | |
| 1576 | |||
| 1577 | // Extract assign operator | ||
| 1578 |
2/2✓ Branch 15 → 16 taken 139275 times.
✓ Branch 15 → 17 taken 14275 times.
|
153550 | if (ctx->ASSIGN()) |
| 1579 | 139275 | assignExprNode->op = AssignExprNode::AssignOp::OP_ASSIGN; | |
| 1580 |
2/2✓ Branch 18 → 19 taken 9976 times.
✓ Branch 18 → 20 taken 4299 times.
|
14275 | else if (ctx->PLUS_EQUAL()) |
| 1581 | 9976 | assignExprNode->op = AssignExprNode::AssignOp::OP_PLUS_EQUAL; | |
| 1582 |
2/2✓ Branch 21 → 22 taken 791 times.
✓ Branch 21 → 23 taken 3508 times.
|
4299 | else if (ctx->MINUS_EQUAL()) |
| 1583 | 791 | assignExprNode->op = AssignExprNode::AssignOp::OP_MINUS_EQUAL; | |
| 1584 |
2/2✓ Branch 24 → 25 taken 1243 times.
✓ Branch 24 → 26 taken 2265 times.
|
3508 | else if (ctx->MUL_EQUAL()) |
| 1585 | 1243 | assignExprNode->op = AssignExprNode::AssignOp::OP_MUL_EQUAL; | |
| 1586 |
2/2✓ Branch 27 → 28 taken 688 times.
✓ Branch 27 → 29 taken 1577 times.
|
2265 | else if (ctx->DIV_EQUAL()) |
| 1587 | 688 | assignExprNode->op = AssignExprNode::AssignOp::OP_DIV_EQUAL; | |
| 1588 |
2/2✓ Branch 30 → 31 taken 264 times.
✓ Branch 30 → 32 taken 1313 times.
|
1577 | else if (ctx->REM_EQUAL()) |
| 1589 | 264 | assignExprNode->op = AssignExprNode::AssignOp::OP_REM_EQUAL; | |
| 1590 |
2/2✓ Branch 33 → 34 taken 54 times.
✓ Branch 33 → 35 taken 1259 times.
|
1313 | else if (ctx->SHL_EQUAL()) |
| 1591 | 54 | assignExprNode->op = AssignExprNode::AssignOp::OP_SHL_EQUAL; | |
| 1592 |
2/2✓ Branch 36 → 37 taken 64 times.
✓ Branch 36 → 38 taken 1195 times.
|
1259 | else if (ctx->SHR_EQUAL()) |
| 1593 | 64 | assignExprNode->op = AssignExprNode::AssignOp::OP_SHR_EQUAL; | |
| 1594 |
2/2✓ Branch 39 → 40 taken 86 times.
✓ Branch 39 → 41 taken 1109 times.
|
1195 | else if (ctx->AND_EQUAL()) |
| 1595 | 86 | assignExprNode->op = AssignExprNode::AssignOp::OP_AND_EQUAL; | |
| 1596 |
2/2✓ Branch 42 → 43 taken 134 times.
✓ Branch 42 → 44 taken 975 times.
|
1109 | else if (ctx->OR_EQUAL()) |
| 1597 | 134 | assignExprNode->op = AssignExprNode::AssignOp::OP_OR_EQUAL; | |
| 1598 |
1/2✓ Branch 45 → 46 taken 975 times.
✗ Branch 45 → 47 not taken.
|
975 | else if (ctx->XOR_EQUAL()) |
| 1599 | 975 | assignExprNode->op = AssignExprNode::AssignOp::OP_XOR_EQUAL; | |
| 1600 | else | ||
| 1601 | ✗ | assert_fail("Unknown assign operator"); | |
| 1602 | |||
| 1603 |
1/2✓ Branch 48 → 49 taken 153550 times.
✗ Branch 48 → 52 not taken.
|
307100 | return nullptr; |
| 1604 | } | ||
| 1605 | |||
| 1606 | 11282 | std::any ASTBuilder::visitOverloadableOp(SpiceParser::OverloadableOpContext *ctx) { | |
| 1607 | 11282 | const auto fctNameNode = resumeForExpansion<FctNameNode>(); | |
| 1608 | |||
| 1609 | // Enrich | ||
| 1610 |
2/2✓ Branch 15 → 16 taken 410 times.
✓ Branch 15 → 17 taken 10872 times.
|
11282 | if (ctx->PLUS()) |
| 1611 | 410 | fctNameNode->name = OP_FCT_PLUS; | |
| 1612 |
2/2✓ Branch 18 → 19 taken 2 times.
✓ Branch 18 → 20 taken 10870 times.
|
10872 | else if (ctx->MINUS()) |
| 1613 | 2 | fctNameNode->name = OP_FCT_MINUS; | |
| 1614 |
2/2✓ Branch 21 → 22 taken 814 times.
✓ Branch 21 → 23 taken 10056 times.
|
10870 | else if (ctx->MUL()) |
| 1615 | 814 | fctNameNode->name = OP_FCT_MUL; | |
| 1616 |
2/2✓ Branch 24 → 25 taken 218 times.
✓ Branch 24 → 26 taken 9838 times.
|
10056 | else if (ctx->DIV()) |
| 1617 | 218 | fctNameNode->name = OP_FCT_DIV; | |
| 1618 |
2/2✓ Branch 27 → 28 taken 2464 times.
✓ Branch 27 → 29 taken 7374 times.
|
9838 | else if (ctx->EQUAL()) |
| 1619 | 2464 | fctNameNode->name = OP_FCT_EQUAL; | |
| 1620 |
2/2✓ Branch 30 → 31 taken 2332 times.
✓ Branch 30 → 32 taken 5042 times.
|
7374 | else if (ctx->NOT_EQUAL()) |
| 1621 | 2332 | fctNameNode->name = OP_FCT_NOT_EQUAL; | |
| 1622 |
3/4✓ Branch 32 → 33 taken 5042 times.
✗ Branch 32 → 85 not taken.
✓ Branch 35 → 36 taken 302 times.
✓ Branch 35 → 37 taken 4740 times.
|
5042 | else if (ctx->LESS().size() == 2) |
| 1623 | 302 | fctNameNode->name = OP_FCT_SHL; | |
| 1624 |
3/4✓ Branch 37 → 38 taken 4740 times.
✗ Branch 37 → 86 not taken.
✓ Branch 40 → 41 taken 2 times.
✓ Branch 40 → 42 taken 4738 times.
|
4740 | else if (ctx->GREATER().size() == 2) |
| 1625 | 2 | fctNameNode->name = OP_FCT_SHR; | |
| 1626 |
2/2✓ Branch 43 → 44 taken 8 times.
✓ Branch 43 → 45 taken 4730 times.
|
4738 | else if (ctx->BITWISE_AND()) |
| 1627 | 8 | fctNameNode->name = OP_FCT_BITWISE_AND; | |
| 1628 |
2/2✓ Branch 46 → 47 taken 8 times.
✓ Branch 46 → 48 taken 4722 times.
|
4730 | else if (ctx->BITWISE_OR()) |
| 1629 | 8 | fctNameNode->name = OP_FCT_BITWISE_OR; | |
| 1630 |
2/2✓ Branch 49 → 50 taken 8 times.
✓ Branch 49 → 51 taken 4714 times.
|
4722 | else if (ctx->BITWISE_XOR()) |
| 1631 | 8 | fctNameNode->name = OP_FCT_BITWISE_XOR; | |
| 1632 |
2/2✓ Branch 52 → 53 taken 8 times.
✓ Branch 52 → 54 taken 4706 times.
|
4714 | else if (ctx->BITWISE_NOT()) |
| 1633 | 8 | fctNameNode->name = OP_FCT_BITWISE_NOT; | |
| 1634 |
2/2✓ Branch 55 → 56 taken 715 times.
✓ Branch 55 → 57 taken 3991 times.
|
4706 | else if (ctx->PLUS_EQUAL()) |
| 1635 | 715 | fctNameNode->name = OP_FCT_PLUS_EQUAL; | |
| 1636 |
2/2✓ Branch 58 → 59 taken 309 times.
✓ Branch 58 → 60 taken 3682 times.
|
3991 | else if (ctx->MINUS_EQUAL()) |
| 1637 | 309 | fctNameNode->name = OP_FCT_MINUS_EQUAL; | |
| 1638 |
2/2✓ Branch 61 → 62 taken 408 times.
✓ Branch 61 → 63 taken 3274 times.
|
3682 | else if (ctx->MUL_EQUAL()) |
| 1639 | 408 | fctNameNode->name = OP_FCT_MUL_EQUAL; | |
| 1640 |
2/2✓ Branch 64 → 65 taken 218 times.
✓ Branch 64 → 66 taken 3056 times.
|
3274 | else if (ctx->DIV_EQUAL()) |
| 1641 | 218 | fctNameNode->name = OP_FCT_DIV_EQUAL; | |
| 1642 |
2/2✓ Branch 67 → 68 taken 507 times.
✓ Branch 67 → 69 taken 2549 times.
|
3056 | else if (ctx->PLUS_PLUS()) |
| 1643 | 507 | fctNameNode->name = OP_FCT_POSTFIX_PLUS_PLUS; | |
| 1644 |
2/2✓ Branch 70 → 71 taken 309 times.
✓ Branch 70 → 72 taken 2240 times.
|
2549 | else if (ctx->MINUS_MINUS()) |
| 1645 | 309 | fctNameNode->name = OP_FCT_POSTFIX_MINUS_MINUS; | |
| 1646 |
2/2✓ Branch 73 → 74 taken 1111 times.
✓ Branch 73 → 75 taken 1129 times.
|
2240 | else if (ctx->LBRACKET()) |
| 1647 | 1111 | fctNameNode->name = OP_FCT_SUBSCRIPT; | |
| 1648 |
1/2✓ Branch 76 → 77 taken 1129 times.
✗ Branch 76 → 78 not taken.
|
1129 | else if (ctx->ASSIGN()) |
| 1649 | 1129 | fctNameNode->name = OP_FCT_ASSIGN; | |
| 1650 | else | ||
| 1651 | − | assert_fail("Unsupported overloadable operator"); // GCOV_EXCL_LINE | |
| 1652 | |||
| 1653 | 11282 | fctNameNode->fqName = fctNameNode->name; | |
| 1654 | 11282 | fctNameNode->nameFragments.push_back(fctNameNode->name); | |
| 1655 | |||
| 1656 |
1/2✓ Branch 81 → 82 taken 11282 times.
✗ Branch 81 → 87 not taken.
|
22564 | return nullptr; |
| 1657 | } | ||
| 1658 | |||
| 1659 | 62304 | int32_t ASTBuilder::parseInt(TerminalNode *terminal, bool isNegative) { | |
| 1660 | 186912 | const NumericParserCallback<int32_t> cb = [isNegative](const std::string &substr, short base, bool isSigned) -> int32_t { | |
| 1661 | // Prepare limits | ||
| 1662 |
2/2✓ Branch 2 → 3 taken 58140 times.
✓ Branch 2 → 4 taken 4164 times.
|
62304 | const int64_t upperLimit = isSigned ? INT32_MAX : UINT32_MAX; |
| 1663 |
2/2✓ Branch 5 → 6 taken 58140 times.
✓ Branch 5 → 7 taken 4164 times.
|
62304 | const int64_t lowerLimit = isSigned ? INT32_MIN : 0; |
| 1664 | // Parse number, apply sign and check for limits | ||
| 1665 | 62304 | int64_t number = std::stoll(substr, nullptr, base); | |
| 1666 |
2/2✓ Branch 9 → 10 taken 867 times.
✓ Branch 9 → 11 taken 61435 times.
|
62302 | if (isNegative) |
| 1667 | 867 | number = -number; | |
| 1668 |
2/4✓ Branch 11 → 12 taken 62302 times.
✗ Branch 11 → 13 not taken.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 16 taken 62302 times.
|
62302 | if (number < lowerLimit || number > upperLimit) |
| 1669 | ✗ | throw std::out_of_range("Number out of range"); | |
| 1670 | 62302 | return static_cast<int32_t>(number); | |
| 1671 | 62304 | }; | |
| 1672 |
2/2✓ Branch 3 → 4 taken 62302 times.
✓ Branch 3 → 8 taken 2 times.
|
124606 | return parseNumeric(terminal, cb); |
| 1673 | 62304 | } | |
| 1674 | |||
| 1675 | 4486 | int16_t ASTBuilder::parseShort(TerminalNode *terminal, bool isNegative) { | |
| 1676 | 13458 | const NumericParserCallback<int16_t> cb = [isNegative](const std::string &substr, short base, bool isSigned) -> int16_t { | |
| 1677 | // Prepare limits | ||
| 1678 |
2/2✓ Branch 2 → 3 taken 3104 times.
✓ Branch 2 → 4 taken 1382 times.
|
4486 | const int64_t upperLimit = isSigned ? INT16_MAX : UINT16_MAX; |
| 1679 |
2/2✓ Branch 5 → 6 taken 3104 times.
✓ Branch 5 → 7 taken 1382 times.
|
4486 | const int64_t lowerLimit = isSigned ? INT16_MIN : 0; |
| 1680 | // Parse number, apply sign and check for limits | ||
| 1681 | 4486 | int64_t number = std::stoll(substr, nullptr, base); | |
| 1682 |
2/2✓ Branch 9 → 10 taken 220 times.
✓ Branch 9 → 11 taken 4266 times.
|
4486 | if (isNegative) |
| 1683 | 220 | number = -number; | |
| 1684 |
2/4✓ Branch 11 → 12 taken 4486 times.
✗ Branch 11 → 13 not taken.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 16 taken 4486 times.
|
4486 | if (number < lowerLimit || number > upperLimit) |
| 1685 | ✗ | throw std::out_of_range("Number out of range"); | |
| 1686 | 4486 | return static_cast<int16_t>(number); | |
| 1687 | 4486 | }; | |
| 1688 |
1/2✓ Branch 3 → 4 taken 4486 times.
✗ Branch 3 → 8 not taken.
|
8972 | return parseNumeric(terminal, cb); |
| 1689 | 4486 | } | |
| 1690 | |||
| 1691 | 84027 | int64_t ASTBuilder::parseLong(TerminalNode *terminal, bool isNegative) { | |
| 1692 | 252081 | const NumericParserCallback<int64_t> cb = [isNegative](const std::string &substr, short base, bool isSigned) -> int64_t { | |
| 1693 | // Parse the magnitude as unsigned so values like 2^63 (the absolute value of INT64_MIN) fit | ||
| 1694 | 84027 | const uint64_t magnitude = std::stoull(substr, nullptr, base); | |
| 1695 |
2/2✓ Branch 3 → 4 taken 6974 times.
✓ Branch 3 → 11 taken 77053 times.
|
84027 | if (isNegative) { |
| 1696 | 6974 | constexpr uint64_t maxNegMagnitude = static_cast<uint64_t>(INT64_MAX) + 1; // 2^63 | |
| 1697 |
1/2✗ Branch 4 → 5 not taken.
✓ Branch 4 → 8 taken 6974 times.
|
6974 | if (magnitude > maxNegMagnitude) |
| 1698 | ✗ | throw std::out_of_range("Number out of range"); | |
| 1699 |
2/2✓ Branch 8 → 9 taken 52 times.
✓ Branch 8 → 10 taken 6922 times.
|
6974 | if (magnitude == maxNegMagnitude) |
| 1700 | 52 | return INT64_MIN; | |
| 1701 | 6922 | return -static_cast<int64_t>(magnitude); | |
| 1702 | } | ||
| 1703 |
3/4✓ Branch 11 → 12 taken 70191 times.
✓ Branch 11 → 16 taken 6862 times.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 16 taken 70191 times.
|
77053 | if (isSigned && magnitude > static_cast<uint64_t>(INT64_MAX)) |
| 1704 | ✗ | throw std::out_of_range("Number out of range"); | |
| 1705 | 77053 | return static_cast<int64_t>(magnitude); | |
| 1706 | 84027 | }; | |
| 1707 |
1/2✓ Branch 3 → 4 taken 84027 times.
✗ Branch 3 → 8 not taken.
|
168054 | return parseNumeric(terminal, cb); |
| 1708 | 84027 | } | |
| 1709 | |||
| 1710 | 24821 | int8_t ASTBuilder::parseChar(TerminalNode *terminal) const { | |
| 1711 |
1/2✓ Branch 2 → 3 taken 24821 times.
✗ Branch 2 → 59 not taken.
|
24821 | const std::string input = terminal->toString(); |
| 1712 |
2/2✓ Branch 4 → 5 taken 17310 times.
✓ Branch 4 → 7 taken 7511 times.
|
24821 | if (input.length() == 3) // Normal char literals |
| 1713 | 17310 | return input[1]; | |
| 1714 | |||
| 1715 |
3/6✓ Branch 8 → 9 taken 7511 times.
✗ Branch 8 → 12 not taken.
✓ Branch 10 → 11 taken 7511 times.
✗ Branch 10 → 12 not taken.
✓ Branch 13 → 14 taken 7511 times.
✗ Branch 13 → 34 not taken.
|
7511 | if (input.length() == 4 && input[1] == '\\') { // Char literals with escape sequence |
| 1716 |
10/11✓ Branch 15 → 16 taken 402 times.
✗ Branch 15 → 17 not taken.
✓ Branch 15 → 18 taken 630 times.
✓ Branch 15 → 19 taken 1042 times.
✓ Branch 15 → 20 taken 650 times.
✓ Branch 15 → 21 taken 604 times.
✓ Branch 15 → 22 taken 114 times.
✓ Branch 15 → 23 taken 132 times.
✓ Branch 15 → 24 taken 118 times.
✓ Branch 15 → 25 taken 3817 times.
✓ Branch 15 → 26 taken 2 times.
|
7511 | switch (input[2]) { |
| 1717 | 402 | case '\'': | |
| 1718 | 402 | return '\''; | |
| 1719 | ✗ | case '"': | |
| 1720 | ✗ | return '\"'; | |
| 1721 | 630 | case '\\': | |
| 1722 | 630 | return '\\'; | |
| 1723 | 1042 | case 'n': | |
| 1724 | 1042 | return '\n'; | |
| 1725 | 650 | case 'r': | |
| 1726 | 650 | return '\r'; | |
| 1727 | 604 | case 't': | |
| 1728 | 604 | return '\t'; | |
| 1729 | 114 | case 'b': | |
| 1730 | 114 | return '\b'; | |
| 1731 | 132 | case 'f': | |
| 1732 | 132 | return '\f'; | |
| 1733 | 118 | case 'v': | |
| 1734 | 118 | return '\v'; | |
| 1735 | 3817 | case '0': | |
| 1736 | 3817 | return '\0'; | |
| 1737 | 2 | default: | |
| 1738 |
2/4✓ Branch 26 → 27 taken 2 times.
✗ Branch 26 → 50 not taken.
✓ Branch 27 → 28 taken 2 times.
✗ Branch 27 → 50 not taken.
|
2 | const CodeLoc codeLoc(terminal->getSymbol(), sourceFile); |
| 1739 |
2/4✓ Branch 29 → 30 taken 2 times.
✗ Branch 29 → 47 not taken.
✓ Branch 30 → 31 taken 2 times.
✗ Branch 30 → 44 not taken.
|
2 | throw ParserError(codeLoc, INVALID_CHAR_LITERAL, "Invalid escape sequence " + input); |
| 1740 | } | ||
| 1741 | } | ||
| 1742 | |||
| 1743 | ✗ | const CodeLoc codeLoc(terminal->getSymbol(), sourceFile); | |
| 1744 | ✗ | throw ParserError(codeLoc, INVALID_CHAR_LITERAL, "Invalid char literal " + input); | |
| 1745 | 24821 | } | |
| 1746 | |||
| 1747 | 135433 | std::string ASTBuilder::parseString(std::string input) { | |
| 1748 |
1/2✓ Branch 3 → 4 taken 135433 times.
✗ Branch 3 → 9 not taken.
|
135433 | input = input.substr(1, input.size() - 2); |
| 1749 | 135433 | replaceEscapeChars(input); | |
| 1750 | 135433 | return input; | |
| 1751 | } | ||
| 1752 | |||
| 1753 | 150817 | template <typename T> T ASTBuilder::parseNumeric(TerminalNode *terminal, const NumericParserCallback<T> &cb) { | |
| 1754 |
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 62304 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 84027 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 4486 times.
✗ Branch 2 → 87 not taken.
|
150817 | const std::string input = terminal->toString(); |
| 1755 | |||
| 1756 | // Set to signed if the input string does not end with 'u' | ||
| 1757 |
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 58140 times.
✓ Branch 4 → 9 taken 4164 times.
✓ Branch 6 → 7 taken 58140 times.
✗ Branch 6 → 9 not taken.
✗ Branch 8 → 9 not taken.
✓ Branch 8 → 10 taken 58140 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 84027 times.
✗ Branch 4 → 9 not taken.
✓ Branch 6 → 7 taken 84027 times.
✗ Branch 6 → 9 not taken.
✓ Branch 8 → 9 taken 6862 times.
✓ Branch 8 → 10 taken 77165 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 4486 times.
✗ Branch 4 → 9 not taken.
✓ Branch 6 → 7 taken 3104 times.
✓ Branch 6 → 9 taken 1382 times.
✗ Branch 8 → 9 not taken.
✓ Branch 8 → 10 taken 3104 times.
|
150817 | const bool isUnsigned = input.ends_with('u') || input.ends_with("us") || input.ends_with("ul"); |
| 1758 | |||
| 1759 | try { | ||
| 1760 |
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 7450 times.
✓ Branch 12 → 30 taken 54854 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 11721 times.
✓ Branch 12 → 30 taken 72306 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 3084 times.
✓ Branch 12 → 30 taken 1402 times.
|
150817 | if (input.length() >= 3) { |
| 1761 |
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 3336 times.
✓ Branch 14 → 30 taken 4114 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 4061 times.
✓ Branch 14 → 30 taken 7660 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 964 times.
✓ Branch 14 → 30 taken 2120 times.
|
22255 | if (input[0] == '0') { |
| 1762 |
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 3336 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 4061 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 964 times.
✗ Branch 15 → 37 not taken.
|
8361 | const std::string subStr = input.substr(2); |
| 1763 |
6/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 taken 746 times.
✓ Branch 17 → 24 taken 2590 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 866 times.
✗ Branch 17 → 24 not taken.
✓ Branch 17 → 26 taken 3195 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 960 times.
✓ Branch 17 → 26 taken 4 times.
|
8361 | switch (input[1]) { |
| 1764 | ✗ | case 'd': // fall-through | |
| 1765 | case 'D': | ||
| 1766 | ✗ | return cb(subStr, 10, !isUnsigned); | |
| 1767 | ✗ | case 'b': // fall-through | |
| 1768 | case 'B': | ||
| 1769 | ✗ | return cb(subStr, 2, !isUnsigned); | |
| 1770 | 1612 | case 'h': // fall-through | |
| 1771 | case 'H': // fall-through | ||
| 1772 | case 'x': // fall-through | ||
| 1773 | case 'X': | ||
| 1774 |
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 22 → 23 taken 746 times.
✗ 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 866 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.
|
1612 | return cb(subStr, 16, !isUnsigned); |
| 1775 | 3550 | case 'o': // fall-through | |
| 1776 | case 'O': | ||
| 1777 |
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 2590 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 960 times.
✗ Branch 24 → 35 not taken.
|
3550 | return cb(subStr, 8, !isUnsigned); |
| 1778 | 3199 | default: // default is decimal | |
| 1779 |
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 3195 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 4 times.
✗ Branch 26 → 35 not taken.
|
3199 | return cb(input, 10, !isUnsigned); |
| 1780 | } | ||
| 1781 | 8361 | } | |
| 1782 | } | ||
| 1783 |
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 58966 times.
✓ Branch 30 → 38 taken 2 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 30 → 31 taken 79966 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 3522 times.
✗ Branch 30 → 38 not taken.
|
142456 | return cb(input, 10, !isUnsigned); |
| 1784 |
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 2 times.
✗ 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.
|
4 | } catch (std::out_of_range &) { |
| 1785 |
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 2 times.
✗ Branch 41 → 70 not taken.
✓ Branch 42 → 43 taken 2 times.
✗ 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.
|
2 | const CodeLoc codeLoc(terminal->getSymbol(), sourceFile); |
| 1786 |
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 2 times.
✗ Branch 46 → 64 not taken.
✓ Branch 47 → 48 taken 2 times.
✗ 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.
|
6 | throw ParserError(codeLoc, NUMBER_OUT_OF_RANGE, "The provided number is out of range"); |
| 1787 | ✗ | } catch (std::invalid_argument &) { | |
| 1788 | ✗ | const CodeLoc codeLoc(terminal->getSymbol(), sourceFile); | |
| 1789 | ✗ | throw ParserError(codeLoc, NUMBER_OUT_OF_RANGE, "You tried to parse '" + input + "' as an integer, but it was no integer"); | |
| 1790 | } | ||
| 1791 | 150817 | } | |
| 1792 | |||
| 1793 | 135433 | void ASTBuilder::replaceEscapeChars(std::string &input) { | |
| 1794 | 135433 | const std::unordered_map<char, char> escapeMap = { | |
| 1795 | {'a', '\a'}, {'b', '\b'}, {'f', '\f'}, {'n', '\n'}, {'r', '\r'}, {'t', '\t'}, | ||
| 1796 | {'v', '\v'}, {'\\', '\\'}, {'?', '\?'}, {'\'', '\''}, {'"', '\"'}, | ||
| 1797 |
1/2✓ Branch 4 → 5 taken 135433 times.
✗ Branch 4 → 40 not taken.
|
270866 | }; |
| 1798 | |||
| 1799 | 135433 | size_t writeIndex = 0; | |
| 1800 | 135433 | size_t readIndex = 0; | |
| 1801 | 135433 | const size_t len = input.length(); | |
| 1802 | |||
| 1803 |
2/2✓ Branch 36 → 8 taken 2110215 times.
✓ Branch 36 → 37 taken 135433 times.
|
2245648 | while (readIndex < len) { |
| 1804 | 2110215 | const char c = input[readIndex]; | |
| 1805 |
3/4✓ Branch 9 → 10 taken 10701 times.
✓ Branch 9 → 33 taken 2099514 times.
✓ Branch 10 → 11 taken 10701 times.
✗ Branch 10 → 33 not taken.
|
2110215 | if (c == '\\' && readIndex + 1 < len) { |
| 1806 | 10701 | char next = input[readIndex + 1]; | |
| 1807 |
1/2✓ Branch 12 → 13 taken 10701 times.
✗ Branch 12 → 45 not taken.
|
10701 | auto it = escapeMap.find(next); |
| 1808 |
2/2✓ Branch 15 → 16 taken 10513 times.
✓ Branch 15 → 19 taken 188 times.
|
10701 | if (it != escapeMap.end()) { |
| 1809 | 10513 | input[writeIndex++] = it->second; | |
| 1810 | 10513 | readIndex += 2; | |
| 1811 | 10695 | continue; | |
| 1812 | } | ||
| 1813 | |||
| 1814 | // Handle octal escape sequences (up to 3 digits) | ||
| 1815 |
3/4✓ Branch 19 → 20 taken 188 times.
✗ Branch 19 → 31 not taken.
✓ Branch 20 → 21 taken 182 times.
✓ Branch 20 → 31 taken 6 times.
|
188 | if (next >= '0' && next <= '7') { |
| 1816 | 182 | int value = 0; | |
| 1817 | 182 | size_t octalDigits = 0; | |
| 1818 | |||
| 1819 | // Look ahead up to 3 digits | ||
| 1820 |
3/4✓ Branch 26 → 27 taken 546 times.
✓ Branch 26 → 28 taken 182 times.
✓ Branch 27 → 22 taken 546 times.
✗ Branch 27 → 28 not taken.
|
728 | for (size_t i = 1; i <= 3 && readIndex + i < len; ++i) { |
| 1821 | 546 | const char oc = input[readIndex + i]; | |
| 1822 |
2/4✓ Branch 23 → 24 taken 546 times.
✗ Branch 23 → 28 not taken.
✓ Branch 24 → 25 taken 546 times.
✗ Branch 24 → 28 not taken.
|
546 | if (oc >= '0' && oc <= '7') { |
| 1823 | 546 | value = value << 3 | (oc - '0'); // multiply by 8 and add digit | |
| 1824 | 546 | octalDigits++; | |
| 1825 | } else { | ||
| 1826 | break; | ||
| 1827 | } | ||
| 1828 | } | ||
| 1829 | |||
| 1830 |
1/2✓ Branch 28 → 29 taken 182 times.
✗ Branch 28 → 31 not taken.
|
182 | if (octalDigits > 0) { |
| 1831 | 182 | input[writeIndex++] = static_cast<char>(value); | |
| 1832 | 182 | readIndex += 1 + octalDigits; // backslash + octal digits | |
| 1833 | 182 | continue; | |
| 1834 | } | ||
| 1835 | } | ||
| 1836 | } | ||
| 1837 | |||
| 1838 | // Copy current character | ||
| 1839 | 2099520 | input[writeIndex++] = c; | |
| 1840 | 2099520 | readIndex++; | |
| 1841 | } | ||
| 1842 | |||
| 1843 |
1/2✓ Branch 37 → 38 taken 135433 times.
✗ Branch 37 → 46 not taken.
|
135433 | input.resize(writeIndex); |
| 1844 | 135433 | } | |
| 1845 | |||
| 1846 | 2697516 | std::string ASTBuilder::getIdentifier(TerminalNode *terminal, bool isTypeIdentifier) const { | |
| 1847 | 2697516 | const std::string identifier = terminal->getText(); | |
| 1848 | |||
| 1849 | // Check if the list of reserved keywords contains the given identifier | ||
| 1850 |
3/4✓ Branch 3 → 4 taken 2697516 times.
✗ Branch 3 → 52 not taken.
✓ Branch 4 → 5 taken 2 times.
✓ Branch 4 → 14 taken 2697514 times.
|
2697516 | if (std::ranges::find(RESERVED_KEYWORDS, identifier) != std::end(RESERVED_KEYWORDS)) { |
| 1851 |
2/4✓ Branch 5 → 6 taken 2 times.
✗ Branch 5 → 41 not taken.
✓ Branch 6 → 7 taken 2 times.
✗ Branch 6 → 41 not taken.
|
2 | const CodeLoc codeLoc(terminal->getSymbol(), sourceFile); |
| 1852 |
3/6✓ Branch 8 → 9 taken 2 times.
✗ Branch 8 → 37 not taken.
✓ Branch 9 → 10 taken 2 times.
✗ Branch 9 → 35 not taken.
✓ Branch 10 → 11 taken 2 times.
✗ Branch 10 → 32 not taken.
|
2 | throw ParserError(codeLoc, RESERVED_KEYWORD, "'" + identifier + "' is a reserved keyword. Please use another name instead"); |
| 1853 | } | ||
| 1854 | |||
| 1855 | // Check if the identifier is a type identifier and is reserved | ||
| 1856 |
6/6✓ Branch 14 → 15 taken 180720 times.
✓ Branch 14 → 19 taken 2516794 times.
✓ Branch 15 → 16 taken 86852 times.
✓ Branch 15 → 19 taken 93868 times.
✓ Branch 20 → 21 taken 2 times.
✓ Branch 20 → 30 taken 2697512 times.
|
2784366 | if (isTypeIdentifier && !sourceFile->isStdFile && |
| 1857 |
3/4✓ Branch 16 → 17 taken 86852 times.
✗ Branch 16 → 52 not taken.
✓ Branch 17 → 18 taken 2 times.
✓ Branch 17 → 19 taken 86850 times.
|
86852 | std::ranges::find(RESERVED_TYPE_NAMES, identifier) != std::end(RESERVED_TYPE_NAMES)) { |
| 1858 |
2/4✓ Branch 21 → 22 taken 2 times.
✗ Branch 21 → 51 not taken.
✓ Branch 22 → 23 taken 2 times.
✗ Branch 22 → 51 not taken.
|
2 | const CodeLoc codeLoc(terminal->getSymbol(), sourceFile); |
| 1859 |
3/6✓ Branch 24 → 25 taken 2 times.
✗ Branch 24 → 47 not taken.
✓ Branch 25 → 26 taken 2 times.
✗ Branch 25 → 45 not taken.
✓ Branch 26 → 27 taken 2 times.
✗ Branch 26 → 42 not taken.
|
2 | throw ParserError(codeLoc, RESERVED_TYPENAME, "'" + identifier + "' is a reserved type name. Please use another one instead"); |
| 1860 | } | ||
| 1861 | |||
| 1862 | 2697512 | return identifier; | |
| 1863 | 4 | } | |
| 1864 | |||
| 1865 | } // namespace spice::compiler | ||
| 1866 |