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 | 2418 | ASTBuilder::ASTBuilder(GlobalResourceManager &resourceManager, SourceFile *sourceFile, antlr4::ANTLRInputStream *inputStream) | |
| 17 |
1/2✓ Branch 4 → 5 taken 2418 times.
✗ Branch 4 → 6 not taken.
|
2418 | : CompilerPass(resourceManager, sourceFile), inputStream(inputStream) {} |
| 18 | |||
| 19 | 2416 | std::any ASTBuilder::visitEntry(SpiceParser::EntryContext *ctx) { | |
| 20 | 2416 | const auto entryNode = createNode<EntryNode>(ctx); | |
| 21 | |||
| 22 | // Visit children | ||
| 23 |
2/2✓ Branch 144 → 5 taken 47899 times.
✓ Branch 144 → 145 taken 2410 times.
|
52725 | for (ParserRuleContext::ParseTree *child : ctx->children) { |
| 24 |
3/4✓ Branch 7 → 8 taken 47899 times.
✗ Branch 7 → 9 not taken.
✓ Branch 10 → 11 taken 543 times.
✓ Branch 10 → 16 taken 47356 times.
|
47899 | if (auto *mainFctDefCtx = dynamic_cast<SpiceParser::MainFunctionDefContext *>(child)) |
| 25 |
4/6✓ Branch 11 → 12 taken 539 times.
✓ Branch 11 → 157 taken 4 times.
✓ Branch 12 → 13 taken 539 times.
✗ Branch 12 → 155 not taken.
✓ Branch 13 → 14 taken 539 times.
✗ Branch 13 → 155 not taken.
|
543 | entryNode->topLevelDefs.push_back(std::any_cast<MainFctDefNode *>(visit(mainFctDefCtx))); |
| 26 |
3/4✓ Branch 16 → 17 taken 47356 times.
✗ Branch 16 → 18 not taken.
✓ Branch 19 → 20 taken 19951 times.
✓ Branch 19 → 25 taken 27405 times.
|
47356 | else if (auto *fctDefCtx = dynamic_cast<SpiceParser::FunctionDefContext *>(child)) |
| 27 |
3/6✓ Branch 20 → 21 taken 19951 times.
✗ Branch 20 → 161 not taken.
✓ Branch 21 → 22 taken 19951 times.
✗ Branch 21 → 159 not taken.
✓ Branch 22 → 23 taken 19951 times.
✗ Branch 22 → 159 not taken.
|
19951 | entryNode->topLevelDefs.push_back(std::any_cast<FctDefNode *>(visit(fctDefCtx))); |
| 28 |
3/4✓ Branch 25 → 26 taken 27405 times.
✗ Branch 25 → 27 not taken.
✓ Branch 28 → 29 taken 10600 times.
✓ Branch 28 → 34 taken 16805 times.
|
27405 | else if (auto *procDefCtx = dynamic_cast<SpiceParser::ProcedureDefContext *>(child)) |
| 29 |
3/6✓ Branch 29 → 30 taken 10600 times.
✗ Branch 29 → 165 not taken.
✓ Branch 30 → 31 taken 10600 times.
✗ Branch 30 → 163 not taken.
✓ Branch 31 → 32 taken 10600 times.
✗ Branch 31 → 163 not taken.
|
10600 | entryNode->topLevelDefs.push_back(std::any_cast<ProcDefNode *>(visit(procDefCtx))); |
| 30 |
3/4✓ Branch 34 → 35 taken 16805 times.
✗ Branch 34 → 36 not taken.
✓ Branch 37 → 38 taken 2813 times.
✓ Branch 37 → 43 taken 13992 times.
|
16805 | else if (auto *structDefCtx = dynamic_cast<SpiceParser::StructDefContext *>(child)) |
| 31 |
4/6✓ Branch 38 → 39 taken 2812 times.
✓ Branch 38 → 169 taken 1 time.
✓ Branch 39 → 40 taken 2812 times.
✗ Branch 39 → 167 not taken.
✓ Branch 40 → 41 taken 2812 times.
✗ Branch 40 → 167 not taken.
|
2813 | entryNode->topLevelDefs.push_back(std::any_cast<StructDefNode *>(visit(structDefCtx))); |
| 32 |
3/4✓ Branch 43 → 44 taken 13992 times.
✗ Branch 43 → 45 not taken.
✓ Branch 46 → 47 taken 366 times.
✓ Branch 46 → 52 taken 13626 times.
|
13992 | else if (auto *interfaceDefCtx = dynamic_cast<SpiceParser::InterfaceDefContext *>(child)) |
| 33 |
3/6✓ Branch 47 → 48 taken 366 times.
✗ Branch 47 → 173 not taken.
✓ Branch 48 → 49 taken 366 times.
✗ Branch 48 → 171 not taken.
✓ Branch 49 → 50 taken 366 times.
✗ Branch 49 → 171 not taken.
|
366 | entryNode->topLevelDefs.push_back(std::any_cast<InterfaceDefNode *>(visit(interfaceDefCtx))); |
| 34 |
3/4✓ Branch 52 → 53 taken 13626 times.
✗ Branch 52 → 54 not taken.
✓ Branch 55 → 56 taken 369 times.
✓ Branch 55 → 61 taken 13257 times.
|
13626 | else if (auto *enumDefCtx = dynamic_cast<SpiceParser::EnumDefContext *>(child)) |
| 35 |
3/6✓ Branch 56 → 57 taken 369 times.
✗ Branch 56 → 177 not taken.
✓ Branch 57 → 58 taken 369 times.
✗ Branch 57 → 175 not taken.
✓ Branch 58 → 59 taken 369 times.
✗ Branch 58 → 175 not taken.
|
369 | entryNode->topLevelDefs.push_back(std::any_cast<EnumDefNode *>(visit(enumDefCtx))); |
| 36 |
3/4✓ Branch 61 → 62 taken 13257 times.
✗ Branch 61 → 63 not taken.
✓ Branch 64 → 65 taken 1929 times.
✓ Branch 64 → 70 taken 11328 times.
|
13257 | else if (auto *genericTypeDefCtx = dynamic_cast<SpiceParser::GenericTypeDefContext *>(child)) |
| 37 |
3/6✓ Branch 65 → 66 taken 1929 times.
✗ Branch 65 → 181 not taken.
✓ Branch 66 → 67 taken 1929 times.
✗ Branch 66 → 179 not taken.
✓ Branch 67 → 68 taken 1929 times.
✗ Branch 67 → 179 not taken.
|
1929 | entryNode->topLevelDefs.push_back(std::any_cast<GenericTypeDefNode *>(visit(genericTypeDefCtx))); |
| 38 |
3/4✓ Branch 70 → 71 taken 11328 times.
✗ Branch 70 → 72 not taken.
✓ Branch 73 → 74 taken 342 times.
✓ Branch 73 → 79 taken 10986 times.
|
11328 | else if (auto *aliasDefCtx = dynamic_cast<SpiceParser::AliasDefContext *>(child)) |
| 39 |
3/6✓ Branch 74 → 75 taken 342 times.
✗ Branch 74 → 185 not taken.
✓ Branch 75 → 76 taken 342 times.
✗ Branch 75 → 183 not taken.
✓ Branch 76 → 77 taken 342 times.
✗ Branch 76 → 183 not taken.
|
342 | entryNode->topLevelDefs.push_back(std::any_cast<AliasDefNode *>(visit(aliasDefCtx))); |
| 40 |
3/4✓ Branch 79 → 80 taken 10986 times.
✗ Branch 79 → 81 not taken.
✓ Branch 82 → 83 taken 2380 times.
✓ Branch 82 → 88 taken 8606 times.
|
10986 | else if (auto *globalVarDefCtx = dynamic_cast<SpiceParser::GlobalVarDefContext *>(child)) |
| 41 |
3/6✓ Branch 83 → 84 taken 2380 times.
✗ Branch 83 → 189 not taken.
✓ Branch 84 → 85 taken 2380 times.
✗ Branch 84 → 187 not taken.
✓ Branch 85 → 86 taken 2380 times.
✗ Branch 85 → 187 not taken.
|
2380 | entryNode->topLevelDefs.push_back(std::any_cast<GlobalVarDefNode *>(visit(globalVarDefCtx))); |
| 42 |
3/4✓ Branch 88 → 89 taken 8606 times.
✗ Branch 88 → 90 not taken.
✓ Branch 91 → 92 taken 2542 times.
✓ Branch 91 → 97 taken 6064 times.
|
8606 | else if (auto *importDefCtx = dynamic_cast<SpiceParser::ImportDefContext *>(child)) |
| 43 |
3/6✓ Branch 92 → 93 taken 2542 times.
✗ Branch 92 → 193 not taken.
✓ Branch 93 → 94 taken 2542 times.
✗ Branch 93 → 191 not taken.
✓ Branch 94 → 95 taken 2542 times.
✗ Branch 94 → 191 not taken.
|
2542 | entryNode->importDefs.push_back(std::any_cast<ImportDefNode *>(visit(importDefCtx))); |
| 44 |
3/4✓ Branch 97 → 98 taken 6064 times.
✗ Branch 97 → 99 not taken.
✓ Branch 100 → 101 taken 2963 times.
✓ Branch 100 → 106 taken 3101 times.
|
6064 | else if (auto *extDeclCtx = dynamic_cast<SpiceParser::ExtDeclContext *>(child)) |
| 45 |
3/6✓ Branch 101 → 102 taken 2963 times.
✗ Branch 101 → 197 not taken.
✓ Branch 102 → 103 taken 2963 times.
✗ Branch 102 → 195 not taken.
✓ Branch 103 → 104 taken 2963 times.
✗ Branch 103 → 195 not taken.
|
2963 | entryNode->topLevelDefs.push_back(std::any_cast<ExtDeclNode *>(visit(extDeclCtx))); |
| 46 |
3/4✓ Branch 106 → 107 taken 3101 times.
✗ Branch 106 → 108 not taken.
✓ Branch 109 → 110 taken 7 times.
✓ Branch 109 → 115 taken 3094 times.
|
3101 | else if (auto *fwdDeclCtx = dynamic_cast<SpiceParser::ForwardDeclContext *>(child)) |
| 47 |
3/6✓ Branch 110 → 111 taken 7 times.
✗ Branch 110 → 201 not taken.
✓ Branch 111 → 112 taken 7 times.
✗ Branch 111 → 199 not taken.
✓ Branch 112 → 113 taken 7 times.
✗ Branch 112 → 199 not taken.
|
7 | entryNode->topLevelDefs.push_back(std::any_cast<ForwardDeclNode *>(visit(fwdDeclCtx))); |
| 48 |
3/4✓ Branch 115 → 116 taken 3094 times.
✗ Branch 115 → 117 not taken.
✓ Branch 118 → 119 taken 684 times.
✓ Branch 118 → 124 taken 2410 times.
|
3094 | else if (auto *modAttrCtx = dynamic_cast<SpiceParser::ModAttrContext *>(child)) |
| 49 |
4/6✓ Branch 119 → 120 taken 683 times.
✓ Branch 119 → 205 taken 1 time.
✓ Branch 120 → 121 taken 683 times.
✗ Branch 120 → 203 not taken.
✓ Branch 121 → 122 taken 683 times.
✗ Branch 121 → 203 not taken.
|
684 | entryNode->modAttrs.push_back(std::any_cast<ModAttrNode *>(visit(modAttrCtx))); |
| 50 |
1/2✓ Branch 124 → 125 taken 2410 times.
✗ Branch 124 → 126 not taken.
|
2410 | else if (const auto *eofCtx = dynamic_cast<TerminalNode *>(child); |
| 51 |
5/10✓ Branch 127 → 128 taken 2410 times.
✗ Branch 127 → 131 not taken.
✓ Branch 128 → 129 taken 2410 times.
✗ Branch 128 → 207 not taken.
✓ Branch 129 → 130 taken 2410 times.
✗ Branch 129 → 207 not taken.
✗ Branch 130 → 131 not taken.
✓ Branch 130 → 132 taken 2410 times.
✗ Branch 133 → 134 not taken.
✓ Branch 133 → 135 taken 2410 times.
|
2410 | !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 2410 times.
✗ Branch 151 → 208 not taken.
|
4820 | return concludeNode(entryNode); |
| 56 | } | ||
| 57 | |||
| 58 | 543 | std::any ASTBuilder::visitMainFunctionDef(SpiceParser::MainFunctionDefContext *ctx) { | |
| 59 | 543 | const auto mainFctDefNode = createNode<MainFctDefNode>(ctx); | |
| 60 | |||
| 61 | // Visit children | ||
| 62 |
2/2✓ Branch 4 → 5 taken 1 time.
✓ Branch 4 → 10 taken 542 times.
|
543 | if (ctx->topLevelDefAttr()) |
| 63 |
3/6✓ Branch 5 → 6 taken 1 time.
✗ Branch 5 → 33 not taken.
✓ Branch 6 → 7 taken 1 time.
✗ Branch 6 → 33 not taken.
✓ Branch 7 → 8 taken 1 time.
✗ Branch 7 → 31 not taken.
|
1 | mainFctDefNode->attrs = std::any_cast<TopLevelDefAttrNode *>(visit(ctx->topLevelDefAttr())); |
| 64 |
2/2✓ Branch 11 → 12 taken 7 times.
✓ Branch 11 → 17 taken 536 times.
|
543 | if (ctx->paramLst()) { |
| 65 | 7 | mainFctDefNode->takesArgs = true; | |
| 66 |
3/6✓ Branch 12 → 13 taken 7 times.
✗ Branch 12 → 36 not taken.
✓ Branch 13 → 14 taken 7 times.
✗ Branch 13 → 36 not taken.
✓ Branch 14 → 15 taken 7 times.
✗ Branch 14 → 34 not taken.
|
7 | mainFctDefNode->paramLst = std::any_cast<ParamLstNode *>(visit(ctx->paramLst())); |
| 67 | } | ||
| 68 |
5/8✓ Branch 17 → 18 taken 543 times.
✗ Branch 17 → 39 not taken.
✓ Branch 18 → 19 taken 539 times.
✓ Branch 18 → 39 taken 4 times.
✓ Branch 19 → 20 taken 539 times.
✗ Branch 19 → 37 not taken.
✓ Branch 21 → 22 taken 539 times.
✗ Branch 21 → 40 not taken.
|
543 | mainFctDefNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 69 | |||
| 70 |
1/2✓ Branch 27 → 28 taken 539 times.
✗ Branch 27 → 40 not taken.
|
1078 | return concludeNode(mainFctDefNode); |
| 71 | } | ||
| 72 | |||
| 73 | 19951 | std::any ASTBuilder::visitFunctionDef(SpiceParser::FunctionDefContext *ctx) { | |
| 74 | 19951 | const auto fctDefNode = createNode<FctDefNode>(ctx); | |
| 75 | |||
| 76 | // Visit children | ||
| 77 |
2/2✓ Branch 4 → 5 taken 692 times.
✓ Branch 4 → 24 taken 19259 times.
|
19951 | if (ctx->topLevelDefAttr()) { |
| 78 |
3/6✓ Branch 5 → 6 taken 692 times.
✗ Branch 5 → 70 not taken.
✓ Branch 6 → 7 taken 692 times.
✗ Branch 6 → 70 not taken.
✓ Branch 7 → 8 taken 692 times.
✗ Branch 7 → 68 not taken.
|
692 | 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 792 times.
✓ Branch 22 → 23 taken 692 times.
|
2176 | for (AttrNode *attr : fctDefNode->attrs->attrLst->attributes) |
| 81 | 792 | attr->target = AttrNode::TARGET_FCT_PROC; | |
| 82 | } | ||
| 83 |
2/2✓ Branch 25 → 26 taken 19326 times.
✓ Branch 25 → 31 taken 625 times.
|
19951 | if (ctx->qualifierLst()) |
| 84 |
3/6✓ Branch 26 → 27 taken 19326 times.
✗ Branch 26 → 73 not taken.
✓ Branch 27 → 28 taken 19326 times.
✗ Branch 27 → 73 not taken.
✓ Branch 28 → 29 taken 19326 times.
✗ Branch 28 → 71 not taken.
|
19326 | fctDefNode->qualifierLst = std::any_cast<QualifierLstNode *>(visit(ctx->qualifierLst())); |
| 85 |
3/6✓ Branch 31 → 32 taken 19951 times.
✗ Branch 31 → 76 not taken.
✓ Branch 32 → 33 taken 19951 times.
✗ Branch 32 → 76 not taken.
✓ Branch 33 → 34 taken 19951 times.
✗ Branch 33 → 74 not taken.
|
19951 | fctDefNode->returnType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 86 | 19951 | fctDefNode->returnType->isReturnType = true; | |
| 87 |
3/6✓ Branch 35 → 36 taken 19951 times.
✗ Branch 35 → 79 not taken.
✓ Branch 36 → 37 taken 19951 times.
✗ Branch 36 → 79 not taken.
✓ Branch 37 → 38 taken 19951 times.
✗ Branch 37 → 77 not taken.
|
19951 | fctDefNode->name = std::any_cast<FctNameNode *>(visit(ctx->fctName())); |
| 88 | 19951 | fctDefNode->isMethod = fctDefNode->name->nameFragments.size() > 1; | |
| 89 |
2/2✓ Branch 41 → 42 taken 2084 times.
✓ Branch 41 → 47 taken 17867 times.
|
19951 | if (ctx->typeLst()) { |
| 90 | 2084 | fctDefNode->hasTemplateTypes = true; | |
| 91 |
3/6✓ Branch 42 → 43 taken 2084 times.
✗ Branch 42 → 82 not taken.
✓ Branch 43 → 44 taken 2084 times.
✗ Branch 43 → 82 not taken.
✓ Branch 44 → 45 taken 2084 times.
✗ Branch 44 → 80 not taken.
|
2084 | fctDefNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst())); |
| 92 | } | ||
| 93 |
2/2✓ Branch 48 → 49 taken 14757 times.
✓ Branch 48 → 54 taken 5194 times.
|
19951 | if (ctx->paramLst()) { |
| 94 | 14757 | fctDefNode->hasParams = true; | |
| 95 |
3/6✓ Branch 49 → 50 taken 14757 times.
✗ Branch 49 → 85 not taken.
✓ Branch 50 → 51 taken 14757 times.
✗ Branch 50 → 85 not taken.
✓ Branch 51 → 52 taken 14757 times.
✗ Branch 51 → 83 not taken.
|
14757 | fctDefNode->paramLst = std::any_cast<ParamLstNode *>(visit(ctx->paramLst())); |
| 96 | } | ||
| 97 |
4/8✓ Branch 54 → 55 taken 19951 times.
✗ Branch 54 → 88 not taken.
✓ Branch 55 → 56 taken 19951 times.
✗ Branch 55 → 88 not taken.
✓ Branch 56 → 57 taken 19951 times.
✗ Branch 56 → 86 not taken.
✓ Branch 58 → 59 taken 19951 times.
✗ Branch 58 → 89 not taken.
|
19951 | fctDefNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 98 | |||
| 99 |
1/2✓ Branch 64 → 65 taken 19951 times.
✗ Branch 64 → 89 not taken.
|
39902 | return concludeNode(fctDefNode); |
| 100 | } | ||
| 101 | |||
| 102 | 10600 | std::any ASTBuilder::visitProcedureDef(SpiceParser::ProcedureDefContext *ctx) { | |
| 103 | 10600 | const auto procDefNode = createNode<ProcDefNode>(ctx); | |
| 104 | |||
| 105 | // Visit children | ||
| 106 |
2/2✓ Branch 4 → 5 taken 1 time.
✓ Branch 4 → 24 taken 10599 times.
|
10600 | if (ctx->topLevelDefAttr()) { |
| 107 |
3/6✓ Branch 5 → 6 taken 1 time.
✗ Branch 5 → 66 not taken.
✓ Branch 6 → 7 taken 1 time.
✗ Branch 6 → 66 not taken.
✓ Branch 7 → 8 taken 1 time.
✗ Branch 7 → 64 not taken.
|
1 | 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 1 time.
✓ Branch 22 → 23 taken 1 time.
|
3 | for (AttrNode *attr : procDefNode->attrs->attrLst->attributes) |
| 110 | 1 | attr->target = AttrNode::TARGET_FCT_PROC; | |
| 111 | } | ||
| 112 |
2/2✓ Branch 25 → 26 taken 9580 times.
✓ Branch 25 → 31 taken 1020 times.
|
10600 | if (ctx->qualifierLst()) |
| 113 |
3/6✓ Branch 26 → 27 taken 9580 times.
✗ Branch 26 → 69 not taken.
✓ Branch 27 → 28 taken 9580 times.
✗ Branch 27 → 69 not taken.
✓ Branch 28 → 29 taken 9580 times.
✗ Branch 28 → 67 not taken.
|
9580 | procDefNode->qualifierLst = std::any_cast<QualifierLstNode *>(visit(ctx->qualifierLst())); |
| 114 |
3/6✓ Branch 31 → 32 taken 10600 times.
✗ Branch 31 → 72 not taken.
✓ Branch 32 → 33 taken 10600 times.
✗ Branch 32 → 72 not taken.
✓ Branch 33 → 34 taken 10600 times.
✗ Branch 33 → 70 not taken.
|
10600 | procDefNode->name = std::any_cast<FctNameNode *>(visit(ctx->fctName())); |
| 115 | 10600 | procDefNode->isMethod = procDefNode->name->nameFragments.size() > 1; | |
| 116 |
2/2✓ Branch 37 → 38 taken 2257 times.
✓ Branch 37 → 43 taken 8343 times.
|
10600 | if (ctx->typeLst()) { |
| 117 | 2257 | procDefNode->hasTemplateTypes = true; | |
| 118 |
3/6✓ Branch 38 → 39 taken 2257 times.
✗ Branch 38 → 75 not taken.
✓ Branch 39 → 40 taken 2257 times.
✗ Branch 39 → 75 not taken.
✓ Branch 40 → 41 taken 2257 times.
✗ Branch 40 → 73 not taken.
|
2257 | procDefNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst())); |
| 119 | } | ||
| 120 |
2/2✓ Branch 44 → 45 taken 8180 times.
✓ Branch 44 → 50 taken 2420 times.
|
10600 | if (ctx->paramLst()) { |
| 121 | 8180 | procDefNode->hasParams = true; | |
| 122 |
3/6✓ Branch 45 → 46 taken 8180 times.
✗ Branch 45 → 78 not taken.
✓ Branch 46 → 47 taken 8180 times.
✗ Branch 46 → 78 not taken.
✓ Branch 47 → 48 taken 8180 times.
✗ Branch 47 → 76 not taken.
|
8180 | procDefNode->paramLst = std::any_cast<ParamLstNode *>(visit(ctx->paramLst())); |
| 123 | } | ||
| 124 |
4/8✓ Branch 50 → 51 taken 10600 times.
✗ Branch 50 → 81 not taken.
✓ Branch 51 → 52 taken 10600 times.
✗ Branch 51 → 81 not taken.
✓ Branch 52 → 53 taken 10600 times.
✗ Branch 52 → 79 not taken.
✓ Branch 54 → 55 taken 10600 times.
✗ Branch 54 → 82 not taken.
|
10600 | procDefNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 125 | |||
| 126 |
1/2✓ Branch 60 → 61 taken 10600 times.
✗ Branch 60 → 82 not taken.
|
21200 | return concludeNode(procDefNode); |
| 127 | } | ||
| 128 | |||
| 129 | 30551 | std::any ASTBuilder::visitFctName(SpiceParser::FctNameContext *ctx) { | |
| 130 |
1/2✓ Branch 2 → 3 taken 30551 times.
✗ Branch 2 → 54 not taken.
|
30551 | const auto fctNameNode = createNode<FctNameNode>(ctx); |
| 131 | |||
| 132 | // Extract function name | ||
| 133 |
1/2✓ Branch 3 → 4 taken 30551 times.
✗ Branch 3 → 54 not taken.
|
30551 | std::stringstream fqName; |
| 134 |
3/4✓ Branch 4 → 5 taken 30551 times.
✗ Branch 4 → 52 not taken.
✓ Branch 5 → 6 taken 18759 times.
✓ Branch 5 → 14 taken 11792 times.
|
30551 | if (ctx->TYPE_IDENTIFIER()) { |
| 135 |
2/4✓ Branch 6 → 7 taken 18759 times.
✗ Branch 6 → 45 not taken.
✓ Branch 7 → 8 taken 18759 times.
✗ Branch 7 → 45 not taken.
|
18759 | const std::string typeIdentifier = getIdentifier(ctx->TYPE_IDENTIFIER(), true); |
| 136 |
1/2✓ Branch 8 → 9 taken 18759 times.
✗ Branch 8 → 43 not taken.
|
18759 | fctNameNode->structName = typeIdentifier; |
| 137 |
2/4✓ Branch 9 → 10 taken 18759 times.
✗ Branch 9 → 43 not taken.
✓ Branch 10 → 11 taken 18759 times.
✗ Branch 10 → 43 not taken.
|
18759 | fqName << typeIdentifier << MEMBER_ACCESS_TOKEN; |
| 138 |
1/2✓ Branch 11 → 12 taken 18759 times.
✗ Branch 11 → 43 not taken.
|
18759 | fctNameNode->nameFragments.push_back(typeIdentifier); |
| 139 | 18759 | } | |
| 140 |
3/4✓ Branch 14 → 15 taken 30551 times.
✗ Branch 14 → 52 not taken.
✓ Branch 15 → 16 taken 27009 times.
✓ Branch 15 → 23 taken 3542 times.
|
30551 | if (ctx->IDENTIFIER()) { |
| 141 |
2/4✓ Branch 16 → 17 taken 27009 times.
✗ Branch 16 → 48 not taken.
✓ Branch 17 → 18 taken 27009 times.
✗ Branch 17 → 48 not taken.
|
27009 | const std::string fctIdentifier = getIdentifier(ctx->IDENTIFIER(), false); |
| 142 |
1/2✓ Branch 18 → 19 taken 27009 times.
✗ Branch 18 → 46 not taken.
|
27009 | fctNameNode->name = fctIdentifier; |
| 143 |
1/2✓ Branch 19 → 20 taken 27009 times.
✗ Branch 19 → 46 not taken.
|
27009 | fqName << fctIdentifier; |
| 144 |
1/2✓ Branch 20 → 21 taken 27009 times.
✗ Branch 20 → 46 not taken.
|
27009 | fctNameNode->nameFragments.push_back(fctIdentifier); |
| 145 | 27009 | } | |
| 146 |
1/2✓ Branch 23 → 24 taken 30551 times.
✗ Branch 23 → 49 not taken.
|
30551 | fctNameNode->fqName = fqName.str(); |
| 147 | |||
| 148 | // Visit children | ||
| 149 |
3/4✓ Branch 26 → 27 taken 30551 times.
✗ Branch 26 → 52 not taken.
✓ Branch 27 → 28 taken 3542 times.
✓ Branch 27 → 32 taken 27009 times.
|
30551 | if (ctx->overloadableOp()) |
| 150 |
2/4✓ Branch 28 → 29 taken 3542 times.
✗ Branch 28 → 50 not taken.
✓ Branch 29 → 30 taken 3542 times.
✗ Branch 29 → 50 not taken.
|
3542 | visit(ctx->overloadableOp()); |
| 151 | |||
| 152 |
1/2✓ Branch 38 → 39 taken 30551 times.
✗ Branch 38 → 51 not taken.
|
61102 | return concludeNode(fctNameNode); |
| 153 | 30551 | } | |
| 154 | |||
| 155 | 2813 | std::any ASTBuilder::visitStructDef(SpiceParser::StructDefContext *ctx) { | |
| 156 | 2813 | const auto structDefNode = createNode<StructDefNode>(ctx); | |
| 157 | |||
| 158 | // Enrich | ||
| 159 |
3/4✓ Branch 3 → 4 taken 2813 times.
✗ Branch 3 → 103 not taken.
✓ Branch 4 → 5 taken 2812 times.
✓ Branch 4 → 103 taken 1 time.
|
2813 | structDefNode->structName = getIdentifier(ctx->TYPE_IDENTIFIER(), true); |
| 160 | 2812 | structDefNode->typeId = resourceManager.getNextCustomTypeId(); | |
| 161 | |||
| 162 | // Visit children | ||
| 163 |
2/2✓ Branch 9 → 10 taken 105 times.
✓ Branch 9 → 49 taken 2707 times.
|
2812 | if (ctx->topLevelDefAttr()) { |
| 164 |
3/6✓ Branch 10 → 11 taken 105 times.
✗ Branch 10 → 106 not taken.
✓ Branch 11 → 12 taken 105 times.
✗ Branch 11 → 106 not taken.
✓ Branch 12 → 13 taken 105 times.
✗ Branch 12 → 104 not taken.
|
105 | 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 105 times.
✓ Branch 27 → 28 taken 105 times.
|
315 | for (AttrNode *attr : structDefNode->attrs->attrLst->attributes) |
| 168 | 105 | attr->target = AttrNode::TARGET_STRUCT; | |
| 169 | |||
| 170 | // Check if a custom type id was set | ||
| 171 |
7/18✓ Branch 28 → 29 taken 105 times.
✗ Branch 28 → 35 not taken.
✓ Branch 31 → 32 taken 105 times.
✗ Branch 31 → 107 not taken.
✓ Branch 32 → 33 taken 105 times.
✗ Branch 32 → 107 not taken.
✗ Branch 33 → 34 not taken.
✓ Branch 33 → 35 taken 105 times.
✓ Branch 36 → 37 taken 105 times.
✗ Branch 36 → 38 not taken.
✓ Branch 38 → 39 taken 105 times.
✗ Branch 38 → 41 not taken.
✗ Branch 41 → 42 not taken.
✓ Branch 41 → 49 taken 105 times.
✗ Branch 107 → 108 not taken.
✗ Branch 107 → 109 not taken.
✗ Branch 111 → 112 not taken.
✗ Branch 111 → 114 not taken.
|
315 | 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 2560 times.
✓ Branch 50 → 56 taken 252 times.
|
2812 | if (ctx->qualifierLst()) |
| 175 |
3/6✓ Branch 51 → 52 taken 2560 times.
✗ Branch 51 → 124 not taken.
✓ Branch 52 → 53 taken 2560 times.
✗ Branch 52 → 124 not taken.
✓ Branch 53 → 54 taken 2560 times.
✗ Branch 53 → 122 not taken.
|
2560 | structDefNode->qualifierLst = std::any_cast<QualifierLstNode *>(visit(ctx->qualifierLst())); |
| 176 |
2/2✓ Branch 57 → 58 taken 632 times.
✓ Branch 57 → 63 taken 2180 times.
|
2812 | if (ctx->LESS()) { |
| 177 | 632 | structDefNode->hasTemplateTypes = true; | |
| 178 |
3/6✓ Branch 58 → 59 taken 632 times.
✗ Branch 58 → 127 not taken.
✓ Branch 59 → 60 taken 632 times.
✗ Branch 59 → 127 not taken.
✓ Branch 60 → 61 taken 632 times.
✗ Branch 60 → 125 not taken.
|
632 | structDefNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst(0))); |
| 179 | } | ||
| 180 |
2/2✓ Branch 64 → 65 taken 374 times.
✓ Branch 64 → 73 taken 2438 times.
|
2812 | if (ctx->COLON()) { |
| 181 | 374 | structDefNode->hasInterfaces = true; | |
| 182 |
5/8✓ Branch 65 → 66 taken 310 times.
✓ Branch 65 → 67 taken 64 times.
✓ Branch 68 → 69 taken 374 times.
✗ Branch 68 → 130 not taken.
✓ Branch 69 → 70 taken 374 times.
✗ Branch 69 → 130 not taken.
✓ Branch 70 → 71 taken 374 times.
✗ Branch 70 → 128 not taken.
|
374 | structDefNode->interfaceTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst(structDefNode->hasTemplateTypes ? 1 : 0))); |
| 183 | } | ||
| 184 |
3/4✓ Branch 73 → 74 taken 2812 times.
✗ Branch 73 → 137 not taken.
✓ Branch 91 → 76 taken 5316 times.
✓ Branch 91 → 92 taken 2812 times.
|
10940 | for (SpiceParser::FieldContext *field : ctx->field()) |
| 185 |
3/6✓ Branch 78 → 79 taken 5316 times.
✗ Branch 78 → 133 not taken.
✓ Branch 79 → 80 taken 5316 times.
✗ Branch 79 → 131 not taken.
✓ Branch 80 → 81 taken 5316 times.
✗ Branch 80 → 131 not taken.
|
8128 | structDefNode->fields.push_back(std::any_cast<FieldNode *>(visit(field))); |
| 186 | |||
| 187 |
1/2✓ Branch 99 → 100 taken 2812 times.
✗ Branch 99 → 138 not taken.
|
5624 | return concludeNode(structDefNode); |
| 188 | } | ||
| 189 | |||
| 190 | 366 | std::any ASTBuilder::visitInterfaceDef(SpiceParser::InterfaceDefContext *ctx) { | |
| 191 | 366 | const auto interfaceDefNode = createNode<InterfaceDefNode>(ctx); | |
| 192 | |||
| 193 | // Enrich | ||
| 194 |
2/4✓ Branch 3 → 4 taken 366 times.
✗ Branch 3 → 93 not taken.
✓ Branch 4 → 5 taken 366 times.
✗ Branch 4 → 93 not taken.
|
366 | interfaceDefNode->interfaceName = getIdentifier(ctx->TYPE_IDENTIFIER(), true); |
| 195 | 366 | interfaceDefNode->typeId = resourceManager.getNextCustomTypeId(); | |
| 196 | |||
| 197 | // Visit children | ||
| 198 |
2/2✓ Branch 9 → 10 taken 153 times.
✓ Branch 9 → 49 taken 213 times.
|
366 | if (ctx->topLevelDefAttr()) { |
| 199 |
3/6✓ Branch 10 → 11 taken 153 times.
✗ Branch 10 → 96 not taken.
✓ Branch 11 → 12 taken 153 times.
✗ Branch 11 → 96 not taken.
✓ Branch 12 → 13 taken 153 times.
✗ Branch 12 → 94 not taken.
|
153 | 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 153 times.
✓ Branch 27 → 28 taken 153 times.
|
459 | for (AttrNode *attr : interfaceDefNode->attrs->attrLst->attributes) |
| 203 | 153 | attr->target = AttrNode::TARGET_INTERFACE; | |
| 204 | |||
| 205 | // Check if a custom type id was set | ||
| 206 |
7/18✓ Branch 28 → 29 taken 153 times.
✗ Branch 28 → 35 not taken.
✓ Branch 31 → 32 taken 153 times.
✗ Branch 31 → 97 not taken.
✓ Branch 32 → 33 taken 153 times.
✗ Branch 32 → 97 not taken.
✓ Branch 33 → 34 taken 153 times.
✗ Branch 33 → 35 not taken.
✓ Branch 36 → 37 taken 153 times.
✗ Branch 36 → 38 not taken.
✓ Branch 38 → 39 taken 153 times.
✗ Branch 38 → 41 not taken.
✓ Branch 41 → 42 taken 153 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.
|
459 | if (interfaceDefNode->attrs && interfaceDefNode->attrs->attrLst->hasAttr(ATTR_CORE_COMPILER_FIXED_TYPE_ID)) |
| 207 |
2/4✓ Branch 44 → 45 taken 153 times.
✗ Branch 44 → 108 not taken.
✓ Branch 45 → 46 taken 153 times.
✗ Branch 45 → 106 not taken.
|
459 | interfaceDefNode->typeId = interfaceDefNode->attrs->attrLst->getAttrValueByName(ATTR_CORE_COMPILER_FIXED_TYPE_ID)->intValue; |
| 208 | } | ||
| 209 |
2/2✓ Branch 50 → 51 taken 345 times.
✓ Branch 50 → 56 taken 21 times.
|
366 | if (ctx->qualifierLst()) |
| 210 |
3/6✓ Branch 51 → 52 taken 345 times.
✗ Branch 51 → 114 not taken.
✓ Branch 52 → 53 taken 345 times.
✗ Branch 52 → 114 not taken.
✓ Branch 53 → 54 taken 345 times.
✗ Branch 53 → 112 not taken.
|
345 | interfaceDefNode->qualifierLst = std::any_cast<QualifierLstNode *>(visit(ctx->qualifierLst())); |
| 211 |
2/2✓ Branch 57 → 58 taken 156 times.
✓ Branch 57 → 63 taken 210 times.
|
366 | if (ctx->LESS()) { |
| 212 | 156 | interfaceDefNode->hasTemplateTypes = true; | |
| 213 |
3/6✓ Branch 58 → 59 taken 156 times.
✗ Branch 58 → 117 not taken.
✓ Branch 59 → 60 taken 156 times.
✗ Branch 59 → 117 not taken.
✓ Branch 60 → 61 taken 156 times.
✗ Branch 60 → 115 not taken.
|
156 | interfaceDefNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst())); |
| 214 | } | ||
| 215 |
3/4✓ Branch 63 → 64 taken 366 times.
✗ Branch 63 → 124 not taken.
✓ Branch 81 → 66 taken 1333 times.
✓ Branch 81 → 82 taken 366 times.
|
2065 | for (SpiceParser::SignatureContext *signature : ctx->signature()) |
| 216 |
3/6✓ Branch 68 → 69 taken 1333 times.
✗ Branch 68 → 120 not taken.
✓ Branch 69 → 70 taken 1333 times.
✗ Branch 69 → 118 not taken.
✓ Branch 70 → 71 taken 1333 times.
✗ Branch 70 → 118 not taken.
|
1699 | interfaceDefNode->signatures.push_back(std::any_cast<SignatureNode *>(visit(signature))); |
| 217 | |||
| 218 |
1/2✓ Branch 89 → 90 taken 366 times.
✗ Branch 89 → 125 not taken.
|
732 | return concludeNode(interfaceDefNode); |
| 219 | } | ||
| 220 | |||
| 221 | 7 | std::any ASTBuilder::visitForwardDecl(SpiceParser::ForwardDeclContext *ctx) { | |
| 222 | 7 | const auto forwardDeclNode = createNode<ForwardDeclNode>(ctx); | |
| 223 | |||
| 224 | // Determine if this is a struct or interface forward declaration | ||
| 225 | 7 | forwardDeclNode->isStruct = ctx->STRUCT() != nullptr; | |
| 226 |
2/4✓ Branch 4 → 5 taken 7 times.
✗ Branch 4 → 37 not taken.
✓ Branch 5 → 6 taken 7 times.
✗ Branch 5 → 37 not taken.
|
7 | forwardDeclNode->typeName = getIdentifier(ctx->TYPE_IDENTIFIER(), true); |
| 227 | 7 | forwardDeclNode->typeId = resourceManager.getNextCustomTypeId(); | |
| 228 |
1/2✓ Branch 9 → 10 taken 7 times.
✗ Branch 9 → 11 not taken.
|
7 | forwardDeclNode->qualifiers = TypeQualifiers::of(forwardDeclNode->isStruct ? TY_STRUCT : TY_INTERFACE); |
| 229 | |||
| 230 | // Visit children | ||
| 231 |
1/2✗ Branch 14 → 15 not taken.
✓ Branch 14 → 20 taken 7 times.
|
7 | if (ctx->topLevelDefAttr()) |
| 232 | ✗ | forwardDeclNode->attrs = std::any_cast<TopLevelDefAttrNode *>(visit(ctx->topLevelDefAttr())); | |
| 233 |
2/2✓ Branch 21 → 22 taken 2 times.
✓ Branch 21 → 27 taken 5 times.
|
7 | if (ctx->qualifierLst()) |
| 234 |
3/6✓ Branch 22 → 23 taken 2 times.
✗ Branch 22 → 43 not taken.
✓ Branch 23 → 24 taken 2 times.
✗ Branch 23 → 43 not taken.
✓ Branch 24 → 25 taken 2 times.
✗ Branch 24 → 41 not taken.
|
2 | forwardDeclNode->qualifierLst = std::any_cast<QualifierLstNode *>(visit(ctx->qualifierLst())); |
| 235 | |||
| 236 |
1/2✓ Branch 33 → 34 taken 7 times.
✗ Branch 33 → 44 not taken.
|
14 | return concludeNode(forwardDeclNode); |
| 237 | } | ||
| 238 | |||
| 239 | 369 | std::any ASTBuilder::visitEnumDef(SpiceParser::EnumDefContext *ctx) { | |
| 240 | 369 | const auto enumDefNode = createNode<EnumDefNode>(ctx); | |
| 241 | |||
| 242 | // Enrich | ||
| 243 |
2/4✓ Branch 3 → 4 taken 369 times.
✗ Branch 3 → 43 not taken.
✓ Branch 4 → 5 taken 369 times.
✗ Branch 4 → 43 not taken.
|
369 | enumDefNode->enumName = getIdentifier(ctx->TYPE_IDENTIFIER(), true); |
| 244 | 369 | enumDefNode->typeId = resourceManager.getNextCustomTypeId(); | |
| 245 | |||
| 246 | // Visit children | ||
| 247 |
2/2✓ Branch 9 → 10 taken 331 times.
✓ Branch 9 → 15 taken 38 times.
|
369 | if (ctx->qualifierLst()) |
| 248 |
3/6✓ Branch 10 → 11 taken 331 times.
✗ Branch 10 → 46 not taken.
✓ Branch 11 → 12 taken 331 times.
✗ Branch 11 → 46 not taken.
✓ Branch 12 → 13 taken 331 times.
✗ Branch 12 → 44 not taken.
|
331 | enumDefNode->qualifierLst = std::any_cast<QualifierLstNode *>(visit(ctx->qualifierLst())); |
| 249 |
3/6✓ Branch 15 → 16 taken 369 times.
✗ Branch 15 → 49 not taken.
✓ Branch 16 → 17 taken 369 times.
✗ Branch 16 → 49 not taken.
✓ Branch 17 → 18 taken 369 times.
✗ Branch 17 → 47 not taken.
|
369 | enumDefNode->itemLst = std::any_cast<EnumItemLstNode *>(visit(ctx->enumItemLst())); |
| 250 | |||
| 251 | // Tell all items about the enum def | ||
| 252 |
2/2✓ Branch 32 → 21 taken 4910 times.
✓ Branch 32 → 33 taken 369 times.
|
5648 | for (EnumItemNode *enumItem : enumDefNode->itemLst->items) |
| 253 | 4910 | enumItem->enumDef = enumDefNode; | |
| 254 | |||
| 255 |
1/2✓ Branch 39 → 40 taken 369 times.
✗ Branch 39 → 50 not taken.
|
738 | return concludeNode(enumDefNode); |
| 256 | } | ||
| 257 | |||
| 258 | 1929 | std::any ASTBuilder::visitGenericTypeDef(SpiceParser::GenericTypeDefContext *ctx) { | |
| 259 | 1929 | const auto genericTypeDefNode = createNode<GenericTypeDefNode>(ctx); | |
| 260 | |||
| 261 | // Enrich | ||
| 262 |
2/4✓ Branch 3 → 4 taken 1929 times.
✗ Branch 3 → 21 not taken.
✓ Branch 4 → 5 taken 1929 times.
✗ Branch 4 → 21 not taken.
|
1929 | genericTypeDefNode->typeName = getIdentifier(ctx->TYPE_IDENTIFIER(), true); |
| 263 | |||
| 264 | // Visit children | ||
| 265 |
4/8✓ Branch 7 → 8 taken 1929 times.
✗ Branch 7 → 24 not taken.
✓ Branch 8 → 9 taken 1929 times.
✗ Branch 8 → 24 not taken.
✓ Branch 9 → 10 taken 1929 times.
✗ Branch 9 → 22 not taken.
✓ Branch 11 → 12 taken 1929 times.
✗ Branch 11 → 25 not taken.
|
1929 | genericTypeDefNode->typeAltsLst = std::any_cast<TypeAltsLstNode *>(visit(ctx->typeAltsLst())); |
| 266 | |||
| 267 |
1/2✓ Branch 17 → 18 taken 1929 times.
✗ Branch 17 → 25 not taken.
|
3858 | return concludeNode(genericTypeDefNode); |
| 268 | } | ||
| 269 | |||
| 270 | 342 | std::any ASTBuilder::visitAliasDef(SpiceParser::AliasDefContext *ctx) { | |
| 271 | 342 | const auto aliasDefNode = createNode<AliasDefNode>(ctx); | |
| 272 | |||
| 273 | // Enrich | ||
| 274 |
2/4✓ Branch 3 → 4 taken 342 times.
✗ Branch 3 → 33 not taken.
✓ Branch 4 → 5 taken 342 times.
✗ Branch 4 → 33 not taken.
|
342 | aliasDefNode->aliasName = getIdentifier(ctx->TYPE_IDENTIFIER(), true); |
| 275 |
2/4✓ Branch 7 → 8 taken 342 times.
✗ Branch 7 → 34 not taken.
✓ Branch 8 → 9 taken 342 times.
✗ Branch 8 → 34 not taken.
|
342 | aliasDefNode->dataTypeString = ctx->dataType()->getText(); |
| 276 | 342 | aliasDefNode->typeId = resourceManager.getNextCustomTypeId(); | |
| 277 | |||
| 278 | // Visit children | ||
| 279 |
2/2✓ Branch 13 → 14 taken 104 times.
✓ Branch 13 → 19 taken 238 times.
|
342 | if (ctx->qualifierLst()) |
| 280 |
3/6✓ Branch 14 → 15 taken 104 times.
✗ Branch 14 → 37 not taken.
✓ Branch 15 → 16 taken 104 times.
✗ Branch 15 → 37 not taken.
✓ Branch 16 → 17 taken 104 times.
✗ Branch 16 → 35 not taken.
|
104 | aliasDefNode->qualifierLst = std::any_cast<QualifierLstNode *>(visit(ctx->qualifierLst())); |
| 281 |
4/8✓ Branch 19 → 20 taken 342 times.
✗ Branch 19 → 40 not taken.
✓ Branch 20 → 21 taken 342 times.
✗ Branch 20 → 40 not taken.
✓ Branch 21 → 22 taken 342 times.
✗ Branch 21 → 38 not taken.
✓ Branch 23 → 24 taken 342 times.
✗ Branch 23 → 41 not taken.
|
342 | aliasDefNode->dataType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 282 | |||
| 283 |
1/2✓ Branch 29 → 30 taken 342 times.
✗ Branch 29 → 41 not taken.
|
684 | return concludeNode(aliasDefNode); |
| 284 | } | ||
| 285 | |||
| 286 | 2380 | std::any ASTBuilder::visitGlobalVarDef(SpiceParser::GlobalVarDefContext *ctx) { | |
| 287 | 2380 | const auto globalVarDefNode = createNode<GlobalVarDefNode>(ctx); | |
| 288 | |||
| 289 | // Enrich | ||
| 290 |
2/4✓ Branch 3 → 4 taken 2380 times.
✗ Branch 3 → 28 not taken.
✓ Branch 4 → 5 taken 2380 times.
✗ Branch 4 → 28 not taken.
|
2380 | globalVarDefNode->varName = getIdentifier(ctx->TYPE_IDENTIFIER(), true); |
| 291 | |||
| 292 | // Visit children | ||
| 293 |
3/6✓ Branch 7 → 8 taken 2380 times.
✗ Branch 7 → 31 not taken.
✓ Branch 8 → 9 taken 2380 times.
✗ Branch 8 → 31 not taken.
✓ Branch 9 → 10 taken 2380 times.
✗ Branch 9 → 29 not taken.
|
2380 | globalVarDefNode->dataType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 294 | 2380 | globalVarDefNode->dataType->isGlobalType = true; | |
| 295 |
2/2✓ Branch 12 → 13 taken 2378 times.
✓ Branch 12 → 18 taken 2 times.
|
2380 | if (ctx->constant()) { |
| 296 | 2378 | globalVarDefNode->hasValue = true; | |
| 297 |
3/6✓ Branch 13 → 14 taken 2378 times.
✗ Branch 13 → 34 not taken.
✓ Branch 14 → 15 taken 2378 times.
✗ Branch 14 → 34 not taken.
✓ Branch 15 → 16 taken 2378 times.
✗ Branch 15 → 32 not taken.
|
2378 | globalVarDefNode->constant = std::any_cast<ConstantNode *>(visit(ctx->constant())); |
| 298 | } | ||
| 299 | |||
| 300 |
1/2✓ Branch 24 → 25 taken 2380 times.
✗ Branch 24 → 35 not taken.
|
4760 | return concludeNode(globalVarDefNode); |
| 301 | } | ||
| 302 | |||
| 303 | 2963 | std::any ASTBuilder::visitExtDecl(SpiceParser::ExtDeclContext *ctx) { | |
| 304 | 2963 | const auto extDeclNode = createNode<ExtDeclNode>(ctx); | |
| 305 | |||
| 306 | // Enrich | ||
| 307 |
6/10✓ Branch 3 → 4 taken 2963 times.
✗ Branch 3 → 57 not taken.
✓ Branch 4 → 5 taken 1577 times.
✓ Branch 4 → 7 taken 1386 times.
✓ Branch 5 → 6 taken 1577 times.
✗ Branch 5 → 57 not taken.
✓ Branch 7 → 8 taken 1386 times.
✗ Branch 7 → 57 not taken.
✓ Branch 9 → 10 taken 2963 times.
✗ Branch 9 → 57 not taken.
|
2963 | extDeclNode->extFunctionName = getIdentifier(ctx->IDENTIFIER() ? ctx->IDENTIFIER() : ctx->TYPE_IDENTIFIER(), false); |
| 308 | |||
| 309 | // Visit children | ||
| 310 |
2/2✓ Branch 13 → 14 taken 1 time.
✓ Branch 13 → 33 taken 2962 times.
|
2963 | if (ctx->topLevelDefAttr()) { |
| 311 |
3/6✓ Branch 14 → 15 taken 1 time.
✗ Branch 14 → 60 not taken.
✓ Branch 15 → 16 taken 1 time.
✗ Branch 15 → 60 not taken.
✓ Branch 16 → 17 taken 1 time.
✗ Branch 16 → 58 not taken.
|
1 | extDeclNode->attrs = std::any_cast<TopLevelDefAttrNode *>(visit(ctx->topLevelDefAttr())); |
| 312 | |||
| 313 | // Tell the attributes that they are ext decl attributes | ||
| 314 |
2/2✓ Branch 31 → 20 taken 1 time.
✓ Branch 31 → 32 taken 1 time.
|
3 | for (AttrNode *attr : extDeclNode->attrs->attrLst->attributes) |
| 315 | 1 | attr->target = AttrNode::TARGET_EXT_DECL; | |
| 316 | } | ||
| 317 |
2/2✓ Branch 34 → 35 taken 1967 times.
✓ Branch 34 → 40 taken 996 times.
|
2963 | if (ctx->F()) { |
| 318 |
3/6✓ Branch 35 → 36 taken 1967 times.
✗ Branch 35 → 63 not taken.
✓ Branch 36 → 37 taken 1967 times.
✗ Branch 36 → 63 not taken.
✓ Branch 37 → 38 taken 1967 times.
✗ Branch 37 → 61 not taken.
|
1967 | extDeclNode->returnType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 319 | 1967 | extDeclNode->returnType->isReturnType = true; | |
| 320 | } | ||
| 321 |
2/2✓ Branch 41 → 42 taken 2756 times.
✓ Branch 41 → 47 taken 207 times.
|
2963 | if (ctx->typeLstWithEllipsis()) { |
| 322 | 2756 | extDeclNode->hasArgs = true; | |
| 323 |
3/6✓ Branch 42 → 43 taken 2756 times.
✗ Branch 42 → 66 not taken.
✓ Branch 43 → 44 taken 2756 times.
✗ Branch 43 → 66 not taken.
✓ Branch 44 → 45 taken 2756 times.
✗ Branch 44 → 64 not taken.
|
2756 | extDeclNode->argTypeLst = std::any_cast<TypeLstWithEllipsisNode *>(visit(ctx->typeLstWithEllipsis())); |
| 324 | } | ||
| 325 | |||
| 326 |
1/2✓ Branch 53 → 54 taken 2963 times.
✗ Branch 53 → 67 not taken.
|
5926 | return concludeNode(extDeclNode); |
| 327 | } | ||
| 328 | |||
| 329 | 2542 | std::any ASTBuilder::visitImportDef(SpiceParser::ImportDefContext *ctx) { | |
| 330 |
1/2✓ Branch 2 → 3 taken 2542 times.
✗ Branch 2 → 32 not taken.
|
2542 | const auto importDefNode = createNode<ImportDefNode>(ctx); |
| 331 | |||
| 332 | // Extract path | ||
| 333 |
2/4✓ Branch 3 → 4 taken 2542 times.
✗ Branch 3 → 32 not taken.
✓ Branch 4 → 5 taken 2542 times.
✗ Branch 4 → 32 not taken.
|
2542 | const std::string pathStr = ctx->STRING_LIT()->getText(); |
| 334 |
1/2✓ Branch 6 → 7 taken 2542 times.
✗ Branch 6 → 27 not taken.
|
2542 | importDefNode->importPath = pathStr.substr(1, pathStr.size() - 2); |
| 335 | |||
| 336 | // If no name is given, use the path as name | ||
| 337 |
7/12✓ Branch 9 → 10 taken 2542 times.
✗ Branch 9 → 28 not taken.
✓ Branch 10 → 11 taken 80 times.
✓ Branch 10 → 13 taken 2462 times.
✓ Branch 11 → 12 taken 80 times.
✗ Branch 11 → 28 not taken.
✓ Branch 12 → 14 taken 80 times.
✗ Branch 12 → 28 not taken.
✓ Branch 13 → 14 taken 2462 times.
✗ Branch 13 → 28 not taken.
✓ Branch 16 → 17 taken 2542 times.
✗ Branch 16 → 29 not taken.
|
2542 | importDefNode->importName = ctx->AS() ? getIdentifier(ctx->IDENTIFIER(), false) : importDefNode->importPath; |
| 338 | |||
| 339 |
1/2✓ Branch 22 → 23 taken 2542 times.
✗ Branch 22 → 29 not taken.
|
5084 | return concludeNode(importDefNode); |
| 340 | 2542 | } | |
| 341 | |||
| 342 | 5375 | std::any ASTBuilder::visitUnsafeBlock(SpiceParser::UnsafeBlockContext *ctx) { | |
| 343 | 5375 | const auto unsafeBlockDefNode = createNode<UnsafeBlockNode>(ctx); | |
| 344 | |||
| 345 | // Visit children | ||
| 346 |
4/8✓ Branch 3 → 4 taken 5375 times.
✗ Branch 3 → 19 not taken.
✓ Branch 4 → 5 taken 5375 times.
✗ Branch 4 → 19 not taken.
✓ Branch 5 → 6 taken 5375 times.
✗ Branch 5 → 17 not taken.
✓ Branch 7 → 8 taken 5375 times.
✗ Branch 7 → 20 not taken.
|
5375 | unsafeBlockDefNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 347 | |||
| 348 |
1/2✓ Branch 13 → 14 taken 5375 times.
✗ Branch 13 → 20 not taken.
|
10750 | return concludeNode(unsafeBlockDefNode); |
| 349 | } | ||
| 350 | |||
| 351 | 2826 | std::any ASTBuilder::visitForLoop(SpiceParser::ForLoopContext *ctx) { | |
| 352 | 2826 | const auto forLoopNode = createNode<ForLoopNode>(ctx); | |
| 353 | |||
| 354 |
2/4✓ Branch 3 → 4 taken 2826 times.
✗ Branch 3 → 20 not taken.
✓ Branch 4 → 5 taken 2826 times.
✗ Branch 4 → 20 not taken.
|
2826 | visit(ctx->forHead()); |
| 355 |
4/8✓ Branch 6 → 7 taken 2826 times.
✗ Branch 6 → 23 not taken.
✓ Branch 7 → 8 taken 2826 times.
✗ Branch 7 → 23 not taken.
✓ Branch 8 → 9 taken 2826 times.
✗ Branch 8 → 21 not taken.
✓ Branch 10 → 11 taken 2826 times.
✗ Branch 10 → 24 not taken.
|
2826 | forLoopNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 356 | |||
| 357 |
1/2✓ Branch 16 → 17 taken 2826 times.
✗ Branch 16 → 24 not taken.
|
5652 | return concludeNode(forLoopNode); |
| 358 | } | ||
| 359 | |||
| 360 | 2826 | std::any ASTBuilder::visitForHead(SpiceParser::ForHeadContext *ctx) { | |
| 361 | 2826 | const auto forLoopNode = resumeForExpansion<ForLoopNode>(); | |
| 362 | |||
| 363 | // Visit children | ||
| 364 |
3/6✓ Branch 12 → 13 taken 2826 times.
✗ Branch 12 → 30 not taken.
✓ Branch 13 → 14 taken 2826 times.
✗ Branch 13 → 30 not taken.
✓ Branch 14 → 15 taken 2826 times.
✗ Branch 14 → 28 not taken.
|
2826 | forLoopNode->initDecl = std::any_cast<DeclStmtNode *>(visit(ctx->declStmt())); |
| 365 |
3/6✓ Branch 16 → 17 taken 2826 times.
✗ Branch 16 → 33 not taken.
✓ Branch 17 → 18 taken 2826 times.
✗ Branch 17 → 33 not taken.
✓ Branch 18 → 19 taken 2826 times.
✗ Branch 18 → 31 not taken.
|
2826 | forLoopNode->condAssign = std::any_cast<ExprNode *>(visit(ctx->assignExpr(0))); |
| 366 |
3/6✓ Branch 20 → 21 taken 2826 times.
✗ Branch 20 → 36 not taken.
✓ Branch 21 → 22 taken 2826 times.
✗ Branch 21 → 36 not taken.
✓ Branch 22 → 23 taken 2826 times.
✗ Branch 22 → 34 not taken.
|
2826 | forLoopNode->incAssign = std::any_cast<ExprNode *>(visit(ctx->assignExpr(1))); |
| 367 | |||
| 368 |
1/2✓ Branch 24 → 25 taken 2826 times.
✗ Branch 24 → 37 not taken.
|
5652 | return nullptr; |
| 369 | } | ||
| 370 | |||
| 371 | 471 | std::any ASTBuilder::visitForeachLoop(SpiceParser::ForeachLoopContext *ctx) { | |
| 372 | 471 | const auto foreachLoopNode = createNode<ForeachLoopNode>(ctx); | |
| 373 | |||
| 374 | // Visit children | ||
| 375 |
2/4✓ Branch 3 → 4 taken 471 times.
✗ Branch 3 → 20 not taken.
✓ Branch 4 → 5 taken 471 times.
✗ Branch 4 → 20 not taken.
|
471 | visit(ctx->foreachHead()); |
| 376 |
3/6✓ Branch 6 → 7 taken 471 times.
✗ Branch 6 → 23 not taken.
✓ Branch 7 → 8 taken 471 times.
✗ Branch 7 → 23 not taken.
✓ Branch 8 → 9 taken 471 times.
✗ Branch 8 → 21 not taken.
|
471 | foreachLoopNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 377 | |||
| 378 | // Tell the foreach item that it is one | ||
| 379 |
1/2✓ Branch 10 → 11 taken 471 times.
✗ Branch 10 → 24 not taken.
|
471 | foreachLoopNode->itemVarDecl->isForEachItem = true; |
| 380 | |||
| 381 |
1/2✓ Branch 16 → 17 taken 471 times.
✗ Branch 16 → 24 not taken.
|
942 | return concludeNode(foreachLoopNode); |
| 382 | } | ||
| 383 | |||
| 384 | 471 | std::any ASTBuilder::visitForeachHead(SpiceParser::ForeachHeadContext *ctx) { | |
| 385 | 471 | const auto foreachLoopNode = resumeForExpansion<ForeachLoopNode>(); | |
| 386 | |||
| 387 | // Visit children | ||
| 388 |
3/4✓ Branch 12 → 13 taken 471 times.
✗ Branch 12 → 43 not taken.
✓ Branch 15 → 16 taken 413 times.
✓ Branch 15 → 21 taken 58 times.
|
471 | if (ctx->declStmt().size() == 1) { |
| 389 |
3/6✓ Branch 16 → 17 taken 413 times.
✗ Branch 16 → 46 not taken.
✓ Branch 17 → 18 taken 413 times.
✗ Branch 17 → 46 not taken.
✓ Branch 18 → 19 taken 413 times.
✗ Branch 18 → 44 not taken.
|
413 | foreachLoopNode->itemVarDecl = std::any_cast<DeclStmtNode *>(visit(ctx->declStmt(0))); |
| 390 |
2/4✓ Branch 21 → 22 taken 58 times.
✗ Branch 21 → 47 not taken.
✓ Branch 24 → 25 taken 58 times.
✗ Branch 24 → 34 not taken.
|
58 | } else if (ctx->declStmt().size() == 2) { |
| 391 |
3/6✓ Branch 25 → 26 taken 58 times.
✗ Branch 25 → 50 not taken.
✓ Branch 26 → 27 taken 58 times.
✗ Branch 26 → 50 not taken.
✓ Branch 27 → 28 taken 58 times.
✗ Branch 27 → 48 not taken.
|
58 | foreachLoopNode->idxVarDecl = std::any_cast<DeclStmtNode *>(visit(ctx->declStmt(0))); |
| 392 |
3/6✓ Branch 29 → 30 taken 58 times.
✗ Branch 29 → 53 not taken.
✓ Branch 30 → 31 taken 58 times.
✗ Branch 30 → 53 not taken.
✓ Branch 31 → 32 taken 58 times.
✗ Branch 31 → 51 not taken.
|
58 | foreachLoopNode->itemVarDecl = std::any_cast<DeclStmtNode *>(visit(ctx->declStmt(1))); |
| 393 | } else { | ||
| 394 | − | assert_fail("Invalid number of decl statements in foreach loop"); // GCOV_EXCL_LINE | |
| 395 | } | ||
| 396 |
3/6✓ Branch 35 → 36 taken 471 times.
✗ Branch 35 → 56 not taken.
✓ Branch 36 → 37 taken 471 times.
✗ Branch 36 → 56 not taken.
✓ Branch 37 → 38 taken 471 times.
✗ Branch 37 → 54 not taken.
|
471 | foreachLoopNode->iteratorAssign = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 397 | |||
| 398 |
1/2✓ Branch 39 → 40 taken 471 times.
✗ Branch 39 → 57 not taken.
|
942 | return nullptr; |
| 399 | } | ||
| 400 | |||
| 401 | 1660 | std::any ASTBuilder::visitWhileLoop(SpiceParser::WhileLoopContext *ctx) { | |
| 402 | 1660 | const auto whileLoopNode = createNode<WhileLoopNode>(ctx); | |
| 403 | |||
| 404 | // Visit children | ||
| 405 |
3/6✓ Branch 3 → 4 taken 1660 times.
✗ Branch 3 → 23 not taken.
✓ Branch 4 → 5 taken 1660 times.
✗ Branch 4 → 23 not taken.
✓ Branch 5 → 6 taken 1660 times.
✗ Branch 5 → 21 not taken.
|
1660 | whileLoopNode->condition = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 406 |
4/8✓ Branch 7 → 8 taken 1660 times.
✗ Branch 7 → 26 not taken.
✓ Branch 8 → 9 taken 1660 times.
✗ Branch 8 → 26 not taken.
✓ Branch 9 → 10 taken 1660 times.
✗ Branch 9 → 24 not taken.
✓ Branch 11 → 12 taken 1660 times.
✗ Branch 11 → 27 not taken.
|
1660 | whileLoopNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 407 | |||
| 408 |
1/2✓ Branch 17 → 18 taken 1660 times.
✗ Branch 17 → 27 not taken.
|
3320 | return concludeNode(whileLoopNode); |
| 409 | } | ||
| 410 | |||
| 411 | 16 | std::any ASTBuilder::visitDoWhileLoop(SpiceParser::DoWhileLoopContext *ctx) { | |
| 412 | 16 | const auto doWhileLoopNode = createNode<DoWhileLoopNode>(ctx); | |
| 413 | |||
| 414 | // Visit children | ||
| 415 |
3/6✓ Branch 3 → 4 taken 16 times.
✗ Branch 3 → 23 not taken.
✓ Branch 4 → 5 taken 16 times.
✗ Branch 4 → 23 not taken.
✓ Branch 5 → 6 taken 16 times.
✗ Branch 5 → 21 not taken.
|
16 | doWhileLoopNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 416 |
4/8✓ Branch 7 → 8 taken 16 times.
✗ Branch 7 → 26 not taken.
✓ Branch 8 → 9 taken 16 times.
✗ Branch 8 → 26 not taken.
✓ Branch 9 → 10 taken 16 times.
✗ Branch 9 → 24 not taken.
✓ Branch 11 → 12 taken 16 times.
✗ Branch 11 → 27 not taken.
|
16 | doWhileLoopNode->condition = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 417 | |||
| 418 |
1/2✓ Branch 17 → 18 taken 16 times.
✗ Branch 17 → 27 not taken.
|
32 | return concludeNode(doWhileLoopNode); |
| 419 | } | ||
| 420 | |||
| 421 | 10901 | std::any ASTBuilder::visitIfStmt(SpiceParser::IfStmtContext *ctx) { | |
| 422 | 10901 | const auto ifStmtNode = createNode<IfStmtNode>(ctx); | |
| 423 | |||
| 424 | // Visit children | ||
| 425 |
3/6✓ Branch 3 → 4 taken 10901 times.
✗ Branch 3 → 30 not taken.
✓ Branch 4 → 5 taken 10901 times.
✗ Branch 4 → 30 not taken.
✓ Branch 5 → 6 taken 10901 times.
✗ Branch 5 → 28 not taken.
|
10901 | ifStmtNode->condition = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 426 |
3/6✓ Branch 7 → 8 taken 10901 times.
✗ Branch 7 → 33 not taken.
✓ Branch 8 → 9 taken 10901 times.
✗ Branch 8 → 33 not taken.
✓ Branch 9 → 10 taken 10901 times.
✗ Branch 9 → 31 not taken.
|
10901 | ifStmtNode->thenBody = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 427 |
2/2✓ Branch 12 → 13 taken 958 times.
✓ Branch 12 → 18 taken 9943 times.
|
10901 | if (ctx->elseStmt()) |
| 428 |
3/6✓ Branch 13 → 14 taken 958 times.
✗ Branch 13 → 36 not taken.
✓ Branch 14 → 15 taken 958 times.
✗ Branch 14 → 36 not taken.
✓ Branch 15 → 16 taken 958 times.
✗ Branch 15 → 34 not taken.
|
958 | ifStmtNode->elseStmt = std::any_cast<ElseStmtNode *>(visit(ctx->elseStmt())); |
| 429 | |||
| 430 |
1/2✓ Branch 24 → 25 taken 10901 times.
✗ Branch 24 → 37 not taken.
|
21802 | return concludeNode(ifStmtNode); |
| 431 | } | ||
| 432 | |||
| 433 | 958 | std::any ASTBuilder::visitElseStmt(SpiceParser::ElseStmtContext *ctx) { | |
| 434 | 958 | const auto elseStmtNode = createNode<ElseStmtNode>(ctx); | |
| 435 | |||
| 436 | // Visit children | ||
| 437 |
2/2✓ Branch 4 → 5 taken 376 times.
✓ Branch 4 → 10 taken 582 times.
|
958 | if (ctx->ifStmt()) { |
| 438 | 376 | elseStmtNode->isElseIf = true; | |
| 439 |
3/6✓ Branch 5 → 6 taken 376 times.
✗ Branch 5 → 27 not taken.
✓ Branch 6 → 7 taken 376 times.
✗ Branch 6 → 27 not taken.
✓ Branch 7 → 8 taken 376 times.
✗ Branch 7 → 25 not taken.
|
376 | elseStmtNode->ifStmt = std::any_cast<IfStmtNode *>(visit(ctx->ifStmt())); |
| 440 | } else { | ||
| 441 |
3/6✓ Branch 10 → 11 taken 582 times.
✗ Branch 10 → 30 not taken.
✓ Branch 11 → 12 taken 582 times.
✗ Branch 11 → 30 not taken.
✓ Branch 12 → 13 taken 582 times.
✗ Branch 12 → 28 not taken.
|
582 | elseStmtNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 442 | } | ||
| 443 | |||
| 444 |
1/2✓ Branch 21 → 22 taken 958 times.
✗ Branch 21 → 31 not taken.
|
1916 | return concludeNode(elseStmtNode); |
| 445 | } | ||
| 446 | |||
| 447 | 85 | std::any ASTBuilder::visitSwitchStmt(SpiceParser::SwitchStmtContext *ctx) { | |
| 448 | 85 | const auto switchStmtNode = createNode<SwitchStmtNode>(ctx); | |
| 449 | |||
| 450 | // Visit children | ||
| 451 |
3/6✓ Branch 3 → 4 taken 85 times.
✗ Branch 3 → 29 not taken.
✓ Branch 4 → 5 taken 85 times.
✗ Branch 4 → 29 not taken.
✓ Branch 5 → 6 taken 85 times.
✗ Branch 5 → 27 not taken.
|
85 | switchStmtNode->assignExpr = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 452 |
2/4✓ Branch 7 → 8 taken 85 times.
✗ Branch 7 → 32 not taken.
✓ Branch 8 → 9 taken 85 times.
✗ Branch 8 → 30 not taken.
|
85 | fetchChildrenIntoVector(switchStmtNode->caseBranches, ctx->caseBranch()); |
| 453 |
2/2✓ Branch 11 → 12 taken 69 times.
✓ Branch 11 → 17 taken 16 times.
|
85 | if (ctx->defaultBranch()) { |
| 454 | 69 | switchStmtNode->hasDefaultBranch = true; | |
| 455 |
3/6✓ Branch 12 → 13 taken 69 times.
✗ Branch 12 → 35 not taken.
✓ Branch 13 → 14 taken 69 times.
✗ Branch 13 → 35 not taken.
✓ Branch 14 → 15 taken 69 times.
✗ Branch 14 → 33 not taken.
|
69 | switchStmtNode->defaultBranch = std::any_cast<DefaultBranchNode *>(visit(ctx->defaultBranch())); |
| 456 | } | ||
| 457 | |||
| 458 |
1/2✓ Branch 23 → 24 taken 85 times.
✗ Branch 23 → 36 not taken.
|
170 | return concludeNode(switchStmtNode); |
| 459 | } | ||
| 460 | |||
| 461 | 662 | std::any ASTBuilder::visitCaseBranch(SpiceParser::CaseBranchContext *ctx) { | |
| 462 | 662 | const auto caseBranchNode = createNode<CaseBranchNode>(ctx); | |
| 463 | |||
| 464 | // Visit children | ||
| 465 |
2/4✓ Branch 3 → 4 taken 662 times.
✗ Branch 3 → 22 not taken.
✓ Branch 4 → 5 taken 662 times.
✗ Branch 4 → 20 not taken.
|
662 | fetchChildrenIntoVector(caseBranchNode->caseConstants, ctx->caseConstant()); |
| 466 |
4/8✓ Branch 6 → 7 taken 662 times.
✗ Branch 6 → 25 not taken.
✓ Branch 7 → 8 taken 662 times.
✗ Branch 7 → 25 not taken.
✓ Branch 8 → 9 taken 662 times.
✗ Branch 8 → 23 not taken.
✓ Branch 10 → 11 taken 662 times.
✗ Branch 10 → 26 not taken.
|
662 | caseBranchNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 467 | |||
| 468 |
1/2✓ Branch 16 → 17 taken 662 times.
✗ Branch 16 → 26 not taken.
|
1324 | return concludeNode(caseBranchNode); |
| 469 | } | ||
| 470 | |||
| 471 | 69 | std::any ASTBuilder::visitDefaultBranch(SpiceParser::DefaultBranchContext *ctx) { | |
| 472 | 69 | const auto defaultBranchNode = createNode<DefaultBranchNode>(ctx); | |
| 473 | |||
| 474 | // Visit children | ||
| 475 |
4/8✓ Branch 3 → 4 taken 69 times.
✗ Branch 3 → 19 not taken.
✓ Branch 4 → 5 taken 69 times.
✗ Branch 4 → 19 not taken.
✓ Branch 5 → 6 taken 69 times.
✗ Branch 5 → 17 not taken.
✓ Branch 7 → 8 taken 69 times.
✗ Branch 7 → 20 not taken.
|
69 | defaultBranchNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 476 | |||
| 477 |
1/2✓ Branch 13 → 14 taken 69 times.
✗ Branch 13 → 20 not taken.
|
138 | return concludeNode(defaultBranchNode); |
| 478 | } | ||
| 479 | |||
| 480 | 43 | std::any ASTBuilder::visitAnonymousBlockStmt(SpiceParser::AnonymousBlockStmtContext *ctx) { | |
| 481 | 43 | const auto anonymousBlockStmtNode = createNode<AnonymousBlockStmtNode>(ctx); | |
| 482 | |||
| 483 | // Visit children | ||
| 484 |
4/8✓ Branch 3 → 4 taken 43 times.
✗ Branch 3 → 19 not taken.
✓ Branch 4 → 5 taken 43 times.
✗ Branch 4 → 19 not taken.
✓ Branch 5 → 6 taken 43 times.
✗ Branch 5 → 17 not taken.
✓ Branch 7 → 8 taken 43 times.
✗ Branch 7 → 20 not taken.
|
43 | anonymousBlockStmtNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 485 | |||
| 486 |
1/2✓ Branch 13 → 14 taken 43 times.
✗ Branch 13 → 20 not taken.
|
86 | return concludeNode(anonymousBlockStmtNode); |
| 487 | } | ||
| 488 | |||
| 489 | 53793 | std::any ASTBuilder::visitStmtLst(SpiceParser::StmtLstContext *ctx) { | |
| 490 | 53793 | const auto stmtLstNode = createNode<StmtLstNode>(ctx); | |
| 491 | |||
| 492 | // Enrich | ||
| 493 |
2/4✓ Branch 3 → 4 taken 53793 times.
✗ Branch 3 → 124 not taken.
✓ Branch 4 → 5 taken 53793 times.
✗ Branch 4 → 124 not taken.
|
53793 | stmtLstNode->closingBraceCodeLoc = CodeLoc(ctx->getStop(), sourceFile); |
| 494 | |||
| 495 | // Visit children | ||
| 496 |
2/2✓ Branch 113 → 7 taken 207776 times.
✓ Branch 113 → 114 taken 53789 times.
|
315358 | for (ParserRuleContext::ParseTree *stmt : ctx->children) { |
| 497 |
3/4✓ Branch 9 → 10 taken 207776 times.
✗ Branch 9 → 11 not taken.
✓ Branch 12 → 13 taken 75791 times.
✓ Branch 12 → 18 taken 131985 times.
|
207776 | if (auto *stmtCtx = dynamic_cast<SpiceParser::StmtContext *>(stmt)) |
| 498 |
4/6✓ Branch 13 → 14 taken 75787 times.
✓ Branch 13 → 127 taken 4 times.
✓ Branch 14 → 15 taken 75787 times.
✗ Branch 14 → 125 not taken.
✓ Branch 15 → 16 taken 75787 times.
✗ Branch 15 → 125 not taken.
|
75791 | stmtLstNode->statements.push_back(std::any_cast<StmtNode *>(visit(stmtCtx))); |
| 499 |
3/4✓ Branch 18 → 19 taken 131985 times.
✗ Branch 18 → 20 not taken.
✓ Branch 21 → 22 taken 2826 times.
✓ Branch 21 → 27 taken 129159 times.
|
131985 | else if (auto *forLoopCtx = dynamic_cast<SpiceParser::ForLoopContext *>(stmt)) |
| 500 |
3/6✓ Branch 22 → 23 taken 2826 times.
✗ Branch 22 → 131 not taken.
✓ Branch 23 → 24 taken 2826 times.
✗ Branch 23 → 129 not taken.
✓ Branch 24 → 25 taken 2826 times.
✗ Branch 24 → 129 not taken.
|
2826 | stmtLstNode->statements.push_back(std::any_cast<ForLoopNode *>(visit(forLoopCtx))); |
| 501 |
3/4✓ Branch 27 → 28 taken 129159 times.
✗ Branch 27 → 29 not taken.
✓ Branch 30 → 31 taken 471 times.
✓ Branch 30 → 36 taken 128688 times.
|
129159 | else if (auto *foreachLoopCtx = dynamic_cast<SpiceParser::ForeachLoopContext *>(stmt)) |
| 502 |
3/6✓ Branch 31 → 32 taken 471 times.
✗ Branch 31 → 135 not taken.
✓ Branch 32 → 33 taken 471 times.
✗ Branch 32 → 133 not taken.
✓ Branch 33 → 34 taken 471 times.
✗ Branch 33 → 133 not taken.
|
471 | stmtLstNode->statements.push_back(std::any_cast<ForeachLoopNode *>(visit(foreachLoopCtx))); |
| 503 |
3/4✓ Branch 36 → 37 taken 128688 times.
✗ Branch 36 → 38 not taken.
✓ Branch 39 → 40 taken 1660 times.
✓ Branch 39 → 45 taken 127028 times.
|
128688 | else if (auto *whileLoopCtx = dynamic_cast<SpiceParser::WhileLoopContext *>(stmt)) |
| 504 |
3/6✓ Branch 40 → 41 taken 1660 times.
✗ Branch 40 → 139 not taken.
✓ Branch 41 → 42 taken 1660 times.
✗ Branch 41 → 137 not taken.
✓ Branch 42 → 43 taken 1660 times.
✗ Branch 42 → 137 not taken.
|
1660 | stmtLstNode->statements.push_back(std::any_cast<WhileLoopNode *>(visit(whileLoopCtx))); |
| 505 |
3/4✓ Branch 45 → 46 taken 127028 times.
✗ Branch 45 → 47 not taken.
✓ Branch 48 → 49 taken 16 times.
✓ Branch 48 → 54 taken 127012 times.
|
127028 | else if (auto *doWhileLoopCtx = dynamic_cast<SpiceParser::DoWhileLoopContext *>(stmt)) |
| 506 |
3/6✓ Branch 49 → 50 taken 16 times.
✗ Branch 49 → 143 not taken.
✓ Branch 50 → 51 taken 16 times.
✗ Branch 50 → 141 not taken.
✓ Branch 51 → 52 taken 16 times.
✗ Branch 51 → 141 not taken.
|
16 | stmtLstNode->statements.push_back(std::any_cast<DoWhileLoopNode *>(visit(doWhileLoopCtx))); |
| 507 |
3/4✓ Branch 54 → 55 taken 127012 times.
✗ Branch 54 → 56 not taken.
✓ Branch 57 → 58 taken 10525 times.
✓ Branch 57 → 63 taken 116487 times.
|
127012 | else if (auto *ifStmtCtx = dynamic_cast<SpiceParser::IfStmtContext *>(stmt)) |
| 508 |
3/6✓ Branch 58 → 59 taken 10525 times.
✗ Branch 58 → 147 not taken.
✓ Branch 59 → 60 taken 10525 times.
✗ Branch 59 → 145 not taken.
✓ Branch 60 → 61 taken 10525 times.
✗ Branch 60 → 145 not taken.
|
10525 | stmtLstNode->statements.push_back(std::any_cast<IfStmtNode *>(visit(ifStmtCtx))); |
| 509 |
3/4✓ Branch 63 → 64 taken 116487 times.
✗ Branch 63 → 65 not taken.
✓ Branch 66 → 67 taken 85 times.
✓ Branch 66 → 72 taken 116402 times.
|
116487 | else if (auto *switchStmtCtx = dynamic_cast<SpiceParser::SwitchStmtContext *>(stmt)) |
| 510 |
3/6✓ Branch 67 → 68 taken 85 times.
✗ Branch 67 → 151 not taken.
✓ Branch 68 → 69 taken 85 times.
✗ Branch 68 → 149 not taken.
✓ Branch 69 → 70 taken 85 times.
✗ Branch 69 → 149 not taken.
|
85 | stmtLstNode->statements.push_back(std::any_cast<SwitchStmtNode *>(visit(switchStmtCtx))); |
| 511 |
3/4✓ Branch 72 → 73 taken 116402 times.
✗ Branch 72 → 74 not taken.
✓ Branch 75 → 76 taken 3402 times.
✓ Branch 75 → 81 taken 113000 times.
|
116402 | else if (auto *assetStmtCtx = dynamic_cast<SpiceParser::AssertStmtContext *>(stmt)) |
| 512 |
3/6✓ Branch 76 → 77 taken 3402 times.
✗ Branch 76 → 155 not taken.
✓ Branch 77 → 78 taken 3402 times.
✗ Branch 77 → 153 not taken.
✓ Branch 78 → 79 taken 3402 times.
✗ Branch 78 → 153 not taken.
|
3402 | stmtLstNode->statements.push_back(std::any_cast<AssertStmtNode *>(visit(assetStmtCtx))); |
| 513 |
3/4✓ Branch 81 → 82 taken 113000 times.
✗ Branch 81 → 83 not taken.
✓ Branch 84 → 85 taken 5375 times.
✓ Branch 84 → 90 taken 107625 times.
|
113000 | else if (auto *unsafeBlockCtx = dynamic_cast<SpiceParser::UnsafeBlockContext *>(stmt)) |
| 514 |
3/6✓ Branch 85 → 86 taken 5375 times.
✗ Branch 85 → 159 not taken.
✓ Branch 86 → 87 taken 5375 times.
✗ Branch 86 → 157 not taken.
✓ Branch 87 → 88 taken 5375 times.
✗ Branch 87 → 157 not taken.
|
5375 | stmtLstNode->statements.push_back(std::any_cast<UnsafeBlockNode *>(visit(unsafeBlockCtx))); |
| 515 |
3/4✓ Branch 90 → 91 taken 107625 times.
✗ Branch 90 → 92 not taken.
✓ Branch 93 → 94 taken 43 times.
✓ Branch 93 → 99 taken 107582 times.
|
107625 | else if (auto *anonymousScopeCtx = dynamic_cast<SpiceParser::AnonymousBlockStmtContext *>(stmt)) |
| 516 |
3/6✓ Branch 94 → 95 taken 43 times.
✗ Branch 94 → 163 not taken.
✓ Branch 95 → 96 taken 43 times.
✗ Branch 95 → 161 not taken.
✓ Branch 96 → 97 taken 43 times.
✗ Branch 96 → 161 not taken.
|
43 | stmtLstNode->statements.push_back(std::any_cast<AnonymousBlockStmtNode *>(visit(anonymousScopeCtx))); |
| 517 | else | ||
| 518 | − | assert(dynamic_cast<TerminalNode *>(stmt) != nullptr); // GCOV_EXCL_LINE | |
| 519 | } | ||
| 520 | |||
| 521 |
1/2✓ Branch 120 → 121 taken 53789 times.
✗ Branch 120 → 166 not taken.
|
107578 | return concludeNode(stmtLstNode); |
| 522 | } | ||
| 523 | |||
| 524 | 19774 | std::any ASTBuilder::visitTypeLst(SpiceParser::TypeLstContext *ctx) { | |
| 525 | 19774 | const auto typeLstNode = createNode<TypeLstNode>(ctx); | |
| 526 | |||
| 527 | // Visit children | ||
| 528 |
3/6✓ Branch 3 → 4 taken 19774 times.
✗ Branch 3 → 18 not taken.
✓ Branch 4 → 5 taken 19774 times.
✗ Branch 4 → 16 not taken.
✓ Branch 6 → 7 taken 19774 times.
✗ Branch 6 → 19 not taken.
|
19774 | fetchChildrenIntoVector(typeLstNode->dataTypes, ctx->dataType()); |
| 529 | |||
| 530 |
1/2✓ Branch 12 → 13 taken 19774 times.
✗ Branch 12 → 19 not taken.
|
39548 | return concludeNode(typeLstNode); |
| 531 | } | ||
| 532 | |||
| 533 | 2756 | std::any ASTBuilder::visitTypeLstWithEllipsis(SpiceParser::TypeLstWithEllipsisContext *ctx) { | |
| 534 | 2756 | const auto typeLstWithEllipsisNode = createNode<TypeLstWithEllipsisNode>(ctx); | |
| 535 | |||
| 536 | // Visit children | ||
| 537 |
3/6✓ Branch 3 → 4 taken 2756 times.
✗ Branch 3 → 20 not taken.
✓ Branch 4 → 5 taken 2756 times.
✗ Branch 4 → 20 not taken.
✓ Branch 5 → 6 taken 2756 times.
✗ Branch 5 → 18 not taken.
|
2756 | typeLstWithEllipsisNode->typeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst())); |
| 538 | |||
| 539 | // Set some flags | ||
| 540 |
1/2✓ Branch 8 → 9 taken 2756 times.
✗ Branch 8 → 21 not taken.
|
2756 | typeLstWithEllipsisNode->hasEllipsis = ctx->ELLIPSIS() != nullptr; |
| 541 | |||
| 542 |
1/2✓ Branch 14 → 15 taken 2756 times.
✗ Branch 14 → 21 not taken.
|
5512 | return concludeNode(typeLstWithEllipsisNode); |
| 543 | } | ||
| 544 | |||
| 545 | 1929 | std::any ASTBuilder::visitTypeAltsLst(SpiceParser::TypeAltsLstContext *ctx) { | |
| 546 | 1929 | const auto typeAltsLstNode = createNode<TypeAltsLstNode>(ctx); | |
| 547 | |||
| 548 | // Visit children | ||
| 549 |
3/6✓ Branch 3 → 4 taken 1929 times.
✗ Branch 3 → 18 not taken.
✓ Branch 4 → 5 taken 1929 times.
✗ Branch 4 → 16 not taken.
✓ Branch 6 → 7 taken 1929 times.
✗ Branch 6 → 19 not taken.
|
1929 | fetchChildrenIntoVector(typeAltsLstNode->dataTypes, ctx->dataType()); |
| 550 | |||
| 551 |
1/2✓ Branch 12 → 13 taken 1929 times.
✗ Branch 12 → 19 not taken.
|
3858 | return concludeNode(typeAltsLstNode); |
| 552 | } | ||
| 553 | |||
| 554 | 23020 | std::any ASTBuilder::visitParamLst(SpiceParser::ParamLstContext *ctx) { | |
| 555 | 23020 | const auto paramLstNode = createNode<ParamLstNode>(ctx); | |
| 556 | |||
| 557 | // Visit children | ||
| 558 |
2/4✓ Branch 3 → 4 taken 23020 times.
✗ Branch 3 → 32 not taken.
✓ Branch 4 → 5 taken 23020 times.
✗ Branch 4 → 30 not taken.
|
23020 | fetchChildrenIntoVector(paramLstNode->params, ctx->declStmt()); |
| 559 | |||
| 560 | // Set some flags to later detect that the decl statements are parameters | ||
| 561 |
2/2✓ Branch 19 → 8 taken 33724 times.
✓ Branch 19 → 20 taken 23020 times.
|
79764 | for (DeclStmtNode *declStmt : paramLstNode->params) { |
| 562 | 33724 | declStmt->isFctParam = true; | |
| 563 | 33724 | declStmt->dataType->isParamType = true; | |
| 564 | } | ||
| 565 | |||
| 566 |
1/2✓ Branch 26 → 27 taken 23020 times.
✗ Branch 26 → 33 not taken.
|
46040 | return concludeNode(paramLstNode); |
| 567 | } | ||
| 568 | |||
| 569 | 39025 | std::any ASTBuilder::visitArgLst(SpiceParser::ArgLstContext *ctx) { | |
| 570 | 39025 | const auto argLstNode = createNode<ArgLstNode>(ctx); | |
| 571 | |||
| 572 | // Visit children | ||
| 573 |
2/4✓ Branch 3 → 4 taken 39025 times.
✗ Branch 3 → 20 not taken.
✓ Branch 4 → 5 taken 39025 times.
✗ Branch 4 → 18 not taken.
|
39025 | fetchChildrenIntoVector(argLstNode->args, ctx->assignExpr()); |
| 574 | 39025 | argLstNode->argInfos.reserve(argLstNode->args.size()); | |
| 575 | |||
| 576 |
1/2✓ Branch 14 → 15 taken 39025 times.
✗ Branch 14 → 21 not taken.
|
78050 | return concludeNode(argLstNode); |
| 577 | } | ||
| 578 | |||
| 579 | 369 | std::any ASTBuilder::visitEnumItemLst(SpiceParser::EnumItemLstContext *ctx) { | |
| 580 | 369 | const auto enumItemLstNode = createNode<EnumItemLstNode>(ctx); | |
| 581 | |||
| 582 | // Visit children | ||
| 583 |
3/6✓ Branch 3 → 4 taken 369 times.
✗ Branch 3 → 18 not taken.
✓ Branch 4 → 5 taken 369 times.
✗ Branch 4 → 16 not taken.
✓ Branch 6 → 7 taken 369 times.
✗ Branch 6 → 19 not taken.
|
369 | fetchChildrenIntoVector(enumItemLstNode->items, ctx->enumItem()); |
| 584 | |||
| 585 |
1/2✓ Branch 12 → 13 taken 369 times.
✗ Branch 12 → 19 not taken.
|
738 | return concludeNode(enumItemLstNode); |
| 586 | } | ||
| 587 | |||
| 588 | 4910 | std::any ASTBuilder::visitEnumItem(SpiceParser::EnumItemContext *ctx) { | |
| 589 | 4910 | const auto enumItemNode = createNode<EnumItemNode>(ctx); | |
| 590 | |||
| 591 | // Enrich | ||
| 592 |
2/4✓ Branch 3 → 4 taken 4910 times.
✗ Branch 3 → 22 not taken.
✓ Branch 4 → 5 taken 4910 times.
✗ Branch 4 → 22 not taken.
|
4910 | enumItemNode->itemName = getIdentifier(ctx->TYPE_IDENTIFIER(), false); |
| 593 |
2/2✓ Branch 8 → 9 taken 2642 times.
✓ Branch 8 → 12 taken 2268 times.
|
4910 | if (ctx->ASSIGN()) { |
| 594 | 2642 | enumItemNode->itemValue = parseInt(ctx->INT_LIT()); | |
| 595 | 2642 | enumItemNode->hasValue = true; | |
| 596 | } | ||
| 597 | |||
| 598 |
1/2✓ Branch 18 → 19 taken 4910 times.
✗ Branch 18 → 23 not taken.
|
9820 | return concludeNode(enumItemNode); |
| 599 | } | ||
| 600 | |||
| 601 | 5316 | std::any ASTBuilder::visitField(SpiceParser::FieldContext *ctx) { | |
| 602 | 5316 | const auto fieldNode = createNode<FieldNode>(ctx); | |
| 603 | |||
| 604 | // Enrich | ||
| 605 |
2/4✓ Branch 3 → 4 taken 5316 times.
✗ Branch 3 → 29 not taken.
✓ Branch 4 → 5 taken 5316 times.
✗ Branch 4 → 29 not taken.
|
5316 | fieldNode->fieldName = getIdentifier(ctx->IDENTIFIER(), false); |
| 606 | |||
| 607 | // Visit children | ||
| 608 |
3/6✓ Branch 7 → 8 taken 5316 times.
✗ Branch 7 → 32 not taken.
✓ Branch 8 → 9 taken 5316 times.
✗ Branch 8 → 32 not taken.
✓ Branch 9 → 10 taken 5316 times.
✗ Branch 9 → 30 not taken.
|
5316 | fieldNode->dataType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 609 | 5316 | fieldNode->dataType->setFieldTypeRecursive(); | |
| 610 |
2/2✓ Branch 13 → 14 taken 1104 times.
✓ Branch 13 → 19 taken 4212 times.
|
5316 | if (ctx->ternaryExpr()) |
| 611 |
3/6✓ Branch 14 → 15 taken 1104 times.
✗ Branch 14 → 35 not taken.
✓ Branch 15 → 16 taken 1104 times.
✗ Branch 15 → 35 not taken.
✓ Branch 16 → 17 taken 1104 times.
✗ Branch 16 → 33 not taken.
|
1104 | fieldNode->defaultValue = std::any_cast<ExprNode *>(visit(ctx->ternaryExpr())); |
| 612 | |||
| 613 |
1/2✓ Branch 25 → 26 taken 5316 times.
✗ Branch 25 → 36 not taken.
|
10632 | return concludeNode(fieldNode); |
| 614 | } | ||
| 615 | |||
| 616 | 1333 | std::any ASTBuilder::visitSignature(SpiceParser::SignatureContext *ctx) { | |
| 617 | 1333 | const auto signatureNode = createNode<SignatureNode>(ctx); | |
| 618 | |||
| 619 | // Extract method name | ||
| 620 |
2/4✓ Branch 3 → 4 taken 1333 times.
✗ Branch 3 → 73 not taken.
✓ Branch 4 → 5 taken 1333 times.
✗ Branch 4 → 73 not taken.
|
1333 | signatureNode->methodName = getIdentifier(ctx->IDENTIFIER(), false); |
| 621 | |||
| 622 | // Visit children | ||
| 623 |
2/2✓ Branch 8 → 9 taken 734 times.
✓ Branch 8 → 14 taken 599 times.
|
1333 | if (ctx->qualifierLst()) { |
| 624 |
3/6✓ Branch 9 → 10 taken 734 times.
✗ Branch 9 → 76 not taken.
✓ Branch 10 → 11 taken 734 times.
✗ Branch 10 → 76 not taken.
✓ Branch 11 → 12 taken 734 times.
✗ Branch 11 → 74 not taken.
|
734 | signatureNode->qualifierLst = std::any_cast<QualifierLstNode *>(visit(ctx->qualifierLst())); |
| 625 | } | ||
| 626 |
2/2✓ Branch 15 → 16 taken 1205 times.
✓ Branch 15 → 22 taken 128 times.
|
1333 | if (ctx->F()) { |
| 627 | 1205 | signatureNode->hasReturnType = true; | |
| 628 | 1205 | signatureNode->signatureType = SignatureNode::SignatureType::TYPE_FUNCTION; | |
| 629 | 1205 | signatureNode->signatureQualifiers = TypeQualifiers::of(TY_FUNCTION); | |
| 630 |
3/6✓ Branch 17 → 18 taken 1205 times.
✗ Branch 17 → 79 not taken.
✓ Branch 18 → 19 taken 1205 times.
✗ Branch 18 → 79 not taken.
✓ Branch 19 → 20 taken 1205 times.
✗ Branch 19 → 77 not taken.
|
1205 | signatureNode->returnType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 631 | } else { | ||
| 632 | 128 | signatureNode->signatureType = SignatureNode::SignatureType::TYPE_PROCEDURE; | |
| 633 | 128 | signatureNode->signatureQualifiers = TypeQualifiers::of(TY_PROCEDURE); | |
| 634 | } | ||
| 635 |
10/16✓ Branch 24 → 25 taken 1205 times.
✓ Branch 24 → 28 taken 128 times.
✓ Branch 25 → 26 taken 1205 times.
✗ Branch 25 → 80 not taken.
✓ Branch 28 → 29 taken 128 times.
✗ Branch 28 → 80 not taken.
✓ Branch 31 → 32 taken 128 times.
✓ Branch 31 → 33 taken 1205 times.
✓ Branch 33 → 34 taken 1205 times.
✓ Branch 33 → 35 taken 128 times.
✓ Branch 35 → 36 taken 237 times.
✓ Branch 35 → 41 taken 1096 times.
✗ Branch 80 → 81 not taken.
✗ Branch 80 → 82 not taken.
✗ Branch 84 → 85 not taken.
✗ Branch 84 → 86 not taken.
|
1333 | if (ctx->F() ? ctx->LESS().size() == 2 : ctx->LESS().size() == 1) { |
| 636 | 237 | signatureNode->hasTemplateTypes = true; | |
| 637 |
3/6✓ Branch 36 → 37 taken 237 times.
✗ Branch 36 → 90 not taken.
✓ Branch 37 → 38 taken 237 times.
✗ Branch 37 → 90 not taken.
✓ Branch 38 → 39 taken 237 times.
✗ Branch 38 → 88 not taken.
|
237 | signatureNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst(0))); |
| 638 | } | ||
| 639 |
13/20✓ Branch 41 → 42 taken 1333 times.
✗ Branch 41 → 91 not taken.
✓ Branch 43 → 44 taken 1331 times.
✓ Branch 43 → 48 taken 2 times.
✓ Branch 44 → 45 taken 1331 times.
✗ Branch 44 → 91 not taken.
✓ Branch 46 → 47 taken 659 times.
✓ Branch 46 → 49 taken 672 times.
✓ Branch 47 → 48 taken 424 times.
✓ Branch 47 → 49 taken 235 times.
✓ Branch 50 → 51 taken 1331 times.
✓ Branch 50 → 52 taken 2 times.
✓ Branch 52 → 53 taken 1333 times.
✗ Branch 52 → 54 not taken.
✓ Branch 54 → 55 taken 426 times.
✓ Branch 54 → 63 taken 907 times.
✗ Branch 91 → 92 not taken.
✗ Branch 91 → 93 not taken.
✗ Branch 95 → 96 not taken.
✗ Branch 95 → 97 not taken.
|
1333 | if (ctx->typeLst().size() == 2 || (ctx->typeLst().size() == 1 && !signatureNode->hasTemplateTypes)) { |
| 640 | 426 | signatureNode->hasParams = true; | |
| 641 |
5/8✓ Branch 55 → 56 taken 2 times.
✓ Branch 55 → 57 taken 424 times.
✓ Branch 58 → 59 taken 426 times.
✗ Branch 58 → 101 not taken.
✓ Branch 59 → 60 taken 426 times.
✗ Branch 59 → 101 not taken.
✓ Branch 60 → 61 taken 426 times.
✗ Branch 60 → 99 not taken.
|
426 | signatureNode->paramTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst(signatureNode->hasTemplateTypes ? 1 : 0))); |
| 642 | } | ||
| 643 | |||
| 644 |
1/2✓ Branch 69 → 70 taken 1333 times.
✗ Branch 69 → 102 not taken.
|
2666 | return concludeNode(signatureNode); |
| 645 | } | ||
| 646 | |||
| 647 | 75791 | std::any ASTBuilder::visitStmt(SpiceParser::StmtContext *ctx) { | |
| 648 |
2/2✓ Branch 3 → 4 taken 14061 times.
✓ Branch 3 → 11 taken 61730 times.
|
75791 | if (ctx->declStmt()) |
| 649 |
5/8✓ Branch 4 → 5 taken 14061 times.
✗ Branch 4 → 60 not taken.
✓ Branch 5 → 6 taken 14057 times.
✓ Branch 5 → 60 taken 4 times.
✓ Branch 6 → 7 taken 14057 times.
✗ Branch 6 → 58 not taken.
✓ Branch 7 → 8 taken 14057 times.
✗ Branch 7 → 58 not taken.
|
28118 | return static_cast<StmtNode *>(std::any_cast<DeclStmtNode *>(visit(ctx->declStmt()))); |
| 650 |
2/2✓ Branch 12 → 13 taken 36785 times.
✓ Branch 12 → 20 taken 24945 times.
|
61730 | if (ctx->exprStmt()) |
| 651 |
4/8✓ Branch 13 → 14 taken 36785 times.
✗ Branch 13 → 64 not taken.
✓ Branch 14 → 15 taken 36785 times.
✗ Branch 14 → 64 not taken.
✓ Branch 15 → 16 taken 36785 times.
✗ Branch 15 → 62 not taken.
✓ Branch 16 → 17 taken 36785 times.
✗ Branch 16 → 62 not taken.
|
73570 | return static_cast<StmtNode *>(std::any_cast<ExprStmtNode *>(visit(ctx->exprStmt()))); |
| 652 |
2/2✓ Branch 21 → 22 taken 24307 times.
✓ Branch 21 → 29 taken 638 times.
|
24945 | if (ctx->returnStmt()) |
| 653 |
4/8✓ Branch 22 → 23 taken 24307 times.
✗ Branch 22 → 68 not taken.
✓ Branch 23 → 24 taken 24307 times.
✗ Branch 23 → 68 not taken.
✓ Branch 24 → 25 taken 24307 times.
✗ Branch 24 → 66 not taken.
✓ Branch 25 → 26 taken 24307 times.
✗ Branch 25 → 66 not taken.
|
48614 | return static_cast<StmtNode *>(std::any_cast<ReturnStmtNode *>(visit(ctx->returnStmt()))); |
| 654 |
2/2✓ Branch 30 → 31 taken 229 times.
✓ Branch 30 → 38 taken 409 times.
|
638 | if (ctx->breakStmt()) |
| 655 |
4/8✓ Branch 31 → 32 taken 229 times.
✗ Branch 31 → 72 not taken.
✓ Branch 32 → 33 taken 229 times.
✗ Branch 32 → 72 not taken.
✓ Branch 33 → 34 taken 229 times.
✗ Branch 33 → 70 not taken.
✓ Branch 34 → 35 taken 229 times.
✗ Branch 34 → 70 not taken.
|
458 | return static_cast<StmtNode *>(std::any_cast<BreakStmtNode *>(visit(ctx->breakStmt()))); |
| 656 |
2/2✓ Branch 39 → 40 taken 403 times.
✓ Branch 39 → 47 taken 6 times.
|
409 | if (ctx->continueStmt()) |
| 657 |
4/8✓ Branch 40 → 41 taken 403 times.
✗ Branch 40 → 76 not taken.
✓ Branch 41 → 42 taken 403 times.
✗ Branch 41 → 76 not taken.
✓ Branch 42 → 43 taken 403 times.
✗ Branch 42 → 74 not taken.
✓ Branch 43 → 44 taken 403 times.
✗ Branch 43 → 74 not taken.
|
806 | return static_cast<StmtNode *>(std::any_cast<ContinueStmtNode *>(visit(ctx->continueStmt()))); |
| 658 |
1/2✓ Branch 48 → 49 taken 6 times.
✗ Branch 48 → 56 not taken.
|
6 | if (ctx->fallthroughStmt()) |
| 659 |
4/8✓ Branch 49 → 50 taken 6 times.
✗ Branch 49 → 80 not taken.
✓ Branch 50 → 51 taken 6 times.
✗ Branch 50 → 80 not taken.
✓ Branch 51 → 52 taken 6 times.
✗ Branch 51 → 78 not taken.
✓ Branch 52 → 53 taken 6 times.
✗ Branch 52 → 78 not taken.
|
12 | return static_cast<StmtNode *>(std::any_cast<FallthroughStmtNode *>(visit(ctx->fallthroughStmt()))); |
| 660 | − | assert_fail("Unknown statement type"); // GCOV_EXCL_LINE | |
| 661 | return nullptr; // GCOV_EXCL_LINE | ||
| 662 | } | ||
| 663 | |||
| 664 | 51140 | std::any ASTBuilder::visitDeclStmt(SpiceParser::DeclStmtContext *ctx) { | |
| 665 | 51140 | const auto declStmtNode = createNode<DeclStmtNode>(ctx); | |
| 666 | |||
| 667 | // Enrich | ||
| 668 |
3/4✓ Branch 3 → 4 taken 51140 times.
✗ Branch 3 → 28 not taken.
✓ Branch 4 → 5 taken 51139 times.
✓ Branch 4 → 28 taken 1 time.
|
51140 | declStmtNode->varName = getIdentifier(ctx->IDENTIFIER(), false); |
| 669 | |||
| 670 | // Visit children | ||
| 671 |
4/6✓ Branch 7 → 8 taken 51139 times.
✗ Branch 7 → 31 not taken.
✓ Branch 8 → 9 taken 51138 times.
✓ Branch 8 → 31 taken 1 time.
✓ Branch 9 → 10 taken 51138 times.
✗ Branch 9 → 29 not taken.
|
51139 | declStmtNode->dataType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 672 |
2/2✓ Branch 12 → 13 taken 18332 times.
✓ Branch 12 → 18 taken 32806 times.
|
51138 | if (ctx->assignExpr()) { |
| 673 | 18332 | declStmtNode->hasAssignment = true; | |
| 674 |
4/6✓ Branch 13 → 14 taken 18332 times.
✗ Branch 13 → 34 not taken.
✓ Branch 14 → 15 taken 18330 times.
✓ Branch 14 → 34 taken 2 times.
✓ Branch 15 → 16 taken 18330 times.
✗ Branch 15 → 32 not taken.
|
18332 | declStmtNode->assignExpr = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 675 | } | ||
| 676 | |||
| 677 |
1/2✓ Branch 24 → 25 taken 51136 times.
✗ Branch 24 → 35 not taken.
|
102272 | return concludeNode(declStmtNode); |
| 678 | } | ||
| 679 | |||
| 680 | 36785 | std::any ASTBuilder::visitExprStmt(SpiceParser::ExprStmtContext *ctx) { | |
| 681 | 36785 | const auto exprStmtNode = createNode<ExprStmtNode>(ctx); | |
| 682 | |||
| 683 | // Enrich | ||
| 684 |
4/8✓ Branch 3 → 4 taken 36785 times.
✗ Branch 3 → 19 not taken.
✓ Branch 4 → 5 taken 36785 times.
✗ Branch 4 → 19 not taken.
✓ Branch 5 → 6 taken 36785 times.
✗ Branch 5 → 17 not taken.
✓ Branch 7 → 8 taken 36785 times.
✗ Branch 7 → 20 not taken.
|
36785 | exprStmtNode->expr = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 685 | |||
| 686 |
1/2✓ Branch 13 → 14 taken 36785 times.
✗ Branch 13 → 20 not taken.
|
73570 | return concludeNode(exprStmtNode); |
| 687 | } | ||
| 688 | |||
| 689 | 77432 | std::any ASTBuilder::visitQualifierLst(SpiceParser::QualifierLstContext *ctx) { | |
| 690 | 77432 | const auto qualifierLstNode = createNode<QualifierLstNode>(ctx); | |
| 691 | |||
| 692 | // Visit children | ||
| 693 |
2/4✓ Branch 3 → 4 taken 77432 times.
✗ Branch 3 → 45 not taken.
✓ Branch 4 → 5 taken 77432 times.
✗ Branch 4 → 43 not taken.
|
77432 | fetchChildrenIntoVector(qualifierLstNode->qualifiers, ctx->qualifier()); |
| 694 | |||
| 695 | // Check if qualifier combination is invalid | ||
| 696 | 77432 | bool seenSignedOrUnsigned = false; | |
| 697 |
2/2✓ Branch 32 → 8 taken 91351 times.
✓ Branch 32 → 33 taken 77431 times.
|
246214 | for (const QualifierNode *qualifier : qualifierLstNode->qualifiers) { |
| 698 | // Check if we have both, signed and unsigned qualifier | ||
| 699 |
2/2✓ Branch 10 → 11 taken 91344 times.
✓ Branch 10 → 13 taken 7 times.
|
91351 | if (qualifier->type != QualifierNode::QualifierType::TY_SIGNED && |
| 700 |
2/2✓ Branch 11 → 12 taken 72247 times.
✓ Branch 11 → 13 taken 19097 times.
|
91344 | qualifier->type != QualifierNode::QualifierType::TY_UNSIGNED) |
| 701 | 72247 | continue; | |
| 702 |
2/2✓ Branch 13 → 14 taken 1 time.
✓ Branch 13 → 22 taken 19103 times.
|
19104 | if (seenSignedOrUnsigned) |
| 703 |
2/4✓ Branch 17 → 18 taken 1 time.
✗ Branch 17 → 49 not taken.
✓ Branch 18 → 19 taken 1 time.
✗ Branch 18 → 46 not taken.
|
3 | throw ParserError(qualifier->codeLoc, INVALID_QUALIFIER_COMBINATION, "A variable can not be signed and unsigned"); |
| 704 | 19103 | seenSignedOrUnsigned = true; | |
| 705 | } | ||
| 706 | |||
| 707 |
1/2✓ Branch 39 → 40 taken 77431 times.
✗ Branch 39 → 56 not taken.
|
154862 | return concludeNode(qualifierLstNode); |
| 708 | } | ||
| 709 | |||
| 710 | 91351 | std::any ASTBuilder::visitQualifier(SpiceParser::QualifierContext *ctx) { | |
| 711 | 91351 | const auto qualifierNode = createNode<QualifierNode>(ctx); | |
| 712 | |||
| 713 |
3/4✓ Branch 7 → 8 taken 91351 times.
✗ Branch 7 → 9 not taken.
✓ Branch 40 → 5 taken 91351 times.
✓ Branch 40 → 41 taken 91351 times.
|
365404 | for (ParserRuleContext::ParseTree *subTree : ctx->children) { |
| 714 | 91351 | const auto token = spice_pointer_cast<TerminalNode *>(subTree); | |
| 715 |
2/4✓ Branch 14 → 15 taken 91351 times.
✗ Branch 14 → 51 not taken.
✓ Branch 15 → 16 taken 91351 times.
✗ Branch 15 → 51 not taken.
|
91351 | const size_t symbolType = token->getSymbol()->getType(); |
| 716 |
2/2✓ Branch 16 → 17 taken 19503 times.
✓ Branch 16 → 18 taken 71848 times.
|
91351 | if (symbolType == SpiceParser::CONST) |
| 717 | 19503 | qualifierNode->type = QualifierNode::QualifierType::TY_CONST; | |
| 718 |
2/2✓ Branch 18 → 19 taken 7 times.
✓ Branch 18 → 20 taken 71841 times.
|
71848 | else if (symbolType == SpiceParser::SIGNED) |
| 719 | 7 | qualifierNode->type = QualifierNode::QualifierType::TY_SIGNED; | |
| 720 |
2/2✓ Branch 20 → 21 taken 19097 times.
✓ Branch 20 → 22 taken 52744 times.
|
71841 | else if (symbolType == SpiceParser::UNSIGNED) |
| 721 | 19097 | qualifierNode->type = QualifierNode::QualifierType::TY_UNSIGNED; | |
| 722 |
2/2✓ Branch 22 → 23 taken 6611 times.
✓ Branch 22 → 24 taken 46133 times.
|
52744 | else if (symbolType == SpiceParser::INLINE) |
| 723 | 6611 | qualifierNode->type = QualifierNode::QualifierType::TY_INLINE; | |
| 724 |
2/2✓ Branch 24 → 25 taken 36117 times.
✓ Branch 24 → 26 taken 10016 times.
|
46133 | else if (symbolType == SpiceParser::PUBLIC) |
| 725 | 36117 | qualifierNode->type = QualifierNode::QualifierType::TY_PUBLIC; | |
| 726 |
2/2✓ Branch 26 → 27 taken 8923 times.
✓ Branch 26 → 28 taken 1093 times.
|
10016 | else if (symbolType == SpiceParser::HEAP) |
| 727 | 8923 | qualifierNode->type = QualifierNode::QualifierType::TY_HEAP; | |
| 728 |
1/2✓ Branch 28 → 29 taken 1093 times.
✗ Branch 28 → 30 not taken.
|
1093 | else if (symbolType == SpiceParser::COMPOSE) |
| 729 | 1093 | qualifierNode->type = QualifierNode::QualifierType::TY_COMPOSITION; | |
| 730 | else | ||
| 731 | − | assert_fail("Unknown qualifier type"); // GCOV_EXCL_LINE | |
| 732 | } | ||
| 733 | |||
| 734 |
1/2✓ Branch 47 → 48 taken 91351 times.
✗ Branch 47 → 52 not taken.
|
182702 | return concludeNode(qualifierNode); |
| 735 | } | ||
| 736 | |||
| 737 | 684 | std::any ASTBuilder::visitModAttr(SpiceParser::ModAttrContext *ctx) { | |
| 738 | 684 | const auto modAttrNode = createNode<ModAttrNode>(ctx); | |
| 739 | |||
| 740 | // Visit children | ||
| 741 |
4/6✓ Branch 3 → 4 taken 684 times.
✗ Branch 3 → 33 not taken.
✓ Branch 4 → 5 taken 683 times.
✓ Branch 4 → 33 taken 1 time.
✓ Branch 5 → 6 taken 683 times.
✗ Branch 5 → 31 not taken.
|
684 | modAttrNode->attrLst = std::any_cast<AttrLstNode *>(visit(ctx->attrLst())); |
| 742 | |||
| 743 | // Tell the attributes that they are module attributes | ||
| 744 |
2/2✓ Branch 20 → 9 taken 2207 times.
✓ Branch 20 → 21 taken 683 times.
|
3573 | for (AttrNode *attr : modAttrNode->attrLst->attributes) |
| 745 | 2207 | attr->target = AttrNode::TARGET_MODULE; | |
| 746 | |||
| 747 |
1/2✓ Branch 27 → 28 taken 683 times.
✗ Branch 27 → 34 not taken.
|
1366 | return concludeNode(modAttrNode); |
| 748 | } | ||
| 749 | |||
| 750 | 953 | std::any ASTBuilder::visitTopLevelDefAttr(SpiceParser::TopLevelDefAttrContext *ctx) { | |
| 751 | 953 | const auto fctAttrNode = createNode<TopLevelDefAttrNode>(ctx); | |
| 752 | |||
| 753 | // Visit children | ||
| 754 |
4/8✓ Branch 3 → 4 taken 953 times.
✗ Branch 3 → 19 not taken.
✓ Branch 4 → 5 taken 953 times.
✗ Branch 4 → 19 not taken.
✓ Branch 5 → 6 taken 953 times.
✗ Branch 5 → 17 not taken.
✓ Branch 7 → 8 taken 953 times.
✗ Branch 7 → 20 not taken.
|
953 | fctAttrNode->attrLst = std::any_cast<AttrLstNode *>(visit(ctx->attrLst())); |
| 755 | |||
| 756 |
1/2✓ Branch 13 → 14 taken 953 times.
✗ Branch 13 → 20 not taken.
|
1906 | return concludeNode(fctAttrNode); |
| 757 | } | ||
| 758 | |||
| 759 | 6 | std::any ASTBuilder::visitLambdaAttr(SpiceParser::LambdaAttrContext *ctx) { | |
| 760 | 6 | const auto lambdaAttrNode = createNode<LambdaAttrNode>(ctx); | |
| 761 | |||
| 762 | // Visit children | ||
| 763 |
3/6✓ Branch 3 → 4 taken 6 times.
✗ Branch 3 → 33 not taken.
✓ Branch 4 → 5 taken 6 times.
✗ Branch 4 → 33 not taken.
✓ Branch 5 → 6 taken 6 times.
✗ Branch 5 → 31 not taken.
|
6 | lambdaAttrNode->attrLst = std::any_cast<AttrLstNode *>(visit(ctx->attrLst())); |
| 764 | |||
| 765 | // Tell the attributes that they are module attributes | ||
| 766 |
2/2✓ Branch 20 → 9 taken 6 times.
✓ Branch 20 → 21 taken 6 times.
|
18 | for (AttrNode *attr : lambdaAttrNode->attrLst->attributes) |
| 767 | 6 | attr->target = AttrNode::TARGET_LAMBDA; | |
| 768 | |||
| 769 |
1/2✓ Branch 27 → 28 taken 6 times.
✗ Branch 27 → 34 not taken.
|
12 | return concludeNode(lambdaAttrNode); |
| 770 | } | ||
| 771 | |||
| 772 | 1643 | std::any ASTBuilder::visitAttrLst(SpiceParser::AttrLstContext *ctx) { | |
| 773 | 1643 | const auto attrLstNode = createNode<AttrLstNode>(ctx); | |
| 774 | |||
| 775 | // Visit children | ||
| 776 |
4/6✓ Branch 3 → 4 taken 1643 times.
✗ Branch 3 → 18 not taken.
✓ Branch 4 → 5 taken 1642 times.
✓ Branch 4 → 16 taken 1 time.
✓ Branch 6 → 7 taken 1642 times.
✗ Branch 6 → 19 not taken.
|
1644 | fetchChildrenIntoVector(attrLstNode->attributes, ctx->attr()); |
| 777 | |||
| 778 |
1/2✓ Branch 12 → 13 taken 1642 times.
✗ Branch 12 → 19 not taken.
|
3284 | return concludeNode(attrLstNode); |
| 779 | } | ||
| 780 | |||
| 781 | 3267 | std::any ASTBuilder::visitAttr(SpiceParser::AttrContext *ctx) { | |
| 782 |
1/2✓ Branch 2 → 3 taken 3267 times.
✗ Branch 2 → 83 not taken.
|
3267 | const auto attrNode = createNode<AttrNode>(ctx); |
| 783 | |||
| 784 | // Extract key | ||
| 785 |
1/2✓ Branch 3 → 4 taken 3267 times.
✗ Branch 3 → 83 not taken.
|
3267 | std::stringstream key; |
| 786 |
3/4✓ Branch 12 → 13 taken 11817 times.
✗ Branch 12 → 66 not taken.
✓ Branch 15 → 5 taken 8550 times.
✓ Branch 15 → 16 taken 3267 times.
|
11817 | for (size_t i = 0; i < ctx->IDENTIFIER().size(); i++) { |
| 787 |
2/2✓ Branch 5 → 6 taken 5283 times.
✓ Branch 5 → 7 taken 3267 times.
|
8550 | if (i > 0) |
| 788 |
1/2✓ Branch 6 → 7 taken 5283 times.
✗ Branch 6 → 81 not taken.
|
5283 | key << MEMBER_ACCESS_TOKEN; |
| 789 |
3/6✓ Branch 7 → 8 taken 8550 times.
✗ Branch 7 → 65 not taken.
✓ Branch 8 → 9 taken 8550 times.
✗ Branch 8 → 65 not taken.
✓ Branch 9 → 10 taken 8550 times.
✗ Branch 9 → 63 not taken.
|
8550 | key << ctx->IDENTIFIER(i)->getText(); |
| 790 | } | ||
| 791 |
1/2✓ Branch 16 → 17 taken 3267 times.
✗ Branch 16 → 67 not taken.
|
3267 | attrNode->key = key.str(); |
| 792 | |||
| 793 | // Visit children | ||
| 794 |
3/4✓ Branch 19 → 20 taken 3267 times.
✗ Branch 19 → 81 not taken.
✓ Branch 20 → 21 taken 2556 times.
✓ Branch 20 → 51 taken 711 times.
|
3267 | if (ctx->constant()) { |
| 795 |
3/6✓ Branch 21 → 22 taken 2556 times.
✗ Branch 21 → 70 not taken.
✓ Branch 22 → 23 taken 2556 times.
✗ Branch 22 → 70 not taken.
✓ Branch 23 → 24 taken 2556 times.
✗ Branch 23 → 68 not taken.
|
2556 | attrNode->value = std::any_cast<ConstantNode *>(visit(ctx->constant())); |
| 796 | |||
| 797 |
4/6✓ Branch 25 → 26 taken 2556 times.
✗ Branch 25 → 81 not taken.
✓ Branch 26 → 27 taken 2556 times.
✗ Branch 26 → 81 not taken.
✓ Branch 27 → 28 taken 1642 times.
✓ Branch 27 → 29 taken 914 times.
|
2556 | if (ctx->constant()->STRING_LIT()) |
| 798 | 1642 | attrNode->type = AttrNode::AttrType::TYPE_STRING; | |
| 799 |
4/6✓ Branch 29 → 30 taken 914 times.
✗ Branch 29 → 81 not taken.
✓ Branch 30 → 31 taken 914 times.
✗ Branch 30 → 81 not taken.
✓ Branch 31 → 32 taken 154 times.
✓ Branch 31 → 33 taken 760 times.
|
914 | else if (ctx->constant()->INT_LIT()) |
| 800 | 154 | attrNode->type = AttrNode::AttrType::TYPE_INT; | |
| 801 |
10/14✓ Branch 33 → 34 taken 760 times.
✗ Branch 33 → 81 not taken.
✓ Branch 34 → 35 taken 760 times.
✗ Branch 34 → 81 not taken.
✓ Branch 35 → 36 taken 5 times.
✓ Branch 35 → 39 taken 755 times.
✓ Branch 36 → 37 taken 5 times.
✗ Branch 36 → 81 not taken.
✓ Branch 37 → 38 taken 5 times.
✗ Branch 37 → 81 not taken.
✓ Branch 38 → 39 taken 4 times.
✓ Branch 38 → 40 taken 1 time.
✓ Branch 41 → 42 taken 759 times.
✓ Branch 41 → 43 taken 1 time.
|
760 | else if (ctx->constant()->TRUE() || ctx->constant()->FALSE()) |
| 802 | 759 | attrNode->type = AttrNode::AttrType::TYPE_BOOL; | |
| 803 | else | ||
| 804 |
2/4✓ Branch 46 → 47 taken 1 time.
✗ Branch 46 → 74 not taken.
✓ Branch 47 → 48 taken 1 time.
✗ Branch 47 → 71 not taken.
|
3 | throw ParserError(attrNode->value->codeLoc, INVALID_ATTR_VALUE_TYPE, "Invalid attribute value type"); |
| 805 | } else { | ||
| 806 | // If no value is given, use the bool type | ||
| 807 | 711 | attrNode->type = AttrNode::AttrType::TYPE_BOOL; | |
| 808 | } | ||
| 809 | |||
| 810 |
1/2✓ Branch 58 → 59 taken 3266 times.
✗ Branch 58 → 80 not taken.
|
6532 | return concludeNode(attrNode); |
| 811 | 3267 | } | |
| 812 | |||
| 813 | 847 | std::any ASTBuilder::visitCaseConstant(SpiceParser::CaseConstantContext *ctx) { | |
| 814 | 847 | const auto caseConstantNode = createNode<CaseConstantNode>(ctx); | |
| 815 | |||
| 816 | // Visit children | ||
| 817 |
2/2✓ Branch 4 → 5 taken 18 times.
✓ Branch 4 → 10 taken 829 times.
|
847 | if (ctx->constant()) { |
| 818 |
3/6✓ Branch 5 → 6 taken 18 times.
✗ Branch 5 → 65 not taken.
✓ Branch 6 → 7 taken 18 times.
✗ Branch 6 → 65 not taken.
✓ Branch 7 → 8 taken 18 times.
✗ Branch 7 → 63 not taken.
|
18 | caseConstantNode->constant = std::any_cast<ConstantNode *>(visit(ctx->constant())); |
| 819 |
2/4✓ Branch 10 → 11 taken 829 times.
✗ Branch 10 → 66 not taken.
✓ Branch 13 → 14 taken 829 times.
✗ Branch 13 → 52 not taken.
|
829 | } else if (!ctx->TYPE_IDENTIFIER().empty()) { |
| 820 |
1/2✓ Branch 14 → 15 taken 829 times.
✗ Branch 14 → 75 not taken.
|
829 | std::stringstream fqIdentifier; |
| 821 |
2/2✓ Branch 46 → 17 taken 2233 times.
✓ Branch 46 → 47 taken 829 times.
|
3891 | for (antlr4::tree::ParseTree *parseTree : ctx->children) { |
| 822 |
1/2✓ Branch 19 → 20 taken 2233 times.
✗ Branch 19 → 21 not taken.
|
2233 | const auto terminal = dynamic_cast<TerminalNode *>(parseTree); |
| 823 |
1/2✗ Branch 22 → 23 not taken.
✓ Branch 22 → 24 taken 2233 times.
|
2233 | if (!terminal) |
| 824 | ✗ | continue; | |
| 825 | |||
| 826 |
2/4✓ Branch 24 → 25 taken 2233 times.
✗ Branch 24 → 71 not taken.
✓ Branch 25 → 26 taken 2233 times.
✗ Branch 25 → 71 not taken.
|
2233 | const size_t terminalType = terminal->getSymbol()->getType(); |
| 827 |
3/4✓ Branch 26 → 27 taken 2233 times.
✗ Branch 26 → 28 not taken.
✓ Branch 27 → 28 taken 1531 times.
✓ Branch 27 → 37 taken 702 times.
|
2233 | if (terminalType == SpiceParser::IDENTIFIER || terminalType == SpiceParser::TYPE_IDENTIFIER) { |
| 828 |
1/2✓ Branch 28 → 29 taken 1531 times.
✗ Branch 28 → 70 not taken.
|
1531 | const std::string fragment = getIdentifier(terminal, false); |
| 829 |
1/2✓ Branch 29 → 30 taken 1531 times.
✗ Branch 29 → 68 not taken.
|
1531 | caseConstantNode->identifierFragments.push_back(fragment); |
| 830 |
3/4✓ Branch 30 → 31 taken 1531 times.
✗ Branch 30 → 67 not taken.
✓ Branch 32 → 33 taken 702 times.
✓ Branch 32 → 34 taken 829 times.
|
1531 | if (fqIdentifier.tellp() != 0) |
| 831 |
1/2✓ Branch 33 → 34 taken 702 times.
✗ Branch 33 → 68 not taken.
|
702 | fqIdentifier << SCOPE_ACCESS_TOKEN; |
| 832 |
1/2✓ Branch 34 → 35 taken 1531 times.
✗ Branch 34 → 68 not taken.
|
1531 | fqIdentifier << fragment; |
| 833 | 1531 | } | |
| 834 | } | ||
| 835 |
1/2✓ Branch 47 → 48 taken 829 times.
✗ Branch 47 → 72 not taken.
|
829 | caseConstantNode->fqIdentifier = fqIdentifier.str(); |
| 836 | 829 | } else { | |
| 837 | − | assert_fail("Unknown case constant type"); // GCOV_EXCL_LINE | |
| 838 | } | ||
| 839 | |||
| 840 |
1/2✓ Branch 59 → 60 taken 847 times.
✗ Branch 59 → 76 not taken.
|
1694 | return concludeNode(caseConstantNode); |
| 841 | } | ||
| 842 | |||
| 843 | 24307 | std::any ASTBuilder::visitReturnStmt(SpiceParser::ReturnStmtContext *ctx) { | |
| 844 | 24307 | const auto returnStmtNode = createNode<ReturnStmtNode>(ctx); | |
| 845 | |||
| 846 | // Visit children | ||
| 847 |
2/2✓ Branch 4 → 5 taken 23616 times.
✓ Branch 4 → 10 taken 691 times.
|
24307 | if (ctx->assignExpr()) { |
| 848 | 23616 | returnStmtNode->hasReturnValue = true; | |
| 849 |
3/6✓ Branch 5 → 6 taken 23616 times.
✗ Branch 5 → 22 not taken.
✓ Branch 6 → 7 taken 23616 times.
✗ Branch 6 → 22 not taken.
✓ Branch 7 → 8 taken 23616 times.
✗ Branch 7 → 20 not taken.
|
23616 | returnStmtNode->assignExpr = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 850 | } | ||
| 851 | |||
| 852 |
1/2✓ Branch 16 → 17 taken 24307 times.
✗ Branch 16 → 23 not taken.
|
48614 | return concludeNode(returnStmtNode); |
| 853 | } | ||
| 854 | |||
| 855 | 229 | std::any ASTBuilder::visitBreakStmt(SpiceParser::BreakStmtContext *ctx) { | |
| 856 | 229 | const auto breakStmtNode = createNode<BreakStmtNode>(ctx); | |
| 857 | |||
| 858 | // Extract number of breaks | ||
| 859 |
2/2✓ Branch 4 → 5 taken 6 times.
✓ Branch 4 → 10 taken 223 times.
|
229 | if (ctx->INT_LIT()) |
| 860 |
3/6✓ Branch 5 → 6 taken 6 times.
✗ Branch 5 → 24 not taken.
✓ Branch 6 → 7 taken 6 times.
✗ Branch 6 → 24 not taken.
✓ Branch 7 → 8 taken 6 times.
✗ Branch 7 → 22 not taken.
|
6 | breakStmtNode->breakTimes = std::stoi(ctx->INT_LIT()->toString()); |
| 861 | |||
| 862 | // Visit children | ||
| 863 |
2/4✓ Branch 10 → 11 taken 229 times.
✗ Branch 10 → 25 not taken.
✓ Branch 12 → 13 taken 229 times.
✗ Branch 12 → 26 not taken.
|
229 | visitChildren(ctx); |
| 864 | |||
| 865 |
1/2✓ Branch 18 → 19 taken 229 times.
✗ Branch 18 → 26 not taken.
|
458 | return concludeNode(breakStmtNode); |
| 866 | } | ||
| 867 | |||
| 868 | 403 | std::any ASTBuilder::visitContinueStmt(SpiceParser::ContinueStmtContext *ctx) { | |
| 869 | 403 | const auto continueStmtNode = createNode<ContinueStmtNode>(ctx); | |
| 870 | |||
| 871 | // Extract number of continues | ||
| 872 |
2/2✓ Branch 4 → 5 taken 328 times.
✓ Branch 4 → 10 taken 75 times.
|
403 | if (ctx->INT_LIT()) |
| 873 |
3/6✓ Branch 5 → 6 taken 328 times.
✗ Branch 5 → 24 not taken.
✓ Branch 6 → 7 taken 328 times.
✗ Branch 6 → 24 not taken.
✓ Branch 7 → 8 taken 328 times.
✗ Branch 7 → 22 not taken.
|
328 | continueStmtNode->continueTimes = std::stoi(ctx->INT_LIT()->toString()); |
| 874 | |||
| 875 | // Visit children | ||
| 876 |
2/4✓ Branch 10 → 11 taken 403 times.
✗ Branch 10 → 25 not taken.
✓ Branch 12 → 13 taken 403 times.
✗ Branch 12 → 26 not taken.
|
403 | visitChildren(ctx); |
| 877 | |||
| 878 |
1/2✓ Branch 18 → 19 taken 403 times.
✗ Branch 18 → 26 not taken.
|
806 | return concludeNode(continueStmtNode); |
| 879 | } | ||
| 880 | |||
| 881 | 6 | std::any ASTBuilder::visitFallthroughStmt(SpiceParser::FallthroughStmtContext *ctx) { | |
| 882 | 6 | const auto fallthroughStmtNode = createNode<FallthroughStmtNode>(ctx); | |
| 883 | |||
| 884 | // Visit children | ||
| 885 |
2/4✓ Branch 3 → 4 taken 6 times.
✗ Branch 3 → 15 not taken.
✓ Branch 5 → 6 taken 6 times.
✗ Branch 5 → 16 not taken.
|
6 | visitChildren(ctx); |
| 886 | |||
| 887 |
1/2✓ Branch 11 → 12 taken 6 times.
✗ Branch 11 → 16 not taken.
|
12 | return concludeNode(fallthroughStmtNode); |
| 888 | } | ||
| 889 | |||
| 890 | 3402 | std::any ASTBuilder::visitAssertStmt(SpiceParser::AssertStmtContext *ctx) { | |
| 891 |
1/2✓ Branch 2 → 3 taken 3402 times.
✗ Branch 2 → 30 not taken.
|
3402 | const auto assertStmtNode = createNode<AssertStmtNode>(ctx); |
| 892 | |||
| 893 | // Enrich | ||
| 894 |
5/10✓ Branch 3 → 4 taken 3402 times.
✗ Branch 3 → 30 not taken.
✓ Branch 4 → 5 taken 3402 times.
✗ Branch 4 → 30 not taken.
✓ Branch 5 → 6 taken 3402 times.
✗ Branch 5 → 30 not taken.
✓ Branch 6 → 7 taken 3402 times.
✗ Branch 6 → 30 not taken.
✓ Branch 7 → 8 taken 3402 times.
✗ Branch 7 → 30 not taken.
|
3402 | const antlr4::misc::Interval interval(ctx->assignExpr()->start->getStartIndex(), ctx->assignExpr()->stop->getStopIndex()); |
| 895 |
1/2✓ Branch 8 → 9 taken 3402 times.
✗ Branch 8 → 25 not taken.
|
3402 | assertStmtNode->expressionString = inputStream->getText(interval); |
| 896 | |||
| 897 | // Visit children | ||
| 898 |
4/8✓ Branch 11 → 12 taken 3402 times.
✗ Branch 11 → 28 not taken.
✓ Branch 12 → 13 taken 3402 times.
✗ Branch 12 → 28 not taken.
✓ Branch 13 → 14 taken 3402 times.
✗ Branch 13 → 26 not taken.
✓ Branch 15 → 16 taken 3402 times.
✗ Branch 15 → 29 not taken.
|
3402 | assertStmtNode->assignExpr = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 899 | |||
| 900 |
1/2✓ Branch 21 → 22 taken 3402 times.
✗ Branch 21 → 29 not taken.
|
6804 | return concludeNode(assertStmtNode); |
| 901 | } | ||
| 902 | |||
| 903 | 195366 | std::any ASTBuilder::visitAssignExpr(SpiceParser::AssignExprContext *ctx) { | |
| 904 |
2/2✓ Branch 3 → 4 taken 176450 times.
✓ Branch 3 → 6 taken 18916 times.
|
195366 | if (!ctx->assignOp()) |
| 905 | 176450 | return visit(ctx->ternaryExpr()); | |
| 906 | |||
| 907 | 18916 | const auto assignExprNode = createNode<AssignExprNode>(ctx); | |
| 908 | |||
| 909 | // Visit children | ||
| 910 |
1/2✗ Branch 8 → 9 not taken.
✓ Branch 8 → 14 taken 18916 times.
|
18916 | if (ctx->ternaryExpr()) { |
| 911 | ✗ | assignExprNode->ternaryExpr = std::any_cast<ExprNode *>(visit(ctx->ternaryExpr())); | |
| 912 |
1/2✓ Branch 15 → 16 taken 18916 times.
✗ Branch 15 → 28 not taken.
|
18916 | } else if (ctx->prefixUnaryExpr()) { |
| 913 |
3/6✓ Branch 16 → 17 taken 18916 times.
✗ Branch 16 → 44 not taken.
✓ Branch 17 → 18 taken 18916 times.
✗ Branch 17 → 44 not taken.
✓ Branch 18 → 19 taken 18916 times.
✗ Branch 18 → 42 not taken.
|
18916 | assignExprNode->lhs = std::any_cast<ExprNode *>(visit(ctx->prefixUnaryExpr())); |
| 914 |
2/4✓ Branch 20 → 21 taken 18916 times.
✗ Branch 20 → 45 not taken.
✓ Branch 21 → 22 taken 18916 times.
✗ Branch 21 → 45 not taken.
|
18916 | visit(ctx->assignOp()); |
| 915 |
3/6✓ Branch 23 → 24 taken 18916 times.
✗ Branch 23 → 48 not taken.
✓ Branch 24 → 25 taken 18916 times.
✗ Branch 24 → 48 not taken.
✓ Branch 25 → 26 taken 18916 times.
✗ Branch 25 → 46 not taken.
|
18916 | assignExprNode->rhs = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 916 | } else { | ||
| 917 | − | assert_fail("Invalid assign expression"); // GCOV_EXCL_LINE | |
| 918 | } | ||
| 919 | |||
| 920 |
1/2✓ Branch 35 → 36 taken 18916 times.
✗ Branch 35 → 49 not taken.
|
37832 | return concludeExprNode(assignExprNode); |
| 921 | } | ||
| 922 | |||
| 923 | 177554 | std::any ASTBuilder::visitTernaryExpr(SpiceParser::TernaryExprContext *ctx) { | |
| 924 |
3/4✓ Branch 2 → 3 taken 177554 times.
✗ Branch 2 → 45 not taken.
✓ Branch 5 → 6 taken 176406 times.
✓ Branch 5 → 8 taken 1148 times.
|
177554 | if (ctx->logicalOrExpr().size() == 1) |
| 925 | 176406 | return visit(ctx->logicalOrExpr(0)); | |
| 926 | |||
| 927 | 1148 | const auto ternaryExprNode = createNode<TernaryExprNode>(ctx); | |
| 928 | |||
| 929 |
3/6✓ Branch 9 → 10 taken 1148 times.
✗ Branch 9 → 48 not taken.
✓ Branch 10 → 11 taken 1148 times.
✗ Branch 10 → 48 not taken.
✓ Branch 11 → 12 taken 1148 times.
✗ Branch 11 → 46 not taken.
|
1148 | ternaryExprNode->condition = std::any_cast<ExprNode *>(visit(ctx->logicalOrExpr(0))); |
| 930 |
3/4✓ Branch 13 → 14 taken 1148 times.
✗ Branch 13 → 49 not taken.
✓ Branch 16 → 17 taken 1147 times.
✓ Branch 16 → 26 taken 1 time.
|
1148 | if (ctx->logicalOrExpr().size() == 3) { |
| 931 |
3/6✓ Branch 17 → 18 taken 1147 times.
✗ Branch 17 → 52 not taken.
✓ Branch 18 → 19 taken 1147 times.
✗ Branch 18 → 52 not taken.
✓ Branch 19 → 20 taken 1147 times.
✗ Branch 19 → 50 not taken.
|
1147 | ternaryExprNode->trueExpr = std::any_cast<ExprNode *>(visit(ctx->logicalOrExpr(1))); |
| 932 |
3/6✓ Branch 21 → 22 taken 1147 times.
✗ Branch 21 → 55 not taken.
✓ Branch 22 → 23 taken 1147 times.
✗ Branch 22 → 55 not taken.
✓ Branch 23 → 24 taken 1147 times.
✗ Branch 23 → 53 not taken.
|
1147 | ternaryExprNode->falseExpr = std::any_cast<ExprNode *>(visit(ctx->logicalOrExpr(2))); |
| 933 |
2/4✓ Branch 26 → 27 taken 1 time.
✗ Branch 26 → 56 not taken.
✓ Branch 29 → 30 taken 1 time.
✗ Branch 29 → 35 not taken.
|
1 | } else if (ctx->logicalOrExpr().size() == 2) { |
| 934 | 1 | ternaryExprNode->isShortened = true; | |
| 935 |
3/6✓ Branch 30 → 31 taken 1 time.
✗ Branch 30 → 59 not taken.
✓ Branch 31 → 32 taken 1 time.
✗ Branch 31 → 59 not taken.
✓ Branch 32 → 33 taken 1 time.
✗ Branch 32 → 57 not taken.
|
1 | ternaryExprNode->falseExpr = std::any_cast<ExprNode *>(visit(ctx->logicalOrExpr(1))); |
| 936 | } | ||
| 937 | |||
| 938 |
1/2✓ Branch 41 → 42 taken 1148 times.
✗ Branch 41 → 60 not taken.
|
2296 | return concludeExprNode(ternaryExprNode); |
| 939 | } | ||
| 940 | |||
| 941 | 179849 | std::any ASTBuilder::visitLogicalOrExpr(SpiceParser::LogicalOrExprContext *ctx) { | |
| 942 |
3/4✓ Branch 2 → 3 taken 179849 times.
✗ Branch 2 → 22 not taken.
✓ Branch 5 → 6 taken 177923 times.
✓ Branch 5 → 8 taken 1926 times.
|
179849 | if (ctx->logicalAndExpr().size() == 1) |
| 943 | 177923 | return visit(ctx->logicalAndExpr(0)); | |
| 944 | |||
| 945 | 1926 | const auto logicalOrExprNode = createNode<LogicalOrExprNode>(ctx); | |
| 946 | |||
| 947 | // Visit children | ||
| 948 |
3/6✓ Branch 9 → 10 taken 1926 times.
✗ Branch 9 → 25 not taken.
✓ Branch 10 → 11 taken 1926 times.
✗ Branch 10 → 23 not taken.
✓ Branch 12 → 13 taken 1926 times.
✗ Branch 12 → 26 not taken.
|
1926 | fetchChildrenIntoVector(logicalOrExprNode->operands, ctx->logicalAndExpr()); |
| 949 | |||
| 950 |
1/2✓ Branch 18 → 19 taken 1926 times.
✗ Branch 18 → 26 not taken.
|
3852 | return concludeExprNode(logicalOrExprNode); |
| 951 | } | ||
| 952 | |||
| 953 | 182401 | std::any ASTBuilder::visitLogicalAndExpr(SpiceParser::LogicalAndExprContext *ctx) { | |
| 954 |
3/4✓ Branch 2 → 3 taken 182401 times.
✗ Branch 2 → 22 not taken.
✓ Branch 5 → 6 taken 181414 times.
✓ Branch 5 → 8 taken 987 times.
|
182401 | if (ctx->bitwiseOrExpr().size() == 1) |
| 955 | 181414 | return visit(ctx->bitwiseOrExpr(0)); | |
| 956 | |||
| 957 | 987 | const auto logicalAndExprNode = createNode<LogicalAndExprNode>(ctx); | |
| 958 | |||
| 959 | // Visit children | ||
| 960 |
3/6✓ Branch 9 → 10 taken 987 times.
✗ Branch 9 → 25 not taken.
✓ Branch 10 → 11 taken 987 times.
✗ Branch 10 → 23 not taken.
✓ Branch 12 → 13 taken 987 times.
✗ Branch 12 → 26 not taken.
|
987 | fetchChildrenIntoVector(logicalAndExprNode->operands, ctx->bitwiseOrExpr()); |
| 961 | |||
| 962 |
1/2✓ Branch 18 → 19 taken 987 times.
✗ Branch 18 → 26 not taken.
|
1974 | return concludeExprNode(logicalAndExprNode); |
| 963 | } | ||
| 964 | |||
| 965 | 183745 | std::any ASTBuilder::visitBitwiseOrExpr(SpiceParser::BitwiseOrExprContext *ctx) { | |
| 966 |
3/4✓ Branch 2 → 3 taken 183745 times.
✗ Branch 2 → 22 not taken.
✓ Branch 5 → 6 taken 183476 times.
✓ Branch 5 → 8 taken 269 times.
|
183745 | if (ctx->bitwiseXorExpr().size() == 1) |
| 967 | 183476 | return visit(ctx->bitwiseXorExpr(0)); | |
| 968 | |||
| 969 | 269 | const auto bitwiseOrExprNode = createNode<BitwiseOrExprNode>(ctx); | |
| 970 | |||
| 971 | // Visit children | ||
| 972 |
3/6✓ Branch 9 → 10 taken 269 times.
✗ Branch 9 → 25 not taken.
✓ Branch 10 → 11 taken 269 times.
✗ Branch 10 → 23 not taken.
✓ Branch 12 → 13 taken 269 times.
✗ Branch 12 → 26 not taken.
|
269 | fetchChildrenIntoVector(bitwiseOrExprNode->operands, ctx->bitwiseXorExpr()); |
| 973 | |||
| 974 |
1/2✓ Branch 18 → 19 taken 269 times.
✗ Branch 18 → 26 not taken.
|
538 | return concludeExprNode(bitwiseOrExprNode); |
| 975 | } | ||
| 976 | |||
| 977 | 184015 | std::any ASTBuilder::visitBitwiseXorExpr(SpiceParser::BitwiseXorExprContext *ctx) { | |
| 978 |
3/4✓ Branch 2 → 3 taken 184015 times.
✗ Branch 2 → 22 not taken.
✓ Branch 5 → 6 taken 183982 times.
✓ Branch 5 → 8 taken 33 times.
|
184015 | if (ctx->bitwiseAndExpr().size() == 1) |
| 979 | 183982 | return visit(ctx->bitwiseAndExpr(0)); | |
| 980 | |||
| 981 | 33 | const auto bitwiseXorExprNode = createNode<BitwiseXorExprNode>(ctx); | |
| 982 | |||
| 983 | // Visit children | ||
| 984 |
3/6✓ Branch 9 → 10 taken 33 times.
✗ Branch 9 → 25 not taken.
✓ Branch 10 → 11 taken 33 times.
✗ Branch 10 → 23 not taken.
✓ Branch 12 → 13 taken 33 times.
✗ Branch 12 → 26 not taken.
|
33 | fetchChildrenIntoVector(bitwiseXorExprNode->operands, ctx->bitwiseAndExpr()); |
| 985 | |||
| 986 |
1/2✓ Branch 18 → 19 taken 33 times.
✗ Branch 18 → 26 not taken.
|
66 | return concludeExprNode(bitwiseXorExprNode); |
| 987 | } | ||
| 988 | |||
| 989 | 184049 | std::any ASTBuilder::visitBitwiseAndExpr(SpiceParser::BitwiseAndExprContext *ctx) { | |
| 990 |
3/4✓ Branch 2 → 3 taken 184049 times.
✗ Branch 2 → 22 not taken.
✓ Branch 5 → 6 taken 183993 times.
✓ Branch 5 → 8 taken 56 times.
|
184049 | if (ctx->equalityExpr().size() == 1) |
| 991 | 183993 | return visit(ctx->equalityExpr(0)); | |
| 992 | |||
| 993 | 56 | const auto bitwiseAndExprNode = createNode<BitwiseAndExprNode>(ctx); | |
| 994 | |||
| 995 | // Visit children | ||
| 996 |
3/6✓ Branch 9 → 10 taken 56 times.
✗ Branch 9 → 25 not taken.
✓ Branch 10 → 11 taken 56 times.
✗ Branch 10 → 23 not taken.
✓ Branch 12 → 13 taken 56 times.
✗ Branch 12 → 26 not taken.
|
56 | fetchChildrenIntoVector(bitwiseAndExprNode->operands, ctx->equalityExpr()); |
| 997 | |||
| 998 |
1/2✓ Branch 18 → 19 taken 56 times.
✗ Branch 18 → 26 not taken.
|
112 | return concludeExprNode(bitwiseAndExprNode); |
| 999 | } | ||
| 1000 | |||
| 1001 | 184106 | std::any ASTBuilder::visitEqualityExpr(SpiceParser::EqualityExprContext *ctx) { | |
| 1002 |
3/4✓ Branch 2 → 3 taken 184106 times.
✗ Branch 2 → 28 not taken.
✓ Branch 5 → 6 taken 171126 times.
✓ Branch 5 → 8 taken 12980 times.
|
184106 | if (ctx->relationalExpr().size() == 1) |
| 1003 | 171126 | return visit(ctx->relationalExpr(0)); | |
| 1004 | |||
| 1005 | 12980 | const auto equalityExprNode = createNode<EqualityExprNode>(ctx); | |
| 1006 | |||
| 1007 | // Visit children | ||
| 1008 |
2/4✓ Branch 9 → 10 taken 12980 times.
✗ Branch 9 → 31 not taken.
✓ Branch 10 → 11 taken 12980 times.
✗ Branch 10 → 29 not taken.
|
12980 | fetchChildrenIntoVector(equalityExprNode->operands, ctx->relationalExpr()); |
| 1009 | |||
| 1010 | // Extract operator | ||
| 1011 |
2/2✓ Branch 13 → 14 taken 9890 times.
✓ Branch 13 → 15 taken 3090 times.
|
12980 | if (ctx->EQUAL()) |
| 1012 | 9890 | equalityExprNode->op = EqualityExprNode::EqualityOp::OP_EQUAL; | |
| 1013 |
1/2✓ Branch 16 → 17 taken 3090 times.
✗ Branch 16 → 18 not taken.
|
3090 | else if (ctx->NOT_EQUAL()) |
| 1014 | 3090 | equalityExprNode->op = EqualityExprNode::EqualityOp::OP_NOT_EQUAL; | |
| 1015 | |||
| 1016 |
1/2✓ Branch 24 → 25 taken 12980 times.
✗ Branch 24 → 32 not taken.
|
25960 | return concludeExprNode(equalityExprNode); |
| 1017 | } | ||
| 1018 | |||
| 1019 | 197086 | std::any ASTBuilder::visitRelationalExpr(SpiceParser::RelationalExprContext *ctx) { | |
| 1020 |
3/4✓ Branch 2 → 3 taken 197086 times.
✗ Branch 2 → 34 not taken.
✓ Branch 5 → 6 taken 188822 times.
✓ Branch 5 → 8 taken 8264 times.
|
197086 | if (ctx->shiftExpr().size() == 1) |
| 1021 | 188822 | return visit(ctx->shiftExpr(0)); | |
| 1022 | |||
| 1023 | 8264 | const auto relationalExprNode = createNode<RelationalExprNode>(ctx); | |
| 1024 | |||
| 1025 | // Visit children | ||
| 1026 |
2/4✓ Branch 9 → 10 taken 8264 times.
✗ Branch 9 → 37 not taken.
✓ Branch 10 → 11 taken 8264 times.
✗ Branch 10 → 35 not taken.
|
8264 | fetchChildrenIntoVector(relationalExprNode->operands, ctx->shiftExpr()); |
| 1027 | |||
| 1028 | // Extract operator | ||
| 1029 |
2/2✓ Branch 13 → 14 taken 4210 times.
✓ Branch 13 → 15 taken 4054 times.
|
8264 | if (ctx->LESS()) |
| 1030 | 4210 | relationalExprNode->op = RelationalExprNode::RelationalOp::OP_LESS; | |
| 1031 |
2/2✓ Branch 16 → 17 taken 1603 times.
✓ Branch 16 → 18 taken 2451 times.
|
4054 | else if (ctx->GREATER()) |
| 1032 | 1603 | relationalExprNode->op = RelationalExprNode::RelationalOp::OP_GREATER; | |
| 1033 |
2/2✓ Branch 19 → 20 taken 831 times.
✓ Branch 19 → 21 taken 1620 times.
|
2451 | else if (ctx->LESS_EQUAL()) |
| 1034 | 831 | relationalExprNode->op = RelationalExprNode::RelationalOp::OP_LESS_EQUAL; | |
| 1035 |
1/2✓ Branch 22 → 23 taken 1620 times.
✗ Branch 22 → 24 not taken.
|
1620 | else if (ctx->GREATER_EQUAL()) |
| 1036 | 1620 | relationalExprNode->op = RelationalExprNode::RelationalOp::OP_GREATER_EQUAL; | |
| 1037 | |||
| 1038 |
1/2✓ Branch 30 → 31 taken 8264 times.
✗ Branch 30 → 38 not taken.
|
16528 | return concludeExprNode(relationalExprNode); |
| 1039 | } | ||
| 1040 | |||
| 1041 | 205350 | std::any ASTBuilder::visitShiftExpr(SpiceParser::ShiftExprContext *ctx) { | |
| 1042 |
3/4✓ Branch 2 → 3 taken 205350 times.
✗ Branch 2 → 60 not taken.
✓ Branch 5 → 6 taken 204588 times.
✓ Branch 5 → 8 taken 762 times.
|
205350 | if (ctx->additiveExpr().size() == 1) |
| 1043 | 204588 | return visit(ctx->additiveExpr(0)); | |
| 1044 | |||
| 1045 | 762 | const auto shiftExprNode = createNode<ShiftExprNode>(ctx); | |
| 1046 | |||
| 1047 | // Visit children | ||
| 1048 |
2/4✓ Branch 9 → 10 taken 762 times.
✗ Branch 9 → 63 not taken.
✓ Branch 10 → 11 taken 762 times.
✗ Branch 10 → 61 not taken.
|
762 | fetchChildrenIntoVector(shiftExprNode->operands, ctx->additiveExpr()); |
| 1049 | |||
| 1050 | 762 | bool seenFirstLess = false; | |
| 1051 | 762 | bool seenFirstGreater = false; | |
| 1052 |
2/2✓ Branch 45 → 14 taken 3774 times.
✓ Branch 45 → 46 taken 762 times.
|
5298 | for (ParserRuleContext::ParseTree *subTree : ctx->children) { |
| 1053 |
1/2✓ Branch 16 → 17 taken 3774 times.
✗ Branch 16 → 18 not taken.
|
3774 | const auto terminal = dynamic_cast<TerminalNode *>(subTree); |
| 1054 |
2/2✓ Branch 19 → 20 taken 1766 times.
✓ Branch 19 → 21 taken 2008 times.
|
3774 | if (!terminal) |
| 1055 | 1766 | continue; | |
| 1056 | |||
| 1057 |
4/6✓ Branch 21 → 22 taken 2008 times.
✗ Branch 21 → 68 not taken.
✓ Branch 22 → 23 taken 2008 times.
✗ Branch 22 → 68 not taken.
✓ Branch 23 → 24 taken 1658 times.
✓ Branch 23 → 28 taken 350 times.
|
2008 | if (terminal->getSymbol()->getType() == SpiceParser::LESS) { |
| 1058 |
2/2✓ Branch 24 → 25 taken 829 times.
✓ Branch 24 → 27 taken 829 times.
|
1658 | if (seenFirstLess) |
| 1059 |
1/2✓ Branch 25 → 26 taken 829 times.
✗ Branch 25 → 64 not taken.
|
829 | shiftExprNode->opQueue.emplace(ShiftExprNode::ShiftOp::OP_SHIFT_LEFT, TY_INVALID); |
| 1060 | 1658 | seenFirstLess = !seenFirstLess; | |
| 1061 | 1658 | continue; | |
| 1062 | } | ||
| 1063 | |||
| 1064 |
3/6✓ Branch 28 → 29 taken 350 times.
✗ Branch 28 → 68 not taken.
✓ Branch 29 → 30 taken 350 times.
✗ Branch 29 → 68 not taken.
✓ Branch 30 → 31 taken 350 times.
✗ Branch 30 → 35 not taken.
|
350 | if (terminal->getSymbol()->getType() == SpiceParser::GREATER) { |
| 1065 |
2/2✓ Branch 31 → 32 taken 175 times.
✓ Branch 31 → 34 taken 175 times.
|
350 | if (seenFirstGreater) |
| 1066 |
1/2✓ Branch 32 → 33 taken 175 times.
✗ Branch 32 → 66 not taken.
|
175 | shiftExprNode->opQueue.emplace(ShiftExprNode::ShiftOp::OP_SHIFT_RIGHT, TY_INVALID); |
| 1067 | 350 | seenFirstGreater = !seenFirstGreater; | |
| 1068 | 350 | continue; | |
| 1069 | } | ||
| 1070 | |||
| 1071 | − | assert_fail("Invalid terminal symbol for additive expression"); // GCOV_EXCL_LINE | |
| 1072 | } | ||
| 1073 |
2/4✓ Branch 46 → 47 taken 762 times.
✗ Branch 46 → 49 not taken.
✓ Branch 47 → 48 taken 762 times.
✗ Branch 47 → 49 not taken.
|
762 | assert(!seenFirstLess && !seenFirstGreater); |
| 1074 | |||
| 1075 |
1/2✓ Branch 56 → 57 taken 762 times.
✗ Branch 56 → 69 not taken.
|
1524 | return concludeExprNode(shiftExprNode); |
| 1076 | } | ||
| 1077 | |||
| 1078 | 206354 | std::any ASTBuilder::visitAdditiveExpr(SpiceParser::AdditiveExprContext *ctx) { | |
| 1079 |
3/4✓ Branch 2 → 3 taken 206354 times.
✗ Branch 2 → 52 not taken.
✓ Branch 5 → 6 taken 198524 times.
✓ Branch 5 → 8 taken 7830 times.
|
206354 | if (ctx->multiplicativeExpr().size() == 1) |
| 1080 | 198524 | return visit(ctx->multiplicativeExpr(0)); | |
| 1081 | |||
| 1082 | 7830 | const auto additiveExprNode = createNode<AdditiveExprNode>(ctx); | |
| 1083 | |||
| 1084 | // Visit children | ||
| 1085 |
2/4✓ Branch 9 → 10 taken 7830 times.
✗ Branch 9 → 55 not taken.
✓ Branch 10 → 11 taken 7830 times.
✗ Branch 10 → 53 not taken.
|
7830 | fetchChildrenIntoVector(additiveExprNode->operands, ctx->multiplicativeExpr()); |
| 1086 | |||
| 1087 |
2/2✓ Branch 41 → 14 taken 25354 times.
✓ Branch 41 → 42 taken 7830 times.
|
41014 | for (ParserRuleContext::ParseTree *subTree : ctx->children) { |
| 1088 |
1/2✓ Branch 16 → 17 taken 25354 times.
✗ Branch 16 → 18 not taken.
|
25354 | const auto terminal = dynamic_cast<TerminalNode *>(subTree); |
| 1089 |
2/2✓ Branch 19 → 20 taken 16592 times.
✓ Branch 19 → 21 taken 8762 times.
|
25354 | if (!terminal) |
| 1090 | 16592 | continue; | |
| 1091 | |||
| 1092 |
4/6✓ Branch 21 → 22 taken 8762 times.
✗ Branch 21 → 60 not taken.
✓ Branch 22 → 23 taken 8762 times.
✗ Branch 22 → 60 not taken.
✓ Branch 23 → 24 taken 5452 times.
✓ Branch 23 → 26 taken 3310 times.
|
8762 | if (terminal->getSymbol()->getType() == SpiceParser::PLUS) |
| 1093 |
1/2✓ Branch 24 → 25 taken 5452 times.
✗ Branch 24 → 56 not taken.
|
5452 | additiveExprNode->opQueue.emplace(AdditiveExprNode::AdditiveOp::OP_PLUS, TY_INVALID); |
| 1094 |
3/6✓ Branch 26 → 27 taken 3310 times.
✗ Branch 26 → 60 not taken.
✓ Branch 27 → 28 taken 3310 times.
✗ Branch 27 → 60 not taken.
✓ Branch 28 → 29 taken 3310 times.
✗ Branch 28 → 31 not taken.
|
3310 | else if (terminal->getSymbol()->getType() == SpiceParser::MINUS) |
| 1095 |
1/2✓ Branch 29 → 30 taken 3310 times.
✗ Branch 29 → 58 not taken.
|
3310 | additiveExprNode->opQueue.emplace(AdditiveExprNode::AdditiveOp::OP_MINUS, TY_INVALID); |
| 1096 | else | ||
| 1097 | − | assert_fail("Invalid terminal symbol for additive expression"); // GCOV_EXCL_LINE | |
| 1098 | } | ||
| 1099 | |||
| 1100 |
1/2✓ Branch 48 → 49 taken 7830 times.
✗ Branch 48 → 61 not taken.
|
15660 | return concludeExprNode(additiveExprNode); |
| 1101 | } | ||
| 1102 | |||
| 1103 | 215116 | std::any ASTBuilder::visitMultiplicativeExpr(SpiceParser::MultiplicativeExprContext *ctx) { | |
| 1104 |
3/4✓ Branch 2 → 3 taken 215116 times.
✗ Branch 2 → 57 not taken.
✓ Branch 5 → 6 taken 211933 times.
✓ Branch 5 → 8 taken 3183 times.
|
215116 | if (ctx->castExpr().size() == 1) |
| 1105 | 211933 | return visit(ctx->castExpr(0)); | |
| 1106 | |||
| 1107 | 3183 | const auto multiplicativeExprNode = createNode<MultiplicativeExprNode>(ctx); | |
| 1108 | |||
| 1109 | // Visit children | ||
| 1110 |
2/4✓ Branch 9 → 10 taken 3183 times.
✗ Branch 9 → 60 not taken.
✓ Branch 10 → 11 taken 3183 times.
✗ Branch 10 → 58 not taken.
|
3183 | fetchChildrenIntoVector(multiplicativeExprNode->operands, ctx->castExpr()); |
| 1111 | |||
| 1112 |
2/2✓ Branch 46 → 14 taken 9693 times.
✓ Branch 46 → 47 taken 3183 times.
|
16059 | for (ParserRuleContext::ParseTree *subTree : ctx->children) { |
| 1113 |
1/2✓ Branch 16 → 17 taken 9693 times.
✗ Branch 16 → 18 not taken.
|
9693 | const auto terminal = dynamic_cast<TerminalNode *>(subTree); |
| 1114 |
2/2✓ Branch 19 → 20 taken 6438 times.
✓ Branch 19 → 21 taken 3255 times.
|
9693 | if (!terminal) |
| 1115 | 6438 | continue; | |
| 1116 | |||
| 1117 |
4/6✓ Branch 21 → 22 taken 3255 times.
✗ Branch 21 → 67 not taken.
✓ Branch 22 → 23 taken 3255 times.
✗ Branch 22 → 67 not taken.
✓ Branch 23 → 24 taken 2284 times.
✓ Branch 23 → 26 taken 971 times.
|
3255 | if (terminal->getSymbol()->getType() == SpiceParser::MUL) |
| 1118 |
1/2✓ Branch 24 → 25 taken 2284 times.
✗ Branch 24 → 61 not taken.
|
2284 | multiplicativeExprNode->opQueue.emplace(MultiplicativeExprNode::MultiplicativeOp::OP_MUL, TY_INVALID); |
| 1119 |
4/6✓ Branch 26 → 27 taken 971 times.
✗ Branch 26 → 67 not taken.
✓ Branch 27 → 28 taken 971 times.
✗ Branch 27 → 67 not taken.
✓ Branch 28 → 29 taken 531 times.
✓ Branch 28 → 31 taken 440 times.
|
971 | else if (terminal->getSymbol()->getType() == SpiceParser::DIV) |
| 1120 |
1/2✓ Branch 29 → 30 taken 531 times.
✗ Branch 29 → 63 not taken.
|
531 | multiplicativeExprNode->opQueue.emplace(MultiplicativeExprNode::MultiplicativeOp::OP_DIV, TY_INVALID); |
| 1121 |
3/6✓ Branch 31 → 32 taken 440 times.
✗ Branch 31 → 67 not taken.
✓ Branch 32 → 33 taken 440 times.
✗ Branch 32 → 67 not taken.
✓ Branch 33 → 34 taken 440 times.
✗ Branch 33 → 36 not taken.
|
440 | else if (terminal->getSymbol()->getType() == SpiceParser::REM) |
| 1122 |
1/2✓ Branch 34 → 35 taken 440 times.
✗ Branch 34 → 65 not taken.
|
440 | multiplicativeExprNode->opQueue.emplace(MultiplicativeExprNode::MultiplicativeOp::OP_REM, TY_INVALID); |
| 1123 | else | ||
| 1124 | − | assert_fail("Invalid terminal symbol for multiplicative expression"); // GCOV_EXCL_LINE | |
| 1125 | } | ||
| 1126 | |||
| 1127 |
1/2✓ Branch 53 → 54 taken 3183 times.
✗ Branch 53 → 68 not taken.
|
6366 | return concludeExprNode(multiplicativeExprNode); |
| 1128 | } | ||
| 1129 | |||
| 1130 | 218371 | std::any ASTBuilder::visitCastExpr(SpiceParser::CastExprContext *ctx) { | |
| 1131 |
2/2✓ Branch 3 → 4 taken 211781 times.
✓ Branch 3 → 6 taken 6590 times.
|
218371 | if (!ctx->CAST()) |
| 1132 | 211781 | return visit(ctx->prefixUnaryExpr()); | |
| 1133 | |||
| 1134 | 6590 | const auto castExprNode = createNode<CastExprNode>(ctx); | |
| 1135 | |||
| 1136 | // Visit children | ||
| 1137 |
1/2✓ Branch 8 → 9 taken 6590 times.
✗ Branch 8 → 18 not taken.
|
6590 | if (ctx->dataType()) { |
| 1138 |
3/6✓ Branch 9 → 10 taken 6590 times.
✗ Branch 9 → 35 not taken.
✓ Branch 10 → 11 taken 6590 times.
✗ Branch 10 → 35 not taken.
✓ Branch 11 → 12 taken 6590 times.
✗ Branch 11 → 33 not taken.
|
6590 | castExprNode->dataType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 1139 |
3/6✓ Branch 13 → 14 taken 6590 times.
✗ Branch 13 → 38 not taken.
✓ Branch 14 → 15 taken 6590 times.
✗ Branch 14 → 38 not taken.
✓ Branch 15 → 16 taken 6590 times.
✗ Branch 15 → 36 not taken.
|
6590 | castExprNode->assignExpr = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 1140 | 6590 | castExprNode->isCast = true; | |
| 1141 | } else { | ||
| 1142 | ✗ | castExprNode->prefixUnaryExpr = std::any_cast<ExprNode *>(visit(ctx->prefixUnaryExpr())); | |
| 1143 | } | ||
| 1144 | |||
| 1145 |
1/2✓ Branch 29 → 30 taken 6590 times.
✗ Branch 29 → 42 not taken.
|
13180 | return concludeExprNode(castExprNode); |
| 1146 | } | ||
| 1147 | |||
| 1148 | 235064 | std::any ASTBuilder::visitPrefixUnaryExpr(SpiceParser::PrefixUnaryExprContext *ctx) { | |
| 1149 |
2/2✓ Branch 3 → 4 taken 230697 times.
✓ Branch 3 → 6 taken 4367 times.
|
235064 | if (!ctx->prefixUnaryExpr()) |
| 1150 | 230697 | return visit(ctx->postfixUnaryExpr()); | |
| 1151 | |||
| 1152 | 4367 | const auto prefixUnaryExprNode = createNode<PrefixUnaryExprNode>(ctx); | |
| 1153 | |||
| 1154 | // Visit children | ||
| 1155 |
1/2✗ Branch 8 → 9 not taken.
✓ Branch 8 → 14 taken 4367 times.
|
4367 | if (ctx->postfixUnaryExpr()) { |
| 1156 | ✗ | prefixUnaryExprNode->postfixUnaryExpr = std::any_cast<ExprNode *>(visit(ctx->postfixUnaryExpr())); | |
| 1157 |
1/2✓ Branch 15 → 16 taken 4367 times.
✗ Branch 15 → 42 not taken.
|
4367 | } else if (ctx->prefixUnaryExpr()) { |
| 1158 | // Extract operator | ||
| 1159 |
2/2✓ Branch 17 → 18 taken 199 times.
✓ Branch 17 → 19 taken 4168 times.
|
4367 | if (ctx->MINUS()) |
| 1160 | 199 | prefixUnaryExprNode->op = PrefixUnaryExprNode::PrefixUnaryOp::OP_MINUS; | |
| 1161 |
2/2✓ Branch 20 → 21 taken 54 times.
✓ Branch 20 → 22 taken 4114 times.
|
4168 | else if (ctx->PLUS_PLUS()) |
| 1162 | 54 | prefixUnaryExprNode->op = PrefixUnaryExprNode::PrefixUnaryOp::OP_PLUS_PLUS; | |
| 1163 |
2/2✓ Branch 23 → 24 taken 20 times.
✓ Branch 23 → 25 taken 4094 times.
|
4114 | else if (ctx->MINUS_MINUS()) |
| 1164 | 20 | prefixUnaryExprNode->op = PrefixUnaryExprNode::PrefixUnaryOp::OP_MINUS_MINUS; | |
| 1165 |
2/2✓ Branch 26 → 27 taken 2653 times.
✓ Branch 26 → 28 taken 1441 times.
|
4094 | else if (ctx->NOT()) |
| 1166 | 2653 | prefixUnaryExprNode->op = PrefixUnaryExprNode::PrefixUnaryOp::OP_NOT; | |
| 1167 |
2/2✓ Branch 29 → 30 taken 9 times.
✓ Branch 29 → 31 taken 1432 times.
|
1441 | else if (ctx->BITWISE_NOT()) |
| 1168 | 9 | prefixUnaryExprNode->op = PrefixUnaryExprNode::PrefixUnaryOp::OP_BITWISE_NOT; | |
| 1169 |
2/2✓ Branch 32 → 33 taken 681 times.
✓ Branch 32 → 34 taken 751 times.
|
1432 | else if (ctx->MUL()) |
| 1170 | 681 | prefixUnaryExprNode->op = PrefixUnaryExprNode::PrefixUnaryOp::OP_DEREFERENCE; | |
| 1171 |
1/2✓ Branch 35 → 36 taken 751 times.
✗ Branch 35 → 37 not taken.
|
751 | else if (ctx->BITWISE_AND()) |
| 1172 | 751 | prefixUnaryExprNode->op = PrefixUnaryExprNode::PrefixUnaryOp::OP_ADDRESS_OF; | |
| 1173 | |||
| 1174 |
3/6✓ Branch 37 → 38 taken 4367 times.
✗ Branch 37 → 58 not taken.
✓ Branch 38 → 39 taken 4367 times.
✗ Branch 38 → 58 not taken.
✓ Branch 39 → 40 taken 4367 times.
✗ Branch 39 → 56 not taken.
|
4367 | prefixUnaryExprNode->prefixUnaryExpr = std::any_cast<ExprNode *>(visit(ctx->prefixUnaryExpr())); |
| 1175 | } else { | ||
| 1176 | − | assert_fail("Unknown prefix unary expression type"); // GCOV_EXCL_LINE | |
| 1177 | } | ||
| 1178 | |||
| 1179 |
1/2✓ Branch 49 → 50 taken 4367 times.
✗ Branch 49 → 59 not taken.
|
8734 | return concludeExprNode(prefixUnaryExprNode); |
| 1180 | } | ||
| 1181 | |||
| 1182 | 290466 | std::any ASTBuilder::visitPostfixUnaryExpr(SpiceParser::PostfixUnaryExprContext *ctx) { | |
| 1183 |
2/2✓ Branch 3 → 4 taken 230697 times.
✓ Branch 3 → 6 taken 59769 times.
|
290466 | if (!ctx->postfixUnaryExpr()) |
| 1184 | 230697 | return visit(ctx->atomicExpr()); | |
| 1185 | |||
| 1186 | 59769 | const auto postfixUnaryExprNode = createNode<PostfixUnaryExprNode>(ctx); | |
| 1187 | |||
| 1188 |
1/2✗ Branch 8 → 9 not taken.
✓ Branch 8 → 14 taken 59769 times.
|
59769 | if (ctx->atomicExpr()) { |
| 1189 | ✗ | postfixUnaryExprNode->atomicExpr = std::any_cast<ExprNode *>(visit(ctx->atomicExpr())); | |
| 1190 |
1/2✓ Branch 15 → 16 taken 59769 times.
✗ Branch 15 → 40 not taken.
|
59769 | } else if (ctx->postfixUnaryExpr()) { |
| 1191 |
3/6✓ Branch 16 → 17 taken 59769 times.
✗ Branch 16 → 56 not taken.
✓ Branch 17 → 18 taken 59769 times.
✗ Branch 17 → 56 not taken.
✓ Branch 18 → 19 taken 59769 times.
✗ Branch 18 → 54 not taken.
|
59769 | postfixUnaryExprNode->postfixUnaryExpr = std::any_cast<ExprNode *>(visit(ctx->postfixUnaryExpr())); |
| 1192 | |||
| 1193 | // Extract operator | ||
| 1194 |
2/2✓ Branch 21 → 22 taken 7732 times.
✓ Branch 21 → 27 taken 52037 times.
|
59769 | if (ctx->assignExpr()) { |
| 1195 | 7732 | postfixUnaryExprNode->op = PostfixUnaryExprNode::PostfixUnaryOp::OP_SUBSCRIPT; | |
| 1196 |
3/6✓ Branch 22 → 23 taken 7732 times.
✗ Branch 22 → 59 not taken.
✓ Branch 23 → 24 taken 7732 times.
✗ Branch 23 → 59 not taken.
✓ Branch 24 → 25 taken 7732 times.
✗ Branch 24 → 57 not taken.
|
7732 | postfixUnaryExprNode->subscriptIndexExpr = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 1197 |
2/2✓ Branch 28 → 29 taken 47018 times.
✓ Branch 28 → 34 taken 5019 times.
|
52037 | } else if (ctx->IDENTIFIER()) { |
| 1198 | 47018 | postfixUnaryExprNode->op = PostfixUnaryExprNode::PostfixUnaryOp::OP_MEMBER_ACCESS; | |
| 1199 |
2/4✓ Branch 29 → 30 taken 47018 times.
✗ Branch 29 → 60 not taken.
✓ Branch 30 → 31 taken 47018 times.
✗ Branch 30 → 60 not taken.
|
47018 | postfixUnaryExprNode->identifier = getIdentifier(ctx->IDENTIFIER(), false); |
| 1200 |
2/2✓ Branch 35 → 36 taken 4165 times.
✓ Branch 35 → 37 taken 854 times.
|
5019 | } else if (ctx->PLUS_PLUS()) { |
| 1201 | 4165 | postfixUnaryExprNode->op = PostfixUnaryExprNode::PostfixUnaryOp::OP_PLUS_PLUS; | |
| 1202 |
1/2✓ Branch 38 → 39 taken 854 times.
✗ Branch 38 → 41 not taken.
|
854 | } else if (ctx->MINUS_MINUS()) { |
| 1203 | 854 | postfixUnaryExprNode->op = PostfixUnaryExprNode::PostfixUnaryOp::OP_MINUS_MINUS; | |
| 1204 | } | ||
| 1205 | } else { | ||
| 1206 | − | assert_fail("Unknown postfix unary expression type"); // GCOV_EXCL_LINE | |
| 1207 | } | ||
| 1208 | |||
| 1209 |
1/2✓ Branch 47 → 48 taken 59769 times.
✗ Branch 47 → 61 not taken.
|
119538 | return concludeExprNode(postfixUnaryExprNode); |
| 1210 | } | ||
| 1211 | |||
| 1212 | 230697 | std::any ASTBuilder::visitAtomicExpr(SpiceParser::AtomicExprContext *ctx) { | |
| 1213 | 230697 | const auto atomicExprNode = createNode<AtomicExprNode>(ctx); | |
| 1214 | |||
| 1215 | // Visit children | ||
| 1216 |
2/2✓ Branch 4 → 5 taken 41134 times.
✓ Branch 4 → 10 taken 189563 times.
|
230697 | if (ctx->constant()) { |
| 1217 |
4/6✓ Branch 5 → 6 taken 41134 times.
✗ Branch 5 → 88 not taken.
✓ Branch 6 → 7 taken 41132 times.
✓ Branch 6 → 88 taken 2 times.
✓ Branch 7 → 8 taken 41132 times.
✗ Branch 7 → 86 not taken.
|
41134 | atomicExprNode->constant = std::any_cast<ConstantNode *>(visit(ctx->constant())); |
| 1218 |
2/2✓ Branch 11 → 12 taken 57308 times.
✓ Branch 11 → 17 taken 132255 times.
|
189563 | } else if (ctx->value()) { |
| 1219 |
3/6✓ Branch 12 → 13 taken 57308 times.
✗ Branch 12 → 91 not taken.
✓ Branch 13 → 14 taken 57308 times.
✗ Branch 13 → 91 not taken.
✓ Branch 14 → 15 taken 57308 times.
✗ Branch 14 → 89 not taken.
|
57308 | atomicExprNode->value = std::any_cast<ValueNode *>(visit(ctx->value())); |
| 1220 |
11/18✓ Branch 17 → 18 taken 132255 times.
✗ Branch 17 → 92 not taken.
✓ Branch 19 → 20 taken 7879 times.
✓ Branch 19 → 23 taken 124376 times.
✓ Branch 20 → 21 taken 7879 times.
✗ Branch 20 → 92 not taken.
✓ Branch 22 → 23 taken 6503 times.
✓ Branch 22 → 24 taken 1376 times.
✓ Branch 25 → 26 taken 7879 times.
✓ Branch 25 → 27 taken 124376 times.
✓ Branch 27 → 28 taken 132255 times.
✗ Branch 27 → 29 not taken.
✓ Branch 29 → 30 taken 130879 times.
✓ Branch 29 → 68 taken 1376 times.
✗ Branch 92 → 93 not taken.
✗ Branch 92 → 94 not taken.
✗ Branch 96 → 97 not taken.
✗ Branch 96 → 98 not taken.
|
132255 | } else if (!ctx->IDENTIFIER().empty() || !ctx->TYPE_IDENTIFIER().empty()) { |
| 1221 |
1/2✓ Branch 30 → 31 taken 130879 times.
✗ Branch 30 → 108 not taken.
|
130879 | std::stringstream fqIdentifier; |
| 1222 |
2/2✓ Branch 62 → 33 taken 138141 times.
✓ Branch 62 → 63 taken 130879 times.
|
399899 | for (ParserRuleContext::ParseTree *subTree : ctx->children) { |
| 1223 |
1/2✓ Branch 35 → 36 taken 138141 times.
✗ Branch 35 → 37 not taken.
|
138141 | const auto terminal = dynamic_cast<TerminalNode *>(subTree); |
| 1224 |
1/2✗ Branch 38 → 39 not taken.
✓ Branch 38 → 40 taken 138141 times.
|
138141 | if (!terminal) |
| 1225 | ✗ | continue; | |
| 1226 | |||
| 1227 |
2/4✓ Branch 40 → 41 taken 138141 times.
✗ Branch 40 → 104 not taken.
✓ Branch 41 → 42 taken 138141 times.
✗ Branch 41 → 104 not taken.
|
138141 | const size_t terminalType = terminal->getSymbol()->getType(); |
| 1228 |
4/4✓ Branch 42 → 43 taken 13765 times.
✓ Branch 42 → 44 taken 124376 times.
✓ Branch 43 → 44 taken 10134 times.
✓ Branch 43 → 53 taken 3631 times.
|
138141 | if (terminalType == SpiceParser::IDENTIFIER || terminalType == SpiceParser::TYPE_IDENTIFIER) { |
| 1229 |
1/2✓ Branch 44 → 45 taken 134510 times.
✗ Branch 44 → 103 not taken.
|
134510 | const std::string fragment = getIdentifier(terminal, false); |
| 1230 |
1/2✓ Branch 45 → 46 taken 134510 times.
✗ Branch 45 → 101 not taken.
|
134510 | atomicExprNode->identifierFragments.push_back(fragment); |
| 1231 |
3/4✓ Branch 46 → 47 taken 134510 times.
✗ Branch 46 → 100 not taken.
✓ Branch 48 → 49 taken 3631 times.
✓ Branch 48 → 50 taken 130879 times.
|
134510 | if (fqIdentifier.tellp() != 0) |
| 1232 |
1/2✓ Branch 49 → 50 taken 3631 times.
✗ Branch 49 → 101 not taken.
|
3631 | fqIdentifier << SCOPE_ACCESS_TOKEN; |
| 1233 |
1/2✓ Branch 50 → 51 taken 134510 times.
✗ Branch 50 → 101 not taken.
|
134510 | fqIdentifier << fragment; |
| 1234 | 134510 | } | |
| 1235 | } | ||
| 1236 |
1/2✓ Branch 63 → 64 taken 130879 times.
✗ Branch 63 → 105 not taken.
|
130879 | atomicExprNode->fqIdentifier = fqIdentifier.str(); |
| 1237 |
1/2✓ Branch 69 → 70 taken 1376 times.
✗ Branch 69 → 75 not taken.
|
132255 | } else if (ctx->assignExpr()) { |
| 1238 |
3/6✓ Branch 70 → 71 taken 1376 times.
✗ Branch 70 → 111 not taken.
✓ Branch 71 → 72 taken 1376 times.
✗ Branch 71 → 111 not taken.
✓ Branch 72 → 73 taken 1376 times.
✗ Branch 72 → 109 not taken.
|
1376 | atomicExprNode->assignExpr = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 1239 | } else { | ||
| 1240 | − | assert_fail("Unknown atomic expression type"); // GCOV_EXCL_LINE | |
| 1241 | } | ||
| 1242 | |||
| 1243 |
1/2✓ Branch 82 → 83 taken 230695 times.
✗ Branch 82 → 112 not taken.
|
461390 | return concludeExprNode(atomicExprNode); |
| 1244 | } | ||
| 1245 | |||
| 1246 | 57308 | std::any ASTBuilder::visitValue(SpiceParser::ValueContext *ctx) { | |
| 1247 | 57308 | const auto valueNode = createNode<ValueNode>(ctx); | |
| 1248 | |||
| 1249 | // Visit children | ||
| 1250 |
2/2✓ Branch 4 → 5 taken 52018 times.
✓ Branch 4 → 10 taken 5290 times.
|
57308 | if (ctx->fctCall()) { |
| 1251 |
3/6✓ Branch 5 → 6 taken 52018 times.
✗ Branch 5 → 65 not taken.
✓ Branch 6 → 7 taken 52018 times.
✗ Branch 6 → 65 not taken.
✓ Branch 7 → 8 taken 52018 times.
✗ Branch 7 → 63 not taken.
|
52018 | valueNode->fctCall = std::any_cast<FctCallNode *>(visit(ctx->fctCall())); |
| 1252 |
2/2✓ Branch 11 → 12 taken 300 times.
✓ Branch 11 → 17 taken 4990 times.
|
5290 | } else if (ctx->arrayInitialization()) { |
| 1253 |
3/6✓ Branch 12 → 13 taken 300 times.
✗ Branch 12 → 68 not taken.
✓ Branch 13 → 14 taken 300 times.
✗ Branch 13 → 68 not taken.
✓ Branch 14 → 15 taken 300 times.
✗ Branch 14 → 66 not taken.
|
300 | valueNode->arrayInitialization = std::any_cast<ArrayInitializationNode *>(visit(ctx->arrayInitialization())); |
| 1254 |
2/2✓ Branch 18 → 19 taken 927 times.
✓ Branch 18 → 24 taken 4063 times.
|
4990 | } else if (ctx->structInstantiation()) { |
| 1255 |
3/6✓ Branch 19 → 20 taken 927 times.
✗ Branch 19 → 71 not taken.
✓ Branch 20 → 21 taken 927 times.
✗ Branch 20 → 71 not taken.
✓ Branch 21 → 22 taken 927 times.
✗ Branch 21 → 69 not taken.
|
927 | valueNode->structInstantiation = std::any_cast<StructInstantiationNode *>(visit(ctx->structInstantiation())); |
| 1256 |
2/2✓ Branch 25 → 26 taken 22 times.
✓ Branch 25 → 31 taken 4041 times.
|
4063 | } else if (ctx->lambdaFunc()) { |
| 1257 |
3/6✓ Branch 26 → 27 taken 22 times.
✗ Branch 26 → 74 not taken.
✓ Branch 27 → 28 taken 22 times.
✗ Branch 27 → 74 not taken.
✓ Branch 28 → 29 taken 22 times.
✗ Branch 28 → 72 not taken.
|
22 | valueNode->lambdaFunc = std::any_cast<LambdaFuncNode *>(visit(ctx->lambdaFunc())); |
| 1258 |
2/2✓ Branch 32 → 33 taken 72 times.
✓ Branch 32 → 38 taken 3969 times.
|
4041 | } else if (ctx->lambdaProc()) { |
| 1259 |
3/6✓ Branch 33 → 34 taken 72 times.
✗ Branch 33 → 77 not taken.
✓ Branch 34 → 35 taken 72 times.
✗ Branch 34 → 77 not taken.
✓ Branch 35 → 36 taken 72 times.
✗ Branch 35 → 75 not taken.
|
72 | valueNode->lambdaProc = std::any_cast<LambdaProcNode *>(visit(ctx->lambdaProc())); |
| 1260 |
2/2✓ Branch 39 → 40 taken 1 time.
✓ Branch 39 → 45 taken 3968 times.
|
3969 | } else if (ctx->lambdaExpr()) { |
| 1261 |
3/6✓ Branch 40 → 41 taken 1 time.
✗ Branch 40 → 80 not taken.
✓ Branch 41 → 42 taken 1 time.
✗ Branch 41 → 80 not taken.
✓ Branch 42 → 43 taken 1 time.
✗ Branch 42 → 78 not taken.
|
1 | valueNode->lambdaExpr = std::any_cast<LambdaExprNode *>(visit(ctx->lambdaExpr())); |
| 1262 |
1/2✓ Branch 46 → 47 taken 3968 times.
✗ Branch 46 → 52 not taken.
|
3968 | } else if (ctx->dataType()) { |
| 1263 | 3968 | valueNode->isNil = true; | |
| 1264 |
3/6✓ Branch 47 → 48 taken 3968 times.
✗ Branch 47 → 83 not taken.
✓ Branch 48 → 49 taken 3968 times.
✗ Branch 48 → 83 not taken.
✓ Branch 49 → 50 taken 3968 times.
✗ Branch 49 → 81 not taken.
|
3968 | valueNode->nilType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 1265 | } else { | ||
| 1266 | − | assert_fail("Unknown value type"); // GCOV_EXCL_LINE | |
| 1267 | } | ||
| 1268 | |||
| 1269 |
1/2✓ Branch 59 → 60 taken 57308 times.
✗ Branch 59 → 84 not taken.
|
114616 | return concludeNode(valueNode); |
| 1270 | } | ||
| 1271 | |||
| 1272 | 46086 | std::any ASTBuilder::visitConstant(SpiceParser::ConstantContext *ctx) { | |
| 1273 | 46086 | const auto constantNode = createNode<ConstantNode>(ctx); | |
| 1274 | |||
| 1275 | // Detect an optional leading minus sign for numeric literals | ||
| 1276 | 46086 | const bool isNegative = ctx->MINUS() != nullptr; | |
| 1277 | |||
| 1278 | // Enrich | ||
| 1279 |
2/2✓ Branch 5 → 6 taken 1835 times.
✓ Branch 5 → 14 taken 44251 times.
|
46086 | if (ctx->DOUBLE_LIT()) { |
| 1280 | 1835 | constantNode->type = ConstantNode::PrimitiveValueType::TYPE_DOUBLE; | |
| 1281 |
3/6✓ Branch 6 → 7 taken 1835 times.
✗ Branch 6 → 63 not taken.
✓ Branch 7 → 8 taken 1835 times.
✗ Branch 7 → 63 not taken.
✓ Branch 8 → 9 taken 1835 times.
✗ Branch 8 → 61 not taken.
|
1835 | const double value = std::stod(ctx->DOUBLE_LIT()->toString()); |
| 1282 |
2/2✓ Branch 10 → 11 taken 149 times.
✓ Branch 10 → 12 taken 1686 times.
|
1835 | constantNode->compileTimeValue.doubleValue = isNegative ? -value : value; |
| 1283 |
2/2✓ Branch 15 → 16 taken 8580 times.
✓ Branch 15 → 19 taken 35671 times.
|
44251 | } else if (ctx->INT_LIT()) { |
| 1284 | 8580 | constantNode->type = ConstantNode::PrimitiveValueType::TYPE_INT; | |
| 1285 | 8580 | constantNode->compileTimeValue.intValue = parseInt(ctx->INT_LIT(), isNegative); | |
| 1286 |
2/2✓ Branch 20 → 21 taken 1106 times.
✓ Branch 20 → 24 taken 34565 times.
|
35671 | } else if (ctx->SHORT_LIT()) { |
| 1287 | 1106 | constantNode->type = ConstantNode::PrimitiveValueType::TYPE_SHORT; | |
| 1288 | 1106 | constantNode->compileTimeValue.shortValue = parseShort(ctx->SHORT_LIT(), isNegative); | |
| 1289 |
2/2✓ Branch 25 → 26 taken 13439 times.
✓ Branch 25 → 29 taken 21126 times.
|
34565 | } else if (ctx->LONG_LIT()) { |
| 1290 | 13439 | constantNode->type = ConstantNode::PrimitiveValueType::TYPE_LONG; | |
| 1291 | 13439 | constantNode->compileTimeValue.longValue = parseLong(ctx->LONG_LIT(), isNegative); | |
| 1292 |
2/2✓ Branch 30 → 31 taken 5215 times.
✓ Branch 30 → 34 taken 15911 times.
|
21126 | } else if (ctx->CHAR_LIT()) { |
| 1293 | 5215 | constantNode->type = ConstantNode::PrimitiveValueType::TYPE_CHAR; | |
| 1294 | 5215 | constantNode->compileTimeValue.charValue = parseChar(ctx->CHAR_LIT()); | |
| 1295 |
2/2✓ Branch 35 → 36 taken 10812 times.
✓ Branch 35 → 44 taken 5099 times.
|
15911 | } else if (ctx->STRING_LIT()) { |
| 1296 | // Save a pointer to the string in the compile time value | ||
| 1297 | 10812 | constantNode->type = ConstantNode::PrimitiveValueType::TYPE_STRING; | |
| 1298 | 10812 | constantNode->compileTimeValue.stringValueOffset = resourceManager.compileTimeStringValues.size(); | |
| 1299 | // Add the string to the global compile time string list | ||
| 1300 |
4/8✓ Branch 37 → 38 taken 10812 times.
✗ Branch 37 → 68 not taken.
✓ Branch 38 → 39 taken 10812 times.
✗ Branch 38 → 68 not taken.
✓ Branch 39 → 40 taken 10812 times.
✗ Branch 39 → 66 not taken.
✓ Branch 40 → 41 taken 10812 times.
✗ Branch 40 → 64 not taken.
|
10812 | resourceManager.compileTimeStringValues.push_back(parseString(ctx->STRING_LIT()->toString())); |
| 1301 |
2/2✓ Branch 45 → 46 taken 2381 times.
✓ Branch 45 → 47 taken 2718 times.
|
5099 | } else if (ctx->TRUE()) { |
| 1302 | 2381 | constantNode->type = ConstantNode::PrimitiveValueType::TYPE_BOOL; | |
| 1303 | 2381 | constantNode->compileTimeValue.boolValue = true; | |
| 1304 |
1/2✓ Branch 48 → 49 taken 2718 times.
✗ Branch 48 → 50 not taken.
|
2718 | } else if (ctx->FALSE()) { |
| 1305 | 2718 | constantNode->type = ConstantNode::PrimitiveValueType::TYPE_BOOL; | |
| 1306 | 2718 | constantNode->compileTimeValue.boolValue = false; | |
| 1307 | } else { | ||
| 1308 | − | assert_fail("Unknown constant type"); // GCOV_EXCL_LINE | |
| 1309 | } | ||
| 1310 | |||
| 1311 |
1/2✓ Branch 57 → 58 taken 46084 times.
✗ Branch 57 → 70 not taken.
|
92168 | return concludeNode(constantNode); |
| 1312 | } | ||
| 1313 | |||
| 1314 | 52018 | std::any ASTBuilder::visitFctCall(SpiceParser::FctCallContext *ctx) { | |
| 1315 |
1/2✓ Branch 2 → 3 taken 52018 times.
✗ Branch 2 → 92 not taken.
|
52018 | const auto fctCallNode = createNode<FctCallNode>(ctx); |
| 1316 | |||
| 1317 |
1/2✓ Branch 3 → 4 taken 52018 times.
✗ Branch 3 → 92 not taken.
|
52018 | std::stringstream fqFunctionName; |
| 1318 |
2/2✓ Branch 46 → 6 taken 258341 times.
✓ Branch 46 → 47 taken 52018 times.
|
362377 | for (antlr4::ParserRuleContext::ParseTree *subTree : ctx->children) { |
| 1319 |
1/2✓ Branch 8 → 9 taken 258341 times.
✗ Branch 8 → 10 not taken.
|
258341 | const auto terminal = dynamic_cast<antlr4::tree::TerminalNode *>(subTree); |
| 1320 |
2/2✓ Branch 11 → 12 taken 41067 times.
✓ Branch 11 → 13 taken 217274 times.
|
258341 | if (!terminal) |
| 1321 | 41067 | continue; | |
| 1322 | |||
| 1323 |
4/6✓ Branch 13 → 14 taken 217274 times.
✗ Branch 13 → 81 not taken.
✓ Branch 14 → 15 taken 217274 times.
✗ Branch 14 → 81 not taken.
✓ Branch 15 → 16 taken 68627 times.
✓ Branch 15 → 21 taken 148647 times.
|
217274 | if (terminal->getSymbol()->getType() == SpiceParser::IDENTIFIER) { |
| 1324 |
1/2✓ Branch 16 → 17 taken 68627 times.
✗ Branch 16 → 77 not taken.
|
68627 | const std::string fragment = terminal->toString(); |
| 1325 |
1/2✓ Branch 17 → 18 taken 68627 times.
✗ Branch 17 → 75 not taken.
|
68627 | fctCallNode->functionNameFragments.push_back(fragment); |
| 1326 |
1/2✓ Branch 18 → 19 taken 68627 times.
✗ Branch 18 → 75 not taken.
|
68627 | fqFunctionName << fragment; |
| 1327 |
4/6✓ Branch 21 → 22 taken 148647 times.
✗ Branch 21 → 81 not taken.
✓ Branch 22 → 23 taken 148647 times.
✗ Branch 22 → 81 not taken.
✓ Branch 23 → 24 taken 10760 times.
✓ Branch 23 → 29 taken 137887 times.
|
217274 | } else if (terminal->getSymbol()->getType() == SpiceParser::TYPE_IDENTIFIER) { |
| 1328 |
1/2✓ Branch 24 → 25 taken 10760 times.
✗ Branch 24 → 80 not taken.
|
10760 | const std::string fragment = terminal->toString(); |
| 1329 |
1/2✓ Branch 25 → 26 taken 10760 times.
✗ Branch 25 → 78 not taken.
|
10760 | fctCallNode->functionNameFragments.push_back(fragment); |
| 1330 |
1/2✓ Branch 26 → 27 taken 10760 times.
✗ Branch 26 → 78 not taken.
|
10760 | fqFunctionName << fragment; |
| 1331 |
4/6✓ Branch 29 → 30 taken 137887 times.
✗ Branch 29 → 81 not taken.
✓ Branch 30 → 31 taken 137887 times.
✗ Branch 30 → 81 not taken.
✓ Branch 31 → 32 taken 152 times.
✓ Branch 31 → 33 taken 137735 times.
|
148647 | } else if (terminal->getSymbol()->getType() == SpiceParser::SCOPE_ACCESS) { |
| 1332 |
1/2✓ Branch 32 → 37 taken 152 times.
✗ Branch 32 → 81 not taken.
|
152 | fqFunctionName << SCOPE_ACCESS_TOKEN; |
| 1333 |
4/6✓ Branch 33 → 34 taken 137735 times.
✗ Branch 33 → 81 not taken.
✓ Branch 34 → 35 taken 137735 times.
✗ Branch 34 → 81 not taken.
✓ Branch 35 → 36 taken 27217 times.
✓ Branch 35 → 37 taken 110518 times.
|
137735 | } else if (terminal->getSymbol()->getType() == SpiceParser::DOT) { |
| 1334 |
1/2✓ Branch 36 → 37 taken 27217 times.
✗ Branch 36 → 81 not taken.
|
27217 | fqFunctionName << MEMBER_ACCESS_TOKEN; |
| 1335 | } | ||
| 1336 | } | ||
| 1337 |
1/2✓ Branch 47 → 48 taken 52018 times.
✗ Branch 47 → 82 not taken.
|
52018 | fctCallNode->fqFunctionName = fqFunctionName.str(); |
| 1338 | |||
| 1339 | // Visit children | ||
| 1340 |
3/4✓ Branch 50 → 51 taken 52018 times.
✗ Branch 50 → 90 not taken.
✓ Branch 51 → 52 taken 3241 times.
✓ Branch 51 → 57 taken 48777 times.
|
52018 | if (ctx->typeLst()) { |
| 1341 | 3241 | fctCallNode->hasTemplateTypes = true; | |
| 1342 |
3/6✓ Branch 52 → 53 taken 3241 times.
✗ Branch 52 → 85 not taken.
✓ Branch 53 → 54 taken 3241 times.
✗ Branch 53 → 85 not taken.
✓ Branch 54 → 55 taken 3241 times.
✗ Branch 54 → 83 not taken.
|
3241 | fctCallNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst())); |
| 1343 | } | ||
| 1344 |
3/4✓ Branch 57 → 58 taken 52018 times.
✗ Branch 57 → 90 not taken.
✓ Branch 58 → 59 taken 37826 times.
✓ Branch 58 → 64 taken 14192 times.
|
52018 | if (ctx->argLst()) { |
| 1345 | 37826 | fctCallNode->hasArgs = true; | |
| 1346 |
3/6✓ Branch 59 → 60 taken 37826 times.
✗ Branch 59 → 88 not taken.
✓ Branch 60 → 61 taken 37826 times.
✗ Branch 60 → 88 not taken.
✓ Branch 61 → 62 taken 37826 times.
✗ Branch 61 → 86 not taken.
|
37826 | fctCallNode->argLst = std::any_cast<ArgLstNode *>(visit(ctx->argLst())); |
| 1347 | } | ||
| 1348 | |||
| 1349 |
1/2✓ Branch 70 → 71 taken 52018 times.
✗ Branch 70 → 89 not taken.
|
104036 | return concludeNode(fctCallNode); |
| 1350 | 52018 | } | |
| 1351 | |||
| 1352 | 300 | std::any ASTBuilder::visitArrayInitialization(SpiceParser::ArrayInitializationContext *ctx) { | |
| 1353 | 300 | const auto arrayInitializationNode = createNode<ArrayInitializationNode>(ctx); | |
| 1354 | |||
| 1355 | // Visit children | ||
| 1356 |
2/2✓ Branch 4 → 5 taken 299 times.
✓ Branch 4 → 10 taken 1 time.
|
300 | if (ctx->argLst()) |
| 1357 |
3/6✓ Branch 5 → 6 taken 299 times.
✗ Branch 5 → 22 not taken.
✓ Branch 6 → 7 taken 299 times.
✗ Branch 6 → 22 not taken.
✓ Branch 7 → 8 taken 299 times.
✗ Branch 7 → 20 not taken.
|
299 | arrayInitializationNode->itemLst = std::any_cast<ArgLstNode *>(visit(ctx->argLst())); |
| 1358 | |||
| 1359 |
1/2✓ Branch 16 → 17 taken 300 times.
✗ Branch 16 → 23 not taken.
|
600 | return concludeNode(arrayInitializationNode); |
| 1360 | } | ||
| 1361 | |||
| 1362 | 927 | std::any ASTBuilder::visitStructInstantiation(SpiceParser::StructInstantiationContext *ctx) { | |
| 1363 |
1/2✓ Branch 2 → 3 taken 927 times.
✗ Branch 2 → 85 not taken.
|
927 | const auto structInstantiationNode = createNode<StructInstantiationNode>(ctx); |
| 1364 | |||
| 1365 | // Enrich | ||
| 1366 |
1/2✓ Branch 3 → 4 taken 927 times.
✗ Branch 3 → 85 not taken.
|
927 | std::stringstream fqStructName; |
| 1367 |
2/2✓ Branch 39 → 6 taken 3774 times.
✓ Branch 39 → 40 taken 927 times.
|
5628 | for (antlr4::ParserRuleContext::ParseTree *subTree : ctx->children) { |
| 1368 |
1/2✓ Branch 8 → 9 taken 3774 times.
✗ Branch 8 → 10 not taken.
|
3774 | const auto terminal = dynamic_cast<antlr4::tree::TerminalNode *>(subTree); |
| 1369 |
2/2✓ Branch 11 → 12 taken 929 times.
✓ Branch 11 → 13 taken 2845 times.
|
3774 | if (!terminal) |
| 1370 | 929 | continue; | |
| 1371 | |||
| 1372 |
4/6✓ Branch 13 → 14 taken 2845 times.
✗ Branch 13 → 74 not taken.
✓ Branch 14 → 15 taken 2845 times.
✗ Branch 14 → 74 not taken.
✓ Branch 15 → 16 taken 3 times.
✓ Branch 15 → 22 taken 2842 times.
|
2845 | if (terminal->getSymbol()->getType() == SpiceParser::IDENTIFIER) { |
| 1373 |
1/2✓ Branch 16 → 17 taken 3 times.
✗ Branch 16 → 70 not taken.
|
3 | const std::string fragment = terminal->toString(); |
| 1374 |
1/2✓ Branch 17 → 18 taken 3 times.
✗ Branch 17 → 68 not taken.
|
3 | structInstantiationNode->structNameFragments.push_back(fragment); |
| 1375 |
2/4✓ Branch 18 → 19 taken 3 times.
✗ Branch 18 → 68 not taken.
✓ Branch 19 → 20 taken 3 times.
✗ Branch 19 → 68 not taken.
|
3 | fqStructName << fragment << SCOPE_ACCESS_TOKEN; |
| 1376 |
4/6✓ Branch 22 → 23 taken 2842 times.
✗ Branch 22 → 74 not taken.
✓ Branch 23 → 24 taken 2842 times.
✗ Branch 23 → 74 not taken.
✓ Branch 24 → 25 taken 927 times.
✓ Branch 24 → 30 taken 1915 times.
|
2845 | } else if (terminal->getSymbol()->getType() == SpiceParser::TYPE_IDENTIFIER) { |
| 1377 |
1/2✓ Branch 25 → 26 taken 927 times.
✗ Branch 25 → 73 not taken.
|
927 | const std::string fragment = terminal->toString(); |
| 1378 |
1/2✓ Branch 26 → 27 taken 927 times.
✗ Branch 26 → 71 not taken.
|
927 | structInstantiationNode->structNameFragments.push_back(fragment); |
| 1379 |
1/2✓ Branch 27 → 28 taken 927 times.
✗ Branch 27 → 71 not taken.
|
927 | fqStructName << fragment; |
| 1380 | 927 | } | |
| 1381 | } | ||
| 1382 |
1/2✓ Branch 40 → 41 taken 927 times.
✗ Branch 40 → 75 not taken.
|
927 | structInstantiationNode->fqStructName = fqStructName.str(); |
| 1383 | |||
| 1384 | // Visit children | ||
| 1385 |
3/4✓ Branch 43 → 44 taken 927 times.
✗ Branch 43 → 83 not taken.
✓ Branch 44 → 45 taken 29 times.
✓ Branch 44 → 50 taken 898 times.
|
927 | if (ctx->typeLst()) { |
| 1386 | 29 | structInstantiationNode->hasTemplateTypes = true; | |
| 1387 |
3/6✓ Branch 45 → 46 taken 29 times.
✗ Branch 45 → 78 not taken.
✓ Branch 46 → 47 taken 29 times.
✗ Branch 46 → 78 not taken.
✓ Branch 47 → 48 taken 29 times.
✗ Branch 47 → 76 not taken.
|
29 | structInstantiationNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst())); |
| 1388 | } | ||
| 1389 |
3/4✓ Branch 50 → 51 taken 927 times.
✗ Branch 50 → 83 not taken.
✓ Branch 51 → 52 taken 900 times.
✓ Branch 51 → 57 taken 27 times.
|
927 | if (ctx->argLst()) |
| 1390 |
3/6✓ Branch 52 → 53 taken 900 times.
✗ Branch 52 → 81 not taken.
✓ Branch 53 → 54 taken 900 times.
✗ Branch 53 → 81 not taken.
✓ Branch 54 → 55 taken 900 times.
✗ Branch 54 → 79 not taken.
|
900 | structInstantiationNode->fieldLst = std::any_cast<ArgLstNode *>(visit(ctx->argLst())); |
| 1391 | |||
| 1392 |
1/2✓ Branch 63 → 64 taken 927 times.
✗ Branch 63 → 82 not taken.
|
1854 | return concludeNode(structInstantiationNode); |
| 1393 | 927 | } | |
| 1394 | |||
| 1395 | 22 | std::any ASTBuilder::visitLambdaFunc(SpiceParser::LambdaFuncContext *ctx) { | |
| 1396 | 22 | const auto lambdaFuncNode = createNode<LambdaFuncNode>(ctx); | |
| 1397 | |||
| 1398 | // Visit children | ||
| 1399 |
3/6✓ Branch 3 → 4 taken 22 times.
✗ Branch 3 → 37 not taken.
✓ Branch 4 → 5 taken 22 times.
✗ Branch 4 → 37 not taken.
✓ Branch 5 → 6 taken 22 times.
✗ Branch 5 → 35 not taken.
|
22 | lambdaFuncNode->returnType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 1400 |
2/2✓ Branch 8 → 9 taken 17 times.
✓ Branch 8 → 14 taken 5 times.
|
22 | if (ctx->paramLst()) { |
| 1401 | 17 | lambdaFuncNode->hasParams = true; | |
| 1402 |
3/6✓ Branch 9 → 10 taken 17 times.
✗ Branch 9 → 40 not taken.
✓ Branch 10 → 11 taken 17 times.
✗ Branch 10 → 40 not taken.
✓ Branch 11 → 12 taken 17 times.
✗ Branch 11 → 38 not taken.
|
17 | lambdaFuncNode->paramLst = std::any_cast<ParamLstNode *>(visit(ctx->paramLst())); |
| 1403 | } | ||
| 1404 |
1/2✗ Branch 15 → 16 not taken.
✓ Branch 15 → 21 taken 22 times.
|
22 | if (ctx->lambdaAttr()) |
| 1405 | ✗ | lambdaFuncNode->lambdaAttr = std::any_cast<LambdaAttrNode *>(visit(ctx->lambdaAttr())); | |
| 1406 |
4/8✓ Branch 21 → 22 taken 22 times.
✗ Branch 21 → 46 not taken.
✓ Branch 22 → 23 taken 22 times.
✗ Branch 22 → 46 not taken.
✓ Branch 23 → 24 taken 22 times.
✗ Branch 23 → 44 not taken.
✓ Branch 25 → 26 taken 22 times.
✗ Branch 25 → 47 not taken.
|
22 | lambdaFuncNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 1407 | |||
| 1408 |
1/2✓ Branch 31 → 32 taken 22 times.
✗ Branch 31 → 47 not taken.
|
44 | return concludeNode(lambdaFuncNode); |
| 1409 | } | ||
| 1410 | |||
| 1411 | 72 | std::any ASTBuilder::visitLambdaProc(SpiceParser::LambdaProcContext *ctx) { | |
| 1412 | 72 | const auto lambdaProcNode = createNode<LambdaProcNode>(ctx); | |
| 1413 | |||
| 1414 | // Visit children | ||
| 1415 |
2/2✓ Branch 4 → 5 taken 58 times.
✓ Branch 4 → 10 taken 14 times.
|
72 | if (ctx->paramLst()) { |
| 1416 | 58 | lambdaProcNode->hasParams = true; | |
| 1417 |
3/6✓ Branch 5 → 6 taken 58 times.
✗ Branch 5 → 33 not taken.
✓ Branch 6 → 7 taken 58 times.
✗ Branch 6 → 33 not taken.
✓ Branch 7 → 8 taken 58 times.
✗ Branch 7 → 31 not taken.
|
58 | lambdaProcNode->paramLst = std::any_cast<ParamLstNode *>(visit(ctx->paramLst())); |
| 1418 | } | ||
| 1419 |
2/2✓ Branch 11 → 12 taken 6 times.
✓ Branch 11 → 17 taken 66 times.
|
72 | if (ctx->lambdaAttr()) |
| 1420 |
3/6✓ Branch 12 → 13 taken 6 times.
✗ Branch 12 → 36 not taken.
✓ Branch 13 → 14 taken 6 times.
✗ Branch 13 → 36 not taken.
✓ Branch 14 → 15 taken 6 times.
✗ Branch 14 → 34 not taken.
|
6 | lambdaProcNode->lambdaAttr = std::any_cast<LambdaAttrNode *>(visit(ctx->lambdaAttr())); |
| 1421 |
4/8✓ Branch 17 → 18 taken 72 times.
✗ Branch 17 → 39 not taken.
✓ Branch 18 → 19 taken 72 times.
✗ Branch 18 → 39 not taken.
✓ Branch 19 → 20 taken 72 times.
✗ Branch 19 → 37 not taken.
✓ Branch 21 → 22 taken 72 times.
✗ Branch 21 → 40 not taken.
|
72 | lambdaProcNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 1422 | |||
| 1423 |
1/2✓ Branch 27 → 28 taken 72 times.
✗ Branch 27 → 40 not taken.
|
144 | return concludeNode(lambdaProcNode); |
| 1424 | } | ||
| 1425 | |||
| 1426 | 1 | std::any ASTBuilder::visitLambdaExpr(SpiceParser::LambdaExprContext *ctx) { | |
| 1427 | 1 | const auto lambdaExprNode = createNode<LambdaExprNode>(ctx); | |
| 1428 | |||
| 1429 | // Visit children | ||
| 1430 |
1/2✓ Branch 4 → 5 taken 1 time.
✗ Branch 4 → 10 not taken.
|
1 | if (ctx->paramLst()) { |
| 1431 | 1 | lambdaExprNode->hasParams = true; | |
| 1432 |
3/6✓ Branch 5 → 6 taken 1 time.
✗ Branch 5 → 26 not taken.
✓ Branch 6 → 7 taken 1 time.
✗ Branch 6 → 26 not taken.
✓ Branch 7 → 8 taken 1 time.
✗ Branch 7 → 24 not taken.
|
1 | lambdaExprNode->paramLst = std::any_cast<ParamLstNode *>(visit(ctx->paramLst())); |
| 1433 | } | ||
| 1434 |
4/8✓ Branch 10 → 11 taken 1 time.
✗ Branch 10 → 29 not taken.
✓ Branch 11 → 12 taken 1 time.
✗ Branch 11 → 29 not taken.
✓ Branch 12 → 13 taken 1 time.
✗ Branch 12 → 27 not taken.
✓ Branch 14 → 15 taken 1 time.
✗ Branch 14 → 30 not taken.
|
1 | lambdaExprNode->lambdaExpr = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 1435 | |||
| 1436 |
1/2✓ Branch 20 → 21 taken 1 time.
✗ Branch 20 → 30 not taken.
|
2 | return concludeNode(lambdaExprNode); |
| 1437 | } | ||
| 1438 | |||
| 1439 | 123713 | std::any ASTBuilder::visitDataType(SpiceParser::DataTypeContext *ctx) { | |
| 1440 | 123713 | const auto dataTypeNode = createNode<DataTypeNode>(ctx); | |
| 1441 | |||
| 1442 | // Visit children | ||
| 1443 |
2/2✓ Branch 4 → 5 taken 44450 times.
✓ Branch 4 → 10 taken 79263 times.
|
123713 | if (ctx->qualifierLst()) |
| 1444 |
4/6✓ Branch 5 → 6 taken 44450 times.
✗ Branch 5 → 73 not taken.
✓ Branch 6 → 7 taken 44449 times.
✓ Branch 6 → 73 taken 1 time.
✓ Branch 7 → 8 taken 44449 times.
✗ Branch 7 → 71 not taken.
|
44450 | dataTypeNode->qualifierLst = std::any_cast<QualifierLstNode *>(visit(ctx->qualifierLst())); |
| 1445 |
3/6✓ Branch 10 → 11 taken 123712 times.
✗ Branch 10 → 76 not taken.
✓ Branch 11 → 12 taken 123712 times.
✗ Branch 11 → 76 not taken.
✓ Branch 12 → 13 taken 123712 times.
✗ Branch 12 → 74 not taken.
|
123712 | dataTypeNode->baseDataType = std::any_cast<BaseDataTypeNode *>(visit(ctx->baseDataType())); |
| 1446 | |||
| 1447 | // Enrich | ||
| 1448 |
2/2✓ Branch 60 → 15 taken 199992 times.
✓ Branch 60 → 61 taken 123712 times.
|
323704 | for (size_t i = 0; i < ctx->children.size(); i++) { |
| 1449 | 199992 | antlr4::tree::ParseTree *subTree = ctx->children.at(i); | |
| 1450 |
1/2✓ Branch 16 → 17 taken 199992 times.
✗ Branch 16 → 18 not taken.
|
199992 | auto terminal = dynamic_cast<TerminalNode *>(subTree); |
| 1451 |
2/2✓ Branch 19 → 20 taken 168161 times.
✓ Branch 19 → 21 taken 31831 times.
|
199992 | if (!terminal) |
| 1452 | 168161 | continue; | |
| 1453 | |||
| 1454 |
2/2✓ Branch 23 → 24 taken 17854 times.
✓ Branch 23 → 26 taken 13977 times.
|
31831 | if (terminal->getSymbol()->getType() == SpiceParser::MUL) { |
| 1455 |
1/2✓ Branch 24 → 25 taken 17854 times.
✗ Branch 24 → 77 not taken.
|
17854 | dataTypeNode->tmQueue.emplace(DataTypeNode::TypeModifierType::TYPE_PTR, false, 0); |
| 1456 |
2/2✓ Branch 28 → 29 taken 13797 times.
✓ Branch 28 → 31 taken 180 times.
|
13977 | } else if (terminal->getSymbol()->getType() == SpiceParser::BITWISE_AND) { |
| 1457 |
1/2✓ Branch 29 → 30 taken 13797 times.
✗ Branch 29 → 80 not taken.
|
13797 | dataTypeNode->tmQueue.emplace(DataTypeNode::TypeModifierType::TYPE_REF, false, 0); |
| 1458 |
1/2✓ Branch 33 → 34 taken 180 times.
✗ Branch 33 → 58 not taken.
|
180 | } else if (terminal->getSymbol()->getType() == SpiceParser::LBRACKET) { |
| 1459 | 180 | i++; // Consume LBRACKET | |
| 1460 |
1/2✓ Branch 34 → 35 taken 180 times.
✗ Branch 34 → 92 not taken.
|
180 | subTree = ctx->children.at(i); |
| 1461 |
1/2✓ Branch 35 → 36 taken 180 times.
✗ Branch 35 → 37 not taken.
|
180 | terminal = dynamic_cast<TerminalNode *>(subTree); |
| 1462 | 180 | bool hasSize = false; | |
| 1463 | 180 | unsigned int hardCodedSize = 0; | |
| 1464 | 180 | std::string sizeVarName; | |
| 1465 |
4/6✓ Branch 39 → 40 taken 180 times.
✗ Branch 39 → 90 not taken.
✓ Branch 40 → 41 taken 180 times.
✗ Branch 40 → 90 not taken.
✓ Branch 41 → 42 taken 67 times.
✓ Branch 41 → 46 taken 113 times.
|
180 | if (terminal->getSymbol()->getType() == SpiceParser::INT_LIT) { |
| 1466 | 67 | hasSize = true; | |
| 1467 |
2/4✓ Branch 42 → 43 taken 67 times.
✗ Branch 42 → 85 not taken.
✓ Branch 43 → 44 taken 67 times.
✗ Branch 43 → 83 not taken.
|
67 | hardCodedSize = std::stoi(terminal->getText()); |
| 1468 | 67 | i++; // Consume INT_LIT | |
| 1469 |
4/6✓ Branch 46 → 47 taken 113 times.
✗ Branch 46 → 90 not taken.
✓ Branch 47 → 48 taken 113 times.
✗ Branch 47 → 90 not taken.
✓ Branch 48 → 49 taken 41 times.
✓ Branch 48 → 53 taken 72 times.
|
113 | } else if (terminal->getSymbol()->getType() == SpiceParser::TYPE_IDENTIFIER) { |
| 1470 | 41 | hasSize = true; | |
| 1471 |
1/2✓ Branch 49 → 50 taken 41 times.
✗ Branch 49 → 86 not taken.
|
41 | sizeVarName = getIdentifier(terminal, true); |
| 1472 | 41 | i++; // Consume TYPE_IDENTIFIER | |
| 1473 | } | ||
| 1474 |
1/2✓ Branch 54 → 55 taken 180 times.
✗ Branch 54 → 87 not taken.
|
180 | dataTypeNode->tmQueue.push({DataTypeNode::TypeModifierType::TYPE_ARRAY, hasSize, hardCodedSize, sizeVarName}); |
| 1475 | 180 | } | |
| 1476 | } | ||
| 1477 | |||
| 1478 |
1/2✓ Branch 67 → 68 taken 123712 times.
✗ Branch 67 → 93 not taken.
|
247424 | return concludeNode(dataTypeNode); |
| 1479 |
1/2✓ Branch 53 → 54 taken 180 times.
✗ Branch 53 → 89 not taken.
|
180 | } |
| 1480 | |||
| 1481 | 123712 | std::any ASTBuilder::visitBaseDataType(SpiceParser::BaseDataTypeContext *ctx) { | |
| 1482 | 123712 | const auto baseDataTypeNode = createNode<BaseDataTypeNode>(ctx); | |
| 1483 | |||
| 1484 | // Enrich | ||
| 1485 |
2/2✓ Branch 4 → 5 taken 1927 times.
✓ Branch 4 → 6 taken 121785 times.
|
123712 | if (ctx->TYPE_DOUBLE()) { |
| 1486 | 1927 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_DOUBLE; | |
| 1487 |
2/2✓ Branch 7 → 8 taken 7468 times.
✓ Branch 7 → 9 taken 114317 times.
|
121785 | } else if (ctx->TYPE_INT()) { |
| 1488 | 7468 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_INT; | |
| 1489 |
2/2✓ Branch 10 → 11 taken 2126 times.
✓ Branch 10 → 12 taken 112191 times.
|
114317 | } else if (ctx->TYPE_SHORT()) { |
| 1490 | 2126 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_SHORT; | |
| 1491 |
2/2✓ Branch 13 → 14 taken 19125 times.
✓ Branch 13 → 15 taken 93066 times.
|
112191 | } else if (ctx->TYPE_LONG()) { |
| 1492 | 19125 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_LONG; | |
| 1493 |
2/2✓ Branch 16 → 17 taken 6975 times.
✓ Branch 16 → 18 taken 86091 times.
|
93066 | } else if (ctx->TYPE_BYTE()) { |
| 1494 | 6975 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_BYTE; | |
| 1495 |
2/2✓ Branch 19 → 20 taken 9562 times.
✓ Branch 19 → 21 taken 76529 times.
|
86091 | } else if (ctx->TYPE_CHAR()) { |
| 1496 | 9562 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_CHAR; | |
| 1497 |
2/2✓ Branch 22 → 23 taken 8792 times.
✓ Branch 22 → 24 taken 67737 times.
|
76529 | } else if (ctx->TYPE_STRING()) { |
| 1498 | 8792 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_STRING; | |
| 1499 |
2/2✓ Branch 25 → 26 taken 9276 times.
✓ Branch 25 → 27 taken 58461 times.
|
67737 | } else if (ctx->TYPE_BOOL()) { |
| 1500 | 9276 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_BOOL; | |
| 1501 |
2/2✓ Branch 28 → 29 taken 1371 times.
✓ Branch 28 → 30 taken 57090 times.
|
58461 | } else if (ctx->TYPE_DYN()) { |
| 1502 | 1371 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_DYN; | |
| 1503 |
2/2✓ Branch 31 → 32 taken 56878 times.
✓ Branch 31 → 37 taken 212 times.
|
57090 | } else if (ctx->customDataType()) { |
| 1504 | 56878 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_CUSTOM; | |
| 1505 |
3/6✓ Branch 32 → 33 taken 56878 times.
✗ Branch 32 → 57 not taken.
✓ Branch 33 → 34 taken 56878 times.
✗ Branch 33 → 57 not taken.
✓ Branch 34 → 35 taken 56878 times.
✗ Branch 34 → 55 not taken.
|
56878 | baseDataTypeNode->customDataType = std::any_cast<CustomDataTypeNode *>(visit(ctx->customDataType())); |
| 1506 |
1/2✓ Branch 38 → 39 taken 212 times.
✗ Branch 38 → 44 not taken.
|
212 | } else if (ctx->functionDataType()) { |
| 1507 | 212 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_FUNCTION; | |
| 1508 |
3/6✓ Branch 39 → 40 taken 212 times.
✗ Branch 39 → 60 not taken.
✓ Branch 40 → 41 taken 212 times.
✗ Branch 40 → 60 not taken.
✓ Branch 41 → 42 taken 212 times.
✗ Branch 41 → 58 not taken.
|
212 | baseDataTypeNode->functionDataType = std::any_cast<FunctionDataTypeNode *>(visit(ctx->functionDataType())); |
| 1509 | } else { | ||
| 1510 | ✗ | assert_fail("Unknown base data type"); | |
| 1511 | } | ||
| 1512 | |||
| 1513 |
1/2✓ Branch 51 → 52 taken 123712 times.
✗ Branch 51 → 61 not taken.
|
247424 | return concludeNode(baseDataTypeNode); |
| 1514 | } | ||
| 1515 | |||
| 1516 | 56878 | std::any ASTBuilder::visitCustomDataType(SpiceParser::CustomDataTypeContext *ctx) { | |
| 1517 |
1/2✓ Branch 2 → 3 taken 56878 times.
✗ Branch 2 → 75 not taken.
|
56878 | const auto customDataTypeNode = createNode<CustomDataTypeNode>(ctx); |
| 1518 | |||
| 1519 | // Enrich | ||
| 1520 |
1/2✓ Branch 3 → 4 taken 56878 times.
✗ Branch 3 → 75 not taken.
|
56878 | std::stringstream fqTypeName; |
| 1521 |
2/2✓ Branch 39 → 6 taken 79451 times.
✓ Branch 39 → 40 taken 56878 times.
|
193207 | for (ParserRuleContext::ParseTree *subTree : ctx->children) { |
| 1522 |
1/2✓ Branch 8 → 9 taken 79451 times.
✗ Branch 8 → 10 not taken.
|
79451 | const auto terminal = dynamic_cast<TerminalNode *>(subTree); |
| 1523 |
2/2✓ Branch 11 → 12 taken 7423 times.
✓ Branch 11 → 13 taken 72028 times.
|
79451 | if (!terminal) |
| 1524 | 7423 | continue; | |
| 1525 | |||
| 1526 |
4/6✓ Branch 13 → 14 taken 72028 times.
✗ Branch 13 → 67 not taken.
✓ Branch 14 → 15 taken 72028 times.
✗ Branch 14 → 67 not taken.
✓ Branch 15 → 16 taken 152 times.
✓ Branch 15 → 22 taken 71876 times.
|
72028 | if (terminal->getSymbol()->getType() == SpiceParser::IDENTIFIER) { |
| 1527 |
1/2✓ Branch 16 → 17 taken 152 times.
✗ Branch 16 → 63 not taken.
|
152 | const std::string fragment = terminal->toString(); |
| 1528 |
1/2✓ Branch 17 → 18 taken 152 times.
✗ Branch 17 → 61 not taken.
|
152 | customDataTypeNode->typeNameFragments.push_back(fragment); |
| 1529 |
2/4✓ Branch 18 → 19 taken 152 times.
✗ Branch 18 → 61 not taken.
✓ Branch 19 → 20 taken 152 times.
✗ Branch 19 → 61 not taken.
|
152 | fqTypeName << fragment << SCOPE_ACCESS_TOKEN; |
| 1530 |
4/6✓ Branch 22 → 23 taken 71876 times.
✗ Branch 22 → 67 not taken.
✓ Branch 23 → 24 taken 71876 times.
✗ Branch 23 → 67 not taken.
✓ Branch 24 → 25 taken 56878 times.
✓ Branch 24 → 30 taken 14998 times.
|
72028 | } else if (terminal->getSymbol()->getType() == SpiceParser::TYPE_IDENTIFIER) { |
| 1531 |
1/2✓ Branch 25 → 26 taken 56878 times.
✗ Branch 25 → 66 not taken.
|
56878 | const std::string fragment = terminal->toString(); |
| 1532 |
1/2✓ Branch 26 → 27 taken 56878 times.
✗ Branch 26 → 64 not taken.
|
56878 | customDataTypeNode->typeNameFragments.push_back(fragment); |
| 1533 |
1/2✓ Branch 27 → 28 taken 56878 times.
✗ Branch 27 → 64 not taken.
|
56878 | fqTypeName << fragment; |
| 1534 | 56878 | } | |
| 1535 | } | ||
| 1536 |
1/2✓ Branch 40 → 41 taken 56878 times.
✗ Branch 40 → 68 not taken.
|
56878 | customDataTypeNode->fqTypeName = fqTypeName.str(); |
| 1537 | |||
| 1538 | // Visit children | ||
| 1539 |
3/4✓ Branch 43 → 44 taken 56878 times.
✗ Branch 43 → 73 not taken.
✓ Branch 44 → 45 taken 7423 times.
✓ Branch 44 → 50 taken 49455 times.
|
56878 | if (ctx->typeLst()) |
| 1540 |
3/6✓ Branch 45 → 46 taken 7423 times.
✗ Branch 45 → 71 not taken.
✓ Branch 46 → 47 taken 7423 times.
✗ Branch 46 → 71 not taken.
✓ Branch 47 → 48 taken 7423 times.
✗ Branch 47 → 69 not taken.
|
7423 | customDataTypeNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst())); |
| 1541 | |||
| 1542 |
1/2✓ Branch 56 → 57 taken 56878 times.
✗ Branch 56 → 72 not taken.
|
113756 | return concludeNode(customDataTypeNode); |
| 1543 | 56878 | } | |
| 1544 | |||
| 1545 | 212 | std::any ASTBuilder::visitFunctionDataType(SpiceParser::FunctionDataTypeContext *ctx) { | |
| 1546 | 212 | const auto functionDataTypeNode = createNode<FunctionDataTypeNode>(ctx); | |
| 1547 | |||
| 1548 | // Enrich | ||
| 1549 |
2/2✓ Branch 4 → 5 taken 49 times.
✓ Branch 4 → 11 taken 163 times.
|
212 | if (ctx->dataType()) { |
| 1550 | 49 | functionDataTypeNode->isFunction = ctx->dataType(); | |
| 1551 |
3/6✓ Branch 6 → 7 taken 49 times.
✗ Branch 6 → 30 not taken.
✓ Branch 7 → 8 taken 49 times.
✗ Branch 7 → 30 not taken.
✓ Branch 8 → 9 taken 49 times.
✗ Branch 8 → 28 not taken.
|
49 | functionDataTypeNode->returnType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 1552 | } | ||
| 1553 |
2/2✓ Branch 12 → 13 taken 159 times.
✓ Branch 12 → 18 taken 53 times.
|
212 | if (ctx->typeLst()) |
| 1554 |
3/6✓ Branch 13 → 14 taken 159 times.
✗ Branch 13 → 33 not taken.
✓ Branch 14 → 15 taken 159 times.
✗ Branch 14 → 33 not taken.
✓ Branch 15 → 16 taken 159 times.
✗ Branch 15 → 31 not taken.
|
159 | functionDataTypeNode->paramTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst())); |
| 1555 | |||
| 1556 |
1/2✓ Branch 24 → 25 taken 212 times.
✗ Branch 24 → 34 not taken.
|
424 | return concludeNode(functionDataTypeNode); |
| 1557 | } | ||
| 1558 | |||
| 1559 | 18916 | std::any ASTBuilder::visitAssignOp(SpiceParser::AssignOpContext *ctx) { | |
| 1560 | 18916 | const auto assignExprNode = resumeForExpansion<AssignExprNode>(); | |
| 1561 | |||
| 1562 | // Extract assign operator | ||
| 1563 |
2/2✓ Branch 13 → 14 taken 16698 times.
✓ Branch 13 → 15 taken 2218 times.
|
18916 | if (ctx->ASSIGN()) |
| 1564 | 16698 | assignExprNode->op = AssignExprNode::AssignOp::OP_ASSIGN; | |
| 1565 |
2/2✓ Branch 16 → 17 taken 1079 times.
✓ Branch 16 → 18 taken 1139 times.
|
2218 | else if (ctx->PLUS_EQUAL()) |
| 1566 | 1079 | assignExprNode->op = AssignExprNode::AssignOp::OP_PLUS_EQUAL; | |
| 1567 |
2/2✓ Branch 19 → 20 taken 159 times.
✓ Branch 19 → 21 taken 980 times.
|
1139 | else if (ctx->MINUS_EQUAL()) |
| 1568 | 159 | assignExprNode->op = AssignExprNode::AssignOp::OP_MINUS_EQUAL; | |
| 1569 |
2/2✓ Branch 22 → 23 taken 177 times.
✓ Branch 22 → 24 taken 803 times.
|
980 | else if (ctx->MUL_EQUAL()) |
| 1570 | 177 | assignExprNode->op = AssignExprNode::AssignOp::OP_MUL_EQUAL; | |
| 1571 |
2/2✓ Branch 25 → 26 taken 90 times.
✓ Branch 25 → 27 taken 713 times.
|
803 | else if (ctx->DIV_EQUAL()) |
| 1572 | 90 | assignExprNode->op = AssignExprNode::AssignOp::OP_DIV_EQUAL; | |
| 1573 |
2/2✓ Branch 28 → 29 taken 25 times.
✓ Branch 28 → 30 taken 688 times.
|
713 | else if (ctx->REM_EQUAL()) |
| 1574 | 25 | assignExprNode->op = AssignExprNode::AssignOp::OP_REM_EQUAL; | |
| 1575 |
2/2✓ Branch 31 → 32 taken 3 times.
✓ Branch 31 → 33 taken 685 times.
|
688 | else if (ctx->SHL_EQUAL()) |
| 1576 | 3 | assignExprNode->op = AssignExprNode::AssignOp::OP_SHL_EQUAL; | |
| 1577 |
2/2✓ Branch 34 → 35 taken 4 times.
✓ Branch 34 → 36 taken 681 times.
|
685 | else if (ctx->SHR_EQUAL()) |
| 1578 | 4 | assignExprNode->op = AssignExprNode::AssignOp::OP_SHR_EQUAL; | |
| 1579 |
2/2✓ Branch 37 → 38 taken 8 times.
✓ Branch 37 → 39 taken 673 times.
|
681 | else if (ctx->AND_EQUAL()) |
| 1580 | 8 | assignExprNode->op = AssignExprNode::AssignOp::OP_AND_EQUAL; | |
| 1581 |
2/2✓ Branch 40 → 41 taken 4 times.
✓ Branch 40 → 42 taken 669 times.
|
673 | else if (ctx->OR_EQUAL()) |
| 1582 | 4 | assignExprNode->op = AssignExprNode::AssignOp::OP_OR_EQUAL; | |
| 1583 |
1/2✓ Branch 43 → 44 taken 669 times.
✗ Branch 43 → 45 not taken.
|
669 | else if (ctx->XOR_EQUAL()) |
| 1584 | 669 | assignExprNode->op = AssignExprNode::AssignOp::OP_XOR_EQUAL; | |
| 1585 | else | ||
| 1586 | ✗ | assert_fail("Unknown assign operator"); | |
| 1587 | |||
| 1588 |
1/2✓ Branch 46 → 47 taken 18916 times.
✗ Branch 46 → 50 not taken.
|
37832 | return nullptr; |
| 1589 | } | ||
| 1590 | |||
| 1591 | 3542 | std::any ASTBuilder::visitOverloadableOp(SpiceParser::OverloadableOpContext *ctx) { | |
| 1592 | 3542 | const auto fctNameNode = resumeForExpansion<FctNameNode>(); | |
| 1593 | |||
| 1594 | // Enrich | ||
| 1595 |
2/2✓ Branch 13 → 14 taken 152 times.
✓ Branch 13 → 15 taken 3390 times.
|
3542 | if (ctx->PLUS()) |
| 1596 | 152 | fctNameNode->name = OP_FCT_PLUS; | |
| 1597 |
2/2✓ Branch 16 → 17 taken 1 time.
✓ Branch 16 → 18 taken 3389 times.
|
3390 | else if (ctx->MINUS()) |
| 1598 | 1 | fctNameNode->name = OP_FCT_MINUS; | |
| 1599 |
2/2✓ Branch 19 → 20 taken 303 times.
✓ Branch 19 → 21 taken 3086 times.
|
3389 | else if (ctx->MUL()) |
| 1600 | 303 | fctNameNode->name = OP_FCT_MUL; | |
| 1601 |
2/2✓ Branch 22 → 23 taken 37 times.
✓ Branch 22 → 24 taken 3049 times.
|
3086 | else if (ctx->DIV()) |
| 1602 | 37 | fctNameNode->name = OP_FCT_DIV; | |
| 1603 |
2/2✓ Branch 25 → 26 taken 796 times.
✓ Branch 25 → 27 taken 2253 times.
|
3049 | else if (ctx->EQUAL()) |
| 1604 | 796 | fctNameNode->name = OP_FCT_EQUAL; | |
| 1605 |
2/2✓ Branch 28 → 29 taken 762 times.
✓ Branch 28 → 30 taken 1491 times.
|
2253 | else if (ctx->NOT_EQUAL()) |
| 1606 | 762 | fctNameNode->name = OP_FCT_NOT_EQUAL; | |
| 1607 |
3/4✓ Branch 30 → 31 taken 1491 times.
✗ Branch 30 → 83 not taken.
✓ Branch 33 → 34 taken 70 times.
✓ Branch 33 → 35 taken 1421 times.
|
1491 | else if (ctx->LESS().size() == 2) |
| 1608 | 70 | fctNameNode->name = OP_FCT_SHL; | |
| 1609 |
3/4✓ Branch 35 → 36 taken 1421 times.
✗ Branch 35 → 84 not taken.
✓ Branch 38 → 39 taken 1 time.
✓ Branch 38 → 40 taken 1420 times.
|
1421 | else if (ctx->GREATER().size() == 2) |
| 1610 | 1 | fctNameNode->name = OP_FCT_SHR; | |
| 1611 |
2/2✓ Branch 41 → 42 taken 3 times.
✓ Branch 41 → 43 taken 1417 times.
|
1420 | else if (ctx->BITWISE_AND()) |
| 1612 | 3 | fctNameNode->name = OP_FCT_BITWISE_AND; | |
| 1613 |
2/2✓ Branch 44 → 45 taken 3 times.
✓ Branch 44 → 46 taken 1414 times.
|
1417 | else if (ctx->BITWISE_OR()) |
| 1614 | 3 | fctNameNode->name = OP_FCT_BITWISE_OR; | |
| 1615 |
2/2✓ Branch 47 → 48 taken 3 times.
✓ Branch 47 → 49 taken 1411 times.
|
1414 | else if (ctx->BITWISE_XOR()) |
| 1616 | 3 | fctNameNode->name = OP_FCT_BITWISE_XOR; | |
| 1617 |
2/2✓ Branch 50 → 51 taken 3 times.
✓ Branch 50 → 52 taken 1408 times.
|
1411 | else if (ctx->BITWISE_NOT()) |
| 1618 | 3 | fctNameNode->name = OP_FCT_BITWISE_NOT; | |
| 1619 |
2/2✓ Branch 53 → 54 taken 247 times.
✓ Branch 53 → 55 taken 1161 times.
|
1408 | else if (ctx->PLUS_EQUAL()) |
| 1620 | 247 | fctNameNode->name = OP_FCT_PLUS_EQUAL; | |
| 1621 |
2/2✓ Branch 56 → 57 taken 96 times.
✓ Branch 56 → 58 taken 1065 times.
|
1161 | else if (ctx->MINUS_EQUAL()) |
| 1622 | 96 | fctNameNode->name = OP_FCT_MINUS_EQUAL; | |
| 1623 |
2/2✓ Branch 59 → 60 taken 152 times.
✓ Branch 59 → 61 taken 913 times.
|
1065 | else if (ctx->MUL_EQUAL()) |
| 1624 | 152 | fctNameNode->name = OP_FCT_MUL_EQUAL; | |
| 1625 |
2/2✓ Branch 62 → 63 taken 37 times.
✓ Branch 62 → 64 taken 876 times.
|
913 | else if (ctx->DIV_EQUAL()) |
| 1626 | 37 | fctNameNode->name = OP_FCT_DIV_EQUAL; | |
| 1627 |
2/2✓ Branch 65 → 66 taken 124 times.
✓ Branch 65 → 67 taken 752 times.
|
876 | else if (ctx->PLUS_PLUS()) |
| 1628 | 124 | fctNameNode->name = OP_FCT_POSTFIX_PLUS_PLUS; | |
| 1629 |
2/2✓ Branch 68 → 69 taken 96 times.
✓ Branch 68 → 70 taken 656 times.
|
752 | else if (ctx->MINUS_MINUS()) |
| 1630 | 96 | fctNameNode->name = OP_FCT_POSTFIX_MINUS_MINUS; | |
| 1631 |
2/2✓ Branch 71 → 72 taken 383 times.
✓ Branch 71 → 73 taken 273 times.
|
656 | else if (ctx->LBRACKET()) |
| 1632 | 383 | fctNameNode->name = OP_FCT_SUBSCRIPT; | |
| 1633 |
1/2✓ Branch 74 → 75 taken 273 times.
✗ Branch 74 → 76 not taken.
|
273 | else if (ctx->ASSIGN()) |
| 1634 | 273 | fctNameNode->name = OP_FCT_ASSIGN; | |
| 1635 | else | ||
| 1636 | − | assert_fail("Unsupported overloadable operator"); // GCOV_EXCL_LINE | |
| 1637 | |||
| 1638 | 3542 | fctNameNode->fqName = fctNameNode->name; | |
| 1639 | 3542 | fctNameNode->nameFragments.push_back(fctNameNode->name); | |
| 1640 | |||
| 1641 |
1/2✓ Branch 79 → 80 taken 3542 times.
✗ Branch 79 → 85 not taken.
|
7084 | return nullptr; |
| 1642 | } | ||
| 1643 | |||
| 1644 | 11222 | int32_t ASTBuilder::parseInt(TerminalNode *terminal, bool isNegative) { | |
| 1645 | 33666 | const NumericParserCallback<int32_t> cb = [isNegative](const std::string &substr, short base, bool isSigned) -> int32_t { | |
| 1646 | // Prepare limits | ||
| 1647 |
2/2✓ Branch 2 → 3 taken 11160 times.
✓ Branch 2 → 4 taken 62 times.
|
11222 | const int64_t upperLimit = isSigned ? INT32_MAX : UINT32_MAX; |
| 1648 |
2/2✓ Branch 5 → 6 taken 11160 times.
✓ Branch 5 → 7 taken 62 times.
|
11222 | const int64_t lowerLimit = isSigned ? INT32_MIN : 0; |
| 1649 | // Parse number, apply sign and check for limits | ||
| 1650 | 11222 | int64_t number = std::stoll(substr, nullptr, base); | |
| 1651 |
2/2✓ Branch 9 → 10 taken 206 times.
✓ Branch 9 → 11 taken 11015 times.
|
11221 | if (isNegative) |
| 1652 | 206 | number = -number; | |
| 1653 |
2/4✓ Branch 11 → 12 taken 11221 times.
✗ Branch 11 → 13 not taken.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 16 taken 11221 times.
|
11221 | if (number < lowerLimit || number > upperLimit) |
| 1654 | ✗ | throw std::out_of_range("Number out of range"); | |
| 1655 | 11221 | return static_cast<int32_t>(number); | |
| 1656 | 11222 | }; | |
| 1657 |
2/2✓ Branch 3 → 4 taken 11221 times.
✓ Branch 3 → 8 taken 1 time.
|
22443 | return parseNumeric(terminal, cb); |
| 1658 | 11222 | } | |
| 1659 | |||
| 1660 | 1106 | int16_t ASTBuilder::parseShort(TerminalNode *terminal, bool isNegative) { | |
| 1661 | 3318 | const NumericParserCallback<int16_t> cb = [isNegative](const std::string &substr, short base, bool isSigned) -> int16_t { | |
| 1662 | // Prepare limits | ||
| 1663 |
2/2✓ Branch 2 → 3 taken 772 times.
✓ Branch 2 → 4 taken 334 times.
|
1106 | const int64_t upperLimit = isSigned ? INT16_MAX : UINT16_MAX; |
| 1664 |
2/2✓ Branch 5 → 6 taken 772 times.
✓ Branch 5 → 7 taken 334 times.
|
1106 | const int64_t lowerLimit = isSigned ? INT16_MIN : 0; |
| 1665 | // Parse number, apply sign and check for limits | ||
| 1666 | 1106 | int64_t number = std::stoll(substr, nullptr, base); | |
| 1667 |
2/2✓ Branch 9 → 10 taken 86 times.
✓ Branch 9 → 11 taken 1020 times.
|
1106 | if (isNegative) |
| 1668 | 86 | number = -number; | |
| 1669 |
2/4✓ Branch 11 → 12 taken 1106 times.
✗ Branch 11 → 13 not taken.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 16 taken 1106 times.
|
1106 | if (number < lowerLimit || number > upperLimit) |
| 1670 | ✗ | throw std::out_of_range("Number out of range"); | |
| 1671 | 1106 | return static_cast<int16_t>(number); | |
| 1672 | 1106 | }; | |
| 1673 |
1/2✓ Branch 3 → 4 taken 1106 times.
✗ Branch 3 → 8 not taken.
|
2212 | return parseNumeric(terminal, cb); |
| 1674 | 1106 | } | |
| 1675 | |||
| 1676 | 13439 | int64_t ASTBuilder::parseLong(TerminalNode *terminal, bool isNegative) { | |
| 1677 | 40317 | const NumericParserCallback<int64_t> cb = [isNegative](const std::string &substr, short base, bool isSigned) -> int64_t { | |
| 1678 | // Parse the magnitude as unsigned so values like 2^63 (the absolute value of INT64_MIN) fit | ||
| 1679 | 13439 | const uint64_t magnitude = std::stoull(substr, nullptr, base); | |
| 1680 |
2/2✓ Branch 3 → 4 taken 1675 times.
✓ Branch 3 → 11 taken 11764 times.
|
13439 | if (isNegative) { |
| 1681 | 1675 | constexpr uint64_t maxNegMagnitude = static_cast<uint64_t>(INT64_MAX) + 1; // 2^63 | |
| 1682 |
1/2✗ Branch 4 → 5 not taken.
✓ Branch 4 → 8 taken 1675 times.
|
1675 | if (magnitude > maxNegMagnitude) |
| 1683 | ✗ | throw std::out_of_range("Number out of range"); | |
| 1684 |
2/2✓ Branch 8 → 9 taken 2 times.
✓ Branch 8 → 10 taken 1673 times.
|
1675 | if (magnitude == maxNegMagnitude) |
| 1685 | 2 | return INT64_MIN; | |
| 1686 | 1673 | return -static_cast<int64_t>(magnitude); | |
| 1687 | } | ||
| 1688 |
3/4✓ Branch 11 → 12 taken 10750 times.
✓ Branch 11 → 16 taken 1014 times.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 16 taken 10750 times.
|
11764 | if (isSigned && magnitude > static_cast<uint64_t>(INT64_MAX)) |
| 1689 | ✗ | throw std::out_of_range("Number out of range"); | |
| 1690 | 11764 | return static_cast<int64_t>(magnitude); | |
| 1691 | 13439 | }; | |
| 1692 |
1/2✓ Branch 3 → 4 taken 13439 times.
✗ Branch 3 → 8 not taken.
|
26878 | return parseNumeric(terminal, cb); |
| 1693 | 13439 | } | |
| 1694 | |||
| 1695 | 5215 | int8_t ASTBuilder::parseChar(TerminalNode *terminal) const { | |
| 1696 |
1/2✓ Branch 2 → 3 taken 5215 times.
✗ Branch 2 → 59 not taken.
|
5215 | const std::string input = terminal->toString(); |
| 1697 |
2/2✓ Branch 4 → 5 taken 3402 times.
✓ Branch 4 → 7 taken 1813 times.
|
5215 | if (input.length() == 3) // Normal char literals |
| 1698 | 3402 | return input[1]; | |
| 1699 | |||
| 1700 |
3/6✓ Branch 8 → 9 taken 1813 times.
✗ Branch 8 → 12 not taken.
✓ Branch 10 → 11 taken 1813 times.
✗ Branch 10 → 12 not taken.
✓ Branch 13 → 14 taken 1813 times.
✗ Branch 13 → 34 not taken.
|
1813 | if (input.length() == 4 && input[1] == '\\') { // Char literals with escape sequence |
| 1701 |
9/11✓ Branch 15 → 16 taken 24 times.
✗ Branch 15 → 17 not taken.
✓ Branch 15 → 18 taken 35 times.
✓ Branch 15 → 19 taken 206 times.
✓ Branch 15 → 20 taken 157 times.
✓ Branch 15 → 21 taken 154 times.
✓ Branch 15 → 22 taken 3 times.
✓ Branch 15 → 23 taken 3 times.
✗ Branch 15 → 24 not taken.
✓ Branch 15 → 25 taken 1230 times.
✓ Branch 15 → 26 taken 1 time.
|
1813 | switch (input[2]) { |
| 1702 | 24 | case '\'': | |
| 1703 | 24 | return '\''; | |
| 1704 | ✗ | case '"': | |
| 1705 | ✗ | return '\"'; | |
| 1706 | 35 | case '\\': | |
| 1707 | 35 | return '\\'; | |
| 1708 | 206 | case 'n': | |
| 1709 | 206 | return '\n'; | |
| 1710 | 157 | case 'r': | |
| 1711 | 157 | return '\r'; | |
| 1712 | 154 | case 't': | |
| 1713 | 154 | return '\t'; | |
| 1714 | 3 | case 'b': | |
| 1715 | 3 | return '\b'; | |
| 1716 | 3 | case 'f': | |
| 1717 | 3 | return '\f'; | |
| 1718 | ✗ | case 'v': | |
| 1719 | ✗ | return '\v'; | |
| 1720 | 1230 | case '0': | |
| 1721 | 1230 | return '\0'; | |
| 1722 | 1 | default: | |
| 1723 |
2/4✓ Branch 26 → 27 taken 1 time.
✗ Branch 26 → 50 not taken.
✓ Branch 27 → 28 taken 1 time.
✗ Branch 27 → 50 not taken.
|
1 | const CodeLoc codeLoc(terminal->getSymbol(), sourceFile); |
| 1724 |
2/4✓ Branch 29 → 30 taken 1 time.
✗ Branch 29 → 47 not taken.
✓ Branch 30 → 31 taken 1 time.
✗ Branch 30 → 44 not taken.
|
1 | throw ParserError(codeLoc, INVALID_CHAR_LITERAL, "Invalid escape sequence " + input); |
| 1725 | } | ||
| 1726 | } | ||
| 1727 | |||
| 1728 | ✗ | const CodeLoc codeLoc(terminal->getSymbol(), sourceFile); | |
| 1729 | ✗ | throw ParserError(codeLoc, INVALID_CHAR_LITERAL, "Invalid char literal " + input); | |
| 1730 | 5215 | } | |
| 1731 | |||
| 1732 | 10812 | std::string ASTBuilder::parseString(std::string input) { | |
| 1733 |
1/2✓ Branch 3 → 4 taken 10812 times.
✗ Branch 3 → 9 not taken.
|
10812 | input = input.substr(1, input.size() - 2); |
| 1734 | 10812 | replaceEscapeChars(input); | |
| 1735 | 10812 | return input; | |
| 1736 | } | ||
| 1737 | |||
| 1738 | 25767 | template <typename T> T ASTBuilder::parseNumeric(TerminalNode *terminal, const NumericParserCallback<T> &cb) { | |
| 1739 |
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 11222 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 13439 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 1106 times.
✗ Branch 2 → 87 not taken.
|
25767 | const std::string input = terminal->toString(); |
| 1740 | |||
| 1741 | // Set to signed if the input string does not end with 'u' | ||
| 1742 |
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 11160 times.
✓ Branch 4 → 9 taken 62 times.
✓ Branch 6 → 7 taken 11160 times.
✗ Branch 6 → 9 not taken.
✗ Branch 8 → 9 not taken.
✓ Branch 8 → 10 taken 11160 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 13439 times.
✗ Branch 4 → 9 not taken.
✓ Branch 6 → 7 taken 13439 times.
✗ Branch 6 → 9 not taken.
✓ Branch 8 → 9 taken 1014 times.
✓ Branch 8 → 10 taken 12425 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 1106 times.
✗ Branch 4 → 9 not taken.
✓ Branch 6 → 7 taken 772 times.
✓ Branch 6 → 9 taken 334 times.
✗ Branch 8 → 9 not taken.
✓ Branch 8 → 10 taken 772 times.
|
25767 | const bool isUnsigned = input.ends_with('u') || input.ends_with("us") || input.ends_with("ul"); |
| 1743 | |||
| 1744 | try { | ||
| 1745 |
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 1410 times.
✓ Branch 12 → 30 taken 9812 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 1767 times.
✓ Branch 12 → 30 taken 11672 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 733 times.
✓ Branch 12 → 30 taken 373 times.
|
25767 | if (input.length() >= 3) { |
| 1746 |
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 332 times.
✓ Branch 14 → 30 taken 1078 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 500 times.
✓ Branch 14 → 30 taken 1267 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 181 times.
✓ Branch 14 → 30 taken 552 times.
|
3910 | if (input[0] == '0') { |
| 1747 |
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 332 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 500 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 181 times.
✗ Branch 15 → 37 not taken.
|
1013 | const std::string subStr = input.substr(2); |
| 1748 |
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 13 times.
✓ Branch 17 → 24 taken 319 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 123 times.
✗ Branch 17 → 24 not taken.
✓ Branch 17 → 26 taken 377 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 180 times.
✓ Branch 17 → 26 taken 1 time.
|
1013 | switch (input[1]) { |
| 1749 | ✗ | case 'd': // fall-through | |
| 1750 | case 'D': | ||
| 1751 | ✗ | return cb(subStr, 10, !isUnsigned); | |
| 1752 | ✗ | case 'b': // fall-through | |
| 1753 | case 'B': | ||
| 1754 | ✗ | return cb(subStr, 2, !isUnsigned); | |
| 1755 | 136 | case 'h': // fall-through | |
| 1756 | case 'H': // fall-through | ||
| 1757 | case 'x': // fall-through | ||
| 1758 | case 'X': | ||
| 1759 |
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 13 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 123 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.
|
136 | return cb(subStr, 16, !isUnsigned); |
| 1760 | 499 | case 'o': // fall-through | |
| 1761 | case 'O': | ||
| 1762 |
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 319 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 180 times.
✗ Branch 24 → 35 not taken.
|
499 | return cb(subStr, 8, !isUnsigned); |
| 1763 | 378 | default: // default is decimal | |
| 1764 |
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 377 times.
✗ Branch 26 → 35 not taken.
short spice::compiler::ASTBuilder::parseNumeric<short>(antlr4::tree::TerminalNode*, std::function<short (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✓ Branch 26 → 27 taken 1 time.
✗ Branch 26 → 35 not taken.
|
378 | return cb(input, 10, !isUnsigned); |
| 1765 | } | ||
| 1766 | 1013 | } | |
| 1767 | } | ||
| 1768 |
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 10889 times.
✓ Branch 30 → 38 taken 1 time.
long spice::compiler::ASTBuilder::parseNumeric<long>(antlr4::tree::TerminalNode*, std::function<long (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✓ Branch 30 → 31 taken 12939 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 925 times.
✗ Branch 30 → 38 not taken.
|
24754 | return cb(input, 10, !isUnsigned); |
| 1769 |
1/9int spice::compiler::ASTBuilder::parseNumeric<int>(antlr4::tree::TerminalNode*, std::function<int (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✗ Branch 38 → 39 not taken.
✓ Branch 38 → 40 taken 1 time.
✗ Branch 38 → 51 not taken.
long spice::compiler::ASTBuilder::parseNumeric<long>(antlr4::tree::TerminalNode*, std::function<long (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✗ Branch 38 → 39 not taken.
✗ Branch 38 → 40 not taken.
✗ Branch 38 → 51 not taken.
short spice::compiler::ASTBuilder::parseNumeric<short>(antlr4::tree::TerminalNode*, std::function<short (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✗ Branch 38 → 39 not taken.
✗ Branch 38 → 40 not taken.
✗ Branch 38 → 51 not taken.
|
2 | } catch (std::out_of_range &) { |
| 1770 |
2/12int spice::compiler::ASTBuilder::parseNumeric<int>(antlr4::tree::TerminalNode*, std::function<int (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✓ Branch 41 → 42 taken 1 time.
✗ Branch 41 → 70 not taken.
✓ Branch 42 → 43 taken 1 time.
✗ Branch 42 → 70 not taken.
long spice::compiler::ASTBuilder::parseNumeric<long>(antlr4::tree::TerminalNode*, std::function<long (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✗ Branch 41 → 42 not taken.
✗ Branch 41 → 70 not taken.
✗ Branch 42 → 43 not taken.
✗ Branch 42 → 70 not taken.
short spice::compiler::ASTBuilder::parseNumeric<short>(antlr4::tree::TerminalNode*, std::function<short (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✗ Branch 41 → 42 not taken.
✗ Branch 41 → 70 not taken.
✗ Branch 42 → 43 not taken.
✗ Branch 42 → 70 not taken.
|
1 | const CodeLoc codeLoc(terminal->getSymbol(), sourceFile); |
| 1771 |
2/12int spice::compiler::ASTBuilder::parseNumeric<int>(antlr4::tree::TerminalNode*, std::function<int (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✓ Branch 46 → 47 taken 1 time.
✗ Branch 46 → 64 not taken.
✓ Branch 47 → 48 taken 1 time.
✗ Branch 47 → 61 not taken.
long spice::compiler::ASTBuilder::parseNumeric<long>(antlr4::tree::TerminalNode*, std::function<long (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✗ Branch 46 → 47 not taken.
✗ Branch 46 → 64 not taken.
✗ Branch 47 → 48 not taken.
✗ Branch 47 → 61 not taken.
short spice::compiler::ASTBuilder::parseNumeric<short>(antlr4::tree::TerminalNode*, std::function<short (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✗ Branch 46 → 47 not taken.
✗ Branch 46 → 64 not taken.
✗ Branch 47 → 48 not taken.
✗ Branch 47 → 61 not taken.
|
3 | throw ParserError(codeLoc, NUMBER_OUT_OF_RANGE, "The provided number is out of range"); |
| 1772 | ✗ | } catch (std::invalid_argument &) { | |
| 1773 | ✗ | const CodeLoc codeLoc(terminal->getSymbol(), sourceFile); | |
| 1774 | ✗ | throw ParserError(codeLoc, NUMBER_OUT_OF_RANGE, "You tried to parse '" + input + "' as an integer, but it was no integer"); | |
| 1775 | } | ||
| 1776 | 25767 | } | |
| 1777 | |||
| 1778 | 10812 | void ASTBuilder::replaceEscapeChars(std::string &input) { | |
| 1779 | 10812 | const std::unordered_map<char, char> escapeMap = { | |
| 1780 | {'a', '\a'}, {'b', '\b'}, {'f', '\f'}, {'n', '\n'}, {'r', '\r'}, {'t', '\t'}, | ||
| 1781 | {'v', '\v'}, {'\\', '\\'}, {'?', '\?'}, {'\'', '\''}, {'"', '\"'}, | ||
| 1782 |
1/2✓ Branch 4 → 5 taken 10812 times.
✗ Branch 4 → 40 not taken.
|
21624 | }; |
| 1783 | |||
| 1784 | 10812 | size_t writeIndex = 0; | |
| 1785 | 10812 | size_t readIndex = 0; | |
| 1786 | 10812 | const size_t len = input.length(); | |
| 1787 | |||
| 1788 |
2/2✓ Branch 36 → 8 taken 151632 times.
✓ Branch 36 → 37 taken 10812 times.
|
162444 | while (readIndex < len) { |
| 1789 | 151632 | const char c = input[readIndex]; | |
| 1790 |
3/4✓ Branch 9 → 10 taken 1320 times.
✓ Branch 9 → 33 taken 150312 times.
✓ Branch 10 → 11 taken 1320 times.
✗ Branch 10 → 33 not taken.
|
151632 | if (c == '\\' && readIndex + 1 < len) { |
| 1791 | 1320 | char next = input[readIndex + 1]; | |
| 1792 |
1/2✓ Branch 12 → 13 taken 1320 times.
✗ Branch 12 → 45 not taken.
|
1320 | auto it = escapeMap.find(next); |
| 1793 |
2/2✓ Branch 15 → 16 taken 1311 times.
✓ Branch 15 → 19 taken 9 times.
|
1320 | if (it != escapeMap.end()) { |
| 1794 | 1311 | input[writeIndex++] = it->second; | |
| 1795 | 1311 | readIndex += 2; | |
| 1796 | 1317 | continue; | |
| 1797 | } | ||
| 1798 | |||
| 1799 | // Handle octal escape sequences (up to 3 digits) | ||
| 1800 |
3/4✓ Branch 19 → 20 taken 9 times.
✗ Branch 19 → 31 not taken.
✓ Branch 20 → 21 taken 6 times.
✓ Branch 20 → 31 taken 3 times.
|
9 | if (next >= '0' && next <= '7') { |
| 1801 | 6 | int value = 0; | |
| 1802 | 6 | size_t octalDigits = 0; | |
| 1803 | |||
| 1804 | // Look ahead up to 3 digits | ||
| 1805 |
3/4✓ Branch 26 → 27 taken 18 times.
✓ Branch 26 → 28 taken 6 times.
✓ Branch 27 → 22 taken 18 times.
✗ Branch 27 → 28 not taken.
|
24 | for (size_t i = 1; i <= 3 && readIndex + i < len; ++i) { |
| 1806 | 18 | const char oc = input[readIndex + i]; | |
| 1807 |
2/4✓ Branch 23 → 24 taken 18 times.
✗ Branch 23 → 28 not taken.
✓ Branch 24 → 25 taken 18 times.
✗ Branch 24 → 28 not taken.
|
18 | if (oc >= '0' && oc <= '7') { |
| 1808 | 18 | value = value << 3 | (oc - '0'); // multiply by 8 and add digit | |
| 1809 | 18 | octalDigits++; | |
| 1810 | } else { | ||
| 1811 | break; | ||
| 1812 | } | ||
| 1813 | } | ||
| 1814 | |||
| 1815 |
1/2✓ Branch 28 → 29 taken 6 times.
✗ Branch 28 → 31 not taken.
|
6 | if (octalDigits > 0) { |
| 1816 | 6 | input[writeIndex++] = static_cast<char>(value); | |
| 1817 | 6 | readIndex += 1 + octalDigits; // backslash + octal digits | |
| 1818 | 6 | continue; | |
| 1819 | } | ||
| 1820 | } | ||
| 1821 | } | ||
| 1822 | |||
| 1823 | // Copy current character | ||
| 1824 | 150315 | input[writeIndex++] = c; | |
| 1825 | 150315 | readIndex++; | |
| 1826 | } | ||
| 1827 | |||
| 1828 |
1/2✓ Branch 37 → 38 taken 10812 times.
✗ Branch 37 → 46 not taken.
|
10812 | input.resize(writeIndex); |
| 1829 | 10812 | } | |
| 1830 | |||
| 1831 | 302816 | std::string ASTBuilder::getIdentifier(TerminalNode *terminal, bool isTypeIdentifier) const { | |
| 1832 | 302816 | const std::string identifier = terminal->getText(); | |
| 1833 | |||
| 1834 | // Check if the list of reserved keywords contains the given identifier | ||
| 1835 |
3/4✓ Branch 3 → 4 taken 302816 times.
✗ Branch 3 → 52 not taken.
✓ Branch 4 → 5 taken 1 time.
✓ Branch 4 → 14 taken 302815 times.
|
302816 | if (std::ranges::find(RESERVED_KEYWORDS, identifier) != std::end(RESERVED_KEYWORDS)) { |
| 1836 |
2/4✓ Branch 5 → 6 taken 1 time.
✗ Branch 5 → 41 not taken.
✓ Branch 6 → 7 taken 1 time.
✗ Branch 6 → 41 not taken.
|
1 | const CodeLoc codeLoc(terminal->getSymbol(), sourceFile); |
| 1837 |
3/6✓ Branch 8 → 9 taken 1 time.
✗ Branch 8 → 37 not taken.
✓ Branch 9 → 10 taken 1 time.
✗ Branch 9 → 35 not taken.
✓ Branch 10 → 11 taken 1 time.
✗ Branch 10 → 32 not taken.
|
1 | throw ParserError(codeLoc, RESERVED_KEYWORD, "'" + identifier + "' is a reserved keyword. Please use another name instead"); |
| 1838 | } | ||
| 1839 | |||
| 1840 | // Check if the identifier is a type identifier and is reserved | ||
| 1841 |
6/6✓ Branch 14 → 15 taken 27006 times.
✓ Branch 14 → 19 taken 275809 times.
✓ Branch 15 → 16 taken 6988 times.
✓ Branch 15 → 19 taken 20018 times.
✓ Branch 20 → 21 taken 1 time.
✓ Branch 20 → 30 taken 302814 times.
|
309803 | if (isTypeIdentifier && !sourceFile->isStdFile && |
| 1842 |
3/4✓ Branch 16 → 17 taken 6988 times.
✗ Branch 16 → 52 not taken.
✓ Branch 17 → 18 taken 1 time.
✓ Branch 17 → 19 taken 6987 times.
|
6988 | std::ranges::find(RESERVED_TYPE_NAMES, identifier) != std::end(RESERVED_TYPE_NAMES)) { |
| 1843 |
2/4✓ Branch 21 → 22 taken 1 time.
✗ Branch 21 → 51 not taken.
✓ Branch 22 → 23 taken 1 time.
✗ Branch 22 → 51 not taken.
|
1 | const CodeLoc codeLoc(terminal->getSymbol(), sourceFile); |
| 1844 |
3/6✓ Branch 24 → 25 taken 1 time.
✗ Branch 24 → 47 not taken.
✓ Branch 25 → 26 taken 1 time.
✗ Branch 25 → 45 not taken.
✓ Branch 26 → 27 taken 1 time.
✗ Branch 26 → 42 not taken.
|
1 | throw ParserError(codeLoc, RESERVED_TYPENAME, "'" + identifier + "' is a reserved type name. Please use another one instead"); |
| 1845 | } | ||
| 1846 | |||
| 1847 | 302814 | return identifier; | |
| 1848 | 2 | } | |
| 1849 | |||
| 1850 | } // namespace spice::compiler | ||
| 1851 |