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 | 2519 | ASTBuilder::ASTBuilder(GlobalResourceManager &resourceManager, SourceFile *sourceFile, antlr4::ANTLRInputStream *inputStream) | |
| 17 |
1/2✓ Branch 4 → 5 taken 2519 times.
✗ Branch 4 → 6 not taken.
|
2519 | : CompilerPass(resourceManager, sourceFile), inputStream(inputStream) {} |
| 18 | |||
| 19 | 2517 | std::any ASTBuilder::visitEntry(SpiceParser::EntryContext *ctx) { | |
| 20 | 2517 | const auto entryNode = createNode<EntryNode>(ctx); | |
| 21 | |||
| 22 | // Visit children | ||
| 23 |
2/2✓ Branch 135 → 5 taken 50419 times.
✓ Branch 135 → 136 taken 2511 times.
|
55447 | for (ParserRuleContext::ParseTree *child : ctx->children) { |
| 24 |
3/4✓ Branch 7 → 8 taken 50419 times.
✗ Branch 7 → 9 not taken.
✓ Branch 10 → 11 taken 569 times.
✓ Branch 10 → 16 taken 49850 times.
|
50419 | if (auto *mainFctDefCtx = dynamic_cast<SpiceParser::MainFunctionDefContext *>(child)) |
| 25 |
4/6✓ Branch 11 → 12 taken 565 times.
✓ Branch 11 → 148 taken 4 times.
✓ Branch 12 → 13 taken 565 times.
✗ Branch 12 → 146 not taken.
✓ Branch 13 → 14 taken 565 times.
✗ Branch 13 → 146 not taken.
|
569 | entryNode->topLevelDefs.push_back(std::any_cast<MainFctDefNode *>(visit(mainFctDefCtx))); |
| 26 |
3/4✓ Branch 16 → 17 taken 49850 times.
✗ Branch 16 → 18 not taken.
✓ Branch 19 → 20 taken 20843 times.
✓ Branch 19 → 25 taken 29007 times.
|
49850 | else if (auto *fctDefCtx = dynamic_cast<SpiceParser::FunctionDefContext *>(child)) |
| 27 |
3/6✓ Branch 20 → 21 taken 20843 times.
✗ Branch 20 → 152 not taken.
✓ Branch 21 → 22 taken 20843 times.
✗ Branch 21 → 150 not taken.
✓ Branch 22 → 23 taken 20843 times.
✗ Branch 22 → 150 not taken.
|
20843 | entryNode->topLevelDefs.push_back(std::any_cast<FctDefNode *>(visit(fctDefCtx))); |
| 28 |
3/4✓ Branch 25 → 26 taken 29007 times.
✗ Branch 25 → 27 not taken.
✓ Branch 28 → 29 taken 11521 times.
✓ Branch 28 → 34 taken 17486 times.
|
29007 | else if (auto *procDefCtx = dynamic_cast<SpiceParser::ProcedureDefContext *>(child)) |
| 29 |
3/6✓ Branch 29 → 30 taken 11521 times.
✗ Branch 29 → 156 not taken.
✓ Branch 30 → 31 taken 11521 times.
✗ Branch 30 → 154 not taken.
✓ Branch 31 → 32 taken 11521 times.
✗ Branch 31 → 154 not taken.
|
11521 | entryNode->topLevelDefs.push_back(std::any_cast<ProcDefNode *>(visit(procDefCtx))); |
| 30 |
3/4✓ Branch 34 → 35 taken 17486 times.
✗ Branch 34 → 36 not taken.
✓ Branch 37 → 38 taken 3082 times.
✓ Branch 37 → 43 taken 14404 times.
|
17486 | else if (auto *structDefCtx = dynamic_cast<SpiceParser::StructDefContext *>(child)) |
| 31 |
4/6✓ Branch 38 → 39 taken 3081 times.
✓ Branch 38 → 160 taken 1 time.
✓ Branch 39 → 40 taken 3081 times.
✗ Branch 39 → 158 not taken.
✓ Branch 40 → 41 taken 3081 times.
✗ Branch 40 → 158 not taken.
|
3082 | entryNode->topLevelDefs.push_back(std::any_cast<StructDefNode *>(visit(structDefCtx))); |
| 32 |
3/4✓ Branch 43 → 44 taken 14404 times.
✗ Branch 43 → 45 not taken.
✓ Branch 46 → 47 taken 374 times.
✓ Branch 46 → 52 taken 14030 times.
|
14404 | else if (auto *interfaceDefCtx = dynamic_cast<SpiceParser::InterfaceDefContext *>(child)) |
| 33 |
3/6✓ Branch 47 → 48 taken 374 times.
✗ Branch 47 → 164 not taken.
✓ Branch 48 → 49 taken 374 times.
✗ Branch 48 → 162 not taken.
✓ Branch 49 → 50 taken 374 times.
✗ Branch 49 → 162 not taken.
|
374 | entryNode->topLevelDefs.push_back(std::any_cast<InterfaceDefNode *>(visit(interfaceDefCtx))); |
| 34 |
3/4✓ Branch 52 → 53 taken 14030 times.
✗ Branch 52 → 54 not taken.
✓ Branch 55 → 56 taken 373 times.
✓ Branch 55 → 61 taken 13657 times.
|
14030 | else if (auto *enumDefCtx = dynamic_cast<SpiceParser::EnumDefContext *>(child)) |
| 35 |
3/6✓ Branch 56 → 57 taken 373 times.
✗ Branch 56 → 168 not taken.
✓ Branch 57 → 58 taken 373 times.
✗ Branch 57 → 166 not taken.
✓ Branch 58 → 59 taken 373 times.
✗ Branch 58 → 166 not taken.
|
373 | entryNode->topLevelDefs.push_back(std::any_cast<EnumDefNode *>(visit(enumDefCtx))); |
| 36 |
3/4✓ Branch 61 → 62 taken 13657 times.
✗ Branch 61 → 63 not taken.
✓ Branch 64 → 65 taken 2044 times.
✓ Branch 64 → 70 taken 11613 times.
|
13657 | else if (auto *genericTypeDefCtx = dynamic_cast<SpiceParser::GenericTypeDefContext *>(child)) |
| 37 |
3/6✓ Branch 65 → 66 taken 2044 times.
✗ Branch 65 → 172 not taken.
✓ Branch 66 → 67 taken 2044 times.
✗ Branch 66 → 170 not taken.
✓ Branch 67 → 68 taken 2044 times.
✗ Branch 67 → 170 not taken.
|
2044 | entryNode->topLevelDefs.push_back(std::any_cast<GenericTypeDefNode *>(visit(genericTypeDefCtx))); |
| 38 |
3/4✓ Branch 70 → 71 taken 11613 times.
✗ Branch 70 → 72 not taken.
✓ Branch 73 → 74 taken 345 times.
✓ Branch 73 → 79 taken 11268 times.
|
11613 | else if (auto *aliasDefCtx = dynamic_cast<SpiceParser::AliasDefContext *>(child)) |
| 39 |
3/6✓ Branch 74 → 75 taken 345 times.
✗ Branch 74 → 176 not taken.
✓ Branch 75 → 76 taken 345 times.
✗ Branch 75 → 174 not taken.
✓ Branch 76 → 77 taken 345 times.
✗ Branch 76 → 174 not taken.
|
345 | entryNode->topLevelDefs.push_back(std::any_cast<AliasDefNode *>(visit(aliasDefCtx))); |
| 40 |
3/4✓ Branch 79 → 80 taken 11268 times.
✗ Branch 79 → 81 not taken.
✓ Branch 82 → 83 taken 2420 times.
✓ Branch 82 → 88 taken 8848 times.
|
11268 | else if (auto *globalVarDefCtx = dynamic_cast<SpiceParser::GlobalVarDefContext *>(child)) |
| 41 |
3/6✓ Branch 83 → 84 taken 2420 times.
✗ Branch 83 → 180 not taken.
✓ Branch 84 → 85 taken 2420 times.
✗ Branch 84 → 178 not taken.
✓ Branch 85 → 86 taken 2420 times.
✗ Branch 85 → 178 not taken.
|
2420 | entryNode->topLevelDefs.push_back(std::any_cast<GlobalVarDefNode *>(visit(globalVarDefCtx))); |
| 42 |
3/4✓ Branch 88 → 89 taken 8848 times.
✗ Branch 88 → 90 not taken.
✓ Branch 91 → 92 taken 2555 times.
✓ Branch 91 → 97 taken 6293 times.
|
8848 | else if (auto *importDefCtx = dynamic_cast<SpiceParser::ImportDefContext *>(child)) |
| 43 |
3/6✓ Branch 92 → 93 taken 2555 times.
✗ Branch 92 → 184 not taken.
✓ Branch 93 → 94 taken 2555 times.
✗ Branch 93 → 182 not taken.
✓ Branch 94 → 95 taken 2555 times.
✗ Branch 94 → 182 not taken.
|
2555 | entryNode->importDefs.push_back(std::any_cast<ImportDefNode *>(visit(importDefCtx))); |
| 44 |
3/4✓ Branch 97 → 98 taken 6293 times.
✗ Branch 97 → 99 not taken.
✓ Branch 100 → 101 taken 3054 times.
✓ Branch 100 → 106 taken 3239 times.
|
6293 | else if (auto *extDeclCtx = dynamic_cast<SpiceParser::ExtDeclContext *>(child)) |
| 45 |
3/6✓ Branch 101 → 102 taken 3054 times.
✗ Branch 101 → 188 not taken.
✓ Branch 102 → 103 taken 3054 times.
✗ Branch 102 → 186 not taken.
✓ Branch 103 → 104 taken 3054 times.
✗ Branch 103 → 186 not taken.
|
3054 | entryNode->topLevelDefs.push_back(std::any_cast<ExtDeclNode *>(visit(extDeclCtx))); |
| 46 |
3/4✓ Branch 106 → 107 taken 3239 times.
✗ Branch 106 → 108 not taken.
✓ Branch 109 → 110 taken 728 times.
✓ Branch 109 → 115 taken 2511 times.
|
3239 | else if (auto *modAttrCtx = dynamic_cast<SpiceParser::ModAttrContext *>(child)) |
| 47 |
4/6✓ Branch 110 → 111 taken 727 times.
✓ Branch 110 → 192 taken 1 time.
✓ Branch 111 → 112 taken 727 times.
✗ Branch 111 → 190 not taken.
✓ Branch 112 → 113 taken 727 times.
✗ Branch 112 → 190 not taken.
|
728 | entryNode->modAttrs.push_back(std::any_cast<ModAttrNode *>(visit(modAttrCtx))); |
| 48 |
1/2✓ Branch 115 → 116 taken 2511 times.
✗ Branch 115 → 117 not taken.
|
2511 | else if (const auto *eofCtx = dynamic_cast<TerminalNode *>(child); |
| 49 |
5/10✓ Branch 118 → 119 taken 2511 times.
✗ Branch 118 → 122 not taken.
✓ Branch 119 → 120 taken 2511 times.
✗ Branch 119 → 194 not taken.
✓ Branch 120 → 121 taken 2511 times.
✗ Branch 120 → 194 not taken.
✗ Branch 121 → 122 not taken.
✓ Branch 121 → 123 taken 2511 times.
✗ Branch 124 → 125 not taken.
✓ Branch 124 → 126 taken 2511 times.
|
2511 | !eofCtx || eofCtx->getSymbol()->getType() != SpiceParser::EOF) |
| 50 | − | assert_fail("Unknown top level definition type"); // GCOV_EXCL_LINE | |
| 51 | } | ||
| 52 | |||
| 53 |
1/2✓ Branch 142 → 143 taken 2511 times.
✗ Branch 142 → 195 not taken.
|
5022 | return concludeNode(entryNode); |
| 54 | } | ||
| 55 | |||
| 56 | 569 | std::any ASTBuilder::visitMainFunctionDef(SpiceParser::MainFunctionDefContext *ctx) { | |
| 57 | 569 | const auto mainFctDefNode = createNode<MainFctDefNode>(ctx); | |
| 58 | |||
| 59 | // Visit children | ||
| 60 |
2/2✓ Branch 4 → 5 taken 1 time.
✓ Branch 4 → 10 taken 568 times.
|
569 | if (ctx->topLevelDefAttr()) |
| 61 |
3/6✓ Branch 5 → 6 taken 1 time.
✗ Branch 5 → 33 not taken.
✓ Branch 6 → 7 taken 1 time.
✗ Branch 6 → 33 not taken.
✓ Branch 7 → 8 taken 1 time.
✗ Branch 7 → 31 not taken.
|
1 | mainFctDefNode->attrs = std::any_cast<TopLevelDefAttrNode *>(visit(ctx->topLevelDefAttr())); |
| 62 |
2/2✓ Branch 11 → 12 taken 7 times.
✓ Branch 11 → 17 taken 562 times.
|
569 | if (ctx->paramLst()) { |
| 63 | 7 | mainFctDefNode->takesArgs = true; | |
| 64 |
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())); |
| 65 | } | ||
| 66 |
5/8✓ Branch 17 → 18 taken 569 times.
✗ Branch 17 → 39 not taken.
✓ Branch 18 → 19 taken 565 times.
✓ Branch 18 → 39 taken 4 times.
✓ Branch 19 → 20 taken 565 times.
✗ Branch 19 → 37 not taken.
✓ Branch 21 → 22 taken 565 times.
✗ Branch 21 → 40 not taken.
|
569 | mainFctDefNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 67 | |||
| 68 |
1/2✓ Branch 27 → 28 taken 565 times.
✗ Branch 27 → 40 not taken.
|
1130 | return concludeNode(mainFctDefNode); |
| 69 | } | ||
| 70 | |||
| 71 | 20843 | std::any ASTBuilder::visitFunctionDef(SpiceParser::FunctionDefContext *ctx) { | |
| 72 | 20843 | const auto fctDefNode = createNode<FctDefNode>(ctx); | |
| 73 | |||
| 74 | // Visit children | ||
| 75 |
2/2✓ Branch 4 → 5 taken 718 times.
✓ Branch 4 → 24 taken 20125 times.
|
20843 | if (ctx->topLevelDefAttr()) { |
| 76 |
3/6✓ Branch 5 → 6 taken 718 times.
✗ Branch 5 → 70 not taken.
✓ Branch 6 → 7 taken 718 times.
✗ Branch 6 → 70 not taken.
✓ Branch 7 → 8 taken 718 times.
✗ Branch 7 → 68 not taken.
|
718 | fctDefNode->attrs = std::any_cast<TopLevelDefAttrNode *>(visit(ctx->topLevelDefAttr())); |
| 77 | // Tell the attributes that they are function attributes | ||
| 78 |
2/2✓ Branch 22 → 11 taken 820 times.
✓ Branch 22 → 23 taken 718 times.
|
2256 | for (AttrNode *attr : fctDefNode->attrs->attrLst->attributes) |
| 79 | 820 | attr->target = AttrNode::TARGET_FCT_PROC; | |
| 80 | } | ||
| 81 |
2/2✓ Branch 25 → 26 taken 20183 times.
✓ Branch 25 → 31 taken 660 times.
|
20843 | if (ctx->qualifierLst()) |
| 82 |
3/6✓ Branch 26 → 27 taken 20183 times.
✗ Branch 26 → 73 not taken.
✓ Branch 27 → 28 taken 20183 times.
✗ Branch 27 → 73 not taken.
✓ Branch 28 → 29 taken 20183 times.
✗ Branch 28 → 71 not taken.
|
20183 | fctDefNode->qualifierLst = std::any_cast<QualifierLstNode *>(visit(ctx->qualifierLst())); |
| 83 |
3/6✓ Branch 31 → 32 taken 20843 times.
✗ Branch 31 → 76 not taken.
✓ Branch 32 → 33 taken 20843 times.
✗ Branch 32 → 76 not taken.
✓ Branch 33 → 34 taken 20843 times.
✗ Branch 33 → 74 not taken.
|
20843 | fctDefNode->returnType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 84 | 20843 | fctDefNode->returnType->isReturnType = true; | |
| 85 |
3/6✓ Branch 35 → 36 taken 20843 times.
✗ Branch 35 → 79 not taken.
✓ Branch 36 → 37 taken 20843 times.
✗ Branch 36 → 79 not taken.
✓ Branch 37 → 38 taken 20843 times.
✗ Branch 37 → 77 not taken.
|
20843 | fctDefNode->name = std::any_cast<FctNameNode *>(visit(ctx->fctName())); |
| 86 | 20843 | fctDefNode->isMethod = fctDefNode->name->nameFragments.size() > 1; | |
| 87 |
2/2✓ Branch 41 → 42 taken 2196 times.
✓ Branch 41 → 47 taken 18647 times.
|
20843 | if (ctx->typeLst()) { |
| 88 | 2196 | fctDefNode->hasTemplateTypes = true; | |
| 89 |
3/6✓ Branch 42 → 43 taken 2196 times.
✗ Branch 42 → 82 not taken.
✓ Branch 43 → 44 taken 2196 times.
✗ Branch 43 → 82 not taken.
✓ Branch 44 → 45 taken 2196 times.
✗ Branch 44 → 80 not taken.
|
2196 | fctDefNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst())); |
| 90 | } | ||
| 91 |
2/2✓ Branch 48 → 49 taken 15513 times.
✓ Branch 48 → 54 taken 5330 times.
|
20843 | if (ctx->paramLst()) { |
| 92 | 15513 | fctDefNode->hasParams = true; | |
| 93 |
3/6✓ Branch 49 → 50 taken 15513 times.
✗ Branch 49 → 85 not taken.
✓ Branch 50 → 51 taken 15513 times.
✗ Branch 50 → 85 not taken.
✓ Branch 51 → 52 taken 15513 times.
✗ Branch 51 → 83 not taken.
|
15513 | fctDefNode->paramLst = std::any_cast<ParamLstNode *>(visit(ctx->paramLst())); |
| 94 | } | ||
| 95 |
4/8✓ Branch 54 → 55 taken 20843 times.
✗ Branch 54 → 88 not taken.
✓ Branch 55 → 56 taken 20843 times.
✗ Branch 55 → 88 not taken.
✓ Branch 56 → 57 taken 20843 times.
✗ Branch 56 → 86 not taken.
✓ Branch 58 → 59 taken 20843 times.
✗ Branch 58 → 89 not taken.
|
20843 | fctDefNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 96 | |||
| 97 |
1/2✓ Branch 64 → 65 taken 20843 times.
✗ Branch 64 → 89 not taken.
|
41686 | return concludeNode(fctDefNode); |
| 98 | } | ||
| 99 | |||
| 100 | 11521 | std::any ASTBuilder::visitProcedureDef(SpiceParser::ProcedureDefContext *ctx) { | |
| 101 | 11521 | const auto procDefNode = createNode<ProcDefNode>(ctx); | |
| 102 | |||
| 103 | // Visit children | ||
| 104 |
2/2✓ Branch 4 → 5 taken 1 time.
✓ Branch 4 → 24 taken 11520 times.
|
11521 | if (ctx->topLevelDefAttr()) { |
| 105 |
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())); |
| 106 | // Tell the attributes that they are function attributes | ||
| 107 |
2/2✓ Branch 22 → 11 taken 1 time.
✓ Branch 22 → 23 taken 1 time.
|
3 | for (AttrNode *attr : procDefNode->attrs->attrLst->attributes) |
| 108 | 1 | attr->target = AttrNode::TARGET_FCT_PROC; | |
| 109 | } | ||
| 110 |
2/2✓ Branch 25 → 26 taken 10394 times.
✓ Branch 25 → 31 taken 1127 times.
|
11521 | if (ctx->qualifierLst()) |
| 111 |
3/6✓ Branch 26 → 27 taken 10394 times.
✗ Branch 26 → 69 not taken.
✓ Branch 27 → 28 taken 10394 times.
✗ Branch 27 → 69 not taken.
✓ Branch 28 → 29 taken 10394 times.
✗ Branch 28 → 67 not taken.
|
10394 | procDefNode->qualifierLst = std::any_cast<QualifierLstNode *>(visit(ctx->qualifierLst())); |
| 112 |
3/6✓ Branch 31 → 32 taken 11521 times.
✗ Branch 31 → 72 not taken.
✓ Branch 32 → 33 taken 11521 times.
✗ Branch 32 → 72 not taken.
✓ Branch 33 → 34 taken 11521 times.
✗ Branch 33 → 70 not taken.
|
11521 | procDefNode->name = std::any_cast<FctNameNode *>(visit(ctx->fctName())); |
| 113 | 11521 | procDefNode->isMethod = procDefNode->name->nameFragments.size() > 1; | |
| 114 |
2/2✓ Branch 37 → 38 taken 2387 times.
✓ Branch 37 → 43 taken 9134 times.
|
11521 | if (ctx->typeLst()) { |
| 115 | 2387 | procDefNode->hasTemplateTypes = true; | |
| 116 |
3/6✓ Branch 38 → 39 taken 2387 times.
✗ Branch 38 → 75 not taken.
✓ Branch 39 → 40 taken 2387 times.
✗ Branch 39 → 75 not taken.
✓ Branch 40 → 41 taken 2387 times.
✗ Branch 40 → 73 not taken.
|
2387 | procDefNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst())); |
| 117 | } | ||
| 118 |
2/2✓ Branch 44 → 45 taken 8824 times.
✓ Branch 44 → 50 taken 2697 times.
|
11521 | if (ctx->paramLst()) { |
| 119 | 8824 | procDefNode->hasParams = true; | |
| 120 |
3/6✓ Branch 45 → 46 taken 8824 times.
✗ Branch 45 → 78 not taken.
✓ Branch 46 → 47 taken 8824 times.
✗ Branch 46 → 78 not taken.
✓ Branch 47 → 48 taken 8824 times.
✗ Branch 47 → 76 not taken.
|
8824 | procDefNode->paramLst = std::any_cast<ParamLstNode *>(visit(ctx->paramLst())); |
| 121 | } | ||
| 122 |
4/8✓ Branch 50 → 51 taken 11521 times.
✗ Branch 50 → 81 not taken.
✓ Branch 51 → 52 taken 11521 times.
✗ Branch 51 → 81 not taken.
✓ Branch 52 → 53 taken 11521 times.
✗ Branch 52 → 79 not taken.
✓ Branch 54 → 55 taken 11521 times.
✗ Branch 54 → 82 not taken.
|
11521 | procDefNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 123 | |||
| 124 |
1/2✓ Branch 60 → 61 taken 11521 times.
✗ Branch 60 → 82 not taken.
|
23042 | return concludeNode(procDefNode); |
| 125 | } | ||
| 126 | |||
| 127 | 32364 | std::any ASTBuilder::visitFctName(SpiceParser::FctNameContext *ctx) { | |
| 128 |
1/2✓ Branch 2 → 3 taken 32364 times.
✗ Branch 2 → 54 not taken.
|
32364 | const auto fctNameNode = createNode<FctNameNode>(ctx); |
| 129 | |||
| 130 | // Extract function name | ||
| 131 |
1/2✓ Branch 3 → 4 taken 32364 times.
✗ Branch 3 → 54 not taken.
|
32364 | std::stringstream fqName; |
| 132 |
3/4✓ Branch 4 → 5 taken 32364 times.
✗ Branch 4 → 52 not taken.
✓ Branch 5 → 6 taken 20069 times.
✓ Branch 5 → 14 taken 12295 times.
|
32364 | if (ctx->TYPE_IDENTIFIER()) { |
| 133 |
2/4✓ Branch 6 → 7 taken 20069 times.
✗ Branch 6 → 45 not taken.
✓ Branch 7 → 8 taken 20069 times.
✗ Branch 7 → 45 not taken.
|
20069 | const std::string typeIdentifier = getIdentifier(ctx->TYPE_IDENTIFIER(), true); |
| 134 |
1/2✓ Branch 8 → 9 taken 20069 times.
✗ Branch 8 → 43 not taken.
|
20069 | fctNameNode->structName = typeIdentifier; |
| 135 |
2/4✓ Branch 9 → 10 taken 20069 times.
✗ Branch 9 → 43 not taken.
✓ Branch 10 → 11 taken 20069 times.
✗ Branch 10 → 43 not taken.
|
20069 | fqName << typeIdentifier << MEMBER_ACCESS_TOKEN; |
| 136 |
1/2✓ Branch 11 → 12 taken 20069 times.
✗ Branch 11 → 43 not taken.
|
20069 | fctNameNode->nameFragments.push_back(typeIdentifier); |
| 137 | 20069 | } | |
| 138 |
3/4✓ Branch 14 → 15 taken 32364 times.
✗ Branch 14 → 52 not taken.
✓ Branch 15 → 16 taken 28656 times.
✓ Branch 15 → 23 taken 3708 times.
|
32364 | if (ctx->IDENTIFIER()) { |
| 139 |
2/4✓ Branch 16 → 17 taken 28656 times.
✗ Branch 16 → 48 not taken.
✓ Branch 17 → 18 taken 28656 times.
✗ Branch 17 → 48 not taken.
|
28656 | const std::string fctIdentifier = getIdentifier(ctx->IDENTIFIER(), false); |
| 140 |
1/2✓ Branch 18 → 19 taken 28656 times.
✗ Branch 18 → 46 not taken.
|
28656 | fctNameNode->name = fctIdentifier; |
| 141 |
1/2✓ Branch 19 → 20 taken 28656 times.
✗ Branch 19 → 46 not taken.
|
28656 | fqName << fctIdentifier; |
| 142 |
1/2✓ Branch 20 → 21 taken 28656 times.
✗ Branch 20 → 46 not taken.
|
28656 | fctNameNode->nameFragments.push_back(fctIdentifier); |
| 143 | 28656 | } | |
| 144 |
1/2✓ Branch 23 → 24 taken 32364 times.
✗ Branch 23 → 49 not taken.
|
32364 | fctNameNode->fqName = fqName.str(); |
| 145 | |||
| 146 | // Visit children | ||
| 147 |
3/4✓ Branch 26 → 27 taken 32364 times.
✗ Branch 26 → 52 not taken.
✓ Branch 27 → 28 taken 3708 times.
✓ Branch 27 → 32 taken 28656 times.
|
32364 | if (ctx->overloadableOp()) |
| 148 |
2/4✓ Branch 28 → 29 taken 3708 times.
✗ Branch 28 → 50 not taken.
✓ Branch 29 → 30 taken 3708 times.
✗ Branch 29 → 50 not taken.
|
3708 | visit(ctx->overloadableOp()); |
| 149 | |||
| 150 |
1/2✓ Branch 38 → 39 taken 32364 times.
✗ Branch 38 → 51 not taken.
|
64728 | return concludeNode(fctNameNode); |
| 151 | 32364 | } | |
| 152 | |||
| 153 | 3082 | std::any ASTBuilder::visitStructDef(SpiceParser::StructDefContext *ctx) { | |
| 154 | 3082 | const auto structDefNode = createNode<StructDefNode>(ctx); | |
| 155 | |||
| 156 | // Enrich | ||
| 157 |
3/4✓ Branch 3 → 4 taken 3082 times.
✗ Branch 3 → 103 not taken.
✓ Branch 4 → 5 taken 3081 times.
✓ Branch 4 → 103 taken 1 time.
|
3082 | structDefNode->structName = getIdentifier(ctx->TYPE_IDENTIFIER(), true); |
| 158 | 3081 | structDefNode->typeId = resourceManager.getNextCustomTypeId(); | |
| 159 | |||
| 160 | // Visit children | ||
| 161 |
2/2✓ Branch 9 → 10 taken 110 times.
✓ Branch 9 → 49 taken 2971 times.
|
3081 | if (ctx->topLevelDefAttr()) { |
| 162 |
3/6✓ Branch 10 → 11 taken 110 times.
✗ Branch 10 → 106 not taken.
✓ Branch 11 → 12 taken 110 times.
✗ Branch 11 → 106 not taken.
✓ Branch 12 → 13 taken 110 times.
✗ Branch 12 → 104 not taken.
|
110 | structDefNode->attrs = std::any_cast<TopLevelDefAttrNode *>(visit(ctx->topLevelDefAttr())); |
| 163 | |||
| 164 | // Tell the attributes that they are struct attributes | ||
| 165 |
2/2✓ Branch 27 → 16 taken 110 times.
✓ Branch 27 → 28 taken 110 times.
|
330 | for (AttrNode *attr : structDefNode->attrs->attrLst->attributes) |
| 166 | 110 | attr->target = AttrNode::TARGET_STRUCT; | |
| 167 | |||
| 168 | // Check if a custom type id was set | ||
| 169 |
7/18✓ Branch 28 → 29 taken 110 times.
✗ Branch 28 → 35 not taken.
✓ Branch 31 → 32 taken 110 times.
✗ Branch 31 → 107 not taken.
✓ Branch 32 → 33 taken 110 times.
✗ Branch 32 → 107 not taken.
✗ Branch 33 → 34 not taken.
✓ Branch 33 → 35 taken 110 times.
✓ Branch 36 → 37 taken 110 times.
✗ Branch 36 → 38 not taken.
✓ Branch 38 → 39 taken 110 times.
✗ Branch 38 → 41 not taken.
✗ Branch 41 → 42 not taken.
✓ Branch 41 → 49 taken 110 times.
✗ Branch 107 → 108 not taken.
✗ Branch 107 → 109 not taken.
✗ Branch 111 → 112 not taken.
✗ Branch 111 → 114 not taken.
|
330 | if (structDefNode->attrs && structDefNode->attrs->attrLst->hasAttr(ATTR_CORE_COMPILER_FIXED_TYPE_ID)) |
| 170 | ✗ | structDefNode->typeId = structDefNode->attrs->attrLst->getAttrValueByName(ATTR_CORE_COMPILER_FIXED_TYPE_ID)->intValue; | |
| 171 | } | ||
| 172 |
2/2✓ Branch 50 → 51 taken 2808 times.
✓ Branch 50 → 56 taken 273 times.
|
3081 | if (ctx->qualifierLst()) |
| 173 |
3/6✓ Branch 51 → 52 taken 2808 times.
✗ Branch 51 → 124 not taken.
✓ Branch 52 → 53 taken 2808 times.
✗ Branch 52 → 124 not taken.
✓ Branch 53 → 54 taken 2808 times.
✗ Branch 53 → 122 not taken.
|
2808 | structDefNode->qualifierLst = std::any_cast<QualifierLstNode *>(visit(ctx->qualifierLst())); |
| 174 |
2/2✓ Branch 57 → 58 taken 679 times.
✓ Branch 57 → 63 taken 2402 times.
|
3081 | if (ctx->LESS()) { |
| 175 | 679 | structDefNode->hasTemplateTypes = true; | |
| 176 |
3/6✓ Branch 58 → 59 taken 679 times.
✗ Branch 58 → 127 not taken.
✓ Branch 59 → 60 taken 679 times.
✗ Branch 59 → 127 not taken.
✓ Branch 60 → 61 taken 679 times.
✗ Branch 60 → 125 not taken.
|
679 | structDefNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst(0))); |
| 177 | } | ||
| 178 |
2/2✓ Branch 64 → 65 taken 391 times.
✓ Branch 64 → 73 taken 2690 times.
|
3081 | if (ctx->COLON()) { |
| 179 | 391 | structDefNode->hasInterfaces = true; | |
| 180 |
5/8✓ Branch 65 → 66 taken 326 times.
✓ Branch 65 → 67 taken 65 times.
✓ Branch 68 → 69 taken 391 times.
✗ Branch 68 → 130 not taken.
✓ Branch 69 → 70 taken 391 times.
✗ Branch 69 → 130 not taken.
✓ Branch 70 → 71 taken 391 times.
✗ Branch 70 → 128 not taken.
|
391 | structDefNode->interfaceTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst(structDefNode->hasTemplateTypes ? 1 : 0))); |
| 181 | } | ||
| 182 |
3/4✓ Branch 73 → 74 taken 3081 times.
✗ Branch 73 → 137 not taken.
✓ Branch 91 → 76 taken 5653 times.
✓ Branch 91 → 92 taken 3081 times.
|
11815 | for (SpiceParser::FieldContext *field : ctx->field()) |
| 183 |
3/6✓ Branch 78 → 79 taken 5653 times.
✗ Branch 78 → 133 not taken.
✓ Branch 79 → 80 taken 5653 times.
✗ Branch 79 → 131 not taken.
✓ Branch 80 → 81 taken 5653 times.
✗ Branch 80 → 131 not taken.
|
8734 | structDefNode->fields.push_back(std::any_cast<FieldNode *>(visit(field))); |
| 184 | |||
| 185 |
1/2✓ Branch 99 → 100 taken 3081 times.
✗ Branch 99 → 138 not taken.
|
6162 | return concludeNode(structDefNode); |
| 186 | } | ||
| 187 | |||
| 188 | 374 | std::any ASTBuilder::visitInterfaceDef(SpiceParser::InterfaceDefContext *ctx) { | |
| 189 | 374 | const auto interfaceDefNode = createNode<InterfaceDefNode>(ctx); | |
| 190 | |||
| 191 | // Enrich | ||
| 192 |
2/4✓ Branch 3 → 4 taken 374 times.
✗ Branch 3 → 93 not taken.
✓ Branch 4 → 5 taken 374 times.
✗ Branch 4 → 93 not taken.
|
374 | interfaceDefNode->interfaceName = getIdentifier(ctx->TYPE_IDENTIFIER(), true); |
| 193 | 374 | interfaceDefNode->typeId = resourceManager.getNextCustomTypeId(); | |
| 194 | |||
| 195 | // Visit children | ||
| 196 |
2/2✓ Branch 9 → 10 taken 159 times.
✓ Branch 9 → 49 taken 215 times.
|
374 | if (ctx->topLevelDefAttr()) { |
| 197 |
3/6✓ Branch 10 → 11 taken 159 times.
✗ Branch 10 → 96 not taken.
✓ Branch 11 → 12 taken 159 times.
✗ Branch 11 → 96 not taken.
✓ Branch 12 → 13 taken 159 times.
✗ Branch 12 → 94 not taken.
|
159 | interfaceDefNode->attrs = std::any_cast<TopLevelDefAttrNode *>(visit(ctx->topLevelDefAttr())); |
| 198 | |||
| 199 | // Tell the attributes that they are struct attributes | ||
| 200 |
2/2✓ Branch 27 → 16 taken 159 times.
✓ Branch 27 → 28 taken 159 times.
|
477 | for (AttrNode *attr : interfaceDefNode->attrs->attrLst->attributes) |
| 201 | 159 | attr->target = AttrNode::TARGET_INTERFACE; | |
| 202 | |||
| 203 | // Check if a custom type id was set | ||
| 204 |
7/18✓ Branch 28 → 29 taken 159 times.
✗ Branch 28 → 35 not taken.
✓ Branch 31 → 32 taken 159 times.
✗ Branch 31 → 97 not taken.
✓ Branch 32 → 33 taken 159 times.
✗ Branch 32 → 97 not taken.
✓ Branch 33 → 34 taken 159 times.
✗ Branch 33 → 35 not taken.
✓ Branch 36 → 37 taken 159 times.
✗ Branch 36 → 38 not taken.
✓ Branch 38 → 39 taken 159 times.
✗ Branch 38 → 41 not taken.
✓ Branch 41 → 42 taken 159 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.
|
477 | if (interfaceDefNode->attrs && interfaceDefNode->attrs->attrLst->hasAttr(ATTR_CORE_COMPILER_FIXED_TYPE_ID)) |
| 205 |
2/4✓ Branch 44 → 45 taken 159 times.
✗ Branch 44 → 108 not taken.
✓ Branch 45 → 46 taken 159 times.
✗ Branch 45 → 106 not taken.
|
477 | interfaceDefNode->typeId = interfaceDefNode->attrs->attrLst->getAttrValueByName(ATTR_CORE_COMPILER_FIXED_TYPE_ID)->intValue; |
| 206 | } | ||
| 207 |
2/2✓ Branch 50 → 51 taken 354 times.
✓ Branch 50 → 56 taken 20 times.
|
374 | if (ctx->qualifierLst()) |
| 208 |
3/6✓ Branch 51 → 52 taken 354 times.
✗ Branch 51 → 114 not taken.
✓ Branch 52 → 53 taken 354 times.
✗ Branch 52 → 114 not taken.
✓ Branch 53 → 54 taken 354 times.
✗ Branch 53 → 112 not taken.
|
354 | interfaceDefNode->qualifierLst = std::any_cast<QualifierLstNode *>(visit(ctx->qualifierLst())); |
| 209 |
2/2✓ Branch 57 → 58 taken 162 times.
✓ Branch 57 → 63 taken 212 times.
|
374 | if (ctx->LESS()) { |
| 210 | 162 | interfaceDefNode->hasTemplateTypes = true; | |
| 211 |
3/6✓ Branch 58 → 59 taken 162 times.
✗ Branch 58 → 117 not taken.
✓ Branch 59 → 60 taken 162 times.
✗ Branch 59 → 117 not taken.
✓ Branch 60 → 61 taken 162 times.
✗ Branch 60 → 115 not taken.
|
162 | interfaceDefNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst())); |
| 212 | } | ||
| 213 |
3/4✓ Branch 63 → 64 taken 374 times.
✗ Branch 63 → 124 not taken.
✓ Branch 81 → 66 taken 2366 times.
✓ Branch 81 → 82 taken 374 times.
|
3114 | for (SpiceParser::SignatureContext *signature : ctx->signature()) |
| 214 |
3/6✓ Branch 68 → 69 taken 2366 times.
✗ Branch 68 → 120 not taken.
✓ Branch 69 → 70 taken 2366 times.
✗ Branch 69 → 118 not taken.
✓ Branch 70 → 71 taken 2366 times.
✗ Branch 70 → 118 not taken.
|
2740 | interfaceDefNode->signatures.push_back(std::any_cast<SignatureNode *>(visit(signature))); |
| 215 | |||
| 216 |
1/2✓ Branch 89 → 90 taken 374 times.
✗ Branch 89 → 125 not taken.
|
748 | return concludeNode(interfaceDefNode); |
| 217 | } | ||
| 218 | |||
| 219 | 373 | std::any ASTBuilder::visitEnumDef(SpiceParser::EnumDefContext *ctx) { | |
| 220 | 373 | const auto enumDefNode = createNode<EnumDefNode>(ctx); | |
| 221 | |||
| 222 | // Enrich | ||
| 223 |
2/4✓ Branch 3 → 4 taken 373 times.
✗ Branch 3 → 43 not taken.
✓ Branch 4 → 5 taken 373 times.
✗ Branch 4 → 43 not taken.
|
373 | enumDefNode->enumName = getIdentifier(ctx->TYPE_IDENTIFIER(), true); |
| 224 | 373 | enumDefNode->typeId = resourceManager.getNextCustomTypeId(); | |
| 225 | |||
| 226 | // Visit children | ||
| 227 |
2/2✓ Branch 9 → 10 taken 332 times.
✓ Branch 9 → 15 taken 41 times.
|
373 | if (ctx->qualifierLst()) |
| 228 |
3/6✓ Branch 10 → 11 taken 332 times.
✗ Branch 10 → 46 not taken.
✓ Branch 11 → 12 taken 332 times.
✗ Branch 11 → 46 not taken.
✓ Branch 12 → 13 taken 332 times.
✗ Branch 12 → 44 not taken.
|
332 | enumDefNode->qualifierLst = std::any_cast<QualifierLstNode *>(visit(ctx->qualifierLst())); |
| 229 |
3/6✓ Branch 15 → 16 taken 373 times.
✗ Branch 15 → 49 not taken.
✓ Branch 16 → 17 taken 373 times.
✗ Branch 16 → 49 not taken.
✓ Branch 17 → 18 taken 373 times.
✗ Branch 17 → 47 not taken.
|
373 | enumDefNode->itemLst = std::any_cast<EnumItemLstNode *>(visit(ctx->enumItemLst())); |
| 230 | |||
| 231 | // Tell all items about the enum def | ||
| 232 |
2/2✓ Branch 32 → 21 taken 4931 times.
✓ Branch 32 → 33 taken 373 times.
|
5677 | for (EnumItemNode *enumItem : enumDefNode->itemLst->items) |
| 233 | 4931 | enumItem->enumDef = enumDefNode; | |
| 234 | |||
| 235 |
1/2✓ Branch 39 → 40 taken 373 times.
✗ Branch 39 → 50 not taken.
|
746 | return concludeNode(enumDefNode); |
| 236 | } | ||
| 237 | |||
| 238 | 2044 | std::any ASTBuilder::visitGenericTypeDef(SpiceParser::GenericTypeDefContext *ctx) { | |
| 239 | 2044 | const auto genericTypeDefNode = createNode<GenericTypeDefNode>(ctx); | |
| 240 | |||
| 241 | // Enrich | ||
| 242 |
2/4✓ Branch 3 → 4 taken 2044 times.
✗ Branch 3 → 21 not taken.
✓ Branch 4 → 5 taken 2044 times.
✗ Branch 4 → 21 not taken.
|
2044 | genericTypeDefNode->typeName = getIdentifier(ctx->TYPE_IDENTIFIER(), true); |
| 243 | |||
| 244 | // Visit children | ||
| 245 |
4/8✓ Branch 7 → 8 taken 2044 times.
✗ Branch 7 → 24 not taken.
✓ Branch 8 → 9 taken 2044 times.
✗ Branch 8 → 24 not taken.
✓ Branch 9 → 10 taken 2044 times.
✗ Branch 9 → 22 not taken.
✓ Branch 11 → 12 taken 2044 times.
✗ Branch 11 → 25 not taken.
|
2044 | genericTypeDefNode->typeAltsLst = std::any_cast<TypeAltsLstNode *>(visit(ctx->typeAltsLst())); |
| 246 | |||
| 247 |
1/2✓ Branch 17 → 18 taken 2044 times.
✗ Branch 17 → 25 not taken.
|
4088 | return concludeNode(genericTypeDefNode); |
| 248 | } | ||
| 249 | |||
| 250 | 345 | std::any ASTBuilder::visitAliasDef(SpiceParser::AliasDefContext *ctx) { | |
| 251 | 345 | const auto aliasDefNode = createNode<AliasDefNode>(ctx); | |
| 252 | |||
| 253 | // Enrich | ||
| 254 |
2/4✓ Branch 3 → 4 taken 345 times.
✗ Branch 3 → 33 not taken.
✓ Branch 4 → 5 taken 345 times.
✗ Branch 4 → 33 not taken.
|
345 | aliasDefNode->aliasName = getIdentifier(ctx->TYPE_IDENTIFIER(), true); |
| 255 |
2/4✓ Branch 7 → 8 taken 345 times.
✗ Branch 7 → 34 not taken.
✓ Branch 8 → 9 taken 345 times.
✗ Branch 8 → 34 not taken.
|
345 | aliasDefNode->dataTypeString = ctx->dataType()->getText(); |
| 256 | 345 | aliasDefNode->typeId = resourceManager.getNextCustomTypeId(); | |
| 257 | |||
| 258 | // Visit children | ||
| 259 |
2/2✓ Branch 13 → 14 taken 107 times.
✓ Branch 13 → 19 taken 238 times.
|
345 | if (ctx->qualifierLst()) |
| 260 |
3/6✓ Branch 14 → 15 taken 107 times.
✗ Branch 14 → 37 not taken.
✓ Branch 15 → 16 taken 107 times.
✗ Branch 15 → 37 not taken.
✓ Branch 16 → 17 taken 107 times.
✗ Branch 16 → 35 not taken.
|
107 | aliasDefNode->qualifierLst = std::any_cast<QualifierLstNode *>(visit(ctx->qualifierLst())); |
| 261 |
4/8✓ Branch 19 → 20 taken 345 times.
✗ Branch 19 → 40 not taken.
✓ Branch 20 → 21 taken 345 times.
✗ Branch 20 → 40 not taken.
✓ Branch 21 → 22 taken 345 times.
✗ Branch 21 → 38 not taken.
✓ Branch 23 → 24 taken 345 times.
✗ Branch 23 → 41 not taken.
|
345 | aliasDefNode->dataType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 262 | |||
| 263 |
1/2✓ Branch 29 → 30 taken 345 times.
✗ Branch 29 → 41 not taken.
|
690 | return concludeNode(aliasDefNode); |
| 264 | } | ||
| 265 | |||
| 266 | 2420 | std::any ASTBuilder::visitGlobalVarDef(SpiceParser::GlobalVarDefContext *ctx) { | |
| 267 | 2420 | const auto globalVarDefNode = createNode<GlobalVarDefNode>(ctx); | |
| 268 | |||
| 269 | // Enrich | ||
| 270 |
2/4✓ Branch 3 → 4 taken 2420 times.
✗ Branch 3 → 28 not taken.
✓ Branch 4 → 5 taken 2420 times.
✗ Branch 4 → 28 not taken.
|
2420 | globalVarDefNode->varName = getIdentifier(ctx->TYPE_IDENTIFIER(), true); |
| 271 | |||
| 272 | // Visit children | ||
| 273 |
3/6✓ Branch 7 → 8 taken 2420 times.
✗ Branch 7 → 31 not taken.
✓ Branch 8 → 9 taken 2420 times.
✗ Branch 8 → 31 not taken.
✓ Branch 9 → 10 taken 2420 times.
✗ Branch 9 → 29 not taken.
|
2420 | globalVarDefNode->dataType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 274 | 2420 | globalVarDefNode->dataType->isGlobalType = true; | |
| 275 |
2/2✓ Branch 12 → 13 taken 2418 times.
✓ Branch 12 → 18 taken 2 times.
|
2420 | if (ctx->constant()) { |
| 276 | 2418 | globalVarDefNode->hasValue = true; | |
| 277 |
3/6✓ Branch 13 → 14 taken 2418 times.
✗ Branch 13 → 34 not taken.
✓ Branch 14 → 15 taken 2418 times.
✗ Branch 14 → 34 not taken.
✓ Branch 15 → 16 taken 2418 times.
✗ Branch 15 → 32 not taken.
|
2418 | globalVarDefNode->constant = std::any_cast<ConstantNode *>(visit(ctx->constant())); |
| 278 | } | ||
| 279 | |||
| 280 |
1/2✓ Branch 24 → 25 taken 2420 times.
✗ Branch 24 → 35 not taken.
|
4840 | return concludeNode(globalVarDefNode); |
| 281 | } | ||
| 282 | |||
| 283 | 3054 | std::any ASTBuilder::visitExtDecl(SpiceParser::ExtDeclContext *ctx) { | |
| 284 | 3054 | const auto extDeclNode = createNode<ExtDeclNode>(ctx); | |
| 285 | |||
| 286 | // Enrich | ||
| 287 |
6/10✓ Branch 3 → 4 taken 3054 times.
✗ Branch 3 → 57 not taken.
✓ Branch 4 → 5 taken 1657 times.
✓ Branch 4 → 7 taken 1397 times.
✓ Branch 5 → 6 taken 1657 times.
✗ Branch 5 → 57 not taken.
✓ Branch 7 → 8 taken 1397 times.
✗ Branch 7 → 57 not taken.
✓ Branch 9 → 10 taken 3054 times.
✗ Branch 9 → 57 not taken.
|
3054 | extDeclNode->extFunctionName = getIdentifier(ctx->IDENTIFIER() ? ctx->IDENTIFIER() : ctx->TYPE_IDENTIFIER(), false); |
| 288 | |||
| 289 | // Visit children | ||
| 290 |
2/2✓ Branch 13 → 14 taken 1 time.
✓ Branch 13 → 33 taken 3053 times.
|
3054 | if (ctx->topLevelDefAttr()) { |
| 291 |
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())); |
| 292 | |||
| 293 | // Tell the attributes that they are ext decl attributes | ||
| 294 |
2/2✓ Branch 31 → 20 taken 1 time.
✓ Branch 31 → 32 taken 1 time.
|
3 | for (AttrNode *attr : extDeclNode->attrs->attrLst->attributes) |
| 295 | 1 | attr->target = AttrNode::TARGET_EXT_DECL; | |
| 296 | } | ||
| 297 |
2/2✓ Branch 34 → 35 taken 2011 times.
✓ Branch 34 → 40 taken 1043 times.
|
3054 | if (ctx->F()) { |
| 298 |
3/6✓ Branch 35 → 36 taken 2011 times.
✗ Branch 35 → 63 not taken.
✓ Branch 36 → 37 taken 2011 times.
✗ Branch 36 → 63 not taken.
✓ Branch 37 → 38 taken 2011 times.
✗ Branch 37 → 61 not taken.
|
2011 | extDeclNode->returnType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 299 | 2011 | extDeclNode->returnType->isReturnType = true; | |
| 300 | } | ||
| 301 |
2/2✓ Branch 41 → 42 taken 2847 times.
✓ Branch 41 → 47 taken 207 times.
|
3054 | if (ctx->typeLstWithEllipsis()) { |
| 302 | 2847 | extDeclNode->hasArgs = true; | |
| 303 |
3/6✓ Branch 42 → 43 taken 2847 times.
✗ Branch 42 → 66 not taken.
✓ Branch 43 → 44 taken 2847 times.
✗ Branch 43 → 66 not taken.
✓ Branch 44 → 45 taken 2847 times.
✗ Branch 44 → 64 not taken.
|
2847 | extDeclNode->argTypeLst = std::any_cast<TypeLstWithEllipsisNode *>(visit(ctx->typeLstWithEllipsis())); |
| 304 | } | ||
| 305 | |||
| 306 |
1/2✓ Branch 53 → 54 taken 3054 times.
✗ Branch 53 → 67 not taken.
|
6108 | return concludeNode(extDeclNode); |
| 307 | } | ||
| 308 | |||
| 309 | 2555 | std::any ASTBuilder::visitImportDef(SpiceParser::ImportDefContext *ctx) { | |
| 310 |
1/2✓ Branch 2 → 3 taken 2555 times.
✗ Branch 2 → 32 not taken.
|
2555 | const auto importDefNode = createNode<ImportDefNode>(ctx); |
| 311 | |||
| 312 | // Extract path | ||
| 313 |
2/4✓ Branch 3 → 4 taken 2555 times.
✗ Branch 3 → 32 not taken.
✓ Branch 4 → 5 taken 2555 times.
✗ Branch 4 → 32 not taken.
|
2555 | const std::string pathStr = ctx->STRING_LIT()->getText(); |
| 314 |
1/2✓ Branch 6 → 7 taken 2555 times.
✗ Branch 6 → 27 not taken.
|
2555 | importDefNode->importPath = pathStr.substr(1, pathStr.size() - 2); |
| 315 | |||
| 316 | // If no name is given, use the path as name | ||
| 317 |
7/12✓ Branch 9 → 10 taken 2555 times.
✗ Branch 9 → 28 not taken.
✓ Branch 10 → 11 taken 102 times.
✓ Branch 10 → 13 taken 2453 times.
✓ Branch 11 → 12 taken 102 times.
✗ Branch 11 → 28 not taken.
✓ Branch 12 → 14 taken 102 times.
✗ Branch 12 → 28 not taken.
✓ Branch 13 → 14 taken 2453 times.
✗ Branch 13 → 28 not taken.
✓ Branch 16 → 17 taken 2555 times.
✗ Branch 16 → 29 not taken.
|
2555 | importDefNode->importName = ctx->AS() ? getIdentifier(ctx->IDENTIFIER(), false) : importDefNode->importPath; |
| 318 | |||
| 319 |
1/2✓ Branch 22 → 23 taken 2555 times.
✗ Branch 22 → 29 not taken.
|
5110 | return concludeNode(importDefNode); |
| 320 | 2555 | } | |
| 321 | |||
| 322 | 6220 | std::any ASTBuilder::visitUnsafeBlock(SpiceParser::UnsafeBlockContext *ctx) { | |
| 323 | 6220 | const auto unsafeBlockDefNode = createNode<UnsafeBlockNode>(ctx); | |
| 324 | |||
| 325 | // Visit children | ||
| 326 |
4/8✓ Branch 3 → 4 taken 6220 times.
✗ Branch 3 → 19 not taken.
✓ Branch 4 → 5 taken 6220 times.
✗ Branch 4 → 19 not taken.
✓ Branch 5 → 6 taken 6220 times.
✗ Branch 5 → 17 not taken.
✓ Branch 7 → 8 taken 6220 times.
✗ Branch 7 → 20 not taken.
|
6220 | unsafeBlockDefNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 327 | |||
| 328 |
1/2✓ Branch 13 → 14 taken 6220 times.
✗ Branch 13 → 20 not taken.
|
12440 | return concludeNode(unsafeBlockDefNode); |
| 329 | } | ||
| 330 | |||
| 331 | 3245 | std::any ASTBuilder::visitForLoop(SpiceParser::ForLoopContext *ctx) { | |
| 332 | 3245 | const auto forLoopNode = createNode<ForLoopNode>(ctx); | |
| 333 | |||
| 334 |
2/4✓ Branch 3 → 4 taken 3245 times.
✗ Branch 3 → 20 not taken.
✓ Branch 4 → 5 taken 3245 times.
✗ Branch 4 → 20 not taken.
|
3245 | visit(ctx->forHead()); |
| 335 |
4/8✓ Branch 6 → 7 taken 3245 times.
✗ Branch 6 → 23 not taken.
✓ Branch 7 → 8 taken 3245 times.
✗ Branch 7 → 23 not taken.
✓ Branch 8 → 9 taken 3245 times.
✗ Branch 8 → 21 not taken.
✓ Branch 10 → 11 taken 3245 times.
✗ Branch 10 → 24 not taken.
|
3245 | forLoopNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 336 | |||
| 337 |
1/2✓ Branch 16 → 17 taken 3245 times.
✗ Branch 16 → 24 not taken.
|
6490 | return concludeNode(forLoopNode); |
| 338 | } | ||
| 339 | |||
| 340 | 3245 | std::any ASTBuilder::visitForHead(SpiceParser::ForHeadContext *ctx) { | |
| 341 | 3245 | const auto forLoopNode = resumeForExpansion<ForLoopNode>(); | |
| 342 | |||
| 343 | // Visit children | ||
| 344 |
3/6✓ Branch 12 → 13 taken 3245 times.
✗ Branch 12 → 30 not taken.
✓ Branch 13 → 14 taken 3245 times.
✗ Branch 13 → 30 not taken.
✓ Branch 14 → 15 taken 3245 times.
✗ Branch 14 → 28 not taken.
|
3245 | forLoopNode->initDecl = std::any_cast<DeclStmtNode *>(visit(ctx->declStmt())); |
| 345 |
3/6✓ Branch 16 → 17 taken 3245 times.
✗ Branch 16 → 33 not taken.
✓ Branch 17 → 18 taken 3245 times.
✗ Branch 17 → 33 not taken.
✓ Branch 18 → 19 taken 3245 times.
✗ Branch 18 → 31 not taken.
|
3245 | forLoopNode->condAssign = std::any_cast<ExprNode *>(visit(ctx->assignExpr(0))); |
| 346 |
3/6✓ Branch 20 → 21 taken 3245 times.
✗ Branch 20 → 36 not taken.
✓ Branch 21 → 22 taken 3245 times.
✗ Branch 21 → 36 not taken.
✓ Branch 22 → 23 taken 3245 times.
✗ Branch 22 → 34 not taken.
|
3245 | forLoopNode->incAssign = std::any_cast<ExprNode *>(visit(ctx->assignExpr(1))); |
| 347 | |||
| 348 |
1/2✓ Branch 24 → 25 taken 3245 times.
✗ Branch 24 → 37 not taken.
|
6490 | return nullptr; |
| 349 | } | ||
| 350 | |||
| 351 | 481 | std::any ASTBuilder::visitForeachLoop(SpiceParser::ForeachLoopContext *ctx) { | |
| 352 | 481 | const auto foreachLoopNode = createNode<ForeachLoopNode>(ctx); | |
| 353 | |||
| 354 | // Visit children | ||
| 355 |
2/4✓ Branch 3 → 4 taken 481 times.
✗ Branch 3 → 20 not taken.
✓ Branch 4 → 5 taken 481 times.
✗ Branch 4 → 20 not taken.
|
481 | visit(ctx->foreachHead()); |
| 356 |
3/6✓ Branch 6 → 7 taken 481 times.
✗ Branch 6 → 23 not taken.
✓ Branch 7 → 8 taken 481 times.
✗ Branch 7 → 23 not taken.
✓ Branch 8 → 9 taken 481 times.
✗ Branch 8 → 21 not taken.
|
481 | foreachLoopNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 357 | |||
| 358 | // Tell the foreach item that it is one | ||
| 359 |
1/2✓ Branch 10 → 11 taken 481 times.
✗ Branch 10 → 24 not taken.
|
481 | foreachLoopNode->itemVarDecl->isForEachItem = true; |
| 360 | |||
| 361 |
1/2✓ Branch 16 → 17 taken 481 times.
✗ Branch 16 → 24 not taken.
|
962 | return concludeNode(foreachLoopNode); |
| 362 | } | ||
| 363 | |||
| 364 | 481 | std::any ASTBuilder::visitForeachHead(SpiceParser::ForeachHeadContext *ctx) { | |
| 365 | 481 | const auto foreachLoopNode = resumeForExpansion<ForeachLoopNode>(); | |
| 366 | |||
| 367 | // Visit children | ||
| 368 |
3/4✓ Branch 12 → 13 taken 481 times.
✗ Branch 12 → 43 not taken.
✓ Branch 15 → 16 taken 423 times.
✓ Branch 15 → 21 taken 58 times.
|
481 | if (ctx->declStmt().size() == 1) { |
| 369 |
3/6✓ Branch 16 → 17 taken 423 times.
✗ Branch 16 → 46 not taken.
✓ Branch 17 → 18 taken 423 times.
✗ Branch 17 → 46 not taken.
✓ Branch 18 → 19 taken 423 times.
✗ Branch 18 → 44 not taken.
|
423 | foreachLoopNode->itemVarDecl = std::any_cast<DeclStmtNode *>(visit(ctx->declStmt(0))); |
| 370 |
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) { |
| 371 |
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))); |
| 372 |
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))); |
| 373 | } else { | ||
| 374 | − | assert_fail("Invalid number of decl statements in foreach loop"); // GCOV_EXCL_LINE | |
| 375 | } | ||
| 376 |
3/6✓ Branch 35 → 36 taken 481 times.
✗ Branch 35 → 56 not taken.
✓ Branch 36 → 37 taken 481 times.
✗ Branch 36 → 56 not taken.
✓ Branch 37 → 38 taken 481 times.
✗ Branch 37 → 54 not taken.
|
481 | foreachLoopNode->iteratorAssign = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 377 | |||
| 378 |
1/2✓ Branch 39 → 40 taken 481 times.
✗ Branch 39 → 57 not taken.
|
962 | return nullptr; |
| 379 | } | ||
| 380 | |||
| 381 | 1739 | std::any ASTBuilder::visitWhileLoop(SpiceParser::WhileLoopContext *ctx) { | |
| 382 | 1739 | const auto whileLoopNode = createNode<WhileLoopNode>(ctx); | |
| 383 | |||
| 384 | // Visit children | ||
| 385 |
3/6✓ Branch 3 → 4 taken 1739 times.
✗ Branch 3 → 23 not taken.
✓ Branch 4 → 5 taken 1739 times.
✗ Branch 4 → 23 not taken.
✓ Branch 5 → 6 taken 1739 times.
✗ Branch 5 → 21 not taken.
|
1739 | whileLoopNode->condition = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 386 |
4/8✓ Branch 7 → 8 taken 1739 times.
✗ Branch 7 → 26 not taken.
✓ Branch 8 → 9 taken 1739 times.
✗ Branch 8 → 26 not taken.
✓ Branch 9 → 10 taken 1739 times.
✗ Branch 9 → 24 not taken.
✓ Branch 11 → 12 taken 1739 times.
✗ Branch 11 → 27 not taken.
|
1739 | whileLoopNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 387 | |||
| 388 |
1/2✓ Branch 17 → 18 taken 1739 times.
✗ Branch 17 → 27 not taken.
|
3478 | return concludeNode(whileLoopNode); |
| 389 | } | ||
| 390 | |||
| 391 | 63 | std::any ASTBuilder::visitDoWhileLoop(SpiceParser::DoWhileLoopContext *ctx) { | |
| 392 | 63 | const auto doWhileLoopNode = createNode<DoWhileLoopNode>(ctx); | |
| 393 | |||
| 394 | // Visit children | ||
| 395 |
3/6✓ Branch 3 → 4 taken 63 times.
✗ Branch 3 → 23 not taken.
✓ Branch 4 → 5 taken 63 times.
✗ Branch 4 → 23 not taken.
✓ Branch 5 → 6 taken 63 times.
✗ Branch 5 → 21 not taken.
|
63 | doWhileLoopNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 396 |
4/8✓ Branch 7 → 8 taken 63 times.
✗ Branch 7 → 26 not taken.
✓ Branch 8 → 9 taken 63 times.
✗ Branch 8 → 26 not taken.
✓ Branch 9 → 10 taken 63 times.
✗ Branch 9 → 24 not taken.
✓ Branch 11 → 12 taken 63 times.
✗ Branch 11 → 27 not taken.
|
63 | doWhileLoopNode->condition = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 397 | |||
| 398 |
1/2✓ Branch 17 → 18 taken 63 times.
✗ Branch 17 → 27 not taken.
|
126 | return concludeNode(doWhileLoopNode); |
| 399 | } | ||
| 400 | |||
| 401 | 13433 | std::any ASTBuilder::visitIfStmt(SpiceParser::IfStmtContext *ctx) { | |
| 402 | 13433 | const auto ifStmtNode = createNode<IfStmtNode>(ctx); | |
| 403 | |||
| 404 | // Visit children | ||
| 405 |
3/6✓ Branch 3 → 4 taken 13433 times.
✗ Branch 3 → 30 not taken.
✓ Branch 4 → 5 taken 13433 times.
✗ Branch 4 → 30 not taken.
✓ Branch 5 → 6 taken 13433 times.
✗ Branch 5 → 28 not taken.
|
13433 | ifStmtNode->condition = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 406 |
3/6✓ Branch 7 → 8 taken 13433 times.
✗ Branch 7 → 33 not taken.
✓ Branch 8 → 9 taken 13433 times.
✗ Branch 8 → 33 not taken.
✓ Branch 9 → 10 taken 13433 times.
✗ Branch 9 → 31 not taken.
|
13433 | ifStmtNode->thenBody = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 407 |
2/2✓ Branch 12 → 13 taken 1158 times.
✓ Branch 12 → 18 taken 12275 times.
|
13433 | if (ctx->elseStmt()) |
| 408 |
3/6✓ Branch 13 → 14 taken 1158 times.
✗ Branch 13 → 36 not taken.
✓ Branch 14 → 15 taken 1158 times.
✗ Branch 14 → 36 not taken.
✓ Branch 15 → 16 taken 1158 times.
✗ Branch 15 → 34 not taken.
|
1158 | ifStmtNode->elseStmt = std::any_cast<ElseStmtNode *>(visit(ctx->elseStmt())); |
| 409 | |||
| 410 |
1/2✓ Branch 24 → 25 taken 13433 times.
✗ Branch 24 → 37 not taken.
|
26866 | return concludeNode(ifStmtNode); |
| 411 | } | ||
| 412 | |||
| 413 | 1158 | std::any ASTBuilder::visitElseStmt(SpiceParser::ElseStmtContext *ctx) { | |
| 414 | 1158 | const auto elseStmtNode = createNode<ElseStmtNode>(ctx); | |
| 415 | |||
| 416 | // Visit children | ||
| 417 |
2/2✓ Branch 4 → 5 taken 412 times.
✓ Branch 4 → 10 taken 746 times.
|
1158 | if (ctx->ifStmt()) { |
| 418 | 412 | elseStmtNode->isElseIf = true; | |
| 419 |
3/6✓ Branch 5 → 6 taken 412 times.
✗ Branch 5 → 27 not taken.
✓ Branch 6 → 7 taken 412 times.
✗ Branch 6 → 27 not taken.
✓ Branch 7 → 8 taken 412 times.
✗ Branch 7 → 25 not taken.
|
412 | elseStmtNode->ifStmt = std::any_cast<IfStmtNode *>(visit(ctx->ifStmt())); |
| 420 | } else { | ||
| 421 |
3/6✓ Branch 10 → 11 taken 746 times.
✗ Branch 10 → 30 not taken.
✓ Branch 11 → 12 taken 746 times.
✗ Branch 11 → 30 not taken.
✓ Branch 12 → 13 taken 746 times.
✗ Branch 12 → 28 not taken.
|
746 | elseStmtNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 422 | } | ||
| 423 | |||
| 424 |
1/2✓ Branch 21 → 22 taken 1158 times.
✗ Branch 21 → 31 not taken.
|
2316 | return concludeNode(elseStmtNode); |
| 425 | } | ||
| 426 | |||
| 427 | 86 | std::any ASTBuilder::visitSwitchStmt(SpiceParser::SwitchStmtContext *ctx) { | |
| 428 | 86 | const auto switchStmtNode = createNode<SwitchStmtNode>(ctx); | |
| 429 | |||
| 430 | // Visit children | ||
| 431 |
3/6✓ Branch 3 → 4 taken 86 times.
✗ Branch 3 → 29 not taken.
✓ Branch 4 → 5 taken 86 times.
✗ Branch 4 → 29 not taken.
✓ Branch 5 → 6 taken 86 times.
✗ Branch 5 → 27 not taken.
|
86 | switchStmtNode->assignExpr = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 432 |
2/4✓ Branch 7 → 8 taken 86 times.
✗ Branch 7 → 32 not taken.
✓ Branch 8 → 9 taken 86 times.
✗ Branch 8 → 30 not taken.
|
86 | fetchChildrenIntoVector(switchStmtNode->caseBranches, ctx->caseBranch()); |
| 433 |
2/2✓ Branch 11 → 12 taken 70 times.
✓ Branch 11 → 17 taken 16 times.
|
86 | if (ctx->defaultBranch()) { |
| 434 | 70 | switchStmtNode->hasDefaultBranch = true; | |
| 435 |
3/6✓ Branch 12 → 13 taken 70 times.
✗ Branch 12 → 35 not taken.
✓ Branch 13 → 14 taken 70 times.
✗ Branch 13 → 35 not taken.
✓ Branch 14 → 15 taken 70 times.
✗ Branch 14 → 33 not taken.
|
70 | switchStmtNode->defaultBranch = std::any_cast<DefaultBranchNode *>(visit(ctx->defaultBranch())); |
| 436 | } | ||
| 437 | |||
| 438 |
1/2✓ Branch 23 → 24 taken 86 times.
✗ Branch 23 → 36 not taken.
|
172 | return concludeNode(switchStmtNode); |
| 439 | } | ||
| 440 | |||
| 441 | 663 | std::any ASTBuilder::visitCaseBranch(SpiceParser::CaseBranchContext *ctx) { | |
| 442 | 663 | const auto caseBranchNode = createNode<CaseBranchNode>(ctx); | |
| 443 | |||
| 444 | // Visit children | ||
| 445 |
2/4✓ Branch 3 → 4 taken 663 times.
✗ Branch 3 → 22 not taken.
✓ Branch 4 → 5 taken 663 times.
✗ Branch 4 → 20 not taken.
|
663 | fetchChildrenIntoVector(caseBranchNode->caseConstants, ctx->caseConstant()); |
| 446 |
4/8✓ Branch 6 → 7 taken 663 times.
✗ Branch 6 → 25 not taken.
✓ Branch 7 → 8 taken 663 times.
✗ Branch 7 → 25 not taken.
✓ Branch 8 → 9 taken 663 times.
✗ Branch 8 → 23 not taken.
✓ Branch 10 → 11 taken 663 times.
✗ Branch 10 → 26 not taken.
|
663 | caseBranchNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 447 | |||
| 448 |
1/2✓ Branch 16 → 17 taken 663 times.
✗ Branch 16 → 26 not taken.
|
1326 | return concludeNode(caseBranchNode); |
| 449 | } | ||
| 450 | |||
| 451 | 70 | std::any ASTBuilder::visitDefaultBranch(SpiceParser::DefaultBranchContext *ctx) { | |
| 452 | 70 | const auto defaultBranchNode = createNode<DefaultBranchNode>(ctx); | |
| 453 | |||
| 454 | // Visit children | ||
| 455 |
4/8✓ Branch 3 → 4 taken 70 times.
✗ Branch 3 → 19 not taken.
✓ Branch 4 → 5 taken 70 times.
✗ Branch 4 → 19 not taken.
✓ Branch 5 → 6 taken 70 times.
✗ Branch 5 → 17 not taken.
✓ Branch 7 → 8 taken 70 times.
✗ Branch 7 → 20 not taken.
|
70 | defaultBranchNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 456 | |||
| 457 |
1/2✓ Branch 13 → 14 taken 70 times.
✗ Branch 13 → 20 not taken.
|
140 | return concludeNode(defaultBranchNode); |
| 458 | } | ||
| 459 | |||
| 460 | 62 | std::any ASTBuilder::visitAnonymousBlockStmt(SpiceParser::AnonymousBlockStmtContext *ctx) { | |
| 461 | 62 | const auto anonymousBlockStmtNode = createNode<AnonymousBlockStmtNode>(ctx); | |
| 462 | |||
| 463 | // Visit children | ||
| 464 |
4/8✓ Branch 3 → 4 taken 62 times.
✗ Branch 3 → 19 not taken.
✓ Branch 4 → 5 taken 62 times.
✗ Branch 4 → 19 not taken.
✓ Branch 5 → 6 taken 62 times.
✗ Branch 5 → 17 not taken.
✓ Branch 7 → 8 taken 62 times.
✗ Branch 7 → 20 not taken.
|
62 | anonymousBlockStmtNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 465 | |||
| 466 |
1/2✓ Branch 13 → 14 taken 62 times.
✗ Branch 13 → 20 not taken.
|
124 | return concludeNode(anonymousBlockStmtNode); |
| 467 | } | ||
| 468 | |||
| 469 | 59751 | std::any ASTBuilder::visitStmtLst(SpiceParser::StmtLstContext *ctx) { | |
| 470 | 59751 | const auto stmtLstNode = createNode<StmtLstNode>(ctx); | |
| 471 | |||
| 472 | // Enrich | ||
| 473 |
2/4✓ Branch 3 → 4 taken 59751 times.
✗ Branch 3 → 124 not taken.
✓ Branch 4 → 5 taken 59751 times.
✗ Branch 4 → 124 not taken.
|
59751 | stmtLstNode->closingBraceCodeLoc = CodeLoc(ctx->getStop(), sourceFile); |
| 474 | |||
| 475 | // Visit children | ||
| 476 |
2/2✓ Branch 113 → 7 taken 232061 times.
✓ Branch 113 → 114 taken 59747 times.
|
351559 | for (ParserRuleContext::ParseTree *stmt : ctx->children) { |
| 477 |
3/4✓ Branch 9 → 10 taken 232061 times.
✗ Branch 9 → 11 not taken.
✓ Branch 12 → 13 taken 84211 times.
✓ Branch 12 → 18 taken 147850 times.
|
232061 | if (auto *stmtCtx = dynamic_cast<SpiceParser::StmtContext *>(stmt)) |
| 478 |
4/6✓ Branch 13 → 14 taken 84207 times.
✓ Branch 13 → 127 taken 4 times.
✓ Branch 14 → 15 taken 84207 times.
✗ Branch 14 → 125 not taken.
✓ Branch 15 → 16 taken 84207 times.
✗ Branch 15 → 125 not taken.
|
84211 | stmtLstNode->statements.push_back(std::any_cast<StmtNode *>(visit(stmtCtx))); |
| 479 |
3/4✓ Branch 18 → 19 taken 147850 times.
✗ Branch 18 → 20 not taken.
✓ Branch 21 → 22 taken 3245 times.
✓ Branch 21 → 27 taken 144605 times.
|
147850 | else if (auto *forLoopCtx = dynamic_cast<SpiceParser::ForLoopContext *>(stmt)) |
| 480 |
3/6✓ Branch 22 → 23 taken 3245 times.
✗ Branch 22 → 131 not taken.
✓ Branch 23 → 24 taken 3245 times.
✗ Branch 23 → 129 not taken.
✓ Branch 24 → 25 taken 3245 times.
✗ Branch 24 → 129 not taken.
|
3245 | stmtLstNode->statements.push_back(std::any_cast<ForLoopNode *>(visit(forLoopCtx))); |
| 481 |
3/4✓ Branch 27 → 28 taken 144605 times.
✗ Branch 27 → 29 not taken.
✓ Branch 30 → 31 taken 481 times.
✓ Branch 30 → 36 taken 144124 times.
|
144605 | else if (auto *foreachLoopCtx = dynamic_cast<SpiceParser::ForeachLoopContext *>(stmt)) |
| 482 |
3/6✓ Branch 31 → 32 taken 481 times.
✗ Branch 31 → 135 not taken.
✓ Branch 32 → 33 taken 481 times.
✗ Branch 32 → 133 not taken.
✓ Branch 33 → 34 taken 481 times.
✗ Branch 33 → 133 not taken.
|
481 | stmtLstNode->statements.push_back(std::any_cast<ForeachLoopNode *>(visit(foreachLoopCtx))); |
| 483 |
3/4✓ Branch 36 → 37 taken 144124 times.
✗ Branch 36 → 38 not taken.
✓ Branch 39 → 40 taken 1739 times.
✓ Branch 39 → 45 taken 142385 times.
|
144124 | else if (auto *whileLoopCtx = dynamic_cast<SpiceParser::WhileLoopContext *>(stmt)) |
| 484 |
3/6✓ Branch 40 → 41 taken 1739 times.
✗ Branch 40 → 139 not taken.
✓ Branch 41 → 42 taken 1739 times.
✗ Branch 41 → 137 not taken.
✓ Branch 42 → 43 taken 1739 times.
✗ Branch 42 → 137 not taken.
|
1739 | stmtLstNode->statements.push_back(std::any_cast<WhileLoopNode *>(visit(whileLoopCtx))); |
| 485 |
3/4✓ Branch 45 → 46 taken 142385 times.
✗ Branch 45 → 47 not taken.
✓ Branch 48 → 49 taken 63 times.
✓ Branch 48 → 54 taken 142322 times.
|
142385 | else if (auto *doWhileLoopCtx = dynamic_cast<SpiceParser::DoWhileLoopContext *>(stmt)) |
| 486 |
3/6✓ Branch 49 → 50 taken 63 times.
✗ Branch 49 → 143 not taken.
✓ Branch 50 → 51 taken 63 times.
✗ Branch 50 → 141 not taken.
✓ Branch 51 → 52 taken 63 times.
✗ Branch 51 → 141 not taken.
|
63 | stmtLstNode->statements.push_back(std::any_cast<DoWhileLoopNode *>(visit(doWhileLoopCtx))); |
| 487 |
3/4✓ Branch 54 → 55 taken 142322 times.
✗ Branch 54 → 56 not taken.
✓ Branch 57 → 58 taken 13021 times.
✓ Branch 57 → 63 taken 129301 times.
|
142322 | else if (auto *ifStmtCtx = dynamic_cast<SpiceParser::IfStmtContext *>(stmt)) |
| 488 |
3/6✓ Branch 58 → 59 taken 13021 times.
✗ Branch 58 → 147 not taken.
✓ Branch 59 → 60 taken 13021 times.
✗ Branch 59 → 145 not taken.
✓ Branch 60 → 61 taken 13021 times.
✗ Branch 60 → 145 not taken.
|
13021 | stmtLstNode->statements.push_back(std::any_cast<IfStmtNode *>(visit(ifStmtCtx))); |
| 489 |
3/4✓ Branch 63 → 64 taken 129301 times.
✗ Branch 63 → 65 not taken.
✓ Branch 66 → 67 taken 86 times.
✓ Branch 66 → 72 taken 129215 times.
|
129301 | else if (auto *switchStmtCtx = dynamic_cast<SpiceParser::SwitchStmtContext *>(stmt)) |
| 490 |
3/6✓ Branch 67 → 68 taken 86 times.
✗ Branch 67 → 151 not taken.
✓ Branch 68 → 69 taken 86 times.
✗ Branch 68 → 149 not taken.
✓ Branch 69 → 70 taken 86 times.
✗ Branch 69 → 149 not taken.
|
86 | stmtLstNode->statements.push_back(std::any_cast<SwitchStmtNode *>(visit(switchStmtCtx))); |
| 491 |
3/4✓ Branch 72 → 73 taken 129215 times.
✗ Branch 72 → 74 not taken.
✓ Branch 75 → 76 taken 3435 times.
✓ Branch 75 → 81 taken 125780 times.
|
129215 | else if (auto *assetStmtCtx = dynamic_cast<SpiceParser::AssertStmtContext *>(stmt)) |
| 492 |
3/6✓ Branch 76 → 77 taken 3435 times.
✗ Branch 76 → 155 not taken.
✓ Branch 77 → 78 taken 3435 times.
✗ Branch 77 → 153 not taken.
✓ Branch 78 → 79 taken 3435 times.
✗ Branch 78 → 153 not taken.
|
3435 | stmtLstNode->statements.push_back(std::any_cast<AssertStmtNode *>(visit(assetStmtCtx))); |
| 493 |
3/4✓ Branch 81 → 82 taken 125780 times.
✗ Branch 81 → 83 not taken.
✓ Branch 84 → 85 taken 6220 times.
✓ Branch 84 → 90 taken 119560 times.
|
125780 | else if (auto *unsafeBlockCtx = dynamic_cast<SpiceParser::UnsafeBlockContext *>(stmt)) |
| 494 |
3/6✓ Branch 85 → 86 taken 6220 times.
✗ Branch 85 → 159 not taken.
✓ Branch 86 → 87 taken 6220 times.
✗ Branch 86 → 157 not taken.
✓ Branch 87 → 88 taken 6220 times.
✗ Branch 87 → 157 not taken.
|
6220 | stmtLstNode->statements.push_back(std::any_cast<UnsafeBlockNode *>(visit(unsafeBlockCtx))); |
| 495 |
3/4✓ Branch 90 → 91 taken 119560 times.
✗ Branch 90 → 92 not taken.
✓ Branch 93 → 94 taken 62 times.
✓ Branch 93 → 99 taken 119498 times.
|
119560 | else if (auto *anonymousScopeCtx = dynamic_cast<SpiceParser::AnonymousBlockStmtContext *>(stmt)) |
| 496 |
3/6✓ Branch 94 → 95 taken 62 times.
✗ Branch 94 → 163 not taken.
✓ Branch 95 → 96 taken 62 times.
✗ Branch 95 → 161 not taken.
✓ Branch 96 → 97 taken 62 times.
✗ Branch 96 → 161 not taken.
|
62 | stmtLstNode->statements.push_back(std::any_cast<AnonymousBlockStmtNode *>(visit(anonymousScopeCtx))); |
| 497 | else | ||
| 498 | − | assert(dynamic_cast<TerminalNode *>(stmt) != nullptr); // GCOV_EXCL_LINE | |
| 499 | } | ||
| 500 | |||
| 501 |
1/2✓ Branch 120 → 121 taken 59747 times.
✗ Branch 120 → 166 not taken.
|
119494 | return concludeNode(stmtLstNode); |
| 502 | } | ||
| 503 | |||
| 504 | 22360 | std::any ASTBuilder::visitTypeLst(SpiceParser::TypeLstContext *ctx) { | |
| 505 | 22360 | const auto typeLstNode = createNode<TypeLstNode>(ctx); | |
| 506 | |||
| 507 | // Visit children | ||
| 508 |
3/6✓ Branch 3 → 4 taken 22360 times.
✗ Branch 3 → 18 not taken.
✓ Branch 4 → 5 taken 22360 times.
✗ Branch 4 → 16 not taken.
✓ Branch 6 → 7 taken 22360 times.
✗ Branch 6 → 19 not taken.
|
22360 | fetchChildrenIntoVector(typeLstNode->dataTypes, ctx->dataType()); |
| 509 | |||
| 510 |
1/2✓ Branch 12 → 13 taken 22360 times.
✗ Branch 12 → 19 not taken.
|
44720 | return concludeNode(typeLstNode); |
| 511 | } | ||
| 512 | |||
| 513 | 2847 | std::any ASTBuilder::visitTypeLstWithEllipsis(SpiceParser::TypeLstWithEllipsisContext *ctx) { | |
| 514 | 2847 | const auto typeLstWithEllipsisNode = createNode<TypeLstWithEllipsisNode>(ctx); | |
| 515 | |||
| 516 | // Visit children | ||
| 517 |
3/6✓ Branch 3 → 4 taken 2847 times.
✗ Branch 3 → 20 not taken.
✓ Branch 4 → 5 taken 2847 times.
✗ Branch 4 → 20 not taken.
✓ Branch 5 → 6 taken 2847 times.
✗ Branch 5 → 18 not taken.
|
2847 | typeLstWithEllipsisNode->typeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst())); |
| 518 | |||
| 519 | // Set some flags | ||
| 520 |
1/2✓ Branch 8 → 9 taken 2847 times.
✗ Branch 8 → 21 not taken.
|
2847 | typeLstWithEllipsisNode->hasEllipsis = ctx->ELLIPSIS() != nullptr; |
| 521 | |||
| 522 |
1/2✓ Branch 14 → 15 taken 2847 times.
✗ Branch 14 → 21 not taken.
|
5694 | return concludeNode(typeLstWithEllipsisNode); |
| 523 | } | ||
| 524 | |||
| 525 | 2044 | std::any ASTBuilder::visitTypeAltsLst(SpiceParser::TypeAltsLstContext *ctx) { | |
| 526 | 2044 | const auto typeAltsLstNode = createNode<TypeAltsLstNode>(ctx); | |
| 527 | |||
| 528 | // Visit children | ||
| 529 |
3/6✓ Branch 3 → 4 taken 2044 times.
✗ Branch 3 → 18 not taken.
✓ Branch 4 → 5 taken 2044 times.
✗ Branch 4 → 16 not taken.
✓ Branch 6 → 7 taken 2044 times.
✗ Branch 6 → 19 not taken.
|
2044 | fetchChildrenIntoVector(typeAltsLstNode->dataTypes, ctx->dataType()); |
| 530 | |||
| 531 |
1/2✓ Branch 12 → 13 taken 2044 times.
✗ Branch 12 → 19 not taken.
|
4088 | return concludeNode(typeAltsLstNode); |
| 532 | } | ||
| 533 | |||
| 534 | 24422 | std::any ASTBuilder::visitParamLst(SpiceParser::ParamLstContext *ctx) { | |
| 535 | 24422 | const auto paramLstNode = createNode<ParamLstNode>(ctx); | |
| 536 | |||
| 537 | // Visit children | ||
| 538 |
2/4✓ Branch 3 → 4 taken 24422 times.
✗ Branch 3 → 32 not taken.
✓ Branch 4 → 5 taken 24422 times.
✗ Branch 4 → 30 not taken.
|
24422 | fetchChildrenIntoVector(paramLstNode->params, ctx->declStmt()); |
| 539 | |||
| 540 | // Set some flags to later detect that the decl statements are parameters | ||
| 541 |
2/2✓ Branch 19 → 8 taken 35608 times.
✓ Branch 19 → 20 taken 24422 times.
|
84452 | for (DeclStmtNode *declStmt : paramLstNode->params) { |
| 542 | 35608 | declStmt->isFctParam = true; | |
| 543 | 35608 | declStmt->dataType->isParamType = true; | |
| 544 | } | ||
| 545 | |||
| 546 |
1/2✓ Branch 26 → 27 taken 24422 times.
✗ Branch 26 → 33 not taken.
|
48844 | return concludeNode(paramLstNode); |
| 547 | } | ||
| 548 | |||
| 549 | 43069 | std::any ASTBuilder::visitArgLst(SpiceParser::ArgLstContext *ctx) { | |
| 550 | 43069 | const auto argLstNode = createNode<ArgLstNode>(ctx); | |
| 551 | |||
| 552 | // Visit children | ||
| 553 |
2/4✓ Branch 3 → 4 taken 43069 times.
✗ Branch 3 → 20 not taken.
✓ Branch 4 → 5 taken 43069 times.
✗ Branch 4 → 18 not taken.
|
43069 | fetchChildrenIntoVector(argLstNode->args, ctx->assignExpr()); |
| 554 | 43069 | argLstNode->argInfos.reserve(argLstNode->args.size()); | |
| 555 | |||
| 556 |
1/2✓ Branch 14 → 15 taken 43069 times.
✗ Branch 14 → 21 not taken.
|
86138 | return concludeNode(argLstNode); |
| 557 | } | ||
| 558 | |||
| 559 | 373 | std::any ASTBuilder::visitEnumItemLst(SpiceParser::EnumItemLstContext *ctx) { | |
| 560 | 373 | const auto enumItemLstNode = createNode<EnumItemLstNode>(ctx); | |
| 561 | |||
| 562 | // Visit children | ||
| 563 |
3/6✓ Branch 3 → 4 taken 373 times.
✗ Branch 3 → 18 not taken.
✓ Branch 4 → 5 taken 373 times.
✗ Branch 4 → 16 not taken.
✓ Branch 6 → 7 taken 373 times.
✗ Branch 6 → 19 not taken.
|
373 | fetchChildrenIntoVector(enumItemLstNode->items, ctx->enumItem()); |
| 564 | |||
| 565 |
1/2✓ Branch 12 → 13 taken 373 times.
✗ Branch 12 → 19 not taken.
|
746 | return concludeNode(enumItemLstNode); |
| 566 | } | ||
| 567 | |||
| 568 | 4931 | std::any ASTBuilder::visitEnumItem(SpiceParser::EnumItemContext *ctx) { | |
| 569 | 4931 | const auto enumItemNode = createNode<EnumItemNode>(ctx); | |
| 570 | |||
| 571 | // Enrich | ||
| 572 |
2/4✓ Branch 3 → 4 taken 4931 times.
✗ Branch 3 → 22 not taken.
✓ Branch 4 → 5 taken 4931 times.
✗ Branch 4 → 22 not taken.
|
4931 | enumItemNode->itemName = getIdentifier(ctx->TYPE_IDENTIFIER(), false); |
| 573 |
2/2✓ Branch 8 → 9 taken 2642 times.
✓ Branch 8 → 12 taken 2289 times.
|
4931 | if (ctx->ASSIGN()) { |
| 574 | 2642 | enumItemNode->itemValue = parseInt(ctx->INT_LIT()); | |
| 575 | 2642 | enumItemNode->hasValue = true; | |
| 576 | } | ||
| 577 | |||
| 578 |
1/2✓ Branch 18 → 19 taken 4931 times.
✗ Branch 18 → 23 not taken.
|
9862 | return concludeNode(enumItemNode); |
| 579 | } | ||
| 580 | |||
| 581 | 5653 | std::any ASTBuilder::visitField(SpiceParser::FieldContext *ctx) { | |
| 582 | 5653 | const auto fieldNode = createNode<FieldNode>(ctx); | |
| 583 | |||
| 584 | // Enrich | ||
| 585 |
2/4✓ Branch 3 → 4 taken 5653 times.
✗ Branch 3 → 29 not taken.
✓ Branch 4 → 5 taken 5653 times.
✗ Branch 4 → 29 not taken.
|
5653 | fieldNode->fieldName = getIdentifier(ctx->IDENTIFIER(), false); |
| 586 | |||
| 587 | // Visit children | ||
| 588 |
3/6✓ Branch 7 → 8 taken 5653 times.
✗ Branch 7 → 32 not taken.
✓ Branch 8 → 9 taken 5653 times.
✗ Branch 8 → 32 not taken.
✓ Branch 9 → 10 taken 5653 times.
✗ Branch 9 → 30 not taken.
|
5653 | fieldNode->dataType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 589 | 5653 | fieldNode->dataType->setFieldTypeRecursive(); | |
| 590 |
2/2✓ Branch 13 → 14 taken 1769 times.
✓ Branch 13 → 19 taken 3884 times.
|
5653 | if (ctx->ternaryExpr()) |
| 591 |
3/6✓ Branch 14 → 15 taken 1769 times.
✗ Branch 14 → 35 not taken.
✓ Branch 15 → 16 taken 1769 times.
✗ Branch 15 → 35 not taken.
✓ Branch 16 → 17 taken 1769 times.
✗ Branch 16 → 33 not taken.
|
1769 | fieldNode->defaultValue = std::any_cast<ExprNode *>(visit(ctx->ternaryExpr())); |
| 592 | |||
| 593 |
1/2✓ Branch 25 → 26 taken 5653 times.
✗ Branch 25 → 36 not taken.
|
11306 | return concludeNode(fieldNode); |
| 594 | } | ||
| 595 | |||
| 596 | 2366 | std::any ASTBuilder::visitSignature(SpiceParser::SignatureContext *ctx) { | |
| 597 | 2366 | const auto signatureNode = createNode<SignatureNode>(ctx); | |
| 598 | |||
| 599 | // Extract method name | ||
| 600 |
2/4✓ Branch 3 → 4 taken 2366 times.
✗ Branch 3 → 73 not taken.
✓ Branch 4 → 5 taken 2366 times.
✗ Branch 4 → 73 not taken.
|
2366 | signatureNode->methodName = getIdentifier(ctx->IDENTIFIER(), false); |
| 601 | |||
| 602 | // Visit children | ||
| 603 |
2/2✓ Branch 8 → 9 taken 1907 times.
✓ Branch 8 → 14 taken 459 times.
|
2366 | if (ctx->qualifierLst()) { |
| 604 |
3/6✓ Branch 9 → 10 taken 1907 times.
✗ Branch 9 → 76 not taken.
✓ Branch 10 → 11 taken 1907 times.
✗ Branch 10 → 76 not taken.
✓ Branch 11 → 12 taken 1907 times.
✗ Branch 11 → 74 not taken.
|
1907 | signatureNode->qualifierLst = std::any_cast<QualifierLstNode *>(visit(ctx->qualifierLst())); |
| 605 | } | ||
| 606 |
2/2✓ Branch 15 → 16 taken 2236 times.
✓ Branch 15 → 22 taken 130 times.
|
2366 | if (ctx->F()) { |
| 607 | 2236 | signatureNode->hasReturnType = true; | |
| 608 | 2236 | signatureNode->signatureType = SignatureNode::SignatureType::TYPE_FUNCTION; | |
| 609 | 2236 | signatureNode->signatureQualifiers = TypeQualifiers::of(TY_FUNCTION); | |
| 610 |
3/6✓ Branch 17 → 18 taken 2236 times.
✗ Branch 17 → 79 not taken.
✓ Branch 18 → 19 taken 2236 times.
✗ Branch 18 → 79 not taken.
✓ Branch 19 → 20 taken 2236 times.
✗ Branch 19 → 77 not taken.
|
2236 | signatureNode->returnType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 611 | } else { | ||
| 612 | 130 | signatureNode->signatureType = SignatureNode::SignatureType::TYPE_PROCEDURE; | |
| 613 | 130 | signatureNode->signatureQualifiers = TypeQualifiers::of(TY_PROCEDURE); | |
| 614 | } | ||
| 615 |
10/16✓ Branch 24 → 25 taken 2236 times.
✓ Branch 24 → 28 taken 130 times.
✓ Branch 25 → 26 taken 2236 times.
✗ Branch 25 → 80 not taken.
✓ Branch 28 → 29 taken 130 times.
✗ Branch 28 → 80 not taken.
✓ Branch 31 → 32 taken 130 times.
✓ Branch 31 → 33 taken 2236 times.
✓ Branch 33 → 34 taken 2236 times.
✓ Branch 33 → 35 taken 130 times.
✓ Branch 35 → 36 taken 246 times.
✓ Branch 35 → 41 taken 2120 times.
✗ Branch 80 → 81 not taken.
✗ Branch 80 → 82 not taken.
✗ Branch 84 → 85 not taken.
✗ Branch 84 → 86 not taken.
|
2366 | if (ctx->F() ? ctx->LESS().size() == 2 : ctx->LESS().size() == 1) { |
| 616 | 246 | signatureNode->hasTemplateTypes = true; | |
| 617 |
3/6✓ Branch 36 → 37 taken 246 times.
✗ Branch 36 → 90 not taken.
✓ Branch 37 → 38 taken 246 times.
✗ Branch 37 → 90 not taken.
✓ Branch 38 → 39 taken 246 times.
✗ Branch 38 → 88 not taken.
|
246 | signatureNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst(0))); |
| 618 | } | ||
| 619 |
13/20✓ Branch 41 → 42 taken 2366 times.
✗ Branch 41 → 91 not taken.
✓ Branch 43 → 44 taken 2364 times.
✓ Branch 43 → 48 taken 2 times.
✓ Branch 44 → 45 taken 2364 times.
✗ Branch 44 → 91 not taken.
✓ Branch 46 → 47 taken 1685 times.
✓ Branch 46 → 49 taken 679 times.
✓ Branch 47 → 48 taken 1441 times.
✓ Branch 47 → 49 taken 244 times.
✓ Branch 50 → 51 taken 2364 times.
✓ Branch 50 → 52 taken 2 times.
✓ Branch 52 → 53 taken 2366 times.
✗ Branch 52 → 54 not taken.
✓ Branch 54 → 55 taken 1443 times.
✓ Branch 54 → 63 taken 923 times.
✗ Branch 91 → 92 not taken.
✗ Branch 91 → 93 not taken.
✗ Branch 95 → 96 not taken.
✗ Branch 95 → 97 not taken.
|
2366 | if (ctx->typeLst().size() == 2 || (ctx->typeLst().size() == 1 && !signatureNode->hasTemplateTypes)) { |
| 620 | 1443 | signatureNode->hasParams = true; | |
| 621 |
5/8✓ Branch 55 → 56 taken 2 times.
✓ Branch 55 → 57 taken 1441 times.
✓ Branch 58 → 59 taken 1443 times.
✗ Branch 58 → 101 not taken.
✓ Branch 59 → 60 taken 1443 times.
✗ Branch 59 → 101 not taken.
✓ Branch 60 → 61 taken 1443 times.
✗ Branch 60 → 99 not taken.
|
1443 | signatureNode->paramTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst(signatureNode->hasTemplateTypes ? 1 : 0))); |
| 622 | } | ||
| 623 | |||
| 624 |
1/2✓ Branch 69 → 70 taken 2366 times.
✗ Branch 69 → 102 not taken.
|
4732 | return concludeNode(signatureNode); |
| 625 | } | ||
| 626 | |||
| 627 | 84211 | std::any ASTBuilder::visitStmt(SpiceParser::StmtContext *ctx) { | |
| 628 |
2/2✓ Branch 3 → 4 taken 16060 times.
✓ Branch 3 → 11 taken 68151 times.
|
84211 | if (ctx->declStmt()) |
| 629 |
5/8✓ Branch 4 → 5 taken 16060 times.
✗ Branch 4 → 60 not taken.
✓ Branch 5 → 6 taken 16056 times.
✓ Branch 5 → 60 taken 4 times.
✓ Branch 6 → 7 taken 16056 times.
✗ Branch 6 → 58 not taken.
✓ Branch 7 → 8 taken 16056 times.
✗ Branch 7 → 58 not taken.
|
32116 | return static_cast<StmtNode *>(std::any_cast<DeclStmtNode *>(visit(ctx->declStmt()))); |
| 630 |
2/2✓ Branch 12 → 13 taken 40442 times.
✓ Branch 12 → 20 taken 27709 times.
|
68151 | if (ctx->exprStmt()) |
| 631 |
4/8✓ Branch 13 → 14 taken 40442 times.
✗ Branch 13 → 64 not taken.
✓ Branch 14 → 15 taken 40442 times.
✗ Branch 14 → 64 not taken.
✓ Branch 15 → 16 taken 40442 times.
✗ Branch 15 → 62 not taken.
✓ Branch 16 → 17 taken 40442 times.
✗ Branch 16 → 62 not taken.
|
80884 | return static_cast<StmtNode *>(std::any_cast<ExprStmtNode *>(visit(ctx->exprStmt()))); |
| 632 |
2/2✓ Branch 21 → 22 taken 27048 times.
✓ Branch 21 → 29 taken 661 times.
|
27709 | if (ctx->returnStmt()) |
| 633 |
4/8✓ Branch 22 → 23 taken 27048 times.
✗ Branch 22 → 68 not taken.
✓ Branch 23 → 24 taken 27048 times.
✗ Branch 23 → 68 not taken.
✓ Branch 24 → 25 taken 27048 times.
✗ Branch 24 → 66 not taken.
✓ Branch 25 → 26 taken 27048 times.
✗ Branch 25 → 66 not taken.
|
54096 | return static_cast<StmtNode *>(std::any_cast<ReturnStmtNode *>(visit(ctx->returnStmt()))); |
| 634 |
2/2✓ Branch 30 → 31 taken 244 times.
✓ Branch 30 → 38 taken 417 times.
|
661 | if (ctx->breakStmt()) |
| 635 |
4/8✓ Branch 31 → 32 taken 244 times.
✗ Branch 31 → 72 not taken.
✓ Branch 32 → 33 taken 244 times.
✗ Branch 32 → 72 not taken.
✓ Branch 33 → 34 taken 244 times.
✗ Branch 33 → 70 not taken.
✓ Branch 34 → 35 taken 244 times.
✗ Branch 34 → 70 not taken.
|
488 | return static_cast<StmtNode *>(std::any_cast<BreakStmtNode *>(visit(ctx->breakStmt()))); |
| 636 |
2/2✓ Branch 39 → 40 taken 411 times.
✓ Branch 39 → 47 taken 6 times.
|
417 | if (ctx->continueStmt()) |
| 637 |
4/8✓ Branch 40 → 41 taken 411 times.
✗ Branch 40 → 76 not taken.
✓ Branch 41 → 42 taken 411 times.
✗ Branch 41 → 76 not taken.
✓ Branch 42 → 43 taken 411 times.
✗ Branch 42 → 74 not taken.
✓ Branch 43 → 44 taken 411 times.
✗ Branch 43 → 74 not taken.
|
822 | return static_cast<StmtNode *>(std::any_cast<ContinueStmtNode *>(visit(ctx->continueStmt()))); |
| 638 |
1/2✓ Branch 48 → 49 taken 6 times.
✗ Branch 48 → 56 not taken.
|
6 | if (ctx->fallthroughStmt()) |
| 639 |
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()))); |
| 640 | − | assert_fail("Unknown statement type"); // GCOV_EXCL_LINE | |
| 641 | return nullptr; // GCOV_EXCL_LINE | ||
| 642 | } | ||
| 643 | |||
| 644 | 55452 | std::any ASTBuilder::visitDeclStmt(SpiceParser::DeclStmtContext *ctx) { | |
| 645 | 55452 | const auto declStmtNode = createNode<DeclStmtNode>(ctx); | |
| 646 | |||
| 647 | // Enrich | ||
| 648 |
3/4✓ Branch 3 → 4 taken 55452 times.
✗ Branch 3 → 28 not taken.
✓ Branch 4 → 5 taken 55451 times.
✓ Branch 4 → 28 taken 1 time.
|
55452 | declStmtNode->varName = getIdentifier(ctx->IDENTIFIER(), false); |
| 649 | |||
| 650 | // Visit children | ||
| 651 |
4/6✓ Branch 7 → 8 taken 55451 times.
✗ Branch 7 → 31 not taken.
✓ Branch 8 → 9 taken 55450 times.
✓ Branch 8 → 31 taken 1 time.
✓ Branch 9 → 10 taken 55450 times.
✗ Branch 9 → 29 not taken.
|
55451 | declStmtNode->dataType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 652 |
2/2✓ Branch 12 → 13 taken 20800 times.
✓ Branch 12 → 18 taken 34650 times.
|
55450 | if (ctx->assignExpr()) { |
| 653 | 20800 | declStmtNode->hasAssignment = true; | |
| 654 |
4/6✓ Branch 13 → 14 taken 20800 times.
✗ Branch 13 → 34 not taken.
✓ Branch 14 → 15 taken 20798 times.
✓ Branch 14 → 34 taken 2 times.
✓ Branch 15 → 16 taken 20798 times.
✗ Branch 15 → 32 not taken.
|
20800 | declStmtNode->assignExpr = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 655 | } | ||
| 656 | |||
| 657 |
1/2✓ Branch 24 → 25 taken 55448 times.
✗ Branch 24 → 35 not taken.
|
110896 | return concludeNode(declStmtNode); |
| 658 | } | ||
| 659 | |||
| 660 | 40442 | std::any ASTBuilder::visitExprStmt(SpiceParser::ExprStmtContext *ctx) { | |
| 661 | 40442 | const auto exprStmtNode = createNode<ExprStmtNode>(ctx); | |
| 662 | |||
| 663 | // Enrich | ||
| 664 |
4/8✓ Branch 3 → 4 taken 40442 times.
✗ Branch 3 → 19 not taken.
✓ Branch 4 → 5 taken 40442 times.
✗ Branch 4 → 19 not taken.
✓ Branch 5 → 6 taken 40442 times.
✗ Branch 5 → 17 not taken.
✓ Branch 7 → 8 taken 40442 times.
✗ Branch 7 → 20 not taken.
|
40442 | exprStmtNode->expr = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 665 | |||
| 666 |
1/2✓ Branch 13 → 14 taken 40442 times.
✗ Branch 13 → 20 not taken.
|
80884 | return concludeNode(exprStmtNode); |
| 667 | } | ||
| 668 | |||
| 669 | 86090 | std::any ASTBuilder::visitQualifierLst(SpiceParser::QualifierLstContext *ctx) { | |
| 670 | 86090 | const auto qualifierLstNode = createNode<QualifierLstNode>(ctx); | |
| 671 | |||
| 672 | // Visit children | ||
| 673 |
2/4✓ Branch 3 → 4 taken 86090 times.
✗ Branch 3 → 45 not taken.
✓ Branch 4 → 5 taken 86090 times.
✗ Branch 4 → 43 not taken.
|
86090 | fetchChildrenIntoVector(qualifierLstNode->qualifiers, ctx->qualifier()); |
| 674 | |||
| 675 | // Check if qualifier combination is invalid | ||
| 676 | 86090 | bool seenSignedOrUnsigned = false; | |
| 677 |
2/2✓ Branch 32 → 8 taken 101510 times.
✓ Branch 32 → 33 taken 86089 times.
|
273689 | for (const QualifierNode *qualifier : qualifierLstNode->qualifiers) { |
| 678 | // Check if we have both, signed and unsigned qualifier | ||
| 679 |
2/2✓ Branch 10 → 11 taken 101503 times.
✓ Branch 10 → 13 taken 7 times.
|
101510 | if (qualifier->type != QualifierNode::QualifierType::TY_SIGNED && |
| 680 |
2/2✓ Branch 11 → 12 taken 80446 times.
✓ Branch 11 → 13 taken 21057 times.
|
101503 | qualifier->type != QualifierNode::QualifierType::TY_UNSIGNED) |
| 681 | 80446 | continue; | |
| 682 |
2/2✓ Branch 13 → 14 taken 1 time.
✓ Branch 13 → 22 taken 21063 times.
|
21064 | if (seenSignedOrUnsigned) |
| 683 |
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"); |
| 684 | 21063 | seenSignedOrUnsigned = true; | |
| 685 | } | ||
| 686 | |||
| 687 |
1/2✓ Branch 39 → 40 taken 86089 times.
✗ Branch 39 → 56 not taken.
|
172178 | return concludeNode(qualifierLstNode); |
| 688 | } | ||
| 689 | |||
| 690 | 101510 | std::any ASTBuilder::visitQualifier(SpiceParser::QualifierContext *ctx) { | |
| 691 | 101510 | const auto qualifierNode = createNode<QualifierNode>(ctx); | |
| 692 | |||
| 693 |
3/4✓ Branch 7 → 8 taken 101510 times.
✗ Branch 7 → 9 not taken.
✓ Branch 40 → 5 taken 101510 times.
✓ Branch 40 → 41 taken 101510 times.
|
406040 | for (ParserRuleContext::ParseTree *subTree : ctx->children) { |
| 694 | 101510 | const auto token = spice_pointer_cast<TerminalNode *>(subTree); | |
| 695 |
2/4✓ Branch 14 → 15 taken 101510 times.
✗ Branch 14 → 51 not taken.
✓ Branch 15 → 16 taken 101510 times.
✗ Branch 15 → 51 not taken.
|
101510 | const size_t symbolType = token->getSymbol()->getType(); |
| 696 |
2/2✓ Branch 16 → 17 taken 21973 times.
✓ Branch 16 → 18 taken 79537 times.
|
101510 | if (symbolType == SpiceParser::CONST) |
| 697 | 21973 | qualifierNode->type = QualifierNode::QualifierType::TY_CONST; | |
| 698 |
2/2✓ Branch 18 → 19 taken 7 times.
✓ Branch 18 → 20 taken 79530 times.
|
79537 | else if (symbolType == SpiceParser::SIGNED) |
| 699 | 7 | qualifierNode->type = QualifierNode::QualifierType::TY_SIGNED; | |
| 700 |
2/2✓ Branch 20 → 21 taken 21057 times.
✓ Branch 20 → 22 taken 58473 times.
|
79530 | else if (symbolType == SpiceParser::UNSIGNED) |
| 701 | 21057 | qualifierNode->type = QualifierNode::QualifierType::TY_UNSIGNED; | |
| 702 |
2/2✓ Branch 22 → 23 taken 6985 times.
✓ Branch 22 → 24 taken 51488 times.
|
58473 | else if (symbolType == SpiceParser::INLINE) |
| 703 | 6985 | qualifierNode->type = QualifierNode::QualifierType::TY_INLINE; | |
| 704 |
2/2✓ Branch 24 → 25 taken 39412 times.
✓ Branch 24 → 26 taken 12076 times.
|
51488 | else if (symbolType == SpiceParser::PUBLIC) |
| 705 | 39412 | qualifierNode->type = QualifierNode::QualifierType::TY_PUBLIC; | |
| 706 |
2/2✓ Branch 26 → 27 taken 10818 times.
✓ Branch 26 → 28 taken 1258 times.
|
12076 | else if (symbolType == SpiceParser::HEAP) |
| 707 | 10818 | qualifierNode->type = QualifierNode::QualifierType::TY_HEAP; | |
| 708 |
1/2✓ Branch 28 → 29 taken 1258 times.
✗ Branch 28 → 30 not taken.
|
1258 | else if (symbolType == SpiceParser::COMPOSE) |
| 709 | 1258 | qualifierNode->type = QualifierNode::QualifierType::TY_COMPOSITION; | |
| 710 | else | ||
| 711 | − | assert_fail("Unknown qualifier type"); // GCOV_EXCL_LINE | |
| 712 | } | ||
| 713 | |||
| 714 |
1/2✓ Branch 47 → 48 taken 101510 times.
✗ Branch 47 → 52 not taken.
|
203020 | return concludeNode(qualifierNode); |
| 715 | } | ||
| 716 | |||
| 717 | 728 | std::any ASTBuilder::visitModAttr(SpiceParser::ModAttrContext *ctx) { | |
| 718 | 728 | const auto modAttrNode = createNode<ModAttrNode>(ctx); | |
| 719 | |||
| 720 | // Visit children | ||
| 721 |
4/6✓ Branch 3 → 4 taken 728 times.
✗ Branch 3 → 33 not taken.
✓ Branch 4 → 5 taken 727 times.
✓ Branch 4 → 33 taken 1 time.
✓ Branch 5 → 6 taken 727 times.
✗ Branch 5 → 31 not taken.
|
728 | modAttrNode->attrLst = std::any_cast<AttrLstNode *>(visit(ctx->attrLst())); |
| 722 | |||
| 723 | // Tell the attributes that they are module attributes | ||
| 724 |
2/2✓ Branch 20 → 9 taken 2361 times.
✓ Branch 20 → 21 taken 727 times.
|
3815 | for (AttrNode *attr : modAttrNode->attrLst->attributes) |
| 725 | 2361 | attr->target = AttrNode::TARGET_MODULE; | |
| 726 | |||
| 727 |
1/2✓ Branch 27 → 28 taken 727 times.
✗ Branch 27 → 34 not taken.
|
1454 | return concludeNode(modAttrNode); |
| 728 | } | ||
| 729 | |||
| 730 | 990 | std::any ASTBuilder::visitTopLevelDefAttr(SpiceParser::TopLevelDefAttrContext *ctx) { | |
| 731 | 990 | const auto fctAttrNode = createNode<TopLevelDefAttrNode>(ctx); | |
| 732 | |||
| 733 | // Visit children | ||
| 734 |
4/8✓ Branch 3 → 4 taken 990 times.
✗ Branch 3 → 19 not taken.
✓ Branch 4 → 5 taken 990 times.
✗ Branch 4 → 19 not taken.
✓ Branch 5 → 6 taken 990 times.
✗ Branch 5 → 17 not taken.
✓ Branch 7 → 8 taken 990 times.
✗ Branch 7 → 20 not taken.
|
990 | fctAttrNode->attrLst = std::any_cast<AttrLstNode *>(visit(ctx->attrLst())); |
| 735 | |||
| 736 |
1/2✓ Branch 13 → 14 taken 990 times.
✗ Branch 13 → 20 not taken.
|
1980 | return concludeNode(fctAttrNode); |
| 737 | } | ||
| 738 | |||
| 739 | 6 | std::any ASTBuilder::visitLambdaAttr(SpiceParser::LambdaAttrContext *ctx) { | |
| 740 | 6 | const auto lambdaAttrNode = createNode<LambdaAttrNode>(ctx); | |
| 741 | |||
| 742 | // Visit children | ||
| 743 |
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())); |
| 744 | |||
| 745 | // Tell the attributes that they are module attributes | ||
| 746 |
2/2✓ Branch 20 → 9 taken 6 times.
✓ Branch 20 → 21 taken 6 times.
|
18 | for (AttrNode *attr : lambdaAttrNode->attrLst->attributes) |
| 747 | 6 | attr->target = AttrNode::TARGET_LAMBDA; | |
| 748 | |||
| 749 |
1/2✓ Branch 27 → 28 taken 6 times.
✗ Branch 27 → 34 not taken.
|
12 | return concludeNode(lambdaAttrNode); |
| 750 | } | ||
| 751 | |||
| 752 | 1724 | std::any ASTBuilder::visitAttrLst(SpiceParser::AttrLstContext *ctx) { | |
| 753 | 1724 | const auto attrLstNode = createNode<AttrLstNode>(ctx); | |
| 754 | |||
| 755 | // Visit children | ||
| 756 |
4/6✓ Branch 3 → 4 taken 1724 times.
✗ Branch 3 → 18 not taken.
✓ Branch 4 → 5 taken 1723 times.
✓ Branch 4 → 16 taken 1 time.
✓ Branch 6 → 7 taken 1723 times.
✗ Branch 6 → 19 not taken.
|
1725 | fetchChildrenIntoVector(attrLstNode->attributes, ctx->attr()); |
| 757 | |||
| 758 |
1/2✓ Branch 12 → 13 taken 1723 times.
✗ Branch 12 → 19 not taken.
|
3446 | return concludeNode(attrLstNode); |
| 759 | } | ||
| 760 | |||
| 761 | 3460 | std::any ASTBuilder::visitAttr(SpiceParser::AttrContext *ctx) { | |
| 762 |
1/2✓ Branch 2 → 3 taken 3460 times.
✗ Branch 2 → 83 not taken.
|
3460 | const auto attrNode = createNode<AttrNode>(ctx); |
| 763 | |||
| 764 | // Extract key | ||
| 765 |
1/2✓ Branch 3 → 4 taken 3460 times.
✗ Branch 3 → 83 not taken.
|
3460 | std::stringstream key; |
| 766 |
3/4✓ Branch 12 → 13 taken 12535 times.
✗ Branch 12 → 66 not taken.
✓ Branch 15 → 5 taken 9075 times.
✓ Branch 15 → 16 taken 3460 times.
|
12535 | for (size_t i = 0; i < ctx->IDENTIFIER().size(); i++) { |
| 767 |
2/2✓ Branch 5 → 6 taken 5615 times.
✓ Branch 5 → 7 taken 3460 times.
|
9075 | if (i > 0) |
| 768 |
1/2✓ Branch 6 → 7 taken 5615 times.
✗ Branch 6 → 81 not taken.
|
5615 | key << MEMBER_ACCESS_TOKEN; |
| 769 |
3/6✓ Branch 7 → 8 taken 9075 times.
✗ Branch 7 → 65 not taken.
✓ Branch 8 → 9 taken 9075 times.
✗ Branch 8 → 65 not taken.
✓ Branch 9 → 10 taken 9075 times.
✗ Branch 9 → 63 not taken.
|
9075 | key << ctx->IDENTIFIER(i)->getText(); |
| 770 | } | ||
| 771 |
1/2✓ Branch 16 → 17 taken 3460 times.
✗ Branch 16 → 67 not taken.
|
3460 | attrNode->key = key.str(); |
| 772 | |||
| 773 | // Visit children | ||
| 774 |
3/4✓ Branch 19 → 20 taken 3460 times.
✗ Branch 19 → 81 not taken.
✓ Branch 20 → 21 taken 2723 times.
✓ Branch 20 → 51 taken 737 times.
|
3460 | if (ctx->constant()) { |
| 775 |
3/6✓ Branch 21 → 22 taken 2723 times.
✗ Branch 21 → 70 not taken.
✓ Branch 22 → 23 taken 2723 times.
✗ Branch 22 → 70 not taken.
✓ Branch 23 → 24 taken 2723 times.
✗ Branch 23 → 68 not taken.
|
2723 | attrNode->value = std::any_cast<ConstantNode *>(visit(ctx->constant())); |
| 776 | |||
| 777 |
4/6✓ Branch 25 → 26 taken 2723 times.
✗ Branch 25 → 81 not taken.
✓ Branch 26 → 27 taken 2723 times.
✗ Branch 26 → 81 not taken.
✓ Branch 27 → 28 taken 1754 times.
✓ Branch 27 → 29 taken 969 times.
|
2723 | if (ctx->constant()->STRING_LIT()) |
| 778 | 1754 | attrNode->type = AttrNode::AttrType::TYPE_STRING; | |
| 779 |
4/6✓ Branch 29 → 30 taken 969 times.
✗ Branch 29 → 81 not taken.
✓ Branch 30 → 31 taken 969 times.
✗ Branch 30 → 81 not taken.
✓ Branch 31 → 32 taken 160 times.
✓ Branch 31 → 33 taken 809 times.
|
969 | else if (ctx->constant()->INT_LIT()) |
| 780 | 160 | attrNode->type = AttrNode::AttrType::TYPE_INT; | |
| 781 |
10/14✓ Branch 33 → 34 taken 809 times.
✗ Branch 33 → 81 not taken.
✓ Branch 34 → 35 taken 809 times.
✗ Branch 34 → 81 not taken.
✓ Branch 35 → 36 taken 5 times.
✓ Branch 35 → 39 taken 804 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 808 times.
✓ Branch 41 → 43 taken 1 time.
|
809 | else if (ctx->constant()->TRUE() || ctx->constant()->FALSE()) |
| 782 | 808 | attrNode->type = AttrNode::AttrType::TYPE_BOOL; | |
| 783 | else | ||
| 784 |
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"); |
| 785 | } else { | ||
| 786 | // If no value is given, use the bool type | ||
| 787 | 737 | attrNode->type = AttrNode::AttrType::TYPE_BOOL; | |
| 788 | } | ||
| 789 | |||
| 790 |
1/2✓ Branch 58 → 59 taken 3459 times.
✗ Branch 58 → 80 not taken.
|
6918 | return concludeNode(attrNode); |
| 791 | 3460 | } | |
| 792 | |||
| 793 | 848 | std::any ASTBuilder::visitCaseConstant(SpiceParser::CaseConstantContext *ctx) { | |
| 794 | 848 | const auto caseConstantNode = createNode<CaseConstantNode>(ctx); | |
| 795 | |||
| 796 | // Visit children | ||
| 797 |
2/2✓ Branch 4 → 5 taken 19 times.
✓ Branch 4 → 10 taken 829 times.
|
848 | if (ctx->constant()) { |
| 798 |
3/6✓ Branch 5 → 6 taken 19 times.
✗ Branch 5 → 65 not taken.
✓ Branch 6 → 7 taken 19 times.
✗ Branch 6 → 65 not taken.
✓ Branch 7 → 8 taken 19 times.
✗ Branch 7 → 63 not taken.
|
19 | caseConstantNode->constant = std::any_cast<ConstantNode *>(visit(ctx->constant())); |
| 799 |
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()) { |
| 800 |
1/2✓ Branch 14 → 15 taken 829 times.
✗ Branch 14 → 75 not taken.
|
829 | std::stringstream fqIdentifier; |
| 801 |
2/2✓ Branch 46 → 17 taken 2233 times.
✓ Branch 46 → 47 taken 829 times.
|
3891 | for (antlr4::tree::ParseTree *parseTree : ctx->children) { |
| 802 |
1/2✓ Branch 19 → 20 taken 2233 times.
✗ Branch 19 → 21 not taken.
|
2233 | const auto terminal = dynamic_cast<TerminalNode *>(parseTree); |
| 803 |
1/2✗ Branch 22 → 23 not taken.
✓ Branch 22 → 24 taken 2233 times.
|
2233 | if (!terminal) |
| 804 | ✗ | continue; | |
| 805 | |||
| 806 |
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(); |
| 807 |
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) { |
| 808 |
1/2✓ Branch 28 → 29 taken 1531 times.
✗ Branch 28 → 70 not taken.
|
1531 | const std::string fragment = getIdentifier(terminal, false); |
| 809 |
1/2✓ Branch 29 → 30 taken 1531 times.
✗ Branch 29 → 68 not taken.
|
1531 | caseConstantNode->identifierFragments.push_back(fragment); |
| 810 |
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) |
| 811 |
1/2✓ Branch 33 → 34 taken 702 times.
✗ Branch 33 → 68 not taken.
|
702 | fqIdentifier << SCOPE_ACCESS_TOKEN; |
| 812 |
1/2✓ Branch 34 → 35 taken 1531 times.
✗ Branch 34 → 68 not taken.
|
1531 | fqIdentifier << fragment; |
| 813 | 1531 | } | |
| 814 | } | ||
| 815 |
1/2✓ Branch 47 → 48 taken 829 times.
✗ Branch 47 → 72 not taken.
|
829 | caseConstantNode->fqIdentifier = fqIdentifier.str(); |
| 816 | 829 | } else { | |
| 817 | − | assert_fail("Unknown case constant type"); // GCOV_EXCL_LINE | |
| 818 | } | ||
| 819 | |||
| 820 |
1/2✓ Branch 59 → 60 taken 848 times.
✗ Branch 59 → 76 not taken.
|
1696 | return concludeNode(caseConstantNode); |
| 821 | } | ||
| 822 | |||
| 823 | 27048 | std::any ASTBuilder::visitReturnStmt(SpiceParser::ReturnStmtContext *ctx) { | |
| 824 | 27048 | const auto returnStmtNode = createNode<ReturnStmtNode>(ctx); | |
| 825 | |||
| 826 | // Visit children | ||
| 827 |
2/2✓ Branch 4 → 5 taken 25010 times.
✓ Branch 4 → 10 taken 2038 times.
|
27048 | if (ctx->assignExpr()) { |
| 828 | 25010 | returnStmtNode->hasReturnValue = true; | |
| 829 |
3/6✓ Branch 5 → 6 taken 25010 times.
✗ Branch 5 → 22 not taken.
✓ Branch 6 → 7 taken 25010 times.
✗ Branch 6 → 22 not taken.
✓ Branch 7 → 8 taken 25010 times.
✗ Branch 7 → 20 not taken.
|
25010 | returnStmtNode->assignExpr = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 830 | } | ||
| 831 | |||
| 832 |
1/2✓ Branch 16 → 17 taken 27048 times.
✗ Branch 16 → 23 not taken.
|
54096 | return concludeNode(returnStmtNode); |
| 833 | } | ||
| 834 | |||
| 835 | 244 | std::any ASTBuilder::visitBreakStmt(SpiceParser::BreakStmtContext *ctx) { | |
| 836 | 244 | const auto breakStmtNode = createNode<BreakStmtNode>(ctx); | |
| 837 | |||
| 838 | // Extract number of breaks | ||
| 839 |
2/2✓ Branch 4 → 5 taken 7 times.
✓ Branch 4 → 10 taken 237 times.
|
244 | if (ctx->INT_LIT()) |
| 840 |
3/6✓ Branch 5 → 6 taken 7 times.
✗ Branch 5 → 24 not taken.
✓ Branch 6 → 7 taken 7 times.
✗ Branch 6 → 24 not taken.
✓ Branch 7 → 8 taken 7 times.
✗ Branch 7 → 22 not taken.
|
7 | breakStmtNode->breakTimes = std::stoi(ctx->INT_LIT()->toString()); |
| 841 | |||
| 842 | // Visit children | ||
| 843 |
2/4✓ Branch 10 → 11 taken 244 times.
✗ Branch 10 → 25 not taken.
✓ Branch 12 → 13 taken 244 times.
✗ Branch 12 → 26 not taken.
|
244 | visitChildren(ctx); |
| 844 | |||
| 845 |
1/2✓ Branch 18 → 19 taken 244 times.
✗ Branch 18 → 26 not taken.
|
488 | return concludeNode(breakStmtNode); |
| 846 | } | ||
| 847 | |||
| 848 | 411 | std::any ASTBuilder::visitContinueStmt(SpiceParser::ContinueStmtContext *ctx) { | |
| 849 | 411 | const auto continueStmtNode = createNode<ContinueStmtNode>(ctx); | |
| 850 | |||
| 851 | // Extract number of continues | ||
| 852 |
2/2✓ Branch 4 → 5 taken 348 times.
✓ Branch 4 → 10 taken 63 times.
|
411 | if (ctx->INT_LIT()) |
| 853 |
3/6✓ Branch 5 → 6 taken 348 times.
✗ Branch 5 → 24 not taken.
✓ Branch 6 → 7 taken 348 times.
✗ Branch 6 → 24 not taken.
✓ Branch 7 → 8 taken 348 times.
✗ Branch 7 → 22 not taken.
|
348 | continueStmtNode->continueTimes = std::stoi(ctx->INT_LIT()->toString()); |
| 854 | |||
| 855 | // Visit children | ||
| 856 |
2/4✓ Branch 10 → 11 taken 411 times.
✗ Branch 10 → 25 not taken.
✓ Branch 12 → 13 taken 411 times.
✗ Branch 12 → 26 not taken.
|
411 | visitChildren(ctx); |
| 857 | |||
| 858 |
1/2✓ Branch 18 → 19 taken 411 times.
✗ Branch 18 → 26 not taken.
|
822 | return concludeNode(continueStmtNode); |
| 859 | } | ||
| 860 | |||
| 861 | 6 | std::any ASTBuilder::visitFallthroughStmt(SpiceParser::FallthroughStmtContext *ctx) { | |
| 862 | 6 | const auto fallthroughStmtNode = createNode<FallthroughStmtNode>(ctx); | |
| 863 | |||
| 864 | // Visit children | ||
| 865 |
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); |
| 866 | |||
| 867 |
1/2✓ Branch 11 → 12 taken 6 times.
✗ Branch 11 → 16 not taken.
|
12 | return concludeNode(fallthroughStmtNode); |
| 868 | } | ||
| 869 | |||
| 870 | 3435 | std::any ASTBuilder::visitAssertStmt(SpiceParser::AssertStmtContext *ctx) { | |
| 871 |
1/2✓ Branch 2 → 3 taken 3435 times.
✗ Branch 2 → 30 not taken.
|
3435 | const auto assertStmtNode = createNode<AssertStmtNode>(ctx); |
| 872 | |||
| 873 | // Enrich | ||
| 874 |
5/10✓ Branch 3 → 4 taken 3435 times.
✗ Branch 3 → 30 not taken.
✓ Branch 4 → 5 taken 3435 times.
✗ Branch 4 → 30 not taken.
✓ Branch 5 → 6 taken 3435 times.
✗ Branch 5 → 30 not taken.
✓ Branch 6 → 7 taken 3435 times.
✗ Branch 6 → 30 not taken.
✓ Branch 7 → 8 taken 3435 times.
✗ Branch 7 → 30 not taken.
|
3435 | const antlr4::misc::Interval interval(ctx->assignExpr()->start->getStartIndex(), ctx->assignExpr()->stop->getStopIndex()); |
| 875 |
1/2✓ Branch 8 → 9 taken 3435 times.
✗ Branch 8 → 25 not taken.
|
3435 | assertStmtNode->expressionString = inputStream->getText(interval); |
| 876 | |||
| 877 | // Visit children | ||
| 878 |
4/8✓ Branch 11 → 12 taken 3435 times.
✗ Branch 11 → 28 not taken.
✓ Branch 12 → 13 taken 3435 times.
✗ Branch 12 → 28 not taken.
✓ Branch 13 → 14 taken 3435 times.
✗ Branch 13 → 26 not taken.
✓ Branch 15 → 16 taken 3435 times.
✗ Branch 15 → 29 not taken.
|
3435 | assertStmtNode->assignExpr = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 879 | |||
| 880 |
1/2✓ Branch 21 → 22 taken 3435 times.
✗ Branch 21 → 29 not taken.
|
6870 | return concludeNode(assertStmtNode); |
| 881 | } | ||
| 882 | |||
| 883 | 214545 | std::any ASTBuilder::visitAssignExpr(SpiceParser::AssignExprContext *ctx) { | |
| 884 |
2/2✓ Branch 3 → 4 taken 193699 times.
✓ Branch 3 → 6 taken 20846 times.
|
214545 | if (!ctx->assignOp()) |
| 885 | 193699 | return visit(ctx->ternaryExpr()); | |
| 886 | |||
| 887 | 20846 | const auto assignExprNode = createNode<AssignExprNode>(ctx); | |
| 888 | |||
| 889 | // Visit children | ||
| 890 |
1/2✗ Branch 8 → 9 not taken.
✓ Branch 8 → 14 taken 20846 times.
|
20846 | if (ctx->ternaryExpr()) { |
| 891 | ✗ | assignExprNode->ternaryExpr = std::any_cast<ExprNode *>(visit(ctx->ternaryExpr())); | |
| 892 |
1/2✓ Branch 15 → 16 taken 20846 times.
✗ Branch 15 → 28 not taken.
|
20846 | } else if (ctx->prefixUnaryExpr()) { |
| 893 |
3/6✓ Branch 16 → 17 taken 20846 times.
✗ Branch 16 → 44 not taken.
✓ Branch 17 → 18 taken 20846 times.
✗ Branch 17 → 44 not taken.
✓ Branch 18 → 19 taken 20846 times.
✗ Branch 18 → 42 not taken.
|
20846 | assignExprNode->lhs = std::any_cast<ExprNode *>(visit(ctx->prefixUnaryExpr())); |
| 894 |
2/4✓ Branch 20 → 21 taken 20846 times.
✗ Branch 20 → 45 not taken.
✓ Branch 21 → 22 taken 20846 times.
✗ Branch 21 → 45 not taken.
|
20846 | visit(ctx->assignOp()); |
| 895 |
3/6✓ Branch 23 → 24 taken 20846 times.
✗ Branch 23 → 48 not taken.
✓ Branch 24 → 25 taken 20846 times.
✗ Branch 24 → 48 not taken.
✓ Branch 25 → 26 taken 20846 times.
✗ Branch 25 → 46 not taken.
|
20846 | assignExprNode->rhs = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 896 | } else { | ||
| 897 | − | assert_fail("Invalid assign expression"); // GCOV_EXCL_LINE | |
| 898 | } | ||
| 899 | |||
| 900 |
1/2✓ Branch 35 → 36 taken 20846 times.
✗ Branch 35 → 49 not taken.
|
41692 | return concludeExprNode(assignExprNode); |
| 901 | } | ||
| 902 | |||
| 903 | 195468 | std::any ASTBuilder::visitTernaryExpr(SpiceParser::TernaryExprContext *ctx) { | |
| 904 |
3/4✓ Branch 2 → 3 taken 195468 times.
✗ Branch 2 → 45 not taken.
✓ Branch 5 → 6 taken 193513 times.
✓ Branch 5 → 8 taken 1955 times.
|
195468 | if (ctx->logicalOrExpr().size() == 1) |
| 905 | 193513 | return visit(ctx->logicalOrExpr(0)); | |
| 906 | |||
| 907 | 1955 | const auto ternaryExprNode = createNode<TernaryExprNode>(ctx); | |
| 908 | |||
| 909 |
3/6✓ Branch 9 → 10 taken 1955 times.
✗ Branch 9 → 48 not taken.
✓ Branch 10 → 11 taken 1955 times.
✗ Branch 10 → 48 not taken.
✓ Branch 11 → 12 taken 1955 times.
✗ Branch 11 → 46 not taken.
|
1955 | ternaryExprNode->condition = std::any_cast<ExprNode *>(visit(ctx->logicalOrExpr(0))); |
| 910 |
3/4✓ Branch 13 → 14 taken 1955 times.
✗ Branch 13 → 49 not taken.
✓ Branch 16 → 17 taken 1954 times.
✓ Branch 16 → 26 taken 1 time.
|
1955 | if (ctx->logicalOrExpr().size() == 3) { |
| 911 |
3/6✓ Branch 17 → 18 taken 1954 times.
✗ Branch 17 → 52 not taken.
✓ Branch 18 → 19 taken 1954 times.
✗ Branch 18 → 52 not taken.
✓ Branch 19 → 20 taken 1954 times.
✗ Branch 19 → 50 not taken.
|
1954 | ternaryExprNode->trueExpr = std::any_cast<ExprNode *>(visit(ctx->logicalOrExpr(1))); |
| 912 |
3/6✓ Branch 21 → 22 taken 1954 times.
✗ Branch 21 → 55 not taken.
✓ Branch 22 → 23 taken 1954 times.
✗ Branch 22 → 55 not taken.
✓ Branch 23 → 24 taken 1954 times.
✗ Branch 23 → 53 not taken.
|
1954 | ternaryExprNode->falseExpr = std::any_cast<ExprNode *>(visit(ctx->logicalOrExpr(2))); |
| 913 |
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) { |
| 914 | 1 | ternaryExprNode->isShortened = true; | |
| 915 |
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))); |
| 916 | } | ||
| 917 | |||
| 918 |
1/2✓ Branch 41 → 42 taken 1955 times.
✗ Branch 41 → 60 not taken.
|
3910 | return concludeExprNode(ternaryExprNode); |
| 919 | } | ||
| 920 | |||
| 921 | 199377 | std::any ASTBuilder::visitLogicalOrExpr(SpiceParser::LogicalOrExprContext *ctx) { | |
| 922 |
3/4✓ Branch 2 → 3 taken 199377 times.
✗ Branch 2 → 22 not taken.
✓ Branch 5 → 6 taken 197140 times.
✓ Branch 5 → 8 taken 2237 times.
|
199377 | if (ctx->logicalAndExpr().size() == 1) |
| 923 | 197140 | return visit(ctx->logicalAndExpr(0)); | |
| 924 | |||
| 925 | 2237 | const auto logicalOrExprNode = createNode<LogicalOrExprNode>(ctx); | |
| 926 | |||
| 927 | // Visit children | ||
| 928 |
3/6✓ Branch 9 → 10 taken 2237 times.
✗ Branch 9 → 25 not taken.
✓ Branch 10 → 11 taken 2237 times.
✗ Branch 10 → 23 not taken.
✓ Branch 12 → 13 taken 2237 times.
✗ Branch 12 → 26 not taken.
|
2237 | fetchChildrenIntoVector(logicalOrExprNode->operands, ctx->logicalAndExpr()); |
| 929 | |||
| 930 |
1/2✓ Branch 18 → 19 taken 2237 times.
✗ Branch 18 → 26 not taken.
|
4474 | return concludeExprNode(logicalOrExprNode); |
| 931 | } | ||
| 932 | |||
| 933 | 202270 | std::any ASTBuilder::visitLogicalAndExpr(SpiceParser::LogicalAndExprContext *ctx) { | |
| 934 |
3/4✓ Branch 2 → 3 taken 202270 times.
✗ Branch 2 → 22 not taken.
✓ Branch 5 → 6 taken 201064 times.
✓ Branch 5 → 8 taken 1206 times.
|
202270 | if (ctx->bitwiseOrExpr().size() == 1) |
| 935 | 201064 | return visit(ctx->bitwiseOrExpr(0)); | |
| 936 | |||
| 937 | 1206 | const auto logicalAndExprNode = createNode<LogicalAndExprNode>(ctx); | |
| 938 | |||
| 939 | // Visit children | ||
| 940 |
3/6✓ Branch 9 → 10 taken 1206 times.
✗ Branch 9 → 25 not taken.
✓ Branch 10 → 11 taken 1206 times.
✗ Branch 10 → 23 not taken.
✓ Branch 12 → 13 taken 1206 times.
✗ Branch 12 → 26 not taken.
|
1206 | fetchChildrenIntoVector(logicalAndExprNode->operands, ctx->bitwiseOrExpr()); |
| 941 | |||
| 942 |
1/2✓ Branch 18 → 19 taken 1206 times.
✗ Branch 18 → 26 not taken.
|
2412 | return concludeExprNode(logicalAndExprNode); |
| 943 | } | ||
| 944 | |||
| 945 | 203835 | std::any ASTBuilder::visitBitwiseOrExpr(SpiceParser::BitwiseOrExprContext *ctx) { | |
| 946 |
3/4✓ Branch 2 → 3 taken 203835 times.
✗ Branch 2 → 22 not taken.
✓ Branch 5 → 6 taken 203550 times.
✓ Branch 5 → 8 taken 285 times.
|
203835 | if (ctx->bitwiseXorExpr().size() == 1) |
| 947 | 203550 | return visit(ctx->bitwiseXorExpr(0)); | |
| 948 | |||
| 949 | 285 | const auto bitwiseOrExprNode = createNode<BitwiseOrExprNode>(ctx); | |
| 950 | |||
| 951 | // Visit children | ||
| 952 |
3/6✓ Branch 9 → 10 taken 285 times.
✗ Branch 9 → 25 not taken.
✓ Branch 10 → 11 taken 285 times.
✗ Branch 10 → 23 not taken.
✓ Branch 12 → 13 taken 285 times.
✗ Branch 12 → 26 not taken.
|
285 | fetchChildrenIntoVector(bitwiseOrExprNode->operands, ctx->bitwiseXorExpr()); |
| 953 | |||
| 954 |
1/2✓ Branch 18 → 19 taken 285 times.
✗ Branch 18 → 26 not taken.
|
570 | return concludeExprNode(bitwiseOrExprNode); |
| 955 | } | ||
| 956 | |||
| 957 | 204121 | std::any ASTBuilder::visitBitwiseXorExpr(SpiceParser::BitwiseXorExprContext *ctx) { | |
| 958 |
3/4✓ Branch 2 → 3 taken 204121 times.
✗ Branch 2 → 22 not taken.
✓ Branch 5 → 6 taken 204086 times.
✓ Branch 5 → 8 taken 35 times.
|
204121 | if (ctx->bitwiseAndExpr().size() == 1) |
| 959 | 204086 | return visit(ctx->bitwiseAndExpr(0)); | |
| 960 | |||
| 961 | 35 | const auto bitwiseXorExprNode = createNode<BitwiseXorExprNode>(ctx); | |
| 962 | |||
| 963 | // Visit children | ||
| 964 |
3/6✓ Branch 9 → 10 taken 35 times.
✗ Branch 9 → 25 not taken.
✓ Branch 10 → 11 taken 35 times.
✗ Branch 10 → 23 not taken.
✓ Branch 12 → 13 taken 35 times.
✗ Branch 12 → 26 not taken.
|
35 | fetchChildrenIntoVector(bitwiseXorExprNode->operands, ctx->bitwiseAndExpr()); |
| 965 | |||
| 966 |
1/2✓ Branch 18 → 19 taken 35 times.
✗ Branch 18 → 26 not taken.
|
70 | return concludeExprNode(bitwiseXorExprNode); |
| 967 | } | ||
| 968 | |||
| 969 | 204157 | std::any ASTBuilder::visitBitwiseAndExpr(SpiceParser::BitwiseAndExprContext *ctx) { | |
| 970 |
3/4✓ Branch 2 → 3 taken 204157 times.
✗ Branch 2 → 22 not taken.
✓ Branch 5 → 6 taken 204101 times.
✓ Branch 5 → 8 taken 56 times.
|
204157 | if (ctx->equalityExpr().size() == 1) |
| 971 | 204101 | return visit(ctx->equalityExpr(0)); | |
| 972 | |||
| 973 | 56 | const auto bitwiseAndExprNode = createNode<BitwiseAndExprNode>(ctx); | |
| 974 | |||
| 975 | // Visit children | ||
| 976 |
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()); |
| 977 | |||
| 978 |
1/2✓ Branch 18 → 19 taken 56 times.
✗ Branch 18 → 26 not taken.
|
112 | return concludeExprNode(bitwiseAndExprNode); |
| 979 | } | ||
| 980 | |||
| 981 | 204214 | std::any ASTBuilder::visitEqualityExpr(SpiceParser::EqualityExprContext *ctx) { | |
| 982 |
3/4✓ Branch 2 → 3 taken 204214 times.
✗ Branch 2 → 28 not taken.
✓ Branch 5 → 6 taken 187466 times.
✓ Branch 5 → 8 taken 16748 times.
|
204214 | if (ctx->relationalExpr().size() == 1) |
| 983 | 187466 | return visit(ctx->relationalExpr(0)); | |
| 984 | |||
| 985 | 16748 | const auto equalityExprNode = createNode<EqualityExprNode>(ctx); | |
| 986 | |||
| 987 | // Visit children | ||
| 988 |
2/4✓ Branch 9 → 10 taken 16748 times.
✗ Branch 9 → 31 not taken.
✓ Branch 10 → 11 taken 16748 times.
✗ Branch 10 → 29 not taken.
|
16748 | fetchChildrenIntoVector(equalityExprNode->operands, ctx->relationalExpr()); |
| 989 | |||
| 990 | // Extract operator | ||
| 991 |
2/2✓ Branch 13 → 14 taken 13192 times.
✓ Branch 13 → 15 taken 3556 times.
|
16748 | if (ctx->EQUAL()) |
| 992 | 13192 | equalityExprNode->op = EqualityExprNode::EqualityOp::OP_EQUAL; | |
| 993 |
1/2✓ Branch 16 → 17 taken 3556 times.
✗ Branch 16 → 18 not taken.
|
3556 | else if (ctx->NOT_EQUAL()) |
| 994 | 3556 | equalityExprNode->op = EqualityExprNode::EqualityOp::OP_NOT_EQUAL; | |
| 995 | |||
| 996 |
1/2✓ Branch 24 → 25 taken 16748 times.
✗ Branch 24 → 32 not taken.
|
33496 | return concludeExprNode(equalityExprNode); |
| 997 | } | ||
| 998 | |||
| 999 | 220962 | std::any ASTBuilder::visitRelationalExpr(SpiceParser::RelationalExprContext *ctx) { | |
| 1000 |
3/4✓ Branch 2 → 3 taken 220962 times.
✗ Branch 2 → 34 not taken.
✓ Branch 5 → 6 taken 212007 times.
✓ Branch 5 → 8 taken 8955 times.
|
220962 | if (ctx->shiftExpr().size() == 1) |
| 1001 | 212007 | return visit(ctx->shiftExpr(0)); | |
| 1002 | |||
| 1003 | 8955 | const auto relationalExprNode = createNode<RelationalExprNode>(ctx); | |
| 1004 | |||
| 1005 | // Visit children | ||
| 1006 |
2/4✓ Branch 9 → 10 taken 8955 times.
✗ Branch 9 → 37 not taken.
✓ Branch 10 → 11 taken 8955 times.
✗ Branch 10 → 35 not taken.
|
8955 | fetchChildrenIntoVector(relationalExprNode->operands, ctx->shiftExpr()); |
| 1007 | |||
| 1008 | // Extract operator | ||
| 1009 |
2/2✓ Branch 13 → 14 taken 4658 times.
✓ Branch 13 → 15 taken 4297 times.
|
8955 | if (ctx->LESS()) |
| 1010 | 4658 | relationalExprNode->op = RelationalExprNode::RelationalOp::OP_LESS; | |
| 1011 |
2/2✓ Branch 16 → 17 taken 1684 times.
✓ Branch 16 → 18 taken 2613 times.
|
4297 | else if (ctx->GREATER()) |
| 1012 | 1684 | relationalExprNode->op = RelationalExprNode::RelationalOp::OP_GREATER; | |
| 1013 |
2/2✓ Branch 19 → 20 taken 877 times.
✓ Branch 19 → 21 taken 1736 times.
|
2613 | else if (ctx->LESS_EQUAL()) |
| 1014 | 877 | relationalExprNode->op = RelationalExprNode::RelationalOp::OP_LESS_EQUAL; | |
| 1015 |
1/2✓ Branch 22 → 23 taken 1736 times.
✗ Branch 22 → 24 not taken.
|
1736 | else if (ctx->GREATER_EQUAL()) |
| 1016 | 1736 | relationalExprNode->op = RelationalExprNode::RelationalOp::OP_GREATER_EQUAL; | |
| 1017 | |||
| 1018 |
1/2✓ Branch 30 → 31 taken 8955 times.
✗ Branch 30 → 38 not taken.
|
17910 | return concludeExprNode(relationalExprNode); |
| 1019 | } | ||
| 1020 | |||
| 1021 | 229917 | std::any ASTBuilder::visitShiftExpr(SpiceParser::ShiftExprContext *ctx) { | |
| 1022 |
3/4✓ Branch 2 → 3 taken 229917 times.
✗ Branch 2 → 60 not taken.
✓ Branch 5 → 6 taken 229140 times.
✓ Branch 5 → 8 taken 777 times.
|
229917 | if (ctx->additiveExpr().size() == 1) |
| 1023 | 229140 | return visit(ctx->additiveExpr(0)); | |
| 1024 | |||
| 1025 | 777 | const auto shiftExprNode = createNode<ShiftExprNode>(ctx); | |
| 1026 | |||
| 1027 | // Visit children | ||
| 1028 |
2/4✓ Branch 9 → 10 taken 777 times.
✗ Branch 9 → 63 not taken.
✓ Branch 10 → 11 taken 777 times.
✗ Branch 10 → 61 not taken.
|
777 | fetchChildrenIntoVector(shiftExprNode->operands, ctx->additiveExpr()); |
| 1029 | |||
| 1030 | 777 | bool seenFirstLess = false; | |
| 1031 | 777 | bool seenFirstGreater = false; | |
| 1032 |
2/2✓ Branch 45 → 14 taken 3831 times.
✓ Branch 45 → 46 taken 777 times.
|
5385 | for (ParserRuleContext::ParseTree *subTree : ctx->children) { |
| 1033 |
1/2✓ Branch 16 → 17 taken 3831 times.
✗ Branch 16 → 18 not taken.
|
3831 | const auto terminal = dynamic_cast<TerminalNode *>(subTree); |
| 1034 |
2/2✓ Branch 19 → 20 taken 1795 times.
✓ Branch 19 → 21 taken 2036 times.
|
3831 | if (!terminal) |
| 1035 | 1795 | continue; | |
| 1036 | |||
| 1037 |
4/6✓ Branch 21 → 22 taken 2036 times.
✗ Branch 21 → 68 not taken.
✓ Branch 22 → 23 taken 2036 times.
✗ Branch 22 → 68 not taken.
✓ Branch 23 → 24 taken 1658 times.
✓ Branch 23 → 28 taken 378 times.
|
2036 | if (terminal->getSymbol()->getType() == SpiceParser::LESS) { |
| 1038 |
2/2✓ Branch 24 → 25 taken 829 times.
✓ Branch 24 → 27 taken 829 times.
|
1658 | if (seenFirstLess) |
| 1039 |
1/2✓ Branch 25 → 26 taken 829 times.
✗ Branch 25 → 64 not taken.
|
829 | shiftExprNode->opQueue.emplace(ShiftExprNode::ShiftOp::OP_SHIFT_LEFT, TY_INVALID); |
| 1040 | 1658 | seenFirstLess = !seenFirstLess; | |
| 1041 | 1658 | continue; | |
| 1042 | } | ||
| 1043 | |||
| 1044 |
3/6✓ Branch 28 → 29 taken 378 times.
✗ Branch 28 → 68 not taken.
✓ Branch 29 → 30 taken 378 times.
✗ Branch 29 → 68 not taken.
✓ Branch 30 → 31 taken 378 times.
✗ Branch 30 → 35 not taken.
|
378 | if (terminal->getSymbol()->getType() == SpiceParser::GREATER) { |
| 1045 |
2/2✓ Branch 31 → 32 taken 189 times.
✓ Branch 31 → 34 taken 189 times.
|
378 | if (seenFirstGreater) |
| 1046 |
1/2✓ Branch 32 → 33 taken 189 times.
✗ Branch 32 → 66 not taken.
|
189 | shiftExprNode->opQueue.emplace(ShiftExprNode::ShiftOp::OP_SHIFT_RIGHT, TY_INVALID); |
| 1047 | 378 | seenFirstGreater = !seenFirstGreater; | |
| 1048 | 378 | continue; | |
| 1049 | } | ||
| 1050 | |||
| 1051 | − | assert_fail("Invalid terminal symbol for additive expression"); // GCOV_EXCL_LINE | |
| 1052 | } | ||
| 1053 |
2/4✓ Branch 46 → 47 taken 777 times.
✗ Branch 46 → 49 not taken.
✓ Branch 47 → 48 taken 777 times.
✗ Branch 47 → 49 not taken.
|
777 | assert(!seenFirstLess && !seenFirstGreater); |
| 1054 | |||
| 1055 |
1/2✓ Branch 56 → 57 taken 777 times.
✗ Branch 56 → 69 not taken.
|
1554 | return concludeExprNode(shiftExprNode); |
| 1056 | } | ||
| 1057 | |||
| 1058 | 230935 | std::any ASTBuilder::visitAdditiveExpr(SpiceParser::AdditiveExprContext *ctx) { | |
| 1059 |
3/4✓ Branch 2 → 3 taken 230935 times.
✗ Branch 2 → 52 not taken.
✓ Branch 5 → 6 taken 222712 times.
✓ Branch 5 → 8 taken 8223 times.
|
230935 | if (ctx->multiplicativeExpr().size() == 1) |
| 1060 | 222712 | return visit(ctx->multiplicativeExpr(0)); | |
| 1061 | |||
| 1062 | 8223 | const auto additiveExprNode = createNode<AdditiveExprNode>(ctx); | |
| 1063 | |||
| 1064 | // Visit children | ||
| 1065 |
2/4✓ Branch 9 → 10 taken 8223 times.
✗ Branch 9 → 55 not taken.
✓ Branch 10 → 11 taken 8223 times.
✗ Branch 10 → 53 not taken.
|
8223 | fetchChildrenIntoVector(additiveExprNode->operands, ctx->multiplicativeExpr()); |
| 1066 | |||
| 1067 |
2/2✓ Branch 41 → 14 taken 26623 times.
✓ Branch 41 → 42 taken 8223 times.
|
43069 | for (ParserRuleContext::ParseTree *subTree : ctx->children) { |
| 1068 |
1/2✓ Branch 16 → 17 taken 26623 times.
✗ Branch 16 → 18 not taken.
|
26623 | const auto terminal = dynamic_cast<TerminalNode *>(subTree); |
| 1069 |
2/2✓ Branch 19 → 20 taken 17423 times.
✓ Branch 19 → 21 taken 9200 times.
|
26623 | if (!terminal) |
| 1070 | 17423 | continue; | |
| 1071 | |||
| 1072 |
4/6✓ Branch 21 → 22 taken 9200 times.
✗ Branch 21 → 60 not taken.
✓ Branch 22 → 23 taken 9200 times.
✗ Branch 22 → 60 not taken.
✓ Branch 23 → 24 taken 5710 times.
✓ Branch 23 → 26 taken 3490 times.
|
9200 | if (terminal->getSymbol()->getType() == SpiceParser::PLUS) |
| 1073 |
1/2✓ Branch 24 → 25 taken 5710 times.
✗ Branch 24 → 56 not taken.
|
5710 | additiveExprNode->opQueue.emplace(AdditiveExprNode::AdditiveOp::OP_PLUS, TY_INVALID); |
| 1074 |
3/6✓ Branch 26 → 27 taken 3490 times.
✗ Branch 26 → 60 not taken.
✓ Branch 27 → 28 taken 3490 times.
✗ Branch 27 → 60 not taken.
✓ Branch 28 → 29 taken 3490 times.
✗ Branch 28 → 31 not taken.
|
3490 | else if (terminal->getSymbol()->getType() == SpiceParser::MINUS) |
| 1075 |
1/2✓ Branch 29 → 30 taken 3490 times.
✗ Branch 29 → 58 not taken.
|
3490 | additiveExprNode->opQueue.emplace(AdditiveExprNode::AdditiveOp::OP_MINUS, TY_INVALID); |
| 1076 | else | ||
| 1077 | − | assert_fail("Invalid terminal symbol for additive expression"); // GCOV_EXCL_LINE | |
| 1078 | } | ||
| 1079 | |||
| 1080 |
1/2✓ Branch 48 → 49 taken 8223 times.
✗ Branch 48 → 61 not taken.
|
16446 | return concludeExprNode(additiveExprNode); |
| 1081 | } | ||
| 1082 | |||
| 1083 | 240135 | std::any ASTBuilder::visitMultiplicativeExpr(SpiceParser::MultiplicativeExprContext *ctx) { | |
| 1084 |
3/4✓ Branch 2 → 3 taken 240135 times.
✗ Branch 2 → 57 not taken.
✓ Branch 5 → 6 taken 236968 times.
✓ Branch 5 → 8 taken 3167 times.
|
240135 | if (ctx->castExpr().size() == 1) |
| 1085 | 236968 | return visit(ctx->castExpr(0)); | |
| 1086 | |||
| 1087 | 3167 | const auto multiplicativeExprNode = createNode<MultiplicativeExprNode>(ctx); | |
| 1088 | |||
| 1089 | // Visit children | ||
| 1090 |
2/4✓ Branch 9 → 10 taken 3167 times.
✗ Branch 9 → 60 not taken.
✓ Branch 10 → 11 taken 3167 times.
✗ Branch 10 → 58 not taken.
|
3167 | fetchChildrenIntoVector(multiplicativeExprNode->operands, ctx->castExpr()); |
| 1091 | |||
| 1092 |
2/2✓ Branch 46 → 14 taken 9645 times.
✓ Branch 46 → 47 taken 3167 times.
|
15979 | for (ParserRuleContext::ParseTree *subTree : ctx->children) { |
| 1093 |
1/2✓ Branch 16 → 17 taken 9645 times.
✗ Branch 16 → 18 not taken.
|
9645 | const auto terminal = dynamic_cast<TerminalNode *>(subTree); |
| 1094 |
2/2✓ Branch 19 → 20 taken 6406 times.
✓ Branch 19 → 21 taken 3239 times.
|
9645 | if (!terminal) |
| 1095 | 6406 | continue; | |
| 1096 | |||
| 1097 |
4/6✓ Branch 21 → 22 taken 3239 times.
✗ Branch 21 → 67 not taken.
✓ Branch 22 → 23 taken 3239 times.
✗ Branch 22 → 67 not taken.
✓ Branch 23 → 24 taken 2233 times.
✓ Branch 23 → 26 taken 1006 times.
|
3239 | if (terminal->getSymbol()->getType() == SpiceParser::MUL) |
| 1098 |
1/2✓ Branch 24 → 25 taken 2233 times.
✗ Branch 24 → 61 not taken.
|
2233 | multiplicativeExprNode->opQueue.emplace(MultiplicativeExprNode::MultiplicativeOp::OP_MUL, TY_INVALID); |
| 1099 |
4/6✓ Branch 26 → 27 taken 1006 times.
✗ Branch 26 → 67 not taken.
✓ Branch 27 → 28 taken 1006 times.
✗ Branch 27 → 67 not taken.
✓ Branch 28 → 29 taken 541 times.
✓ Branch 28 → 31 taken 465 times.
|
1006 | else if (terminal->getSymbol()->getType() == SpiceParser::DIV) |
| 1100 |
1/2✓ Branch 29 → 30 taken 541 times.
✗ Branch 29 → 63 not taken.
|
541 | multiplicativeExprNode->opQueue.emplace(MultiplicativeExprNode::MultiplicativeOp::OP_DIV, TY_INVALID); |
| 1101 |
3/6✓ Branch 31 → 32 taken 465 times.
✗ Branch 31 → 67 not taken.
✓ Branch 32 → 33 taken 465 times.
✗ Branch 32 → 67 not taken.
✓ Branch 33 → 34 taken 465 times.
✗ Branch 33 → 36 not taken.
|
465 | else if (terminal->getSymbol()->getType() == SpiceParser::REM) |
| 1102 |
1/2✓ Branch 34 → 35 taken 465 times.
✗ Branch 34 → 65 not taken.
|
465 | multiplicativeExprNode->opQueue.emplace(MultiplicativeExprNode::MultiplicativeOp::OP_REM, TY_INVALID); |
| 1103 | else | ||
| 1104 | − | assert_fail("Invalid terminal symbol for multiplicative expression"); // GCOV_EXCL_LINE | |
| 1105 | } | ||
| 1106 | |||
| 1107 |
1/2✓ Branch 53 → 54 taken 3167 times.
✗ Branch 53 → 68 not taken.
|
6334 | return concludeExprNode(multiplicativeExprNode); |
| 1108 | } | ||
| 1109 | |||
| 1110 | 243374 | std::any ASTBuilder::visitCastExpr(SpiceParser::CastExprContext *ctx) { | |
| 1111 |
2/2✓ Branch 3 → 4 taken 236046 times.
✓ Branch 3 → 6 taken 7328 times.
|
243374 | if (!ctx->CAST()) |
| 1112 | 236046 | return visit(ctx->prefixUnaryExpr()); | |
| 1113 | |||
| 1114 | 7328 | const auto castExprNode = createNode<CastExprNode>(ctx); | |
| 1115 | |||
| 1116 | // Visit children | ||
| 1117 |
1/2✓ Branch 8 → 9 taken 7328 times.
✗ Branch 8 → 18 not taken.
|
7328 | if (ctx->dataType()) { |
| 1118 |
3/6✓ Branch 9 → 10 taken 7328 times.
✗ Branch 9 → 35 not taken.
✓ Branch 10 → 11 taken 7328 times.
✗ Branch 10 → 35 not taken.
✓ Branch 11 → 12 taken 7328 times.
✗ Branch 11 → 33 not taken.
|
7328 | castExprNode->dataType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 1119 |
3/6✓ Branch 13 → 14 taken 7328 times.
✗ Branch 13 → 38 not taken.
✓ Branch 14 → 15 taken 7328 times.
✗ Branch 14 → 38 not taken.
✓ Branch 15 → 16 taken 7328 times.
✗ Branch 15 → 36 not taken.
|
7328 | castExprNode->assignExpr = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 1120 | 7328 | castExprNode->isCast = true; | |
| 1121 | } else { | ||
| 1122 | ✗ | castExprNode->prefixUnaryExpr = std::any_cast<ExprNode *>(visit(ctx->prefixUnaryExpr())); | |
| 1123 | } | ||
| 1124 | |||
| 1125 |
1/2✓ Branch 29 → 30 taken 7328 times.
✗ Branch 29 → 42 not taken.
|
14656 | return concludeExprNode(castExprNode); |
| 1126 | } | ||
| 1127 | |||
| 1128 | 261615 | std::any ASTBuilder::visitPrefixUnaryExpr(SpiceParser::PrefixUnaryExprContext *ctx) { | |
| 1129 |
2/2✓ Branch 3 → 4 taken 256892 times.
✓ Branch 3 → 6 taken 4723 times.
|
261615 | if (!ctx->prefixUnaryExpr()) |
| 1130 | 256892 | return visit(ctx->postfixUnaryExpr()); | |
| 1131 | |||
| 1132 | 4723 | const auto prefixUnaryExprNode = createNode<PrefixUnaryExprNode>(ctx); | |
| 1133 | |||
| 1134 | // Visit children | ||
| 1135 |
1/2✗ Branch 8 → 9 not taken.
✓ Branch 8 → 14 taken 4723 times.
|
4723 | if (ctx->postfixUnaryExpr()) { |
| 1136 | ✗ | prefixUnaryExprNode->postfixUnaryExpr = std::any_cast<ExprNode *>(visit(ctx->postfixUnaryExpr())); | |
| 1137 |
1/2✓ Branch 15 → 16 taken 4723 times.
✗ Branch 15 → 42 not taken.
|
4723 | } else if (ctx->prefixUnaryExpr()) { |
| 1138 | // Extract operator | ||
| 1139 |
2/2✓ Branch 17 → 18 taken 200 times.
✓ Branch 17 → 19 taken 4523 times.
|
4723 | if (ctx->MINUS()) |
| 1140 | 200 | prefixUnaryExprNode->op = PrefixUnaryExprNode::PrefixUnaryOp::OP_MINUS; | |
| 1141 |
2/2✓ Branch 20 → 21 taken 12 times.
✓ Branch 20 → 22 taken 4511 times.
|
4523 | else if (ctx->PLUS_PLUS()) |
| 1142 | 12 | prefixUnaryExprNode->op = PrefixUnaryExprNode::PrefixUnaryOp::OP_PLUS_PLUS; | |
| 1143 |
2/2✓ Branch 23 → 24 taken 14 times.
✓ Branch 23 → 25 taken 4497 times.
|
4511 | else if (ctx->MINUS_MINUS()) |
| 1144 | 14 | prefixUnaryExprNode->op = PrefixUnaryExprNode::PrefixUnaryOp::OP_MINUS_MINUS; | |
| 1145 |
2/2✓ Branch 26 → 27 taken 2852 times.
✓ Branch 26 → 28 taken 1645 times.
|
4497 | else if (ctx->NOT()) |
| 1146 | 2852 | prefixUnaryExprNode->op = PrefixUnaryExprNode::PrefixUnaryOp::OP_NOT; | |
| 1147 |
2/2✓ Branch 29 → 30 taken 9 times.
✓ Branch 29 → 31 taken 1636 times.
|
1645 | else if (ctx->BITWISE_NOT()) |
| 1148 | 9 | prefixUnaryExprNode->op = PrefixUnaryExprNode::PrefixUnaryOp::OP_BITWISE_NOT; | |
| 1149 |
2/2✓ Branch 32 → 33 taken 741 times.
✓ Branch 32 → 34 taken 895 times.
|
1636 | else if (ctx->MUL()) |
| 1150 | 741 | prefixUnaryExprNode->op = PrefixUnaryExprNode::PrefixUnaryOp::OP_DEREFERENCE; | |
| 1151 |
1/2✓ Branch 35 → 36 taken 895 times.
✗ Branch 35 → 37 not taken.
|
895 | else if (ctx->BITWISE_AND()) |
| 1152 | 895 | prefixUnaryExprNode->op = PrefixUnaryExprNode::PrefixUnaryOp::OP_ADDRESS_OF; | |
| 1153 | |||
| 1154 |
3/6✓ Branch 37 → 38 taken 4723 times.
✗ Branch 37 → 58 not taken.
✓ Branch 38 → 39 taken 4723 times.
✗ Branch 38 → 58 not taken.
✓ Branch 39 → 40 taken 4723 times.
✗ Branch 39 → 56 not taken.
|
4723 | prefixUnaryExprNode->prefixUnaryExpr = std::any_cast<ExprNode *>(visit(ctx->prefixUnaryExpr())); |
| 1155 | } else { | ||
| 1156 | − | assert_fail("Unknown prefix unary expression type"); // GCOV_EXCL_LINE | |
| 1157 | } | ||
| 1158 | |||
| 1159 |
1/2✓ Branch 49 → 50 taken 4723 times.
✗ Branch 49 → 59 not taken.
|
9446 | return concludeExprNode(prefixUnaryExprNode); |
| 1160 | } | ||
| 1161 | |||
| 1162 | 324581 | std::any ASTBuilder::visitPostfixUnaryExpr(SpiceParser::PostfixUnaryExprContext *ctx) { | |
| 1163 |
2/2✓ Branch 3 → 4 taken 256892 times.
✓ Branch 3 → 6 taken 67689 times.
|
324581 | if (!ctx->postfixUnaryExpr()) |
| 1164 | 256892 | return visit(ctx->atomicExpr()); | |
| 1165 | |||
| 1166 | 67689 | const auto postfixUnaryExprNode = createNode<PostfixUnaryExprNode>(ctx); | |
| 1167 | |||
| 1168 |
1/2✗ Branch 8 → 9 not taken.
✓ Branch 8 → 14 taken 67689 times.
|
67689 | if (ctx->atomicExpr()) { |
| 1169 | ✗ | postfixUnaryExprNode->atomicExpr = std::any_cast<ExprNode *>(visit(ctx->atomicExpr())); | |
| 1170 |
1/2✓ Branch 15 → 16 taken 67689 times.
✗ Branch 15 → 40 not taken.
|
67689 | } else if (ctx->postfixUnaryExpr()) { |
| 1171 |
3/6✓ Branch 16 → 17 taken 67689 times.
✗ Branch 16 → 56 not taken.
✓ Branch 17 → 18 taken 67689 times.
✗ Branch 17 → 56 not taken.
✓ Branch 18 → 19 taken 67689 times.
✗ Branch 18 → 54 not taken.
|
67689 | postfixUnaryExprNode->postfixUnaryExpr = std::any_cast<ExprNode *>(visit(ctx->postfixUnaryExpr())); |
| 1172 | |||
| 1173 | // Extract operator | ||
| 1174 |
2/2✓ Branch 21 → 22 taken 8500 times.
✓ Branch 21 → 27 taken 59189 times.
|
67689 | if (ctx->assignExpr()) { |
| 1175 | 8500 | postfixUnaryExprNode->op = PostfixUnaryExprNode::PostfixUnaryOp::OP_SUBSCRIPT; | |
| 1176 |
3/6✓ Branch 22 → 23 taken 8500 times.
✗ Branch 22 → 59 not taken.
✓ Branch 23 → 24 taken 8500 times.
✗ Branch 23 → 59 not taken.
✓ Branch 24 → 25 taken 8500 times.
✗ Branch 24 → 57 not taken.
|
8500 | postfixUnaryExprNode->subscriptIndexExpr = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 1177 |
2/2✓ Branch 28 → 29 taken 53593 times.
✓ Branch 28 → 34 taken 5596 times.
|
59189 | } else if (ctx->IDENTIFIER()) { |
| 1178 | 53593 | postfixUnaryExprNode->op = PostfixUnaryExprNode::PostfixUnaryOp::OP_MEMBER_ACCESS; | |
| 1179 |
2/4✓ Branch 29 → 30 taken 53593 times.
✗ Branch 29 → 60 not taken.
✓ Branch 30 → 31 taken 53593 times.
✗ Branch 30 → 60 not taken.
|
53593 | postfixUnaryExprNode->identifier = getIdentifier(ctx->IDENTIFIER(), false); |
| 1180 |
2/2✓ Branch 35 → 36 taken 4693 times.
✓ Branch 35 → 37 taken 903 times.
|
5596 | } else if (ctx->PLUS_PLUS()) { |
| 1181 | 4693 | postfixUnaryExprNode->op = PostfixUnaryExprNode::PostfixUnaryOp::OP_PLUS_PLUS; | |
| 1182 |
1/2✓ Branch 38 → 39 taken 903 times.
✗ Branch 38 → 41 not taken.
|
903 | } else if (ctx->MINUS_MINUS()) { |
| 1183 | 903 | postfixUnaryExprNode->op = PostfixUnaryExprNode::PostfixUnaryOp::OP_MINUS_MINUS; | |
| 1184 | } | ||
| 1185 | } else { | ||
| 1186 | − | assert_fail("Unknown postfix unary expression type"); // GCOV_EXCL_LINE | |
| 1187 | } | ||
| 1188 | |||
| 1189 |
1/2✓ Branch 47 → 48 taken 67689 times.
✗ Branch 47 → 61 not taken.
|
135378 | return concludeExprNode(postfixUnaryExprNode); |
| 1190 | } | ||
| 1191 | |||
| 1192 | 256892 | std::any ASTBuilder::visitAtomicExpr(SpiceParser::AtomicExprContext *ctx) { | |
| 1193 | 256892 | const auto atomicExprNode = createNode<AtomicExprNode>(ctx); | |
| 1194 | |||
| 1195 | // Visit children | ||
| 1196 |
2/2✓ Branch 4 → 5 taken 46186 times.
✓ Branch 4 → 10 taken 210706 times.
|
256892 | if (ctx->constant()) { |
| 1197 |
4/6✓ Branch 5 → 6 taken 46186 times.
✗ Branch 5 → 88 not taken.
✓ Branch 6 → 7 taken 46184 times.
✓ Branch 6 → 88 taken 2 times.
✓ Branch 7 → 8 taken 46184 times.
✗ Branch 7 → 86 not taken.
|
46186 | atomicExprNode->constant = std::any_cast<ConstantNode *>(visit(ctx->constant())); |
| 1198 |
2/2✓ Branch 11 → 12 taken 62686 times.
✓ Branch 11 → 17 taken 148020 times.
|
210706 | } else if (ctx->value()) { |
| 1199 |
3/6✓ Branch 12 → 13 taken 62686 times.
✗ Branch 12 → 91 not taken.
✓ Branch 13 → 14 taken 62686 times.
✗ Branch 13 → 91 not taken.
✓ Branch 14 → 15 taken 62686 times.
✗ Branch 14 → 89 not taken.
|
62686 | atomicExprNode->value = std::any_cast<ValueNode *>(visit(ctx->value())); |
| 1200 |
11/18✓ Branch 17 → 18 taken 148020 times.
✗ Branch 17 → 92 not taken.
✓ Branch 19 → 20 taken 8768 times.
✓ Branch 19 → 23 taken 139252 times.
✓ Branch 20 → 21 taken 8768 times.
✗ Branch 20 → 92 not taken.
✓ Branch 22 → 23 taken 7349 times.
✓ Branch 22 → 24 taken 1419 times.
✓ Branch 25 → 26 taken 8768 times.
✓ Branch 25 → 27 taken 139252 times.
✓ Branch 27 → 28 taken 148020 times.
✗ Branch 27 → 29 not taken.
✓ Branch 29 → 30 taken 146601 times.
✓ Branch 29 → 68 taken 1419 times.
✗ Branch 92 → 93 not taken.
✗ Branch 92 → 94 not taken.
✗ Branch 96 → 97 not taken.
✗ Branch 96 → 98 not taken.
|
148020 | } else if (!ctx->IDENTIFIER().empty() || !ctx->TYPE_IDENTIFIER().empty()) { |
| 1201 |
1/2✓ Branch 30 → 31 taken 146601 times.
✗ Branch 30 → 108 not taken.
|
146601 | std::stringstream fqIdentifier; |
| 1202 |
2/2✓ Branch 62 → 33 taken 153891 times.
✓ Branch 62 → 63 taken 146601 times.
|
447093 | for (ParserRuleContext::ParseTree *subTree : ctx->children) { |
| 1203 |
1/2✓ Branch 35 → 36 taken 153891 times.
✗ Branch 35 → 37 not taken.
|
153891 | const auto terminal = dynamic_cast<TerminalNode *>(subTree); |
| 1204 |
1/2✗ Branch 38 → 39 not taken.
✓ Branch 38 → 40 taken 153891 times.
|
153891 | if (!terminal) |
| 1205 | ✗ | continue; | |
| 1206 | |||
| 1207 |
2/4✓ Branch 40 → 41 taken 153891 times.
✗ Branch 40 → 104 not taken.
✓ Branch 41 → 42 taken 153891 times.
✗ Branch 41 → 104 not taken.
|
153891 | const size_t terminalType = terminal->getSymbol()->getType(); |
| 1208 |
4/4✓ Branch 42 → 43 taken 14639 times.
✓ Branch 42 → 44 taken 139252 times.
✓ Branch 43 → 44 taken 10994 times.
✓ Branch 43 → 53 taken 3645 times.
|
153891 | if (terminalType == SpiceParser::IDENTIFIER || terminalType == SpiceParser::TYPE_IDENTIFIER) { |
| 1209 |
1/2✓ Branch 44 → 45 taken 150246 times.
✗ Branch 44 → 103 not taken.
|
150246 | const std::string fragment = getIdentifier(terminal, false); |
| 1210 |
1/2✓ Branch 45 → 46 taken 150246 times.
✗ Branch 45 → 101 not taken.
|
150246 | atomicExprNode->identifierFragments.push_back(fragment); |
| 1211 |
3/4✓ Branch 46 → 47 taken 150246 times.
✗ Branch 46 → 100 not taken.
✓ Branch 48 → 49 taken 3645 times.
✓ Branch 48 → 50 taken 146601 times.
|
150246 | if (fqIdentifier.tellp() != 0) |
| 1212 |
1/2✓ Branch 49 → 50 taken 3645 times.
✗ Branch 49 → 101 not taken.
|
3645 | fqIdentifier << SCOPE_ACCESS_TOKEN; |
| 1213 |
1/2✓ Branch 50 → 51 taken 150246 times.
✗ Branch 50 → 101 not taken.
|
150246 | fqIdentifier << fragment; |
| 1214 | 150246 | } | |
| 1215 | } | ||
| 1216 |
1/2✓ Branch 63 → 64 taken 146601 times.
✗ Branch 63 → 105 not taken.
|
146601 | atomicExprNode->fqIdentifier = fqIdentifier.str(); |
| 1217 |
1/2✓ Branch 69 → 70 taken 1419 times.
✗ Branch 69 → 75 not taken.
|
148020 | } else if (ctx->assignExpr()) { |
| 1218 |
3/6✓ Branch 70 → 71 taken 1419 times.
✗ Branch 70 → 111 not taken.
✓ Branch 71 → 72 taken 1419 times.
✗ Branch 71 → 111 not taken.
✓ Branch 72 → 73 taken 1419 times.
✗ Branch 72 → 109 not taken.
|
1419 | atomicExprNode->assignExpr = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 1219 | } else { | ||
| 1220 | − | assert_fail("Unknown atomic expression type"); // GCOV_EXCL_LINE | |
| 1221 | } | ||
| 1222 | |||
| 1223 |
1/2✓ Branch 82 → 83 taken 256890 times.
✗ Branch 82 → 112 not taken.
|
513780 | return concludeExprNode(atomicExprNode); |
| 1224 | } | ||
| 1225 | |||
| 1226 | 62686 | std::any ASTBuilder::visitValue(SpiceParser::ValueContext *ctx) { | |
| 1227 | 62686 | const auto valueNode = createNode<ValueNode>(ctx); | |
| 1228 | |||
| 1229 | // Visit children | ||
| 1230 |
2/2✓ Branch 4 → 5 taken 55470 times.
✓ Branch 4 → 10 taken 7216 times.
|
62686 | if (ctx->fctCall()) { |
| 1231 |
3/6✓ Branch 5 → 6 taken 55470 times.
✗ Branch 5 → 65 not taken.
✓ Branch 6 → 7 taken 55470 times.
✗ Branch 6 → 65 not taken.
✓ Branch 7 → 8 taken 55470 times.
✗ Branch 7 → 63 not taken.
|
55470 | valueNode->fctCall = std::any_cast<FctCallNode *>(visit(ctx->fctCall())); |
| 1232 |
2/2✓ Branch 11 → 12 taken 297 times.
✓ Branch 11 → 17 taken 6919 times.
|
7216 | } else if (ctx->arrayInitialization()) { |
| 1233 |
3/6✓ Branch 12 → 13 taken 297 times.
✗ Branch 12 → 68 not taken.
✓ Branch 13 → 14 taken 297 times.
✗ Branch 13 → 68 not taken.
✓ Branch 14 → 15 taken 297 times.
✗ Branch 14 → 66 not taken.
|
297 | valueNode->arrayInitialization = std::any_cast<ArrayInitializationNode *>(visit(ctx->arrayInitialization())); |
| 1234 |
2/2✓ Branch 18 → 19 taken 936 times.
✓ Branch 18 → 24 taken 5983 times.
|
6919 | } else if (ctx->structInstantiation()) { |
| 1235 |
3/6✓ Branch 19 → 20 taken 936 times.
✗ Branch 19 → 71 not taken.
✓ Branch 20 → 21 taken 936 times.
✗ Branch 20 → 71 not taken.
✓ Branch 21 → 22 taken 936 times.
✗ Branch 21 → 69 not taken.
|
936 | valueNode->structInstantiation = std::any_cast<StructInstantiationNode *>(visit(ctx->structInstantiation())); |
| 1236 |
2/2✓ Branch 25 → 26 taken 24 times.
✓ Branch 25 → 31 taken 5959 times.
|
5983 | } else if (ctx->lambdaFunc()) { |
| 1237 |
3/6✓ Branch 26 → 27 taken 24 times.
✗ Branch 26 → 74 not taken.
✓ Branch 27 → 28 taken 24 times.
✗ Branch 27 → 74 not taken.
✓ Branch 28 → 29 taken 24 times.
✗ Branch 28 → 72 not taken.
|
24 | valueNode->lambdaFunc = std::any_cast<LambdaFuncNode *>(visit(ctx->lambdaFunc())); |
| 1238 |
2/2✓ Branch 32 → 33 taken 72 times.
✓ Branch 32 → 38 taken 5887 times.
|
5959 | } else if (ctx->lambdaProc()) { |
| 1239 |
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())); |
| 1240 |
2/2✓ Branch 39 → 40 taken 1 time.
✓ Branch 39 → 45 taken 5886 times.
|
5887 | } else if (ctx->lambdaExpr()) { |
| 1241 |
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())); |
| 1242 |
1/2✓ Branch 46 → 47 taken 5886 times.
✗ Branch 46 → 52 not taken.
|
5886 | } else if (ctx->dataType()) { |
| 1243 | 5886 | valueNode->isNil = true; | |
| 1244 |
3/6✓ Branch 47 → 48 taken 5886 times.
✗ Branch 47 → 83 not taken.
✓ Branch 48 → 49 taken 5886 times.
✗ Branch 48 → 83 not taken.
✓ Branch 49 → 50 taken 5886 times.
✗ Branch 49 → 81 not taken.
|
5886 | valueNode->nilType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 1245 | } else { | ||
| 1246 | − | assert_fail("Unknown value type"); // GCOV_EXCL_LINE | |
| 1247 | } | ||
| 1248 | |||
| 1249 |
1/2✓ Branch 59 → 60 taken 62686 times.
✗ Branch 59 → 84 not taken.
|
125372 | return concludeNode(valueNode); |
| 1250 | } | ||
| 1251 | |||
| 1252 | 51346 | std::any ASTBuilder::visitConstant(SpiceParser::ConstantContext *ctx) { | |
| 1253 | 51346 | const auto constantNode = createNode<ConstantNode>(ctx); | |
| 1254 | |||
| 1255 | // Detect an optional leading minus sign for numeric literals | ||
| 1256 | 51346 | const bool isNegative = ctx->MINUS() != nullptr; | |
| 1257 | |||
| 1258 | // Enrich | ||
| 1259 |
2/2✓ Branch 5 → 6 taken 1841 times.
✓ Branch 5 → 14 taken 49505 times.
|
51346 | if (ctx->DOUBLE_LIT()) { |
| 1260 | 1841 | constantNode->type = ConstantNode::PrimitiveValueType::TYPE_DOUBLE; | |
| 1261 |
3/6✓ Branch 6 → 7 taken 1841 times.
✗ Branch 6 → 63 not taken.
✓ Branch 7 → 8 taken 1841 times.
✗ Branch 7 → 63 not taken.
✓ Branch 8 → 9 taken 1841 times.
✗ Branch 8 → 61 not taken.
|
1841 | const double value = std::stod(ctx->DOUBLE_LIT()->toString()); |
| 1262 |
2/2✓ Branch 10 → 11 taken 149 times.
✓ Branch 10 → 12 taken 1692 times.
|
1841 | constantNode->compileTimeValue.doubleValue = isNegative ? -value : value; |
| 1263 |
2/2✓ Branch 15 → 16 taken 9144 times.
✓ Branch 15 → 19 taken 40361 times.
|
49505 | } else if (ctx->INT_LIT()) { |
| 1264 | 9144 | constantNode->type = ConstantNode::PrimitiveValueType::TYPE_INT; | |
| 1265 | 9144 | constantNode->compileTimeValue.intValue = parseInt(ctx->INT_LIT(), isNegative); | |
| 1266 |
2/2✓ Branch 20 → 21 taken 1108 times.
✓ Branch 20 → 24 taken 39253 times.
|
40361 | } else if (ctx->SHORT_LIT()) { |
| 1267 | 1108 | constantNode->type = ConstantNode::PrimitiveValueType::TYPE_SHORT; | |
| 1268 | 1108 | constantNode->compileTimeValue.shortValue = parseShort(ctx->SHORT_LIT(), isNegative); | |
| 1269 |
2/2✓ Branch 25 → 26 taken 16890 times.
✓ Branch 25 → 29 taken 22363 times.
|
39253 | } else if (ctx->LONG_LIT()) { |
| 1270 | 16890 | constantNode->type = ConstantNode::PrimitiveValueType::TYPE_LONG; | |
| 1271 | 16890 | constantNode->compileTimeValue.longValue = parseLong(ctx->LONG_LIT(), isNegative); | |
| 1272 |
2/2✓ Branch 30 → 31 taken 5510 times.
✓ Branch 30 → 34 taken 16853 times.
|
22363 | } else if (ctx->CHAR_LIT()) { |
| 1273 | 5510 | constantNode->type = ConstantNode::PrimitiveValueType::TYPE_CHAR; | |
| 1274 | 5510 | constantNode->compileTimeValue.charValue = parseChar(ctx->CHAR_LIT()); | |
| 1275 |
2/2✓ Branch 35 → 36 taken 11475 times.
✓ Branch 35 → 44 taken 5378 times.
|
16853 | } else if (ctx->STRING_LIT()) { |
| 1276 | // Save a pointer to the string in the compile time value | ||
| 1277 | 11475 | constantNode->type = ConstantNode::PrimitiveValueType::TYPE_STRING; | |
| 1278 | 11475 | constantNode->compileTimeValue.stringValueOffset = resourceManager.compileTimeStringValues.size(); | |
| 1279 | // Add the string to the global compile time string list | ||
| 1280 |
4/8✓ Branch 37 → 38 taken 11475 times.
✗ Branch 37 → 68 not taken.
✓ Branch 38 → 39 taken 11475 times.
✗ Branch 38 → 68 not taken.
✓ Branch 39 → 40 taken 11475 times.
✗ Branch 39 → 66 not taken.
✓ Branch 40 → 41 taken 11475 times.
✗ Branch 40 → 64 not taken.
|
11475 | resourceManager.compileTimeStringValues.push_back(parseString(ctx->STRING_LIT()->toString())); |
| 1281 |
2/2✓ Branch 45 → 46 taken 2530 times.
✓ Branch 45 → 47 taken 2848 times.
|
5378 | } else if (ctx->TRUE()) { |
| 1282 | 2530 | constantNode->type = ConstantNode::PrimitiveValueType::TYPE_BOOL; | |
| 1283 | 2530 | constantNode->compileTimeValue.boolValue = true; | |
| 1284 |
1/2✓ Branch 48 → 49 taken 2848 times.
✗ Branch 48 → 50 not taken.
|
2848 | } else if (ctx->FALSE()) { |
| 1285 | 2848 | constantNode->type = ConstantNode::PrimitiveValueType::TYPE_BOOL; | |
| 1286 | 2848 | constantNode->compileTimeValue.boolValue = false; | |
| 1287 | } else { | ||
| 1288 | − | assert_fail("Unknown constant type"); // GCOV_EXCL_LINE | |
| 1289 | } | ||
| 1290 | |||
| 1291 |
1/2✓ Branch 57 → 58 taken 51344 times.
✗ Branch 57 → 70 not taken.
|
102688 | return concludeNode(constantNode); |
| 1292 | } | ||
| 1293 | |||
| 1294 | 55470 | std::any ASTBuilder::visitFctCall(SpiceParser::FctCallContext *ctx) { | |
| 1295 |
1/2✓ Branch 2 → 3 taken 55470 times.
✗ Branch 2 → 92 not taken.
|
55470 | const auto fctCallNode = createNode<FctCallNode>(ctx); |
| 1296 | |||
| 1297 |
1/2✓ Branch 3 → 4 taken 55470 times.
✗ Branch 3 → 92 not taken.
|
55470 | std::stringstream fqFunctionName; |
| 1298 |
2/2✓ Branch 46 → 6 taken 278346 times.
✓ Branch 46 → 47 taken 55470 times.
|
389286 | for (antlr4::ParserRuleContext::ParseTree *subTree : ctx->children) { |
| 1299 |
1/2✓ Branch 8 → 9 taken 278346 times.
✗ Branch 8 → 10 not taken.
|
278346 | const auto terminal = dynamic_cast<antlr4::tree::TerminalNode *>(subTree); |
| 1300 |
2/2✓ Branch 11 → 12 taken 45422 times.
✓ Branch 11 → 13 taken 232924 times.
|
278346 | if (!terminal) |
| 1301 | 45422 | continue; | |
| 1302 | |||
| 1303 |
4/6✓ Branch 13 → 14 taken 232924 times.
✗ Branch 13 → 81 not taken.
✓ Branch 14 → 15 taken 232924 times.
✗ Branch 14 → 81 not taken.
✓ Branch 15 → 16 taken 74842 times.
✓ Branch 15 → 21 taken 158082 times.
|
232924 | if (terminal->getSymbol()->getType() == SpiceParser::IDENTIFIER) { |
| 1304 |
1/2✓ Branch 16 → 17 taken 74842 times.
✗ Branch 16 → 77 not taken.
|
74842 | const std::string fragment = terminal->toString(); |
| 1305 |
1/2✓ Branch 17 → 18 taken 74842 times.
✗ Branch 17 → 75 not taken.
|
74842 | fctCallNode->functionNameFragments.push_back(fragment); |
| 1306 |
1/2✓ Branch 18 → 19 taken 74842 times.
✗ Branch 18 → 75 not taken.
|
74842 | fqFunctionName << fragment; |
| 1307 |
4/6✓ Branch 21 → 22 taken 158082 times.
✗ Branch 21 → 81 not taken.
✓ Branch 22 → 23 taken 158082 times.
✗ Branch 22 → 81 not taken.
✓ Branch 23 → 24 taken 10327 times.
✓ Branch 23 → 29 taken 147755 times.
|
232924 | } else if (terminal->getSymbol()->getType() == SpiceParser::TYPE_IDENTIFIER) { |
| 1308 |
1/2✓ Branch 24 → 25 taken 10327 times.
✗ Branch 24 → 80 not taken.
|
10327 | const std::string fragment = terminal->toString(); |
| 1309 |
1/2✓ Branch 25 → 26 taken 10327 times.
✗ Branch 25 → 78 not taken.
|
10327 | fctCallNode->functionNameFragments.push_back(fragment); |
| 1310 |
1/2✓ Branch 26 → 27 taken 10327 times.
✗ Branch 26 → 78 not taken.
|
10327 | fqFunctionName << fragment; |
| 1311 |
4/6✓ Branch 29 → 30 taken 147755 times.
✗ Branch 29 → 81 not taken.
✓ Branch 30 → 31 taken 147755 times.
✗ Branch 30 → 81 not taken.
✓ Branch 31 → 32 taken 162 times.
✓ Branch 31 → 33 taken 147593 times.
|
158082 | } else if (terminal->getSymbol()->getType() == SpiceParser::SCOPE_ACCESS) { |
| 1312 |
1/2✓ Branch 32 → 37 taken 162 times.
✗ Branch 32 → 81 not taken.
|
162 | fqFunctionName << SCOPE_ACCESS_TOKEN; |
| 1313 |
4/6✓ Branch 33 → 34 taken 147593 times.
✗ Branch 33 → 81 not taken.
✓ Branch 34 → 35 taken 147593 times.
✗ Branch 34 → 81 not taken.
✓ Branch 35 → 36 taken 29537 times.
✓ Branch 35 → 37 taken 118056 times.
|
147593 | } else if (terminal->getSymbol()->getType() == SpiceParser::DOT) { |
| 1314 |
1/2✓ Branch 36 → 37 taken 29537 times.
✗ Branch 36 → 81 not taken.
|
29537 | fqFunctionName << MEMBER_ACCESS_TOKEN; |
| 1315 | } | ||
| 1316 | } | ||
| 1317 |
1/2✓ Branch 47 → 48 taken 55470 times.
✗ Branch 47 → 82 not taken.
|
55470 | fctCallNode->fqFunctionName = fqFunctionName.str(); |
| 1318 | |||
| 1319 | // Visit children | ||
| 1320 |
3/4✓ Branch 50 → 51 taken 55470 times.
✗ Branch 50 → 90 not taken.
✓ Branch 51 → 52 taken 3558 times.
✓ Branch 51 → 57 taken 51912 times.
|
55470 | if (ctx->typeLst()) { |
| 1321 | 3558 | fctCallNode->hasTemplateTypes = true; | |
| 1322 |
3/6✓ Branch 52 → 53 taken 3558 times.
✗ Branch 52 → 85 not taken.
✓ Branch 53 → 54 taken 3558 times.
✗ Branch 53 → 85 not taken.
✓ Branch 54 → 55 taken 3558 times.
✗ Branch 54 → 83 not taken.
|
3558 | fctCallNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst())); |
| 1323 | } | ||
| 1324 |
3/4✓ Branch 57 → 58 taken 55470 times.
✗ Branch 57 → 90 not taken.
✓ Branch 58 → 59 taken 41864 times.
✓ Branch 58 → 64 taken 13606 times.
|
55470 | if (ctx->argLst()) { |
| 1325 | 41864 | fctCallNode->hasArgs = true; | |
| 1326 |
3/6✓ Branch 59 → 60 taken 41864 times.
✗ Branch 59 → 88 not taken.
✓ Branch 60 → 61 taken 41864 times.
✗ Branch 60 → 88 not taken.
✓ Branch 61 → 62 taken 41864 times.
✗ Branch 61 → 86 not taken.
|
41864 | fctCallNode->argLst = std::any_cast<ArgLstNode *>(visit(ctx->argLst())); |
| 1327 | } | ||
| 1328 | |||
| 1329 |
1/2✓ Branch 70 → 71 taken 55470 times.
✗ Branch 70 → 89 not taken.
|
110940 | return concludeNode(fctCallNode); |
| 1330 | 55470 | } | |
| 1331 | |||
| 1332 | 297 | std::any ASTBuilder::visitArrayInitialization(SpiceParser::ArrayInitializationContext *ctx) { | |
| 1333 | 297 | const auto arrayInitializationNode = createNode<ArrayInitializationNode>(ctx); | |
| 1334 | |||
| 1335 | // Visit children | ||
| 1336 |
2/2✓ Branch 4 → 5 taken 296 times.
✓ Branch 4 → 10 taken 1 time.
|
297 | if (ctx->argLst()) |
| 1337 |
3/6✓ Branch 5 → 6 taken 296 times.
✗ Branch 5 → 22 not taken.
✓ Branch 6 → 7 taken 296 times.
✗ Branch 6 → 22 not taken.
✓ Branch 7 → 8 taken 296 times.
✗ Branch 7 → 20 not taken.
|
296 | arrayInitializationNode->itemLst = std::any_cast<ArgLstNode *>(visit(ctx->argLst())); |
| 1338 | |||
| 1339 |
1/2✓ Branch 16 → 17 taken 297 times.
✗ Branch 16 → 23 not taken.
|
594 | return concludeNode(arrayInitializationNode); |
| 1340 | } | ||
| 1341 | |||
| 1342 | 936 | std::any ASTBuilder::visitStructInstantiation(SpiceParser::StructInstantiationContext *ctx) { | |
| 1343 |
1/2✓ Branch 2 → 3 taken 936 times.
✗ Branch 2 → 85 not taken.
|
936 | const auto structInstantiationNode = createNode<StructInstantiationNode>(ctx); |
| 1344 | |||
| 1345 | // Enrich | ||
| 1346 |
1/2✓ Branch 3 → 4 taken 936 times.
✗ Branch 3 → 85 not taken.
|
936 | std::stringstream fqStructName; |
| 1347 |
2/2✓ Branch 39 → 6 taken 3825 times.
✓ Branch 39 → 40 taken 936 times.
|
5697 | for (antlr4::ParserRuleContext::ParseTree *subTree : ctx->children) { |
| 1348 |
1/2✓ Branch 8 → 9 taken 3825 times.
✗ Branch 8 → 10 not taken.
|
3825 | const auto terminal = dynamic_cast<antlr4::tree::TerminalNode *>(subTree); |
| 1349 |
2/2✓ Branch 11 → 12 taken 943 times.
✓ Branch 11 → 13 taken 2882 times.
|
3825 | if (!terminal) |
| 1350 | 943 | continue; | |
| 1351 | |||
| 1352 |
4/6✓ Branch 13 → 14 taken 2882 times.
✗ Branch 13 → 74 not taken.
✓ Branch 14 → 15 taken 2882 times.
✗ Branch 14 → 74 not taken.
✓ Branch 15 → 16 taken 3 times.
✓ Branch 15 → 22 taken 2879 times.
|
2882 | if (terminal->getSymbol()->getType() == SpiceParser::IDENTIFIER) { |
| 1353 |
1/2✓ Branch 16 → 17 taken 3 times.
✗ Branch 16 → 70 not taken.
|
3 | const std::string fragment = terminal->toString(); |
| 1354 |
1/2✓ Branch 17 → 18 taken 3 times.
✗ Branch 17 → 68 not taken.
|
3 | structInstantiationNode->structNameFragments.push_back(fragment); |
| 1355 |
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; |
| 1356 |
4/6✓ Branch 22 → 23 taken 2879 times.
✗ Branch 22 → 74 not taken.
✓ Branch 23 → 24 taken 2879 times.
✗ Branch 23 → 74 not taken.
✓ Branch 24 → 25 taken 936 times.
✓ Branch 24 → 30 taken 1943 times.
|
2882 | } else if (terminal->getSymbol()->getType() == SpiceParser::TYPE_IDENTIFIER) { |
| 1357 |
1/2✓ Branch 25 → 26 taken 936 times.
✗ Branch 25 → 73 not taken.
|
936 | const std::string fragment = terminal->toString(); |
| 1358 |
1/2✓ Branch 26 → 27 taken 936 times.
✗ Branch 26 → 71 not taken.
|
936 | structInstantiationNode->structNameFragments.push_back(fragment); |
| 1359 |
1/2✓ Branch 27 → 28 taken 936 times.
✗ Branch 27 → 71 not taken.
|
936 | fqStructName << fragment; |
| 1360 | 936 | } | |
| 1361 | } | ||
| 1362 |
1/2✓ Branch 40 → 41 taken 936 times.
✗ Branch 40 → 75 not taken.
|
936 | structInstantiationNode->fqStructName = fqStructName.str(); |
| 1363 | |||
| 1364 | // Visit children | ||
| 1365 |
3/4✓ Branch 43 → 44 taken 936 times.
✗ Branch 43 → 83 not taken.
✓ Branch 44 → 45 taken 34 times.
✓ Branch 44 → 50 taken 902 times.
|
936 | if (ctx->typeLst()) { |
| 1366 | 34 | structInstantiationNode->hasTemplateTypes = true; | |
| 1367 |
3/6✓ Branch 45 → 46 taken 34 times.
✗ Branch 45 → 78 not taken.
✓ Branch 46 → 47 taken 34 times.
✗ Branch 46 → 78 not taken.
✓ Branch 47 → 48 taken 34 times.
✗ Branch 47 → 76 not taken.
|
34 | structInstantiationNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst())); |
| 1368 | } | ||
| 1369 |
3/4✓ Branch 50 → 51 taken 936 times.
✗ Branch 50 → 83 not taken.
✓ Branch 51 → 52 taken 909 times.
✓ Branch 51 → 57 taken 27 times.
|
936 | if (ctx->argLst()) |
| 1370 |
3/6✓ Branch 52 → 53 taken 909 times.
✗ Branch 52 → 81 not taken.
✓ Branch 53 → 54 taken 909 times.
✗ Branch 53 → 81 not taken.
✓ Branch 54 → 55 taken 909 times.
✗ Branch 54 → 79 not taken.
|
909 | structInstantiationNode->fieldLst = std::any_cast<ArgLstNode *>(visit(ctx->argLst())); |
| 1371 | |||
| 1372 |
1/2✓ Branch 63 → 64 taken 936 times.
✗ Branch 63 → 82 not taken.
|
1872 | return concludeNode(structInstantiationNode); |
| 1373 | 936 | } | |
| 1374 | |||
| 1375 | 24 | std::any ASTBuilder::visitLambdaFunc(SpiceParser::LambdaFuncContext *ctx) { | |
| 1376 | 24 | const auto lambdaFuncNode = createNode<LambdaFuncNode>(ctx); | |
| 1377 | |||
| 1378 | // Visit children | ||
| 1379 |
3/6✓ Branch 3 → 4 taken 24 times.
✗ Branch 3 → 37 not taken.
✓ Branch 4 → 5 taken 24 times.
✗ Branch 4 → 37 not taken.
✓ Branch 5 → 6 taken 24 times.
✗ Branch 5 → 35 not taken.
|
24 | lambdaFuncNode->returnType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 1380 |
2/2✓ Branch 8 → 9 taken 19 times.
✓ Branch 8 → 14 taken 5 times.
|
24 | if (ctx->paramLst()) { |
| 1381 | 19 | lambdaFuncNode->hasParams = true; | |
| 1382 |
3/6✓ Branch 9 → 10 taken 19 times.
✗ Branch 9 → 40 not taken.
✓ Branch 10 → 11 taken 19 times.
✗ Branch 10 → 40 not taken.
✓ Branch 11 → 12 taken 19 times.
✗ Branch 11 → 38 not taken.
|
19 | lambdaFuncNode->paramLst = std::any_cast<ParamLstNode *>(visit(ctx->paramLst())); |
| 1383 | } | ||
| 1384 |
1/2✗ Branch 15 → 16 not taken.
✓ Branch 15 → 21 taken 24 times.
|
24 | if (ctx->lambdaAttr()) |
| 1385 | ✗ | lambdaFuncNode->lambdaAttr = std::any_cast<LambdaAttrNode *>(visit(ctx->lambdaAttr())); | |
| 1386 |
4/8✓ Branch 21 → 22 taken 24 times.
✗ Branch 21 → 46 not taken.
✓ Branch 22 → 23 taken 24 times.
✗ Branch 22 → 46 not taken.
✓ Branch 23 → 24 taken 24 times.
✗ Branch 23 → 44 not taken.
✓ Branch 25 → 26 taken 24 times.
✗ Branch 25 → 47 not taken.
|
24 | lambdaFuncNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 1387 | |||
| 1388 |
1/2✓ Branch 31 → 32 taken 24 times.
✗ Branch 31 → 47 not taken.
|
48 | return concludeNode(lambdaFuncNode); |
| 1389 | } | ||
| 1390 | |||
| 1391 | 72 | std::any ASTBuilder::visitLambdaProc(SpiceParser::LambdaProcContext *ctx) { | |
| 1392 | 72 | const auto lambdaProcNode = createNode<LambdaProcNode>(ctx); | |
| 1393 | |||
| 1394 | // Visit children | ||
| 1395 |
2/2✓ Branch 4 → 5 taken 58 times.
✓ Branch 4 → 10 taken 14 times.
|
72 | if (ctx->paramLst()) { |
| 1396 | 58 | lambdaProcNode->hasParams = true; | |
| 1397 |
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())); |
| 1398 | } | ||
| 1399 |
2/2✓ Branch 11 → 12 taken 6 times.
✓ Branch 11 → 17 taken 66 times.
|
72 | if (ctx->lambdaAttr()) |
| 1400 |
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())); |
| 1401 |
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())); |
| 1402 | |||
| 1403 |
1/2✓ Branch 27 → 28 taken 72 times.
✗ Branch 27 → 40 not taken.
|
144 | return concludeNode(lambdaProcNode); |
| 1404 | } | ||
| 1405 | |||
| 1406 | 1 | std::any ASTBuilder::visitLambdaExpr(SpiceParser::LambdaExprContext *ctx) { | |
| 1407 | 1 | const auto lambdaExprNode = createNode<LambdaExprNode>(ctx); | |
| 1408 | |||
| 1409 | // Visit children | ||
| 1410 |
1/2✓ Branch 4 → 5 taken 1 time.
✗ Branch 4 → 10 not taken.
|
1 | if (ctx->paramLst()) { |
| 1411 | 1 | lambdaExprNode->hasParams = true; | |
| 1412 |
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())); |
| 1413 | } | ||
| 1414 |
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())); |
| 1415 | |||
| 1416 |
1/2✓ Branch 20 → 21 taken 1 time.
✗ Branch 20 → 30 not taken.
|
2 | return concludeNode(lambdaExprNode); |
| 1417 | } | ||
| 1418 | |||
| 1419 | 136282 | std::any ASTBuilder::visitDataType(SpiceParser::DataTypeContext *ctx) { | |
| 1420 | 136282 | const auto dataTypeNode = createNode<DataTypeNode>(ctx); | |
| 1421 | |||
| 1422 | // Visit children | ||
| 1423 |
2/2✓ Branch 4 → 5 taken 50005 times.
✓ Branch 4 → 10 taken 86277 times.
|
136282 | if (ctx->qualifierLst()) |
| 1424 |
4/6✓ Branch 5 → 6 taken 50005 times.
✗ Branch 5 → 73 not taken.
✓ Branch 6 → 7 taken 50004 times.
✓ Branch 6 → 73 taken 1 time.
✓ Branch 7 → 8 taken 50004 times.
✗ Branch 7 → 71 not taken.
|
50005 | dataTypeNode->qualifierLst = std::any_cast<QualifierLstNode *>(visit(ctx->qualifierLst())); |
| 1425 |
3/6✓ Branch 10 → 11 taken 136281 times.
✗ Branch 10 → 76 not taken.
✓ Branch 11 → 12 taken 136281 times.
✗ Branch 11 → 76 not taken.
✓ Branch 12 → 13 taken 136281 times.
✗ Branch 12 → 74 not taken.
|
136281 | dataTypeNode->baseDataType = std::any_cast<BaseDataTypeNode *>(visit(ctx->baseDataType())); |
| 1426 | |||
| 1427 | // Enrich | ||
| 1428 |
2/2✓ Branch 60 → 15 taken 223546 times.
✓ Branch 60 → 61 taken 136281 times.
|
359827 | for (size_t i = 0; i < ctx->children.size(); i++) { |
| 1429 | 223546 | antlr4::tree::ParseTree *subTree = ctx->children.at(i); | |
| 1430 |
1/2✓ Branch 16 → 17 taken 223546 times.
✗ Branch 16 → 18 not taken.
|
223546 | auto terminal = dynamic_cast<TerminalNode *>(subTree); |
| 1431 |
2/2✓ Branch 19 → 20 taken 186285 times.
✓ Branch 19 → 21 taken 37261 times.
|
223546 | if (!terminal) |
| 1432 | 186285 | continue; | |
| 1433 | |||
| 1434 |
2/2✓ Branch 23 → 24 taken 22340 times.
✓ Branch 23 → 26 taken 14921 times.
|
37261 | if (terminal->getSymbol()->getType() == SpiceParser::MUL) { |
| 1435 |
1/2✓ Branch 24 → 25 taken 22340 times.
✗ Branch 24 → 77 not taken.
|
22340 | dataTypeNode->tmQueue.emplace(DataTypeNode::TypeModifierType::TYPE_PTR, false, 0); |
| 1436 |
2/2✓ Branch 28 → 29 taken 14731 times.
✓ Branch 28 → 31 taken 190 times.
|
14921 | } else if (terminal->getSymbol()->getType() == SpiceParser::BITWISE_AND) { |
| 1437 |
1/2✓ Branch 29 → 30 taken 14731 times.
✗ Branch 29 → 80 not taken.
|
14731 | dataTypeNode->tmQueue.emplace(DataTypeNode::TypeModifierType::TYPE_REF, false, 0); |
| 1438 |
1/2✓ Branch 33 → 34 taken 190 times.
✗ Branch 33 → 58 not taken.
|
190 | } else if (terminal->getSymbol()->getType() == SpiceParser::LBRACKET) { |
| 1439 | 190 | i++; // Consume LBRACKET | |
| 1440 |
1/2✓ Branch 34 → 35 taken 190 times.
✗ Branch 34 → 92 not taken.
|
190 | subTree = ctx->children.at(i); |
| 1441 |
1/2✓ Branch 35 → 36 taken 190 times.
✗ Branch 35 → 37 not taken.
|
190 | terminal = dynamic_cast<TerminalNode *>(subTree); |
| 1442 | 190 | bool hasSize = false; | |
| 1443 | 190 | unsigned int hardCodedSize = 0; | |
| 1444 | 190 | std::string sizeVarName; | |
| 1445 |
4/6✓ Branch 39 → 40 taken 190 times.
✗ Branch 39 → 90 not taken.
✓ Branch 40 → 41 taken 190 times.
✗ Branch 40 → 90 not taken.
✓ Branch 41 → 42 taken 77 times.
✓ Branch 41 → 46 taken 113 times.
|
190 | if (terminal->getSymbol()->getType() == SpiceParser::INT_LIT) { |
| 1446 | 77 | hasSize = true; | |
| 1447 |
2/4✓ Branch 42 → 43 taken 77 times.
✗ Branch 42 → 85 not taken.
✓ Branch 43 → 44 taken 77 times.
✗ Branch 43 → 83 not taken.
|
77 | hardCodedSize = std::stoi(terminal->getText()); |
| 1448 | 77 | i++; // Consume INT_LIT | |
| 1449 |
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) { |
| 1450 | 41 | hasSize = true; | |
| 1451 |
1/2✓ Branch 49 → 50 taken 41 times.
✗ Branch 49 → 86 not taken.
|
41 | sizeVarName = getIdentifier(terminal, true); |
| 1452 | 41 | i++; // Consume TYPE_IDENTIFIER | |
| 1453 | } | ||
| 1454 |
1/2✓ Branch 54 → 55 taken 190 times.
✗ Branch 54 → 87 not taken.
|
190 | dataTypeNode->tmQueue.push({DataTypeNode::TypeModifierType::TYPE_ARRAY, hasSize, hardCodedSize, sizeVarName}); |
| 1455 | 190 | } | |
| 1456 | } | ||
| 1457 | |||
| 1458 |
1/2✓ Branch 67 → 68 taken 136281 times.
✗ Branch 67 → 93 not taken.
|
272562 | return concludeNode(dataTypeNode); |
| 1459 |
1/2✓ Branch 53 → 54 taken 190 times.
✗ Branch 53 → 89 not taken.
|
190 | } |
| 1460 | |||
| 1461 | 136281 | std::any ASTBuilder::visitBaseDataType(SpiceParser::BaseDataTypeContext *ctx) { | |
| 1462 | 136281 | const auto baseDataTypeNode = createNode<BaseDataTypeNode>(ctx); | |
| 1463 | |||
| 1464 | // Enrich | ||
| 1465 |
2/2✓ Branch 4 → 5 taken 1937 times.
✓ Branch 4 → 6 taken 134344 times.
|
136281 | if (ctx->TYPE_DOUBLE()) { |
| 1466 | 1937 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_DOUBLE; | |
| 1467 |
2/2✓ Branch 7 → 8 taken 7736 times.
✓ Branch 7 → 9 taken 126608 times.
|
134344 | } else if (ctx->TYPE_INT()) { |
| 1468 | 7736 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_INT; | |
| 1469 |
2/2✓ Branch 10 → 11 taken 2144 times.
✓ Branch 10 → 12 taken 124464 times.
|
126608 | } else if (ctx->TYPE_SHORT()) { |
| 1470 | 2144 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_SHORT; | |
| 1471 |
2/2✓ Branch 13 → 14 taken 21067 times.
✓ Branch 13 → 15 taken 103397 times.
|
124464 | } else if (ctx->TYPE_LONG()) { |
| 1472 | 21067 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_LONG; | |
| 1473 |
2/2✓ Branch 16 → 17 taken 7710 times.
✓ Branch 16 → 18 taken 95687 times.
|
103397 | } else if (ctx->TYPE_BYTE()) { |
| 1474 | 7710 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_BYTE; | |
| 1475 |
2/2✓ Branch 19 → 20 taken 11670 times.
✓ Branch 19 → 21 taken 84017 times.
|
95687 | } else if (ctx->TYPE_CHAR()) { |
| 1476 | 11670 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_CHAR; | |
| 1477 |
2/2✓ Branch 22 → 23 taken 9151 times.
✓ Branch 22 → 24 taken 74866 times.
|
84017 | } else if (ctx->TYPE_STRING()) { |
| 1478 | 9151 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_STRING; | |
| 1479 |
2/2✓ Branch 25 → 26 taken 10021 times.
✓ Branch 25 → 27 taken 64845 times.
|
74866 | } else if (ctx->TYPE_BOOL()) { |
| 1480 | 10021 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_BOOL; | |
| 1481 |
2/2✓ Branch 28 → 29 taken 1420 times.
✓ Branch 28 → 30 taken 63425 times.
|
64845 | } else if (ctx->TYPE_DYN()) { |
| 1482 | 1420 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_DYN; | |
| 1483 |
2/2✓ Branch 31 → 32 taken 63211 times.
✓ Branch 31 → 37 taken 214 times.
|
63425 | } else if (ctx->customDataType()) { |
| 1484 | 63211 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_CUSTOM; | |
| 1485 |
3/6✓ Branch 32 → 33 taken 63211 times.
✗ Branch 32 → 57 not taken.
✓ Branch 33 → 34 taken 63211 times.
✗ Branch 33 → 57 not taken.
✓ Branch 34 → 35 taken 63211 times.
✗ Branch 34 → 55 not taken.
|
63211 | baseDataTypeNode->customDataType = std::any_cast<CustomDataTypeNode *>(visit(ctx->customDataType())); |
| 1486 |
1/2✓ Branch 38 → 39 taken 214 times.
✗ Branch 38 → 44 not taken.
|
214 | } else if (ctx->functionDataType()) { |
| 1487 | 214 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_FUNCTION; | |
| 1488 |
3/6✓ Branch 39 → 40 taken 214 times.
✗ Branch 39 → 60 not taken.
✓ Branch 40 → 41 taken 214 times.
✗ Branch 40 → 60 not taken.
✓ Branch 41 → 42 taken 214 times.
✗ Branch 41 → 58 not taken.
|
214 | baseDataTypeNode->functionDataType = std::any_cast<FunctionDataTypeNode *>(visit(ctx->functionDataType())); |
| 1489 | } else { | ||
| 1490 | ✗ | assert_fail("Unknown base data type"); | |
| 1491 | } | ||
| 1492 | |||
| 1493 |
1/2✓ Branch 51 → 52 taken 136281 times.
✗ Branch 51 → 61 not taken.
|
272562 | return concludeNode(baseDataTypeNode); |
| 1494 | } | ||
| 1495 | |||
| 1496 | 63211 | std::any ASTBuilder::visitCustomDataType(SpiceParser::CustomDataTypeContext *ctx) { | |
| 1497 |
1/2✓ Branch 2 → 3 taken 63211 times.
✗ Branch 2 → 75 not taken.
|
63211 | const auto customDataTypeNode = createNode<CustomDataTypeNode>(ctx); |
| 1498 | |||
| 1499 | // Enrich | ||
| 1500 |
1/2✓ Branch 3 → 4 taken 63211 times.
✗ Branch 3 → 75 not taken.
|
63211 | std::stringstream fqTypeName; |
| 1501 |
2/2✓ Branch 39 → 6 taken 88185 times.
✓ Branch 39 → 40 taken 63211 times.
|
214607 | for (ParserRuleContext::ParseTree *subTree : ctx->children) { |
| 1502 |
1/2✓ Branch 8 → 9 taken 88185 times.
✗ Branch 8 → 10 not taken.
|
88185 | const auto terminal = dynamic_cast<TerminalNode *>(subTree); |
| 1503 |
2/2✓ Branch 11 → 12 taken 8256 times.
✓ Branch 11 → 13 taken 79929 times.
|
88185 | if (!terminal) |
| 1504 | 8256 | continue; | |
| 1505 | |||
| 1506 |
4/6✓ Branch 13 → 14 taken 79929 times.
✗ Branch 13 → 67 not taken.
✓ Branch 14 → 15 taken 79929 times.
✗ Branch 14 → 67 not taken.
✓ Branch 15 → 16 taken 103 times.
✓ Branch 15 → 22 taken 79826 times.
|
79929 | if (terminal->getSymbol()->getType() == SpiceParser::IDENTIFIER) { |
| 1507 |
1/2✓ Branch 16 → 17 taken 103 times.
✗ Branch 16 → 63 not taken.
|
103 | const std::string fragment = terminal->toString(); |
| 1508 |
1/2✓ Branch 17 → 18 taken 103 times.
✗ Branch 17 → 61 not taken.
|
103 | customDataTypeNode->typeNameFragments.push_back(fragment); |
| 1509 |
2/4✓ Branch 18 → 19 taken 103 times.
✗ Branch 18 → 61 not taken.
✓ Branch 19 → 20 taken 103 times.
✗ Branch 19 → 61 not taken.
|
103 | fqTypeName << fragment << SCOPE_ACCESS_TOKEN; |
| 1510 |
4/6✓ Branch 22 → 23 taken 79826 times.
✗ Branch 22 → 67 not taken.
✓ Branch 23 → 24 taken 79826 times.
✗ Branch 23 → 67 not taken.
✓ Branch 24 → 25 taken 63211 times.
✓ Branch 24 → 30 taken 16615 times.
|
79929 | } else if (terminal->getSymbol()->getType() == SpiceParser::TYPE_IDENTIFIER) { |
| 1511 |
1/2✓ Branch 25 → 26 taken 63211 times.
✗ Branch 25 → 66 not taken.
|
63211 | const std::string fragment = terminal->toString(); |
| 1512 |
1/2✓ Branch 26 → 27 taken 63211 times.
✗ Branch 26 → 64 not taken.
|
63211 | customDataTypeNode->typeNameFragments.push_back(fragment); |
| 1513 |
1/2✓ Branch 27 → 28 taken 63211 times.
✗ Branch 27 → 64 not taken.
|
63211 | fqTypeName << fragment; |
| 1514 | 63211 | } | |
| 1515 | } | ||
| 1516 |
1/2✓ Branch 40 → 41 taken 63211 times.
✗ Branch 40 → 68 not taken.
|
63211 | customDataTypeNode->fqTypeName = fqTypeName.str(); |
| 1517 | |||
| 1518 | // Visit children | ||
| 1519 |
3/4✓ Branch 43 → 44 taken 63211 times.
✗ Branch 43 → 73 not taken.
✓ Branch 44 → 45 taken 8256 times.
✓ Branch 44 → 50 taken 54955 times.
|
63211 | if (ctx->typeLst()) |
| 1520 |
3/6✓ Branch 45 → 46 taken 8256 times.
✗ Branch 45 → 71 not taken.
✓ Branch 46 → 47 taken 8256 times.
✗ Branch 46 → 71 not taken.
✓ Branch 47 → 48 taken 8256 times.
✗ Branch 47 → 69 not taken.
|
8256 | customDataTypeNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst())); |
| 1521 | |||
| 1522 |
1/2✓ Branch 56 → 57 taken 63211 times.
✗ Branch 56 → 72 not taken.
|
126422 | return concludeNode(customDataTypeNode); |
| 1523 | 63211 | } | |
| 1524 | |||
| 1525 | 214 | std::any ASTBuilder::visitFunctionDataType(SpiceParser::FunctionDataTypeContext *ctx) { | |
| 1526 | 214 | const auto functionDataTypeNode = createNode<FunctionDataTypeNode>(ctx); | |
| 1527 | |||
| 1528 | // Enrich | ||
| 1529 |
2/2✓ Branch 4 → 5 taken 51 times.
✓ Branch 4 → 11 taken 163 times.
|
214 | if (ctx->dataType()) { |
| 1530 | 51 | functionDataTypeNode->isFunction = ctx->dataType(); | |
| 1531 |
3/6✓ Branch 6 → 7 taken 51 times.
✗ Branch 6 → 30 not taken.
✓ Branch 7 → 8 taken 51 times.
✗ Branch 7 → 30 not taken.
✓ Branch 8 → 9 taken 51 times.
✗ Branch 8 → 28 not taken.
|
51 | functionDataTypeNode->returnType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 1532 | } | ||
| 1533 |
2/2✓ Branch 12 → 13 taken 161 times.
✓ Branch 12 → 18 taken 53 times.
|
214 | if (ctx->typeLst()) |
| 1534 |
3/6✓ Branch 13 → 14 taken 161 times.
✗ Branch 13 → 33 not taken.
✓ Branch 14 → 15 taken 161 times.
✗ Branch 14 → 33 not taken.
✓ Branch 15 → 16 taken 161 times.
✗ Branch 15 → 31 not taken.
|
161 | functionDataTypeNode->paramTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst())); |
| 1535 | |||
| 1536 |
1/2✓ Branch 24 → 25 taken 214 times.
✗ Branch 24 → 34 not taken.
|
428 | return concludeNode(functionDataTypeNode); |
| 1537 | } | ||
| 1538 | |||
| 1539 | 20846 | std::any ASTBuilder::visitAssignOp(SpiceParser::AssignOpContext *ctx) { | |
| 1540 | 20846 | const auto assignExprNode = resumeForExpansion<AssignExprNode>(); | |
| 1541 | |||
| 1542 | // Extract assign operator | ||
| 1543 |
2/2✓ Branch 13 → 14 taken 18542 times.
✓ Branch 13 → 15 taken 2304 times.
|
20846 | if (ctx->ASSIGN()) |
| 1544 | 18542 | assignExprNode->op = AssignExprNode::AssignOp::OP_ASSIGN; | |
| 1545 |
2/2✓ Branch 16 → 17 taken 1106 times.
✓ Branch 16 → 18 taken 1198 times.
|
2304 | else if (ctx->PLUS_EQUAL()) |
| 1546 | 1106 | assignExprNode->op = AssignExprNode::AssignOp::OP_PLUS_EQUAL; | |
| 1547 |
2/2✓ Branch 19 → 20 taken 164 times.
✓ Branch 19 → 21 taken 1034 times.
|
1198 | else if (ctx->MINUS_EQUAL()) |
| 1548 | 164 | assignExprNode->op = AssignExprNode::AssignOp::OP_MINUS_EQUAL; | |
| 1549 |
2/2✓ Branch 22 → 23 taken 183 times.
✓ Branch 22 → 24 taken 851 times.
|
1034 | else if (ctx->MUL_EQUAL()) |
| 1550 | 183 | assignExprNode->op = AssignExprNode::AssignOp::OP_MUL_EQUAL; | |
| 1551 |
2/2✓ Branch 25 → 26 taken 90 times.
✓ Branch 25 → 27 taken 761 times.
|
851 | else if (ctx->DIV_EQUAL()) |
| 1552 | 90 | assignExprNode->op = AssignExprNode::AssignOp::OP_DIV_EQUAL; | |
| 1553 |
2/2✓ Branch 28 → 29 taken 25 times.
✓ Branch 28 → 30 taken 736 times.
|
761 | else if (ctx->REM_EQUAL()) |
| 1554 | 25 | assignExprNode->op = AssignExprNode::AssignOp::OP_REM_EQUAL; | |
| 1555 |
2/2✓ Branch 31 → 32 taken 3 times.
✓ Branch 31 → 33 taken 733 times.
|
736 | else if (ctx->SHL_EQUAL()) |
| 1556 | 3 | assignExprNode->op = AssignExprNode::AssignOp::OP_SHL_EQUAL; | |
| 1557 |
2/2✓ Branch 34 → 35 taken 4 times.
✓ Branch 34 → 36 taken 729 times.
|
733 | else if (ctx->SHR_EQUAL()) |
| 1558 | 4 | assignExprNode->op = AssignExprNode::AssignOp::OP_SHR_EQUAL; | |
| 1559 |
2/2✓ Branch 37 → 38 taken 8 times.
✓ Branch 37 → 39 taken 721 times.
|
729 | else if (ctx->AND_EQUAL()) |
| 1560 | 8 | assignExprNode->op = AssignExprNode::AssignOp::OP_AND_EQUAL; | |
| 1561 |
2/2✓ Branch 40 → 41 taken 4 times.
✓ Branch 40 → 42 taken 717 times.
|
721 | else if (ctx->OR_EQUAL()) |
| 1562 | 4 | assignExprNode->op = AssignExprNode::AssignOp::OP_OR_EQUAL; | |
| 1563 |
1/2✓ Branch 43 → 44 taken 717 times.
✗ Branch 43 → 45 not taken.
|
717 | else if (ctx->XOR_EQUAL()) |
| 1564 | 717 | assignExprNode->op = AssignExprNode::AssignOp::OP_XOR_EQUAL; | |
| 1565 | else | ||
| 1566 | ✗ | assert_fail("Unknown assign operator"); | |
| 1567 | |||
| 1568 |
1/2✓ Branch 46 → 47 taken 20846 times.
✗ Branch 46 → 50 not taken.
|
41692 | return nullptr; |
| 1569 | } | ||
| 1570 | |||
| 1571 | 3708 | std::any ASTBuilder::visitOverloadableOp(SpiceParser::OverloadableOpContext *ctx) { | |
| 1572 | 3708 | const auto fctNameNode = resumeForExpansion<FctNameNode>(); | |
| 1573 | |||
| 1574 | // Enrich | ||
| 1575 |
2/2✓ Branch 13 → 14 taken 163 times.
✓ Branch 13 → 15 taken 3545 times.
|
3708 | if (ctx->PLUS()) |
| 1576 | 163 | fctNameNode->name = OP_FCT_PLUS; | |
| 1577 |
2/2✓ Branch 16 → 17 taken 1 time.
✓ Branch 16 → 18 taken 3544 times.
|
3545 | else if (ctx->MINUS()) |
| 1578 | 1 | fctNameNode->name = OP_FCT_MINUS; | |
| 1579 |
2/2✓ Branch 19 → 20 taken 323 times.
✓ Branch 19 → 21 taken 3221 times.
|
3544 | else if (ctx->MUL()) |
| 1580 | 323 | fctNameNode->name = OP_FCT_MUL; | |
| 1581 |
2/2✓ Branch 22 → 23 taken 37 times.
✓ Branch 22 → 24 taken 3184 times.
|
3221 | else if (ctx->DIV()) |
| 1582 | 37 | fctNameNode->name = OP_FCT_DIV; | |
| 1583 |
2/2✓ Branch 25 → 26 taken 830 times.
✓ Branch 25 → 27 taken 2354 times.
|
3184 | else if (ctx->EQUAL()) |
| 1584 | 830 | fctNameNode->name = OP_FCT_EQUAL; | |
| 1585 |
2/2✓ Branch 28 → 29 taken 796 times.
✓ Branch 28 → 30 taken 1558 times.
|
2354 | else if (ctx->NOT_EQUAL()) |
| 1586 | 796 | fctNameNode->name = OP_FCT_NOT_EQUAL; | |
| 1587 |
3/4✓ Branch 30 → 31 taken 1558 times.
✗ Branch 30 → 83 not taken.
✓ Branch 33 → 34 taken 70 times.
✓ Branch 33 → 35 taken 1488 times.
|
1558 | else if (ctx->LESS().size() == 2) |
| 1588 | 70 | fctNameNode->name = OP_FCT_SHL; | |
| 1589 |
3/4✓ Branch 35 → 36 taken 1488 times.
✗ Branch 35 → 84 not taken.
✓ Branch 38 → 39 taken 1 time.
✓ Branch 38 → 40 taken 1487 times.
|
1488 | else if (ctx->GREATER().size() == 2) |
| 1590 | 1 | fctNameNode->name = OP_FCT_SHR; | |
| 1591 |
2/2✓ Branch 41 → 42 taken 3 times.
✓ Branch 41 → 43 taken 1484 times.
|
1487 | else if (ctx->BITWISE_AND()) |
| 1592 | 3 | fctNameNode->name = OP_FCT_BITWISE_AND; | |
| 1593 |
2/2✓ Branch 44 → 45 taken 3 times.
✓ Branch 44 → 46 taken 1481 times.
|
1484 | else if (ctx->BITWISE_OR()) |
| 1594 | 3 | fctNameNode->name = OP_FCT_BITWISE_OR; | |
| 1595 |
2/2✓ Branch 47 → 48 taken 3 times.
✓ Branch 47 → 49 taken 1478 times.
|
1481 | else if (ctx->BITWISE_XOR()) |
| 1596 | 3 | fctNameNode->name = OP_FCT_BITWISE_XOR; | |
| 1597 |
2/2✓ Branch 50 → 51 taken 3 times.
✓ Branch 50 → 52 taken 1475 times.
|
1478 | else if (ctx->BITWISE_NOT()) |
| 1598 | 3 | fctNameNode->name = OP_FCT_BITWISE_NOT; | |
| 1599 |
2/2✓ Branch 53 → 54 taken 261 times.
✓ Branch 53 → 55 taken 1214 times.
|
1475 | else if (ctx->PLUS_EQUAL()) |
| 1600 | 261 | fctNameNode->name = OP_FCT_PLUS_EQUAL; | |
| 1601 |
2/2✓ Branch 56 → 57 taken 100 times.
✓ Branch 56 → 58 taken 1114 times.
|
1214 | else if (ctx->MINUS_EQUAL()) |
| 1602 | 100 | fctNameNode->name = OP_FCT_MINUS_EQUAL; | |
| 1603 |
2/2✓ Branch 59 → 60 taken 162 times.
✓ Branch 59 → 61 taken 952 times.
|
1114 | else if (ctx->MUL_EQUAL()) |
| 1604 | 162 | fctNameNode->name = OP_FCT_MUL_EQUAL; | |
| 1605 |
2/2✓ Branch 62 → 63 taken 37 times.
✓ Branch 62 → 64 taken 915 times.
|
952 | else if (ctx->DIV_EQUAL()) |
| 1606 | 37 | fctNameNode->name = OP_FCT_DIV_EQUAL; | |
| 1607 |
2/2✓ Branch 65 → 66 taken 130 times.
✓ Branch 65 → 67 taken 785 times.
|
915 | else if (ctx->PLUS_PLUS()) |
| 1608 | 130 | fctNameNode->name = OP_FCT_POSTFIX_PLUS_PLUS; | |
| 1609 |
2/2✓ Branch 68 → 69 taken 100 times.
✓ Branch 68 → 70 taken 685 times.
|
785 | else if (ctx->MINUS_MINUS()) |
| 1610 | 100 | fctNameNode->name = OP_FCT_POSTFIX_MINUS_MINUS; | |
| 1611 |
2/2✓ Branch 71 → 72 taken 406 times.
✓ Branch 71 → 73 taken 279 times.
|
685 | else if (ctx->LBRACKET()) |
| 1612 | 406 | fctNameNode->name = OP_FCT_SUBSCRIPT; | |
| 1613 |
1/2✓ Branch 74 → 75 taken 279 times.
✗ Branch 74 → 76 not taken.
|
279 | else if (ctx->ASSIGN()) |
| 1614 | 279 | fctNameNode->name = OP_FCT_ASSIGN; | |
| 1615 | else | ||
| 1616 | − | assert_fail("Unsupported overloadable operator"); // GCOV_EXCL_LINE | |
| 1617 | |||
| 1618 | 3708 | fctNameNode->fqName = fctNameNode->name; | |
| 1619 | 3708 | fctNameNode->nameFragments.push_back(fctNameNode->name); | |
| 1620 | |||
| 1621 |
1/2✓ Branch 79 → 80 taken 3708 times.
✗ Branch 79 → 85 not taken.
|
7416 | return nullptr; |
| 1622 | } | ||
| 1623 | |||
| 1624 | 11786 | int32_t ASTBuilder::parseInt(TerminalNode *terminal, bool isNegative) { | |
| 1625 | 35358 | const NumericParserCallback<int32_t> cb = [isNegative](const std::string &substr, short base, bool isSigned) -> int32_t { | |
| 1626 | // Prepare limits | ||
| 1627 |
2/2✓ Branch 2 → 3 taken 11724 times.
✓ Branch 2 → 4 taken 62 times.
|
11786 | const int64_t upperLimit = isSigned ? INT32_MAX : UINT32_MAX; |
| 1628 |
2/2✓ Branch 5 → 6 taken 11724 times.
✓ Branch 5 → 7 taken 62 times.
|
11786 | const int64_t lowerLimit = isSigned ? INT32_MIN : 0; |
| 1629 | // Parse number, apply sign and check for limits | ||
| 1630 | 11786 | int64_t number = std::stoll(substr, nullptr, base); | |
| 1631 |
2/2✓ Branch 9 → 10 taken 207 times.
✓ Branch 9 → 11 taken 11578 times.
|
11785 | if (isNegative) |
| 1632 | 207 | number = -number; | |
| 1633 |
2/4✓ Branch 11 → 12 taken 11785 times.
✗ Branch 11 → 13 not taken.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 16 taken 11785 times.
|
11785 | if (number < lowerLimit || number > upperLimit) |
| 1634 | ✗ | throw std::out_of_range("Number out of range"); | |
| 1635 | 11785 | return static_cast<int32_t>(number); | |
| 1636 | 11786 | }; | |
| 1637 |
2/2✓ Branch 3 → 4 taken 11785 times.
✓ Branch 3 → 8 taken 1 time.
|
23571 | return parseNumeric(terminal, cb); |
| 1638 | 11786 | } | |
| 1639 | |||
| 1640 | 1108 | int16_t ASTBuilder::parseShort(TerminalNode *terminal, bool isNegative) { | |
| 1641 | 3324 | const NumericParserCallback<int16_t> cb = [isNegative](const std::string &substr, short base, bool isSigned) -> int16_t { | |
| 1642 | // Prepare limits | ||
| 1643 |
2/2✓ Branch 2 → 3 taken 774 times.
✓ Branch 2 → 4 taken 334 times.
|
1108 | const int64_t upperLimit = isSigned ? INT16_MAX : UINT16_MAX; |
| 1644 |
2/2✓ Branch 5 → 6 taken 774 times.
✓ Branch 5 → 7 taken 334 times.
|
1108 | const int64_t lowerLimit = isSigned ? INT16_MIN : 0; |
| 1645 | // Parse number, apply sign and check for limits | ||
| 1646 | 1108 | int64_t number = std::stoll(substr, nullptr, base); | |
| 1647 |
2/2✓ Branch 9 → 10 taken 86 times.
✓ Branch 9 → 11 taken 1022 times.
|
1108 | if (isNegative) |
| 1648 | 86 | number = -number; | |
| 1649 |
2/4✓ Branch 11 → 12 taken 1108 times.
✗ Branch 11 → 13 not taken.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 16 taken 1108 times.
|
1108 | if (number < lowerLimit || number > upperLimit) |
| 1650 | ✗ | throw std::out_of_range("Number out of range"); | |
| 1651 | 1108 | return static_cast<int16_t>(number); | |
| 1652 | 1108 | }; | |
| 1653 |
1/2✓ Branch 3 → 4 taken 1108 times.
✗ Branch 3 → 8 not taken.
|
2216 | return parseNumeric(terminal, cb); |
| 1654 | 1108 | } | |
| 1655 | |||
| 1656 | 16890 | int64_t ASTBuilder::parseLong(TerminalNode *terminal, bool isNegative) { | |
| 1657 | 50670 | const NumericParserCallback<int64_t> cb = [isNegative](const std::string &substr, short base, bool isSigned) -> int64_t { | |
| 1658 | // Parse the magnitude as unsigned so values like 2^63 (the absolute value of INT64_MIN) fit | ||
| 1659 | 16890 | const uint64_t magnitude = std::stoull(substr, nullptr, base); | |
| 1660 |
2/2✓ Branch 3 → 4 taken 1775 times.
✓ Branch 3 → 11 taken 15115 times.
|
16890 | if (isNegative) { |
| 1661 | 1775 | constexpr uint64_t maxNegMagnitude = static_cast<uint64_t>(INT64_MAX) + 1; // 2^63 | |
| 1662 |
1/2✗ Branch 4 → 5 not taken.
✓ Branch 4 → 8 taken 1775 times.
|
1775 | if (magnitude > maxNegMagnitude) |
| 1663 | ✗ | throw std::out_of_range("Number out of range"); | |
| 1664 |
2/2✓ Branch 8 → 9 taken 2 times.
✓ Branch 8 → 10 taken 1773 times.
|
1775 | if (magnitude == maxNegMagnitude) |
| 1665 | 2 | return INT64_MIN; | |
| 1666 | 1773 | return -static_cast<int64_t>(magnitude); | |
| 1667 | } | ||
| 1668 |
3/4✓ Branch 11 → 12 taken 13824 times.
✓ Branch 11 → 16 taken 1291 times.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 16 taken 13824 times.
|
15115 | if (isSigned && magnitude > static_cast<uint64_t>(INT64_MAX)) |
| 1669 | ✗ | throw std::out_of_range("Number out of range"); | |
| 1670 | 15115 | return static_cast<int64_t>(magnitude); | |
| 1671 | 16890 | }; | |
| 1672 |
1/2✓ Branch 3 → 4 taken 16890 times.
✗ Branch 3 → 8 not taken.
|
33780 | return parseNumeric(terminal, cb); |
| 1673 | 16890 | } | |
| 1674 | |||
| 1675 | 5510 | int8_t ASTBuilder::parseChar(TerminalNode *terminal) const { | |
| 1676 |
1/2✓ Branch 2 → 3 taken 5510 times.
✗ Branch 2 → 59 not taken.
|
5510 | const std::string input = terminal->toString(); |
| 1677 |
2/2✓ Branch 4 → 5 taken 3562 times.
✓ Branch 4 → 7 taken 1948 times.
|
5510 | if (input.length() == 3) // Normal char literals |
| 1678 | 3562 | return input[1]; | |
| 1679 | |||
| 1680 |
3/6✓ Branch 8 → 9 taken 1948 times.
✗ Branch 8 → 12 not taken.
✓ Branch 10 → 11 taken 1948 times.
✗ Branch 10 → 12 not taken.
✓ Branch 13 → 14 taken 1948 times.
✗ Branch 13 → 34 not taken.
|
1948 | if (input.length() == 4 && input[1] == '\\') { // Char literals with escape sequence |
| 1681 |
9/11✓ Branch 15 → 16 taken 24 times.
✗ Branch 15 → 17 not taken.
✓ Branch 15 → 18 taken 35 times.
✓ Branch 15 → 19 taken 216 times.
✓ Branch 15 → 20 taken 167 times.
✓ Branch 15 → 21 taken 164 times.
✓ Branch 15 → 22 taken 3 times.
✓ Branch 15 → 23 taken 3 times.
✗ Branch 15 → 24 not taken.
✓ Branch 15 → 25 taken 1335 times.
✓ Branch 15 → 26 taken 1 time.
|
1948 | switch (input[2]) { |
| 1682 | 24 | case '\'': | |
| 1683 | 24 | return '\''; | |
| 1684 | ✗ | case '"': | |
| 1685 | ✗ | return '\"'; | |
| 1686 | 35 | case '\\': | |
| 1687 | 35 | return '\\'; | |
| 1688 | 216 | case 'n': | |
| 1689 | 216 | return '\n'; | |
| 1690 | 167 | case 'r': | |
| 1691 | 167 | return '\r'; | |
| 1692 | 164 | case 't': | |
| 1693 | 164 | return '\t'; | |
| 1694 | 3 | case 'b': | |
| 1695 | 3 | return '\b'; | |
| 1696 | 3 | case 'f': | |
| 1697 | 3 | return '\f'; | |
| 1698 | ✗ | case 'v': | |
| 1699 | ✗ | return '\v'; | |
| 1700 | 1335 | case '0': | |
| 1701 | 1335 | return '\0'; | |
| 1702 | 1 | default: | |
| 1703 |
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); |
| 1704 |
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); |
| 1705 | } | ||
| 1706 | } | ||
| 1707 | |||
| 1708 | ✗ | const CodeLoc codeLoc(terminal->getSymbol(), sourceFile); | |
| 1709 | ✗ | throw ParserError(codeLoc, INVALID_CHAR_LITERAL, "Invalid char literal " + input); | |
| 1710 | 5510 | } | |
| 1711 | |||
| 1712 | 11475 | std::string ASTBuilder::parseString(std::string input) { | |
| 1713 |
1/2✓ Branch 3 → 4 taken 11475 times.
✗ Branch 3 → 9 not taken.
|
11475 | input = input.substr(1, input.size() - 2); |
| 1714 | 11475 | replaceEscapeChars(input); | |
| 1715 | 11475 | return input; | |
| 1716 | } | ||
| 1717 | |||
| 1718 | 29784 | template <typename T> T ASTBuilder::parseNumeric(TerminalNode *terminal, const NumericParserCallback<T> &cb) { | |
| 1719 |
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 11786 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 16890 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 1108 times.
✗ Branch 2 → 87 not taken.
|
29784 | const std::string input = terminal->toString(); |
| 1720 | |||
| 1721 | // Set to signed if the input string does not end with 'u' | ||
| 1722 |
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 11724 times.
✓ Branch 4 → 9 taken 62 times.
✓ Branch 6 → 7 taken 11724 times.
✗ Branch 6 → 9 not taken.
✗ Branch 8 → 9 not taken.
✓ Branch 8 → 10 taken 11724 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 16890 times.
✗ Branch 4 → 9 not taken.
✓ Branch 6 → 7 taken 16890 times.
✗ Branch 6 → 9 not taken.
✓ Branch 8 → 9 taken 1291 times.
✓ Branch 8 → 10 taken 15599 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 1108 times.
✗ Branch 4 → 9 not taken.
✓ Branch 6 → 7 taken 774 times.
✓ Branch 6 → 9 taken 334 times.
✗ Branch 8 → 9 not taken.
✓ Branch 8 → 10 taken 774 times.
|
29784 | const bool isUnsigned = input.ends_with('u') || input.ends_with("us") || input.ends_with("ul"); |
| 1723 | |||
| 1724 | try { | ||
| 1725 |
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 1421 times.
✓ Branch 12 → 30 taken 10365 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 2028 times.
✓ Branch 12 → 30 taken 14862 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 375 times.
|
29784 | if (input.length() >= 3) { |
| 1726 |
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 1089 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 749 times.
✓ Branch 14 → 30 taken 1279 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.
|
4182 | if (input[0] == '0') { |
| 1727 |
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 749 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.
|
1262 | const std::string subStr = input.substr(2); |
| 1728 |
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 133 times.
✗ Branch 17 → 24 not taken.
✓ Branch 17 → 26 taken 616 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.
|
1262 | switch (input[1]) { |
| 1729 | ✗ | case 'd': // fall-through | |
| 1730 | case 'D': | ||
| 1731 | ✗ | return cb(subStr, 10, !isUnsigned); | |
| 1732 | ✗ | case 'b': // fall-through | |
| 1733 | case 'B': | ||
| 1734 | ✗ | return cb(subStr, 2, !isUnsigned); | |
| 1735 | 146 | case 'h': // fall-through | |
| 1736 | case 'H': // fall-through | ||
| 1737 | case 'x': // fall-through | ||
| 1738 | case 'X': | ||
| 1739 |
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 133 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.
|
146 | return cb(subStr, 16, !isUnsigned); |
| 1740 | 499 | case 'o': // fall-through | |
| 1741 | case 'O': | ||
| 1742 |
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); |
| 1743 | 617 | default: // default is decimal | |
| 1744 |
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 616 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.
|
617 | return cb(input, 10, !isUnsigned); |
| 1745 | } | ||
| 1746 | 1262 | } | |
| 1747 | } | ||
| 1748 |
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 11453 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 16141 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 927 times.
✗ Branch 30 → 38 not taken.
|
28522 | return cb(input, 10, !isUnsigned); |
| 1749 |
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 &) { |
| 1750 |
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); |
| 1751 |
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"); |
| 1752 | ✗ | } catch (std::invalid_argument &) { | |
| 1753 | ✗ | const CodeLoc codeLoc(terminal->getSymbol(), sourceFile); | |
| 1754 | ✗ | throw ParserError(codeLoc, NUMBER_OUT_OF_RANGE, "You tried to parse '" + input + "' as an integer, but it was no integer"); | |
| 1755 | } | ||
| 1756 | 29784 | } | |
| 1757 | |||
| 1758 | 11475 | void ASTBuilder::replaceEscapeChars(std::string &input) { | |
| 1759 | 11475 | const std::unordered_map<char, char> escapeMap = { | |
| 1760 | {'a', '\a'}, {'b', '\b'}, {'f', '\f'}, {'n', '\n'}, {'r', '\r'}, {'t', '\t'}, | ||
| 1761 | {'v', '\v'}, {'\\', '\\'}, {'?', '\?'}, {'\'', '\''}, {'"', '\"'}, | ||
| 1762 |
1/2✓ Branch 4 → 5 taken 11475 times.
✗ Branch 4 → 40 not taken.
|
22950 | }; |
| 1763 | |||
| 1764 | 11475 | size_t writeIndex = 0; | |
| 1765 | 11475 | size_t readIndex = 0; | |
| 1766 | 11475 | const size_t len = input.length(); | |
| 1767 | |||
| 1768 |
2/2✓ Branch 36 → 8 taken 162210 times.
✓ Branch 36 → 37 taken 11475 times.
|
173685 | while (readIndex < len) { |
| 1769 | 162210 | const char c = input[readIndex]; | |
| 1770 |
3/4✓ Branch 9 → 10 taken 1510 times.
✓ Branch 9 → 33 taken 160700 times.
✓ Branch 10 → 11 taken 1510 times.
✗ Branch 10 → 33 not taken.
|
162210 | if (c == '\\' && readIndex + 1 < len) { |
| 1771 | 1510 | char next = input[readIndex + 1]; | |
| 1772 |
1/2✓ Branch 12 → 13 taken 1510 times.
✗ Branch 12 → 45 not taken.
|
1510 | auto it = escapeMap.find(next); |
| 1773 |
2/2✓ Branch 15 → 16 taken 1501 times.
✓ Branch 15 → 19 taken 9 times.
|
1510 | if (it != escapeMap.end()) { |
| 1774 | 1501 | input[writeIndex++] = it->second; | |
| 1775 | 1501 | readIndex += 2; | |
| 1776 | 1507 | continue; | |
| 1777 | } | ||
| 1778 | |||
| 1779 | // Handle octal escape sequences (up to 3 digits) | ||
| 1780 |
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') { |
| 1781 | 6 | int value = 0; | |
| 1782 | 6 | size_t octalDigits = 0; | |
| 1783 | |||
| 1784 | // Look ahead up to 3 digits | ||
| 1785 |
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) { |
| 1786 | 18 | const char oc = input[readIndex + i]; | |
| 1787 |
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') { |
| 1788 | 18 | value = value << 3 | (oc - '0'); // multiply by 8 and add digit | |
| 1789 | 18 | octalDigits++; | |
| 1790 | } else { | ||
| 1791 | break; | ||
| 1792 | } | ||
| 1793 | } | ||
| 1794 | |||
| 1795 |
1/2✓ Branch 28 → 29 taken 6 times.
✗ Branch 28 → 31 not taken.
|
6 | if (octalDigits > 0) { |
| 1796 | 6 | input[writeIndex++] = static_cast<char>(value); | |
| 1797 | 6 | readIndex += 1 + octalDigits; // backslash + octal digits | |
| 1798 | 6 | continue; | |
| 1799 | } | ||
| 1800 | } | ||
| 1801 | } | ||
| 1802 | |||
| 1803 | // Copy current character | ||
| 1804 | 160703 | input[writeIndex++] = c; | |
| 1805 | 160703 | readIndex++; | |
| 1806 | } | ||
| 1807 | |||
| 1808 |
1/2✓ Branch 37 → 38 taken 11475 times.
✗ Branch 37 → 46 not taken.
|
11475 | input.resize(writeIndex); |
| 1809 | 11475 | } | |
| 1810 | |||
| 1811 | 334332 | std::string ASTBuilder::getIdentifier(TerminalNode *terminal, bool isTypeIdentifier) const { | |
| 1812 | 334332 | const std::string identifier = terminal->getText(); | |
| 1813 | |||
| 1814 | // Check if the list of reserved keywords contains the given identifier | ||
| 1815 |
3/4✓ Branch 3 → 4 taken 334332 times.
✗ Branch 3 → 52 not taken.
✓ Branch 4 → 5 taken 1 time.
✓ Branch 4 → 14 taken 334331 times.
|
334332 | if (std::ranges::find(RESERVED_KEYWORDS, identifier) != std::end(RESERVED_KEYWORDS)) { |
| 1816 |
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); |
| 1817 |
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"); |
| 1818 | } | ||
| 1819 | |||
| 1820 | // Check if the identifier is a type identifier and is reserved | ||
| 1821 |
6/6✓ Branch 14 → 15 taken 28748 times.
✓ Branch 14 → 19 taken 305583 times.
✓ Branch 15 → 16 taken 7539 times.
✓ Branch 15 → 19 taken 21209 times.
✓ Branch 20 → 21 taken 1 time.
✓ Branch 20 → 30 taken 334330 times.
|
341870 | if (isTypeIdentifier && !sourceFile->isStdFile && |
| 1822 |
3/4✓ Branch 16 → 17 taken 7539 times.
✗ Branch 16 → 52 not taken.
✓ Branch 17 → 18 taken 1 time.
✓ Branch 17 → 19 taken 7538 times.
|
7539 | std::ranges::find(RESERVED_TYPE_NAMES, identifier) != std::end(RESERVED_TYPE_NAMES)) { |
| 1823 |
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); |
| 1824 |
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"); |
| 1825 | } | ||
| 1826 | |||
| 1827 | 334330 | return identifier; | |
| 1828 | 2 | } | |
| 1829 | |||
| 1830 | } // namespace spice::compiler | ||
| 1831 |