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 | 1304 | ASTBuilder::ASTBuilder(GlobalResourceManager &resourceManager, SourceFile *sourceFile, antlr4::ANTLRInputStream *inputStream) | |
| 17 |
1/2✓ Branch 4 → 5 taken 1304 times.
✗ Branch 4 → 6 not taken.
|
1304 | : CompilerPass(resourceManager, sourceFile), inputStream(inputStream) {} |
| 18 | |||
| 19 | 1302 | std::any ASTBuilder::visitEntry(SpiceParser::EntryContext *ctx) { | |
| 20 | 1302 | const auto entryNode = createNode<EntryNode>(ctx); | |
| 21 | |||
| 22 | // Visit children | ||
| 23 |
2/2✓ Branch 127 → 5 taken 20899 times.
✓ Branch 127 → 128 taken 1296 times.
|
22195 | for (ParserRuleContext::ParseTree *child : ctx->children) { |
| 24 |
3/4✓ Branch 6 → 7 taken 20899 times.
✗ Branch 6 → 8 not taken.
✓ Branch 9 → 10 taken 453 times.
✓ Branch 9 → 15 taken 20446 times.
|
20899 | if (auto *mainFctDefCtx = dynamic_cast<SpiceParser::MainFunctionDefContext *>(child)) |
| 25 |
4/6✓ Branch 10 → 11 taken 449 times.
✓ Branch 10 → 140 taken 4 times.
✓ Branch 11 → 12 taken 449 times.
✗ Branch 11 → 138 not taken.
✓ Branch 12 → 13 taken 449 times.
✗ Branch 12 → 138 not taken.
|
453 | entryNode->topLevelDefs.push_back(std::any_cast<MainFctDefNode *>(visit(mainFctDefCtx))); |
| 26 |
3/4✓ Branch 15 → 16 taken 20446 times.
✗ Branch 15 → 17 not taken.
✓ Branch 18 → 19 taken 8753 times.
✓ Branch 18 → 24 taken 11693 times.
|
20446 | else if (auto *fctDefCtx = dynamic_cast<SpiceParser::FunctionDefContext *>(child)) |
| 27 |
3/6✓ Branch 19 → 20 taken 8753 times.
✗ Branch 19 → 144 not taken.
✓ Branch 20 → 21 taken 8753 times.
✗ Branch 20 → 142 not taken.
✓ Branch 21 → 22 taken 8753 times.
✗ Branch 21 → 142 not taken.
|
8753 | entryNode->topLevelDefs.push_back(std::any_cast<FctDefNode *>(visit(fctDefCtx))); |
| 28 |
3/4✓ Branch 24 → 25 taken 11693 times.
✗ Branch 24 → 26 not taken.
✓ Branch 27 → 28 taken 4712 times.
✓ Branch 27 → 33 taken 6981 times.
|
11693 | else if (auto *procDefCtx = dynamic_cast<SpiceParser::ProcedureDefContext *>(child)) |
| 29 |
3/6✓ Branch 28 → 29 taken 4712 times.
✗ Branch 28 → 148 not taken.
✓ Branch 29 → 30 taken 4712 times.
✗ Branch 29 → 146 not taken.
✓ Branch 30 → 31 taken 4712 times.
✗ Branch 30 → 146 not taken.
|
4712 | entryNode->topLevelDefs.push_back(std::any_cast<ProcDefNode *>(visit(procDefCtx))); |
| 30 |
3/4✓ Branch 33 → 34 taken 6981 times.
✗ Branch 33 → 35 not taken.
✓ Branch 36 → 37 taken 804 times.
✓ Branch 36 → 42 taken 6177 times.
|
6981 | else if (auto *structDefCtx = dynamic_cast<SpiceParser::StructDefContext *>(child)) |
| 31 |
4/6✓ Branch 37 → 38 taken 803 times.
✓ Branch 37 → 152 taken 1 time.
✓ Branch 38 → 39 taken 803 times.
✗ Branch 38 → 150 not taken.
✓ Branch 39 → 40 taken 803 times.
✗ Branch 39 → 150 not taken.
|
804 | entryNode->topLevelDefs.push_back(std::any_cast<StructDefNode *>(visit(structDefCtx))); |
| 32 |
3/4✓ Branch 42 → 43 taken 6177 times.
✗ Branch 42 → 44 not taken.
✓ Branch 45 → 46 taken 110 times.
✓ Branch 45 → 51 taken 6067 times.
|
6177 | else if (auto *interfaceDefCtx = dynamic_cast<SpiceParser::InterfaceDefContext *>(child)) |
| 33 |
3/6✓ Branch 46 → 47 taken 110 times.
✗ Branch 46 → 156 not taken.
✓ Branch 47 → 48 taken 110 times.
✗ Branch 47 → 154 not taken.
✓ Branch 48 → 49 taken 110 times.
✗ Branch 48 → 154 not taken.
|
110 | entryNode->topLevelDefs.push_back(std::any_cast<InterfaceDefNode *>(visit(interfaceDefCtx))); |
| 34 |
3/4✓ Branch 51 → 52 taken 6067 times.
✗ Branch 51 → 53 not taken.
✓ Branch 54 → 55 taken 78 times.
✓ Branch 54 → 60 taken 5989 times.
|
6067 | else if (auto *enumDefCtx = dynamic_cast<SpiceParser::EnumDefContext *>(child)) |
| 35 |
3/6✓ Branch 55 → 56 taken 78 times.
✗ Branch 55 → 160 not taken.
✓ Branch 56 → 57 taken 78 times.
✗ Branch 56 → 158 not taken.
✓ Branch 57 → 58 taken 78 times.
✗ Branch 57 → 158 not taken.
|
78 | entryNode->topLevelDefs.push_back(std::any_cast<EnumDefNode *>(visit(enumDefCtx))); |
| 36 |
3/4✓ Branch 60 → 61 taken 5989 times.
✗ Branch 60 → 62 not taken.
✓ Branch 63 → 64 taken 1059 times.
✓ Branch 63 → 69 taken 4930 times.
|
5989 | else if (auto *genericTypeDefCtx = dynamic_cast<SpiceParser::GenericTypeDefContext *>(child)) |
| 37 |
3/6✓ Branch 64 → 65 taken 1059 times.
✗ Branch 64 → 164 not taken.
✓ Branch 65 → 66 taken 1059 times.
✗ Branch 65 → 162 not taken.
✓ Branch 66 → 67 taken 1059 times.
✗ Branch 66 → 162 not taken.
|
1059 | entryNode->topLevelDefs.push_back(std::any_cast<GenericTypeDefNode *>(visit(genericTypeDefCtx))); |
| 38 |
3/4✓ Branch 69 → 70 taken 4930 times.
✗ Branch 69 → 71 not taken.
✓ Branch 72 → 73 taken 110 times.
✓ Branch 72 → 78 taken 4820 times.
|
4930 | else if (auto *aliasDefCtx = dynamic_cast<SpiceParser::AliasDefContext *>(child)) |
| 39 |
3/6✓ Branch 73 → 74 taken 110 times.
✗ Branch 73 → 168 not taken.
✓ Branch 74 → 75 taken 110 times.
✗ Branch 74 → 166 not taken.
✓ Branch 75 → 76 taken 110 times.
✗ Branch 75 → 166 not taken.
|
110 | entryNode->topLevelDefs.push_back(std::any_cast<AliasDefNode *>(visit(aliasDefCtx))); |
| 40 |
3/4✓ Branch 78 → 79 taken 4820 times.
✗ Branch 78 → 80 not taken.
✓ Branch 81 → 82 taken 1276 times.
✓ Branch 81 → 87 taken 3544 times.
|
4820 | else if (auto *globalVarDefCtx = dynamic_cast<SpiceParser::GlobalVarDefContext *>(child)) |
| 41 |
3/6✓ Branch 82 → 83 taken 1276 times.
✗ Branch 82 → 172 not taken.
✓ Branch 83 → 84 taken 1276 times.
✗ Branch 83 → 170 not taken.
✓ Branch 84 → 85 taken 1276 times.
✗ Branch 84 → 170 not taken.
|
1276 | entryNode->topLevelDefs.push_back(std::any_cast<GlobalVarDefNode *>(visit(globalVarDefCtx))); |
| 42 |
3/4✓ Branch 87 → 88 taken 3544 times.
✗ Branch 87 → 89 not taken.
✓ Branch 90 → 91 taken 684 times.
✓ Branch 90 → 96 taken 2860 times.
|
3544 | else if (auto *importDefCtx = dynamic_cast<SpiceParser::ImportDefContext *>(child)) |
| 43 |
3/6✓ Branch 91 → 92 taken 684 times.
✗ Branch 91 → 176 not taken.
✓ Branch 92 → 93 taken 684 times.
✗ Branch 92 → 174 not taken.
✓ Branch 93 → 94 taken 684 times.
✗ Branch 93 → 174 not taken.
|
684 | entryNode->importDefs.push_back(std::any_cast<ImportDefNode *>(visit(importDefCtx))); |
| 44 |
3/4✓ Branch 96 → 97 taken 2860 times.
✗ Branch 96 → 98 not taken.
✓ Branch 99 → 100 taken 1157 times.
✓ Branch 99 → 105 taken 1703 times.
|
2860 | else if (auto *extDeclCtx = dynamic_cast<SpiceParser::ExtDeclContext *>(child)) |
| 45 |
3/6✓ Branch 100 → 101 taken 1157 times.
✗ Branch 100 → 180 not taken.
✓ Branch 101 → 102 taken 1157 times.
✗ Branch 101 → 178 not taken.
✓ Branch 102 → 103 taken 1157 times.
✗ Branch 102 → 178 not taken.
|
1157 | entryNode->topLevelDefs.push_back(std::any_cast<ExtDeclNode *>(visit(extDeclCtx))); |
| 46 |
3/4✓ Branch 105 → 106 taken 1703 times.
✗ Branch 105 → 107 not taken.
✓ Branch 108 → 109 taken 407 times.
✓ Branch 108 → 114 taken 1296 times.
|
1703 | else if (auto *modAttrCtx = dynamic_cast<SpiceParser::ModAttrContext *>(child)) |
| 47 |
4/6✓ Branch 109 → 110 taken 406 times.
✓ Branch 109 → 184 taken 1 time.
✓ Branch 110 → 111 taken 406 times.
✗ Branch 110 → 182 not taken.
✓ Branch 111 → 112 taken 406 times.
✗ Branch 111 → 182 not taken.
|
407 | entryNode->modAttrs.push_back(std::any_cast<ModAttrNode *>(visit(modAttrCtx))); |
| 48 |
1/2✓ Branch 114 → 115 taken 1296 times.
✗ Branch 114 → 116 not taken.
|
1296 | else if (const auto *eofCtx = dynamic_cast<TerminalNode *>(child); |
| 49 |
5/10✓ Branch 117 → 118 taken 1296 times.
✗ Branch 117 → 121 not taken.
✓ Branch 118 → 119 taken 1296 times.
✗ Branch 118 → 186 not taken.
✓ Branch 119 → 120 taken 1296 times.
✗ Branch 119 → 186 not taken.
✗ Branch 120 → 121 not taken.
✓ Branch 120 → 122 taken 1296 times.
✗ Branch 123 → 124 not taken.
✓ Branch 123 → 125 taken 1296 times.
|
1296 | !eofCtx || eofCtx->getSymbol()->getType() != SpiceParser::EOF) |
| 50 | − | assert_fail("Unknown top level definition type"); // GCOV_EXCL_LINE | |
| 51 | } | ||
| 52 | |||
| 53 |
1/2✓ Branch 134 → 135 taken 1296 times.
✗ Branch 134 → 187 not taken.
|
1296 | return concludeNode(entryNode); |
| 54 | } | ||
| 55 | |||
| 56 | 453 | std::any ASTBuilder::visitMainFunctionDef(SpiceParser::MainFunctionDefContext *ctx) { | |
| 57 | 453 | const auto mainFctDefNode = createNode<MainFctDefNode>(ctx); | |
| 58 | |||
| 59 | // Visit children | ||
| 60 |
2/2✓ Branch 4 → 5 taken 1 time.
✓ Branch 4 → 10 taken 452 times.
|
453 | if (ctx->topLevelDefAttr()) |
| 61 |
3/6✓ Branch 5 → 6 taken 1 time.
✗ Branch 5 → 33 not taken.
✓ Branch 6 → 7 taken 1 time.
✗ Branch 6 → 33 not taken.
✓ Branch 7 → 8 taken 1 time.
✗ Branch 7 → 31 not taken.
|
1 | mainFctDefNode->attrs = std::any_cast<TopLevelDefinitionAttrNode *>(visit(ctx->topLevelDefAttr())); |
| 62 |
2/2✓ Branch 11 → 12 taken 6 times.
✓ Branch 11 → 17 taken 447 times.
|
453 | if (ctx->paramLst()) { |
| 63 | 6 | mainFctDefNode->takesArgs = true; | |
| 64 |
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 | mainFctDefNode->paramLst = std::any_cast<ParamLstNode *>(visit(ctx->paramLst())); |
| 65 | } | ||
| 66 |
4/6✓ Branch 17 → 18 taken 453 times.
✗ Branch 17 → 39 not taken.
✓ Branch 18 → 19 taken 449 times.
✓ Branch 18 → 39 taken 4 times.
✓ Branch 19 → 20 taken 449 times.
✗ Branch 19 → 37 not taken.
|
453 | mainFctDefNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 67 | |||
| 68 |
1/2✓ Branch 27 → 28 taken 449 times.
✗ Branch 27 → 40 not taken.
|
449 | return concludeNode(mainFctDefNode); |
| 69 | } | ||
| 70 | |||
| 71 | 8753 | std::any ASTBuilder::visitFunctionDef(SpiceParser::FunctionDefContext *ctx) { | |
| 72 | 8753 | const auto fctDefNode = createNode<FctDefNode>(ctx); | |
| 73 | |||
| 74 | // Visit children | ||
| 75 |
2/2✓ Branch 4 → 5 taken 361 times.
✓ Branch 4 → 16 taken 8392 times.
|
8753 | if (ctx->topLevelDefAttr()) { |
| 76 |
3/6✓ Branch 5 → 6 taken 361 times.
✗ Branch 5 → 62 not taken.
✓ Branch 6 → 7 taken 361 times.
✗ Branch 6 → 62 not taken.
✓ Branch 7 → 8 taken 361 times.
✗ Branch 7 → 60 not taken.
|
361 | fctDefNode->attrs = std::any_cast<TopLevelDefinitionAttrNode *>(visit(ctx->topLevelDefAttr())); |
| 77 | // Tell the attributes that they are function attributes | ||
| 78 |
2/2✓ Branch 14 → 11 taken 366 times.
✓ Branch 14 → 15 taken 361 times.
|
727 | for (AttrNode *attr : fctDefNode->attrs->attrLst->attributes) |
| 79 | 366 | attr->target = AttrNode::TARGET_FCT_PROC; | |
| 80 | } | ||
| 81 |
2/2✓ Branch 17 → 18 taken 8549 times.
✓ Branch 17 → 23 taken 204 times.
|
8753 | if (ctx->qualifierLst()) |
| 82 |
3/6✓ Branch 18 → 19 taken 8549 times.
✗ Branch 18 → 65 not taken.
✓ Branch 19 → 20 taken 8549 times.
✗ Branch 19 → 65 not taken.
✓ Branch 20 → 21 taken 8549 times.
✗ Branch 20 → 63 not taken.
|
8549 | fctDefNode->qualifierLst = std::any_cast<QualifierLstNode *>(visit(ctx->qualifierLst())); |
| 83 |
3/6✓ Branch 23 → 24 taken 8753 times.
✗ Branch 23 → 68 not taken.
✓ Branch 24 → 25 taken 8753 times.
✗ Branch 24 → 68 not taken.
✓ Branch 25 → 26 taken 8753 times.
✗ Branch 25 → 66 not taken.
|
8753 | fctDefNode->returnType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 84 | 8753 | fctDefNode->returnType->isReturnType = true; | |
| 85 |
3/6✓ Branch 27 → 28 taken 8753 times.
✗ Branch 27 → 71 not taken.
✓ Branch 28 → 29 taken 8753 times.
✗ Branch 28 → 71 not taken.
✓ Branch 29 → 30 taken 8753 times.
✗ Branch 29 → 69 not taken.
|
8753 | fctDefNode->name = std::any_cast<FctNameNode *>(visit(ctx->fctName())); |
| 86 | 8753 | fctDefNode->isMethod = fctDefNode->name->nameFragments.size() > 1; | |
| 87 |
2/2✓ Branch 33 → 34 taken 1081 times.
✓ Branch 33 → 39 taken 7672 times.
|
8753 | if (ctx->typeLst()) { |
| 88 | 1081 | fctDefNode->hasTemplateTypes = true; | |
| 89 |
3/6✓ Branch 34 → 35 taken 1081 times.
✗ Branch 34 → 74 not taken.
✓ Branch 35 → 36 taken 1081 times.
✗ Branch 35 → 74 not taken.
✓ Branch 36 → 37 taken 1081 times.
✗ Branch 36 → 72 not taken.
|
1081 | fctDefNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst())); |
| 90 | } | ||
| 91 |
2/2✓ Branch 40 → 41 taken 6770 times.
✓ Branch 40 → 46 taken 1983 times.
|
8753 | if (ctx->paramLst()) { |
| 92 | 6770 | fctDefNode->hasParams = true; | |
| 93 |
3/6✓ Branch 41 → 42 taken 6770 times.
✗ Branch 41 → 77 not taken.
✓ Branch 42 → 43 taken 6770 times.
✗ Branch 42 → 77 not taken.
✓ Branch 43 → 44 taken 6770 times.
✗ Branch 43 → 75 not taken.
|
6770 | fctDefNode->paramLst = std::any_cast<ParamLstNode *>(visit(ctx->paramLst())); |
| 94 | } | ||
| 95 |
3/6✓ Branch 46 → 47 taken 8753 times.
✗ Branch 46 → 80 not taken.
✓ Branch 47 → 48 taken 8753 times.
✗ Branch 47 → 80 not taken.
✓ Branch 48 → 49 taken 8753 times.
✗ Branch 48 → 78 not taken.
|
8753 | fctDefNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 96 | |||
| 97 |
1/2✓ Branch 56 → 57 taken 8753 times.
✗ Branch 56 → 81 not taken.
|
8753 | return concludeNode(fctDefNode); |
| 98 | } | ||
| 99 | |||
| 100 | 4712 | std::any ASTBuilder::visitProcedureDef(SpiceParser::ProcedureDefContext *ctx) { | |
| 101 | 4712 | const auto procDefNode = createNode<ProcDefNode>(ctx); | |
| 102 | |||
| 103 | // Visit children | ||
| 104 |
2/2✓ Branch 4 → 5 taken 1 time.
✓ Branch 4 → 16 taken 4711 times.
|
4712 | if (ctx->topLevelDefAttr()) { |
| 105 |
3/6✓ Branch 5 → 6 taken 1 time.
✗ Branch 5 → 58 not taken.
✓ Branch 6 → 7 taken 1 time.
✗ Branch 6 → 58 not taken.
✓ Branch 7 → 8 taken 1 time.
✗ Branch 7 → 56 not taken.
|
1 | procDefNode->attrs = std::any_cast<TopLevelDefinitionAttrNode *>(visit(ctx->topLevelDefAttr())); |
| 106 | // Tell the attributes that they are function attributes | ||
| 107 |
2/2✓ Branch 14 → 11 taken 1 time.
✓ Branch 14 → 15 taken 1 time.
|
2 | for (AttrNode *attr : procDefNode->attrs->attrLst->attributes) |
| 108 | 1 | attr->target = AttrNode::TARGET_FCT_PROC; | |
| 109 | } | ||
| 110 |
2/2✓ Branch 17 → 18 taken 4098 times.
✓ Branch 17 → 23 taken 614 times.
|
4712 | if (ctx->qualifierLst()) |
| 111 |
3/6✓ Branch 18 → 19 taken 4098 times.
✗ Branch 18 → 61 not taken.
✓ Branch 19 → 20 taken 4098 times.
✗ Branch 19 → 61 not taken.
✓ Branch 20 → 21 taken 4098 times.
✗ Branch 20 → 59 not taken.
|
4098 | procDefNode->qualifierLst = std::any_cast<QualifierLstNode *>(visit(ctx->qualifierLst())); |
| 112 |
3/6✓ Branch 23 → 24 taken 4712 times.
✗ Branch 23 → 64 not taken.
✓ Branch 24 → 25 taken 4712 times.
✗ Branch 24 → 64 not taken.
✓ Branch 25 → 26 taken 4712 times.
✗ Branch 25 → 62 not taken.
|
4712 | procDefNode->name = std::any_cast<FctNameNode *>(visit(ctx->fctName())); |
| 113 | 4712 | procDefNode->isMethod = procDefNode->name->nameFragments.size() > 1; | |
| 114 |
2/2✓ Branch 29 → 30 taken 1296 times.
✓ Branch 29 → 35 taken 3416 times.
|
4712 | if (ctx->typeLst()) { |
| 115 | 1296 | procDefNode->hasTemplateTypes = true; | |
| 116 |
3/6✓ Branch 30 → 31 taken 1296 times.
✗ Branch 30 → 67 not taken.
✓ Branch 31 → 32 taken 1296 times.
✗ Branch 31 → 67 not taken.
✓ Branch 32 → 33 taken 1296 times.
✗ Branch 32 → 65 not taken.
|
1296 | procDefNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst())); |
| 117 | } | ||
| 118 |
2/2✓ Branch 36 → 37 taken 3525 times.
✓ Branch 36 → 42 taken 1187 times.
|
4712 | if (ctx->paramLst()) { |
| 119 | 3525 | procDefNode->hasParams = true; | |
| 120 |
3/6✓ Branch 37 → 38 taken 3525 times.
✗ Branch 37 → 70 not taken.
✓ Branch 38 → 39 taken 3525 times.
✗ Branch 38 → 70 not taken.
✓ Branch 39 → 40 taken 3525 times.
✗ Branch 39 → 68 not taken.
|
3525 | procDefNode->paramLst = std::any_cast<ParamLstNode *>(visit(ctx->paramLst())); |
| 121 | } | ||
| 122 |
3/6✓ Branch 42 → 43 taken 4712 times.
✗ Branch 42 → 73 not taken.
✓ Branch 43 → 44 taken 4712 times.
✗ Branch 43 → 73 not taken.
✓ Branch 44 → 45 taken 4712 times.
✗ Branch 44 → 71 not taken.
|
4712 | procDefNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 123 | |||
| 124 |
1/2✓ Branch 52 → 53 taken 4712 times.
✗ Branch 52 → 74 not taken.
|
4712 | return concludeNode(procDefNode); |
| 125 | } | ||
| 126 | |||
| 127 | 13465 | std::any ASTBuilder::visitFctName(SpiceParser::FctNameContext *ctx) { | |
| 128 |
1/2✓ Branch 2 → 3 taken 13465 times.
✗ Branch 2 → 54 not taken.
|
13465 | const auto fctNameNode = createNode<FctNameNode>(ctx); |
| 129 | |||
| 130 | // Extract function name | ||
| 131 |
1/2✓ Branch 3 → 4 taken 13465 times.
✗ Branch 3 → 54 not taken.
|
13465 | std::stringstream fqName; |
| 132 |
3/4✓ Branch 4 → 5 taken 13465 times.
✗ Branch 4 → 52 not taken.
✓ Branch 5 → 6 taken 7320 times.
✓ Branch 5 → 14 taken 6145 times.
|
13465 | if (ctx->TYPE_IDENTIFIER()) { |
| 133 |
2/4✓ Branch 6 → 7 taken 7320 times.
✗ Branch 6 → 45 not taken.
✓ Branch 7 → 8 taken 7320 times.
✗ Branch 7 → 45 not taken.
|
7320 | const std::string typeIdentifier = getIdentifier(ctx->TYPE_IDENTIFIER(), true); |
| 134 |
1/2✓ Branch 8 → 9 taken 7320 times.
✗ Branch 8 → 43 not taken.
|
7320 | fctNameNode->structName = typeIdentifier; |
| 135 |
2/4✓ Branch 9 → 10 taken 7320 times.
✗ Branch 9 → 43 not taken.
✓ Branch 10 → 11 taken 7320 times.
✗ Branch 10 → 43 not taken.
|
7320 | fqName << typeIdentifier << MEMBER_ACCESS_TOKEN; |
| 136 |
1/2✓ Branch 11 → 12 taken 7320 times.
✗ Branch 11 → 43 not taken.
|
7320 | fctNameNode->nameFragments.push_back(typeIdentifier); |
| 137 | 7320 | } | |
| 138 |
3/4✓ Branch 14 → 15 taken 13465 times.
✗ Branch 14 → 52 not taken.
✓ Branch 15 → 16 taken 11399 times.
✓ Branch 15 → 23 taken 2066 times.
|
13465 | if (ctx->IDENTIFIER()) { |
| 139 |
2/4✓ Branch 16 → 17 taken 11399 times.
✗ Branch 16 → 48 not taken.
✓ Branch 17 → 18 taken 11399 times.
✗ Branch 17 → 48 not taken.
|
11399 | const std::string fctIdentifier = getIdentifier(ctx->IDENTIFIER(), false); |
| 140 |
1/2✓ Branch 18 → 19 taken 11399 times.
✗ Branch 18 → 46 not taken.
|
11399 | fctNameNode->name = fctIdentifier; |
| 141 |
1/2✓ Branch 19 → 20 taken 11399 times.
✗ Branch 19 → 46 not taken.
|
11399 | fqName << fctIdentifier; |
| 142 |
1/2✓ Branch 20 → 21 taken 11399 times.
✗ Branch 20 → 46 not taken.
|
11399 | fctNameNode->nameFragments.push_back(fctIdentifier); |
| 143 | 11399 | } | |
| 144 |
1/2✓ Branch 23 → 24 taken 13465 times.
✗ Branch 23 → 49 not taken.
|
13465 | fctNameNode->fqName = fqName.str(); |
| 145 | |||
| 146 | // Visit children | ||
| 147 |
3/4✓ Branch 26 → 27 taken 13465 times.
✗ Branch 26 → 52 not taken.
✓ Branch 27 → 28 taken 2066 times.
✓ Branch 27 → 32 taken 11399 times.
|
13465 | if (ctx->overloadableOp()) |
| 148 |
2/4✓ Branch 28 → 29 taken 2066 times.
✗ Branch 28 → 50 not taken.
✓ Branch 29 → 30 taken 2066 times.
✗ Branch 29 → 50 not taken.
|
2066 | visit(ctx->overloadableOp()); |
| 149 | |||
| 150 |
1/2✓ Branch 38 → 39 taken 13465 times.
✗ Branch 38 → 51 not taken.
|
26930 | return concludeNode(fctNameNode); |
| 151 | 13465 | } | |
| 152 | |||
| 153 | 804 | std::any ASTBuilder::visitStructDef(SpiceParser::StructDefContext *ctx) { | |
| 154 | 804 | const auto structDefNode = createNode<StructDefNode>(ctx); | |
| 155 | |||
| 156 | // Enrich | ||
| 157 |
3/4✓ Branch 3 → 4 taken 804 times.
✗ Branch 3 → 87 not taken.
✓ Branch 4 → 5 taken 803 times.
✓ Branch 4 → 87 taken 1 time.
|
804 | structDefNode->structName = getIdentifier(ctx->TYPE_IDENTIFIER(), true); |
| 158 | 803 | structDefNode->typeId = resourceManager.getNextCustomTypeId(); | |
| 159 | |||
| 160 | // Visit children | ||
| 161 |
2/2✓ Branch 9 → 10 taken 66 times.
✓ Branch 9 → 41 taken 737 times.
|
803 | if (ctx->topLevelDefAttr()) { |
| 162 |
3/6✓ Branch 10 → 11 taken 66 times.
✗ Branch 10 → 90 not taken.
✓ Branch 11 → 12 taken 66 times.
✗ Branch 11 → 90 not taken.
✓ Branch 12 → 13 taken 66 times.
✗ Branch 12 → 88 not taken.
|
66 | structDefNode->attrs = std::any_cast<TopLevelDefinitionAttrNode *>(visit(ctx->topLevelDefAttr())); |
| 163 | |||
| 164 | // Tell the attributes that they are struct attributes | ||
| 165 |
2/2✓ Branch 19 → 16 taken 66 times.
✓ Branch 19 → 20 taken 66 times.
|
132 | for (AttrNode *attr : structDefNode->attrs->attrLst->attributes) |
| 166 | 66 | attr->target = AttrNode::TARGET_STRUCT; | |
| 167 | |||
| 168 | // Check if a custom type id was set | ||
| 169 |
7/18✓ Branch 20 → 21 taken 66 times.
✗ Branch 20 → 27 not taken.
✓ Branch 23 → 24 taken 66 times.
✗ Branch 23 → 91 not taken.
✓ Branch 24 → 25 taken 66 times.
✗ Branch 24 → 91 not taken.
✗ Branch 25 → 26 not taken.
✓ Branch 25 → 27 taken 66 times.
✓ Branch 28 → 29 taken 66 times.
✗ Branch 28 → 30 not taken.
✓ Branch 30 → 31 taken 66 times.
✗ Branch 30 → 33 not taken.
✗ Branch 33 → 34 not taken.
✓ Branch 33 → 41 taken 66 times.
✗ Branch 91 → 92 not taken.
✗ Branch 91 → 93 not taken.
✗ Branch 95 → 96 not taken.
✗ Branch 95 → 98 not taken.
|
198 | 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 42 → 43 taken 622 times.
✓ Branch 42 → 48 taken 181 times.
|
803 | if (ctx->qualifierLst()) |
| 173 |
3/6✓ Branch 43 → 44 taken 622 times.
✗ Branch 43 → 108 not taken.
✓ Branch 44 → 45 taken 622 times.
✗ Branch 44 → 108 not taken.
✓ Branch 45 → 46 taken 622 times.
✗ Branch 45 → 106 not taken.
|
622 | structDefNode->qualifierLst = std::any_cast<QualifierLstNode *>(visit(ctx->qualifierLst())); |
| 174 |
2/2✓ Branch 49 → 50 taken 282 times.
✓ Branch 49 → 55 taken 521 times.
|
803 | if (ctx->LESS()) { |
| 175 | 282 | structDefNode->hasTemplateTypes = true; | |
| 176 |
3/6✓ Branch 50 → 51 taken 282 times.
✗ Branch 50 → 111 not taken.
✓ Branch 51 → 52 taken 282 times.
✗ Branch 51 → 111 not taken.
✓ Branch 52 → 53 taken 282 times.
✗ Branch 52 → 109 not taken.
|
282 | structDefNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst(0))); |
| 177 | } | ||
| 178 |
2/2✓ Branch 56 → 57 taken 154 times.
✓ Branch 56 → 65 taken 649 times.
|
803 | if (ctx->COLON()) { |
| 179 | 154 | structDefNode->hasInterfaces = true; | |
| 180 |
5/8✓ Branch 57 → 58 taken 131 times.
✓ Branch 57 → 59 taken 23 times.
✓ Branch 60 → 61 taken 154 times.
✗ Branch 60 → 114 not taken.
✓ Branch 61 → 62 taken 154 times.
✗ Branch 61 → 114 not taken.
✓ Branch 62 → 63 taken 154 times.
✗ Branch 62 → 112 not taken.
|
154 | structDefNode->interfaceTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst(structDefNode->hasTemplateTypes ? 1 : 0))); |
| 181 | } | ||
| 182 |
3/4✓ Branch 65 → 66 taken 803 times.
✗ Branch 65 → 121 not taken.
✓ Branch 75 → 68 taken 1689 times.
✓ Branch 75 → 76 taken 803 times.
|
2492 | for (SpiceParser::FieldContext *field : ctx->field()) |
| 183 |
3/6✓ Branch 69 → 70 taken 1689 times.
✗ Branch 69 → 117 not taken.
✓ Branch 70 → 71 taken 1689 times.
✗ Branch 70 → 115 not taken.
✓ Branch 71 → 72 taken 1689 times.
✗ Branch 71 → 115 not taken.
|
2492 | structDefNode->fields.push_back(std::any_cast<FieldNode *>(visit(field))); |
| 184 | |||
| 185 |
1/2✓ Branch 83 → 84 taken 803 times.
✗ Branch 83 → 122 not taken.
|
803 | return concludeNode(structDefNode); |
| 186 | } | ||
| 187 | |||
| 188 | 110 | std::any ASTBuilder::visitInterfaceDef(SpiceParser::InterfaceDefContext *ctx) { | |
| 189 | 110 | const auto interfaceDefNode = createNode<InterfaceDefNode>(ctx); | |
| 190 | |||
| 191 | // Enrich | ||
| 192 |
2/4✓ Branch 3 → 4 taken 110 times.
✗ Branch 3 → 77 not taken.
✓ Branch 4 → 5 taken 110 times.
✗ Branch 4 → 77 not taken.
|
110 | interfaceDefNode->interfaceName = getIdentifier(ctx->TYPE_IDENTIFIER(), true); |
| 193 | 110 | interfaceDefNode->typeId = resourceManager.getNextCustomTypeId(); | |
| 194 | |||
| 195 | // Visit children | ||
| 196 |
2/2✓ Branch 9 → 10 taken 79 times.
✓ Branch 9 → 41 taken 31 times.
|
110 | if (ctx->topLevelDefAttr()) { |
| 197 |
3/6✓ Branch 10 → 11 taken 79 times.
✗ Branch 10 → 80 not taken.
✓ Branch 11 → 12 taken 79 times.
✗ Branch 11 → 80 not taken.
✓ Branch 12 → 13 taken 79 times.
✗ Branch 12 → 78 not taken.
|
79 | interfaceDefNode->attrs = std::any_cast<TopLevelDefinitionAttrNode *>(visit(ctx->topLevelDefAttr())); |
| 198 | |||
| 199 | // Tell the attributes that they are struct attributes | ||
| 200 |
2/2✓ Branch 19 → 16 taken 79 times.
✓ Branch 19 → 20 taken 79 times.
|
158 | for (AttrNode *attr : interfaceDefNode->attrs->attrLst->attributes) |
| 201 | 79 | attr->target = AttrNode::TARGET_INTERFACE; | |
| 202 | |||
| 203 | // Check if a custom type id was set | ||
| 204 |
7/18✓ Branch 20 → 21 taken 79 times.
✗ Branch 20 → 27 not taken.
✓ Branch 23 → 24 taken 79 times.
✗ Branch 23 → 81 not taken.
✓ Branch 24 → 25 taken 79 times.
✗ Branch 24 → 81 not taken.
✓ Branch 25 → 26 taken 79 times.
✗ Branch 25 → 27 not taken.
✓ Branch 28 → 29 taken 79 times.
✗ Branch 28 → 30 not taken.
✓ Branch 30 → 31 taken 79 times.
✗ Branch 30 → 33 not taken.
✓ Branch 33 → 34 taken 79 times.
✗ Branch 33 → 41 not taken.
✗ Branch 81 → 82 not taken.
✗ Branch 81 → 83 not taken.
✗ Branch 85 → 86 not taken.
✗ Branch 85 → 88 not taken.
|
237 | if (interfaceDefNode->attrs && interfaceDefNode->attrs->attrLst->hasAttr(ATTR_CORE_COMPILER_FIXED_TYPE_ID)) |
| 205 |
2/4✓ Branch 36 → 37 taken 79 times.
✗ Branch 36 → 92 not taken.
✓ Branch 37 → 38 taken 79 times.
✗ Branch 37 → 90 not taken.
|
237 | interfaceDefNode->typeId = interfaceDefNode->attrs->attrLst->getAttrValueByName(ATTR_CORE_COMPILER_FIXED_TYPE_ID)->intValue; |
| 206 | } | ||
| 207 |
2/2✓ Branch 42 → 43 taken 92 times.
✓ Branch 42 → 48 taken 18 times.
|
110 | if (ctx->qualifierLst()) |
| 208 |
3/6✓ Branch 43 → 44 taken 92 times.
✗ Branch 43 → 98 not taken.
✓ Branch 44 → 45 taken 92 times.
✗ Branch 44 → 98 not taken.
✓ Branch 45 → 46 taken 92 times.
✗ Branch 45 → 96 not taken.
|
92 | interfaceDefNode->qualifierLst = std::any_cast<QualifierLstNode *>(visit(ctx->qualifierLst())); |
| 209 |
2/2✓ Branch 49 → 50 taken 82 times.
✓ Branch 49 → 55 taken 28 times.
|
110 | if (ctx->LESS()) { |
| 210 | 82 | interfaceDefNode->hasTemplateTypes = true; | |
| 211 |
3/6✓ Branch 50 → 51 taken 82 times.
✗ Branch 50 → 101 not taken.
✓ Branch 51 → 52 taken 82 times.
✗ Branch 51 → 101 not taken.
✓ Branch 52 → 53 taken 82 times.
✗ Branch 52 → 99 not taken.
|
82 | interfaceDefNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst())); |
| 212 | } | ||
| 213 |
3/4✓ Branch 55 → 56 taken 110 times.
✗ Branch 55 → 108 not taken.
✓ Branch 65 → 58 taken 249 times.
✓ Branch 65 → 66 taken 110 times.
|
359 | for (SpiceParser::SignatureContext *signature : ctx->signature()) |
| 214 |
3/6✓ Branch 59 → 60 taken 249 times.
✗ Branch 59 → 104 not taken.
✓ Branch 60 → 61 taken 249 times.
✗ Branch 60 → 102 not taken.
✓ Branch 61 → 62 taken 249 times.
✗ Branch 61 → 102 not taken.
|
359 | interfaceDefNode->signatures.push_back(std::any_cast<SignatureNode *>(visit(signature))); |
| 215 | |||
| 216 |
1/2✓ Branch 73 → 74 taken 110 times.
✗ Branch 73 → 109 not taken.
|
110 | return concludeNode(interfaceDefNode); |
| 217 | } | ||
| 218 | |||
| 219 | 78 | std::any ASTBuilder::visitEnumDef(SpiceParser::EnumDefContext *ctx) { | |
| 220 | 78 | const auto enumDefNode = createNode<EnumDefNode>(ctx); | |
| 221 | |||
| 222 | // Enrich | ||
| 223 |
2/4✓ Branch 3 → 4 taken 78 times.
✗ Branch 3 → 35 not taken.
✓ Branch 4 → 5 taken 78 times.
✗ Branch 4 → 35 not taken.
|
78 | enumDefNode->enumName = getIdentifier(ctx->TYPE_IDENTIFIER(), true); |
| 224 | 78 | enumDefNode->typeId = resourceManager.getNextCustomTypeId(); | |
| 225 | |||
| 226 | // Visit children | ||
| 227 |
2/2✓ Branch 9 → 10 taken 60 times.
✓ Branch 9 → 15 taken 18 times.
|
78 | if (ctx->qualifierLst()) |
| 228 |
3/6✓ Branch 10 → 11 taken 60 times.
✗ Branch 10 → 38 not taken.
✓ Branch 11 → 12 taken 60 times.
✗ Branch 11 → 38 not taken.
✓ Branch 12 → 13 taken 60 times.
✗ Branch 12 → 36 not taken.
|
60 | enumDefNode->qualifierLst = std::any_cast<QualifierLstNode *>(visit(ctx->qualifierLst())); |
| 229 |
3/6✓ Branch 15 → 16 taken 78 times.
✗ Branch 15 → 41 not taken.
✓ Branch 16 → 17 taken 78 times.
✗ Branch 16 → 41 not taken.
✓ Branch 17 → 18 taken 78 times.
✗ Branch 17 → 39 not taken.
|
78 | enumDefNode->itemLst = std::any_cast<EnumItemLstNode *>(visit(ctx->enumItemLst())); |
| 230 | |||
| 231 | // Tell all items about the enum def | ||
| 232 |
2/2✓ Branch 24 → 21 taken 1186 times.
✓ Branch 24 → 25 taken 78 times.
|
1264 | for (EnumItemNode *enumItem : enumDefNode->itemLst->items) |
| 233 | 1186 | enumItem->enumDef = enumDefNode; | |
| 234 | |||
| 235 |
1/2✓ Branch 31 → 32 taken 78 times.
✗ Branch 31 → 42 not taken.
|
78 | return concludeNode(enumDefNode); |
| 236 | } | ||
| 237 | |||
| 238 | 1059 | std::any ASTBuilder::visitGenericTypeDef(SpiceParser::GenericTypeDefContext *ctx) { | |
| 239 | 1059 | const auto genericTypeDefNode = createNode<GenericTypeDefNode>(ctx); | |
| 240 | |||
| 241 | // Enrich | ||
| 242 |
2/4✓ Branch 3 → 4 taken 1059 times.
✗ Branch 3 → 21 not taken.
✓ Branch 4 → 5 taken 1059 times.
✗ Branch 4 → 21 not taken.
|
1059 | genericTypeDefNode->typeName = getIdentifier(ctx->TYPE_IDENTIFIER(), true); |
| 243 | |||
| 244 | // Visit children | ||
| 245 |
3/6✓ Branch 7 → 8 taken 1059 times.
✗ Branch 7 → 24 not taken.
✓ Branch 8 → 9 taken 1059 times.
✗ Branch 8 → 24 not taken.
✓ Branch 9 → 10 taken 1059 times.
✗ Branch 9 → 22 not taken.
|
1059 | genericTypeDefNode->typeAltsLst = std::any_cast<TypeAltsLstNode *>(visit(ctx->typeAltsLst())); |
| 246 | |||
| 247 |
1/2✓ Branch 17 → 18 taken 1059 times.
✗ Branch 17 → 25 not taken.
|
1059 | return concludeNode(genericTypeDefNode); |
| 248 | } | ||
| 249 | |||
| 250 | 110 | std::any ASTBuilder::visitAliasDef(SpiceParser::AliasDefContext *ctx) { | |
| 251 | 110 | const auto aliasDefNode = createNode<AliasDefNode>(ctx); | |
| 252 | |||
| 253 | // Enrich | ||
| 254 |
2/4✓ Branch 3 → 4 taken 110 times.
✗ Branch 3 → 33 not taken.
✓ Branch 4 → 5 taken 110 times.
✗ Branch 4 → 33 not taken.
|
110 | aliasDefNode->aliasName = getIdentifier(ctx->TYPE_IDENTIFIER(), true); |
| 255 |
2/4✓ Branch 7 → 8 taken 110 times.
✗ Branch 7 → 34 not taken.
✓ Branch 8 → 9 taken 110 times.
✗ Branch 8 → 34 not taken.
|
110 | aliasDefNode->dataTypeString = ctx->dataType()->getText(); |
| 256 | 110 | aliasDefNode->typeId = resourceManager.getNextCustomTypeId(); | |
| 257 | |||
| 258 | // Visit children | ||
| 259 |
2/2✓ Branch 13 → 14 taken 32 times.
✓ Branch 13 → 19 taken 78 times.
|
110 | if (ctx->qualifierLst()) |
| 260 |
3/6✓ Branch 14 → 15 taken 32 times.
✗ Branch 14 → 37 not taken.
✓ Branch 15 → 16 taken 32 times.
✗ Branch 15 → 37 not taken.
✓ Branch 16 → 17 taken 32 times.
✗ Branch 16 → 35 not taken.
|
32 | aliasDefNode->qualifierLst = std::any_cast<QualifierLstNode *>(visit(ctx->qualifierLst())); |
| 261 |
3/6✓ Branch 19 → 20 taken 110 times.
✗ Branch 19 → 40 not taken.
✓ Branch 20 → 21 taken 110 times.
✗ Branch 20 → 40 not taken.
✓ Branch 21 → 22 taken 110 times.
✗ Branch 21 → 38 not taken.
|
110 | aliasDefNode->dataType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 262 | |||
| 263 |
1/2✓ Branch 29 → 30 taken 110 times.
✗ Branch 29 → 41 not taken.
|
110 | return concludeNode(aliasDefNode); |
| 264 | } | ||
| 265 | |||
| 266 | 1276 | std::any ASTBuilder::visitGlobalVarDef(SpiceParser::GlobalVarDefContext *ctx) { | |
| 267 | 1276 | const auto globalVarDefNode = createNode<GlobalVarDefNode>(ctx); | |
| 268 | |||
| 269 | // Enrich | ||
| 270 |
2/4✓ Branch 3 → 4 taken 1276 times.
✗ Branch 3 → 28 not taken.
✓ Branch 4 → 5 taken 1276 times.
✗ Branch 4 → 28 not taken.
|
1276 | globalVarDefNode->varName = getIdentifier(ctx->TYPE_IDENTIFIER(), true); |
| 271 | |||
| 272 | // Visit children | ||
| 273 |
3/6✓ Branch 7 → 8 taken 1276 times.
✗ Branch 7 → 31 not taken.
✓ Branch 8 → 9 taken 1276 times.
✗ Branch 8 → 31 not taken.
✓ Branch 9 → 10 taken 1276 times.
✗ Branch 9 → 29 not taken.
|
1276 | globalVarDefNode->dataType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 274 | 1276 | globalVarDefNode->dataType->isGlobalType = true; | |
| 275 |
2/2✓ Branch 12 → 13 taken 1274 times.
✓ Branch 12 → 18 taken 2 times.
|
1276 | if (ctx->constant()) { |
| 276 | 1274 | globalVarDefNode->hasValue = true; | |
| 277 |
3/6✓ Branch 13 → 14 taken 1274 times.
✗ Branch 13 → 34 not taken.
✓ Branch 14 → 15 taken 1274 times.
✗ Branch 14 → 34 not taken.
✓ Branch 15 → 16 taken 1274 times.
✗ Branch 15 → 32 not taken.
|
1274 | globalVarDefNode->constant = std::any_cast<ConstantNode *>(visit(ctx->constant())); |
| 278 | } | ||
| 279 | |||
| 280 |
1/2✓ Branch 24 → 25 taken 1276 times.
✗ Branch 24 → 35 not taken.
|
1276 | return concludeNode(globalVarDefNode); |
| 281 | } | ||
| 282 | |||
| 283 | 1157 | std::any ASTBuilder::visitExtDecl(SpiceParser::ExtDeclContext *ctx) { | |
| 284 | 1157 | const auto extDeclNode = createNode<ExtDeclNode>(ctx); | |
| 285 | |||
| 286 | // Enrich | ||
| 287 |
6/10✓ Branch 3 → 4 taken 1157 times.
✗ Branch 3 → 49 not taken.
✓ Branch 4 → 5 taken 905 times.
✓ Branch 4 → 7 taken 252 times.
✓ Branch 5 → 6 taken 905 times.
✗ Branch 5 → 49 not taken.
✓ Branch 7 → 8 taken 252 times.
✗ Branch 7 → 49 not taken.
✓ Branch 9 → 10 taken 1157 times.
✗ Branch 9 → 49 not taken.
|
1157 | 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 → 25 taken 1156 times.
|
1157 | if (ctx->topLevelDefAttr()) { |
| 291 |
3/6✓ Branch 14 → 15 taken 1 time.
✗ Branch 14 → 52 not taken.
✓ Branch 15 → 16 taken 1 time.
✗ Branch 15 → 52 not taken.
✓ Branch 16 → 17 taken 1 time.
✗ Branch 16 → 50 not taken.
|
1 | extDeclNode->attrs = std::any_cast<TopLevelDefinitionAttrNode *>(visit(ctx->topLevelDefAttr())); |
| 292 | |||
| 293 | // Tell the attributes that they are ext decl attributes | ||
| 294 |
2/2✓ Branch 23 → 20 taken 1 time.
✓ Branch 23 → 24 taken 1 time.
|
2 | for (AttrNode *attr : extDeclNode->attrs->attrLst->attributes) |
| 295 | 1 | attr->target = AttrNode::TARGET_EXT_DECL; | |
| 296 | } | ||
| 297 |
2/2✓ Branch 26 → 27 taken 744 times.
✓ Branch 26 → 32 taken 413 times.
|
1157 | if (ctx->F()) { |
| 298 |
3/6✓ Branch 27 → 28 taken 744 times.
✗ Branch 27 → 55 not taken.
✓ Branch 28 → 29 taken 744 times.
✗ Branch 28 → 55 not taken.
✓ Branch 29 → 30 taken 744 times.
✗ Branch 29 → 53 not taken.
|
744 | extDeclNode->returnType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 299 | 744 | extDeclNode->returnType->isReturnType = true; | |
| 300 | } | ||
| 301 |
2/2✓ Branch 33 → 34 taken 1115 times.
✓ Branch 33 → 39 taken 42 times.
|
1157 | if (ctx->typeLstWithEllipsis()) { |
| 302 | 1115 | extDeclNode->hasArgs = true; | |
| 303 |
3/6✓ Branch 34 → 35 taken 1115 times.
✗ Branch 34 → 58 not taken.
✓ Branch 35 → 36 taken 1115 times.
✗ Branch 35 → 58 not taken.
✓ Branch 36 → 37 taken 1115 times.
✗ Branch 36 → 56 not taken.
|
1115 | extDeclNode->argTypeLst = std::any_cast<TypeLstWithEllipsisNode *>(visit(ctx->typeLstWithEllipsis())); |
| 304 | } | ||
| 305 | |||
| 306 |
1/2✓ Branch 45 → 46 taken 1157 times.
✗ Branch 45 → 59 not taken.
|
1157 | return concludeNode(extDeclNode); |
| 307 | } | ||
| 308 | |||
| 309 | 684 | std::any ASTBuilder::visitImportDef(SpiceParser::ImportDefContext *ctx) { | |
| 310 |
1/2✓ Branch 2 → 3 taken 684 times.
✗ Branch 2 → 32 not taken.
|
684 | const auto importDefNode = createNode<ImportDefNode>(ctx); |
| 311 | |||
| 312 | // Extract path | ||
| 313 |
2/4✓ Branch 3 → 4 taken 684 times.
✗ Branch 3 → 32 not taken.
✓ Branch 4 → 5 taken 684 times.
✗ Branch 4 → 32 not taken.
|
684 | const std::string pathStr = ctx->STRING_LIT()->getText(); |
| 314 |
1/2✓ Branch 6 → 7 taken 684 times.
✗ Branch 6 → 27 not taken.
|
684 | importDefNode->importPath = pathStr.substr(1, pathStr.size() - 2); |
| 315 | |||
| 316 | // If no name is given, use the path as name | ||
| 317 |
6/10✓ Branch 9 → 10 taken 684 times.
✗ Branch 9 → 28 not taken.
✓ Branch 10 → 11 taken 33 times.
✓ Branch 10 → 13 taken 651 times.
✓ Branch 11 → 12 taken 33 times.
✗ Branch 11 → 28 not taken.
✓ Branch 12 → 14 taken 33 times.
✗ Branch 12 → 28 not taken.
✓ Branch 13 → 14 taken 651 times.
✗ Branch 13 → 28 not taken.
|
684 | importDefNode->importName = ctx->AS() ? getIdentifier(ctx->IDENTIFIER(), false) : importDefNode->importPath; |
| 318 | |||
| 319 |
1/2✓ Branch 22 → 23 taken 684 times.
✗ Branch 22 → 29 not taken.
|
1368 | return concludeNode(importDefNode); |
| 320 | 684 | } | |
| 321 | |||
| 322 | 2937 | std::any ASTBuilder::visitUnsafeBlock(SpiceParser::UnsafeBlockContext *ctx) { | |
| 323 | 2937 | const auto unsafeBlockDefNode = createNode<UnsafeBlockNode>(ctx); | |
| 324 | |||
| 325 | // Visit children | ||
| 326 |
3/6✓ Branch 3 → 4 taken 2937 times.
✗ Branch 3 → 19 not taken.
✓ Branch 4 → 5 taken 2937 times.
✗ Branch 4 → 19 not taken.
✓ Branch 5 → 6 taken 2937 times.
✗ Branch 5 → 17 not taken.
|
2937 | unsafeBlockDefNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 327 | |||
| 328 |
1/2✓ Branch 13 → 14 taken 2937 times.
✗ Branch 13 → 20 not taken.
|
2937 | return concludeNode(unsafeBlockDefNode); |
| 329 | } | ||
| 330 | |||
| 331 | 1538 | std::any ASTBuilder::visitForLoop(SpiceParser::ForLoopContext *ctx) { | |
| 332 | 1538 | const auto forLoopNode = createNode<ForLoopNode>(ctx); | |
| 333 | |||
| 334 |
2/4✓ Branch 3 → 4 taken 1538 times.
✗ Branch 3 → 20 not taken.
✓ Branch 4 → 5 taken 1538 times.
✗ Branch 4 → 20 not taken.
|
1538 | visit(ctx->forHead()); |
| 335 |
3/6✓ Branch 6 → 7 taken 1538 times.
✗ Branch 6 → 23 not taken.
✓ Branch 7 → 8 taken 1538 times.
✗ Branch 7 → 23 not taken.
✓ Branch 8 → 9 taken 1538 times.
✗ Branch 8 → 21 not taken.
|
1538 | forLoopNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 336 | |||
| 337 |
1/2✓ Branch 16 → 17 taken 1538 times.
✗ Branch 16 → 24 not taken.
|
1538 | return concludeNode(forLoopNode); |
| 338 | } | ||
| 339 | |||
| 340 | 1538 | std::any ASTBuilder::visitForHead(SpiceParser::ForHeadContext *ctx) { | |
| 341 | 1538 | const auto forLoopNode = resumeForExpansion<ForLoopNode>(); | |
| 342 | |||
| 343 | // Visit children | ||
| 344 |
3/6✓ Branch 12 → 13 taken 1538 times.
✗ Branch 12 → 29 not taken.
✓ Branch 13 → 14 taken 1538 times.
✗ Branch 13 → 29 not taken.
✓ Branch 14 → 15 taken 1538 times.
✗ Branch 14 → 27 not taken.
|
1538 | forLoopNode->initDecl = std::any_cast<DeclStmtNode *>(visit(ctx->declStmt())); |
| 345 |
3/6✓ Branch 16 → 17 taken 1538 times.
✗ Branch 16 → 32 not taken.
✓ Branch 17 → 18 taken 1538 times.
✗ Branch 17 → 32 not taken.
✓ Branch 18 → 19 taken 1538 times.
✗ Branch 18 → 30 not taken.
|
1538 | forLoopNode->condAssign = std::any_cast<ExprNode *>(visit(ctx->assignExpr(0))); |
| 346 |
3/6✓ Branch 20 → 21 taken 1538 times.
✗ Branch 20 → 35 not taken.
✓ Branch 21 → 22 taken 1538 times.
✗ Branch 21 → 35 not taken.
✓ Branch 22 → 23 taken 1538 times.
✗ Branch 22 → 33 not taken.
|
1538 | forLoopNode->incAssign = std::any_cast<ExprNode *>(visit(ctx->assignExpr(1))); |
| 347 | |||
| 348 |
1/2✓ Branch 24 → 25 taken 1538 times.
✗ Branch 24 → 36 not taken.
|
1538 | return nullptr; |
| 349 | } | ||
| 350 | |||
| 351 | 139 | std::any ASTBuilder::visitForeachLoop(SpiceParser::ForeachLoopContext *ctx) { | |
| 352 | 139 | const auto foreachLoopNode = createNode<ForeachLoopNode>(ctx); | |
| 353 | |||
| 354 | // Visit children | ||
| 355 |
2/4✓ Branch 3 → 4 taken 139 times.
✗ Branch 3 → 20 not taken.
✓ Branch 4 → 5 taken 139 times.
✗ Branch 4 → 20 not taken.
|
139 | visit(ctx->foreachHead()); |
| 356 |
3/6✓ Branch 6 → 7 taken 139 times.
✗ Branch 6 → 23 not taken.
✓ Branch 7 → 8 taken 139 times.
✗ Branch 7 → 23 not taken.
✓ Branch 8 → 9 taken 139 times.
✗ Branch 8 → 21 not taken.
|
139 | foreachLoopNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 357 | |||
| 358 | // Tell the foreach item that it is one | ||
| 359 | 139 | foreachLoopNode->itemVarDecl->isForEachItem = true; | |
| 360 | |||
| 361 |
1/2✓ Branch 16 → 17 taken 139 times.
✗ Branch 16 → 24 not taken.
|
139 | return concludeNode(foreachLoopNode); |
| 362 | } | ||
| 363 | |||
| 364 | 139 | std::any ASTBuilder::visitForeachHead(SpiceParser::ForeachHeadContext *ctx) { | |
| 365 | 139 | const auto foreachLoopNode = resumeForExpansion<ForeachLoopNode>(); | |
| 366 | |||
| 367 | // Visit children | ||
| 368 |
3/4✓ Branch 12 → 13 taken 139 times.
✗ Branch 12 → 42 not taken.
✓ Branch 15 → 16 taken 131 times.
✓ Branch 15 → 21 taken 8 times.
|
139 | if (ctx->declStmt().size() == 1) { |
| 369 |
3/6✓ Branch 16 → 17 taken 131 times.
✗ Branch 16 → 45 not taken.
✓ Branch 17 → 18 taken 131 times.
✗ Branch 17 → 45 not taken.
✓ Branch 18 → 19 taken 131 times.
✗ Branch 18 → 43 not taken.
|
131 | foreachLoopNode->itemVarDecl = std::any_cast<DeclStmtNode *>(visit(ctx->declStmt(0))); |
| 370 |
2/4✓ Branch 21 → 22 taken 8 times.
✗ Branch 21 → 46 not taken.
✓ Branch 24 → 25 taken 8 times.
✗ Branch 24 → 34 not taken.
|
8 | } else if (ctx->declStmt().size() == 2) { |
| 371 |
3/6✓ Branch 25 → 26 taken 8 times.
✗ Branch 25 → 49 not taken.
✓ Branch 26 → 27 taken 8 times.
✗ Branch 26 → 49 not taken.
✓ Branch 27 → 28 taken 8 times.
✗ Branch 27 → 47 not taken.
|
8 | foreachLoopNode->idxVarDecl = std::any_cast<DeclStmtNode *>(visit(ctx->declStmt(0))); |
| 372 |
3/6✓ Branch 29 → 30 taken 8 times.
✗ Branch 29 → 52 not taken.
✓ Branch 30 → 31 taken 8 times.
✗ Branch 30 → 52 not taken.
✓ Branch 31 → 32 taken 8 times.
✗ Branch 31 → 50 not taken.
|
8 | 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 139 times.
✗ Branch 35 → 55 not taken.
✓ Branch 36 → 37 taken 139 times.
✗ Branch 36 → 55 not taken.
✓ Branch 37 → 38 taken 139 times.
✗ Branch 37 → 53 not taken.
|
139 | foreachLoopNode->iteratorAssign = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 377 | |||
| 378 |
1/2✓ Branch 39 → 40 taken 139 times.
✗ Branch 39 → 56 not taken.
|
139 | return nullptr; |
| 379 | } | ||
| 380 | |||
| 381 | 876 | std::any ASTBuilder::visitWhileLoop(SpiceParser::WhileLoopContext *ctx) { | |
| 382 | 876 | const auto whileLoopNode = createNode<WhileLoopNode>(ctx); | |
| 383 | |||
| 384 | // Visit children | ||
| 385 |
3/6✓ Branch 3 → 4 taken 876 times.
✗ Branch 3 → 23 not taken.
✓ Branch 4 → 5 taken 876 times.
✗ Branch 4 → 23 not taken.
✓ Branch 5 → 6 taken 876 times.
✗ Branch 5 → 21 not taken.
|
876 | whileLoopNode->condition = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 386 |
3/6✓ Branch 7 → 8 taken 876 times.
✗ Branch 7 → 26 not taken.
✓ Branch 8 → 9 taken 876 times.
✗ Branch 8 → 26 not taken.
✓ Branch 9 → 10 taken 876 times.
✗ Branch 9 → 24 not taken.
|
876 | whileLoopNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 387 | |||
| 388 |
1/2✓ Branch 17 → 18 taken 876 times.
✗ Branch 17 → 27 not taken.
|
876 | return concludeNode(whileLoopNode); |
| 389 | } | ||
| 390 | |||
| 391 | 8 | std::any ASTBuilder::visitDoWhileLoop(SpiceParser::DoWhileLoopContext *ctx) { | |
| 392 | 8 | const auto doWhileLoopNode = createNode<DoWhileLoopNode>(ctx); | |
| 393 | |||
| 394 | // Visit children | ||
| 395 |
3/6✓ Branch 3 → 4 taken 8 times.
✗ Branch 3 → 23 not taken.
✓ Branch 4 → 5 taken 8 times.
✗ Branch 4 → 23 not taken.
✓ Branch 5 → 6 taken 8 times.
✗ Branch 5 → 21 not taken.
|
8 | doWhileLoopNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 396 |
3/6✓ Branch 7 → 8 taken 8 times.
✗ Branch 7 → 26 not taken.
✓ Branch 8 → 9 taken 8 times.
✗ Branch 8 → 26 not taken.
✓ Branch 9 → 10 taken 8 times.
✗ Branch 9 → 24 not taken.
|
8 | doWhileLoopNode->condition = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 397 | |||
| 398 |
1/2✓ Branch 17 → 18 taken 8 times.
✗ Branch 17 → 27 not taken.
|
8 | return concludeNode(doWhileLoopNode); |
| 399 | } | ||
| 400 | |||
| 401 | 4705 | std::any ASTBuilder::visitIfStmt(SpiceParser::IfStmtContext *ctx) { | |
| 402 | 4705 | const auto ifStmtNode = createNode<IfStmtNode>(ctx); | |
| 403 | |||
| 404 | // Visit children | ||
| 405 |
3/6✓ Branch 3 → 4 taken 4705 times.
✗ Branch 3 → 30 not taken.
✓ Branch 4 → 5 taken 4705 times.
✗ Branch 4 → 30 not taken.
✓ Branch 5 → 6 taken 4705 times.
✗ Branch 5 → 28 not taken.
|
4705 | ifStmtNode->condition = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 406 |
3/6✓ Branch 7 → 8 taken 4705 times.
✗ Branch 7 → 33 not taken.
✓ Branch 8 → 9 taken 4705 times.
✗ Branch 8 → 33 not taken.
✓ Branch 9 → 10 taken 4705 times.
✗ Branch 9 → 31 not taken.
|
4705 | ifStmtNode->thenBody = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 407 |
2/2✓ Branch 12 → 13 taken 254 times.
✓ Branch 12 → 18 taken 4451 times.
|
4705 | if (ctx->elseStmt()) |
| 408 |
3/6✓ Branch 13 → 14 taken 254 times.
✗ Branch 13 → 36 not taken.
✓ Branch 14 → 15 taken 254 times.
✗ Branch 14 → 36 not taken.
✓ Branch 15 → 16 taken 254 times.
✗ Branch 15 → 34 not taken.
|
254 | ifStmtNode->elseStmt = std::any_cast<ElseStmtNode *>(visit(ctx->elseStmt())); |
| 409 | |||
| 410 |
1/2✓ Branch 24 → 25 taken 4705 times.
✗ Branch 24 → 37 not taken.
|
4705 | return concludeNode(ifStmtNode); |
| 411 | } | ||
| 412 | |||
| 413 | 254 | std::any ASTBuilder::visitElseStmt(SpiceParser::ElseStmtContext *ctx) { | |
| 414 | 254 | const auto elseStmtNode = createNode<ElseStmtNode>(ctx); | |
| 415 | |||
| 416 | // Visit children | ||
| 417 |
2/2✓ Branch 4 → 5 taken 75 times.
✓ Branch 4 → 10 taken 179 times.
|
254 | if (ctx->ifStmt()) { |
| 418 | 75 | elseStmtNode->isElseIf = true; | |
| 419 |
3/6✓ Branch 5 → 6 taken 75 times.
✗ Branch 5 → 27 not taken.
✓ Branch 6 → 7 taken 75 times.
✗ Branch 6 → 27 not taken.
✓ Branch 7 → 8 taken 75 times.
✗ Branch 7 → 25 not taken.
|
75 | elseStmtNode->ifStmt = std::any_cast<IfStmtNode *>(visit(ctx->ifStmt())); |
| 420 | } else { | ||
| 421 |
3/6✓ Branch 10 → 11 taken 179 times.
✗ Branch 10 → 30 not taken.
✓ Branch 11 → 12 taken 179 times.
✗ Branch 11 → 30 not taken.
✓ Branch 12 → 13 taken 179 times.
✗ Branch 12 → 28 not taken.
|
179 | elseStmtNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 422 | } | ||
| 423 | |||
| 424 |
1/2✓ Branch 21 → 22 taken 254 times.
✗ Branch 21 → 31 not taken.
|
254 | return concludeNode(elseStmtNode); |
| 425 | } | ||
| 426 | |||
| 427 | 12 | std::any ASTBuilder::visitSwitchStmt(SpiceParser::SwitchStmtContext *ctx) { | |
| 428 | 12 | const auto switchStmtNode = createNode<SwitchStmtNode>(ctx); | |
| 429 | |||
| 430 | // Visit children | ||
| 431 |
3/6✓ Branch 3 → 4 taken 12 times.
✗ Branch 3 → 29 not taken.
✓ Branch 4 → 5 taken 12 times.
✗ Branch 4 → 29 not taken.
✓ Branch 5 → 6 taken 12 times.
✗ Branch 5 → 27 not taken.
|
12 | switchStmtNode->assignExpr = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 432 |
2/4✓ Branch 7 → 8 taken 12 times.
✗ Branch 7 → 32 not taken.
✓ Branch 8 → 9 taken 12 times.
✗ Branch 8 → 30 not taken.
|
12 | fetchChildrenIntoVector(switchStmtNode->caseBranches, ctx->caseBranch()); |
| 433 |
2/2✓ Branch 11 → 12 taken 6 times.
✓ Branch 11 → 17 taken 6 times.
|
12 | if (ctx->defaultBranch()) { |
| 434 | 6 | switchStmtNode->hasDefaultBranch = true; | |
| 435 |
3/6✓ Branch 12 → 13 taken 6 times.
✗ Branch 12 → 35 not taken.
✓ Branch 13 → 14 taken 6 times.
✗ Branch 13 → 35 not taken.
✓ Branch 14 → 15 taken 6 times.
✗ Branch 14 → 33 not taken.
|
6 | switchStmtNode->defaultBranch = std::any_cast<DefaultBranchNode *>(visit(ctx->defaultBranch())); |
| 436 | } | ||
| 437 | |||
| 438 |
1/2✓ Branch 23 → 24 taken 12 times.
✗ Branch 23 → 36 not taken.
|
12 | return concludeNode(switchStmtNode); |
| 439 | } | ||
| 440 | |||
| 441 | 53 | std::any ASTBuilder::visitCaseBranch(SpiceParser::CaseBranchContext *ctx) { | |
| 442 | 53 | const auto caseBranchNode = createNode<CaseBranchNode>(ctx); | |
| 443 | |||
| 444 | // Visit children | ||
| 445 |
2/4✓ Branch 3 → 4 taken 53 times.
✗ Branch 3 → 22 not taken.
✓ Branch 4 → 5 taken 53 times.
✗ Branch 4 → 20 not taken.
|
53 | fetchChildrenIntoVector(caseBranchNode->caseConstants, ctx->caseConstant()); |
| 446 |
3/6✓ Branch 6 → 7 taken 53 times.
✗ Branch 6 → 25 not taken.
✓ Branch 7 → 8 taken 53 times.
✗ Branch 7 → 25 not taken.
✓ Branch 8 → 9 taken 53 times.
✗ Branch 8 → 23 not taken.
|
53 | caseBranchNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 447 | |||
| 448 |
1/2✓ Branch 16 → 17 taken 53 times.
✗ Branch 16 → 26 not taken.
|
53 | return concludeNode(caseBranchNode); |
| 449 | } | ||
| 450 | |||
| 451 | 6 | std::any ASTBuilder::visitDefaultBranch(SpiceParser::DefaultBranchContext *ctx) { | |
| 452 | 6 | const auto defaultBranchNode = createNode<DefaultBranchNode>(ctx); | |
| 453 | |||
| 454 | // Visit children | ||
| 455 |
3/6✓ Branch 3 → 4 taken 6 times.
✗ Branch 3 → 19 not taken.
✓ Branch 4 → 5 taken 6 times.
✗ Branch 4 → 19 not taken.
✓ Branch 5 → 6 taken 6 times.
✗ Branch 5 → 17 not taken.
|
6 | defaultBranchNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 456 | |||
| 457 |
1/2✓ Branch 13 → 14 taken 6 times.
✗ Branch 13 → 20 not taken.
|
6 | return concludeNode(defaultBranchNode); |
| 458 | } | ||
| 459 | |||
| 460 | 33 | std::any ASTBuilder::visitAnonymousBlockStmt(SpiceParser::AnonymousBlockStmtContext *ctx) { | |
| 461 | 33 | const auto anonymousBlockStmtNode = createNode<AnonymousBlockStmtNode>(ctx); | |
| 462 | |||
| 463 | // Visit children | ||
| 464 |
3/6✓ Branch 3 → 4 taken 33 times.
✗ Branch 3 → 19 not taken.
✓ Branch 4 → 5 taken 33 times.
✗ Branch 4 → 19 not taken.
✓ Branch 5 → 6 taken 33 times.
✗ Branch 5 → 17 not taken.
|
33 | anonymousBlockStmtNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 465 | |||
| 466 |
1/2✓ Branch 13 → 14 taken 33 times.
✗ Branch 13 → 20 not taken.
|
33 | return concludeNode(anonymousBlockStmtNode); |
| 467 | } | ||
| 468 | |||
| 469 | 24428 | std::any ASTBuilder::visitStmtLst(SpiceParser::StmtLstContext *ctx) { | |
| 470 | 24428 | const auto stmtLstNode = createNode<StmtLstNode>(ctx); | |
| 471 | |||
| 472 | // Enrich | ||
| 473 |
2/4✓ Branch 3 → 4 taken 24428 times.
✗ Branch 3 → 116 not taken.
✓ Branch 4 → 5 taken 24428 times.
✗ Branch 4 → 116 not taken.
|
24428 | stmtLstNode->closingBraceCodeLoc = CodeLoc(ctx->getStop(), sourceFile); |
| 474 | |||
| 475 | // Visit children | ||
| 476 |
2/2✓ Branch 105 → 7 taken 94038 times.
✓ Branch 105 → 106 taken 24424 times.
|
118462 | for (ParserRuleContext::ParseTree *stmt : ctx->children) { |
| 477 |
3/4✓ Branch 8 → 9 taken 94038 times.
✗ Branch 8 → 10 not taken.
✓ Branch 11 → 12 taken 34170 times.
✓ Branch 11 → 17 taken 59868 times.
|
94038 | if (auto *stmtCtx = dynamic_cast<SpiceParser::StmtContext *>(stmt)) |
| 478 |
4/6✓ Branch 12 → 13 taken 34166 times.
✓ Branch 12 → 119 taken 4 times.
✓ Branch 13 → 14 taken 34166 times.
✗ Branch 13 → 117 not taken.
✓ Branch 14 → 15 taken 34166 times.
✗ Branch 14 → 117 not taken.
|
34170 | stmtLstNode->statements.push_back(std::any_cast<StmtNode *>(visit(stmtCtx))); |
| 479 |
3/4✓ Branch 17 → 18 taken 59868 times.
✗ Branch 17 → 19 not taken.
✓ Branch 20 → 21 taken 1538 times.
✓ Branch 20 → 26 taken 58330 times.
|
59868 | else if (auto *forLoopCtx = dynamic_cast<SpiceParser::ForLoopContext *>(stmt)) |
| 480 |
3/6✓ Branch 21 → 22 taken 1538 times.
✗ Branch 21 → 123 not taken.
✓ Branch 22 → 23 taken 1538 times.
✗ Branch 22 → 121 not taken.
✓ Branch 23 → 24 taken 1538 times.
✗ Branch 23 → 121 not taken.
|
1538 | stmtLstNode->statements.push_back(std::any_cast<ForLoopNode *>(visit(forLoopCtx))); |
| 481 |
3/4✓ Branch 26 → 27 taken 58330 times.
✗ Branch 26 → 28 not taken.
✓ Branch 29 → 30 taken 139 times.
✓ Branch 29 → 35 taken 58191 times.
|
58330 | else if (auto *foreachLoopCtx = dynamic_cast<SpiceParser::ForeachLoopContext *>(stmt)) |
| 482 |
3/6✓ Branch 30 → 31 taken 139 times.
✗ Branch 30 → 127 not taken.
✓ Branch 31 → 32 taken 139 times.
✗ Branch 31 → 125 not taken.
✓ Branch 32 → 33 taken 139 times.
✗ Branch 32 → 125 not taken.
|
139 | stmtLstNode->statements.push_back(std::any_cast<ForeachLoopNode *>(visit(foreachLoopCtx))); |
| 483 |
3/4✓ Branch 35 → 36 taken 58191 times.
✗ Branch 35 → 37 not taken.
✓ Branch 38 → 39 taken 876 times.
✓ Branch 38 → 44 taken 57315 times.
|
58191 | else if (auto *whileLoopCtx = dynamic_cast<SpiceParser::WhileLoopContext *>(stmt)) |
| 484 |
3/6✓ Branch 39 → 40 taken 876 times.
✗ Branch 39 → 131 not taken.
✓ Branch 40 → 41 taken 876 times.
✗ Branch 40 → 129 not taken.
✓ Branch 41 → 42 taken 876 times.
✗ Branch 41 → 129 not taken.
|
876 | stmtLstNode->statements.push_back(std::any_cast<WhileLoopNode *>(visit(whileLoopCtx))); |
| 485 |
3/4✓ Branch 44 → 45 taken 57315 times.
✗ Branch 44 → 46 not taken.
✓ Branch 47 → 48 taken 8 times.
✓ Branch 47 → 53 taken 57307 times.
|
57315 | else if (auto *doWhileLoopCtx = dynamic_cast<SpiceParser::DoWhileLoopContext *>(stmt)) |
| 486 |
3/6✓ Branch 48 → 49 taken 8 times.
✗ Branch 48 → 135 not taken.
✓ Branch 49 → 50 taken 8 times.
✗ Branch 49 → 133 not taken.
✓ Branch 50 → 51 taken 8 times.
✗ Branch 50 → 133 not taken.
|
8 | stmtLstNode->statements.push_back(std::any_cast<DoWhileLoopNode *>(visit(doWhileLoopCtx))); |
| 487 |
3/4✓ Branch 53 → 54 taken 57307 times.
✗ Branch 53 → 55 not taken.
✓ Branch 56 → 57 taken 4630 times.
✓ Branch 56 → 62 taken 52677 times.
|
57307 | else if (auto *ifStmtCtx = dynamic_cast<SpiceParser::IfStmtContext *>(stmt)) |
| 488 |
3/6✓ Branch 57 → 58 taken 4630 times.
✗ Branch 57 → 139 not taken.
✓ Branch 58 → 59 taken 4630 times.
✗ Branch 58 → 137 not taken.
✓ Branch 59 → 60 taken 4630 times.
✗ Branch 59 → 137 not taken.
|
4630 | stmtLstNode->statements.push_back(std::any_cast<IfStmtNode *>(visit(ifStmtCtx))); |
| 489 |
3/4✓ Branch 62 → 63 taken 52677 times.
✗ Branch 62 → 64 not taken.
✓ Branch 65 → 66 taken 12 times.
✓ Branch 65 → 71 taken 52665 times.
|
52677 | else if (auto *switchStmtCtx = dynamic_cast<SpiceParser::SwitchStmtContext *>(stmt)) |
| 490 |
3/6✓ Branch 66 → 67 taken 12 times.
✗ Branch 66 → 143 not taken.
✓ Branch 67 → 68 taken 12 times.
✗ Branch 67 → 141 not taken.
✓ Branch 68 → 69 taken 12 times.
✗ Branch 68 → 141 not taken.
|
12 | stmtLstNode->statements.push_back(std::any_cast<SwitchStmtNode *>(visit(switchStmtCtx))); |
| 491 |
3/4✓ Branch 71 → 72 taken 52665 times.
✗ Branch 71 → 73 not taken.
✓ Branch 74 → 75 taken 843 times.
✓ Branch 74 → 80 taken 51822 times.
|
52665 | else if (auto *assetStmtCtx = dynamic_cast<SpiceParser::AssertStmtContext *>(stmt)) |
| 492 |
3/6✓ Branch 75 → 76 taken 843 times.
✗ Branch 75 → 147 not taken.
✓ Branch 76 → 77 taken 843 times.
✗ Branch 76 → 145 not taken.
✓ Branch 77 → 78 taken 843 times.
✗ Branch 77 → 145 not taken.
|
843 | stmtLstNode->statements.push_back(std::any_cast<AssertStmtNode *>(visit(assetStmtCtx))); |
| 493 |
3/4✓ Branch 80 → 81 taken 51822 times.
✗ Branch 80 → 82 not taken.
✓ Branch 83 → 84 taken 2937 times.
✓ Branch 83 → 89 taken 48885 times.
|
51822 | else if (auto *unsafeBlockCtx = dynamic_cast<SpiceParser::UnsafeBlockContext *>(stmt)) |
| 494 |
3/6✓ Branch 84 → 85 taken 2937 times.
✗ Branch 84 → 151 not taken.
✓ Branch 85 → 86 taken 2937 times.
✗ Branch 85 → 149 not taken.
✓ Branch 86 → 87 taken 2937 times.
✗ Branch 86 → 149 not taken.
|
2937 | stmtLstNode->statements.push_back(std::any_cast<UnsafeBlockNode *>(visit(unsafeBlockCtx))); |
| 495 |
3/4✓ Branch 89 → 90 taken 48885 times.
✗ Branch 89 → 91 not taken.
✓ Branch 92 → 93 taken 33 times.
✓ Branch 92 → 98 taken 48852 times.
|
48885 | else if (auto *anonymousScopeCtx = dynamic_cast<SpiceParser::AnonymousBlockStmtContext *>(stmt)) |
| 496 |
3/6✓ Branch 93 → 94 taken 33 times.
✗ Branch 93 → 155 not taken.
✓ Branch 94 → 95 taken 33 times.
✗ Branch 94 → 153 not taken.
✓ Branch 95 → 96 taken 33 times.
✗ Branch 95 → 153 not taken.
|
33 | 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 112 → 113 taken 24424 times.
✗ Branch 112 → 158 not taken.
|
24424 | return concludeNode(stmtLstNode); |
| 502 | } | ||
| 503 | |||
| 504 | 8654 | std::any ASTBuilder::visitTypeLst(SpiceParser::TypeLstContext *ctx) { | |
| 505 | 8654 | const auto typeLstNode = createNode<TypeLstNode>(ctx); | |
| 506 | |||
| 507 | // Visit children | ||
| 508 |
2/4✓ Branch 3 → 4 taken 8654 times.
✗ Branch 3 → 18 not taken.
✓ Branch 4 → 5 taken 8654 times.
✗ Branch 4 → 16 not taken.
|
8654 | fetchChildrenIntoVector(typeLstNode->dataTypes, ctx->dataType()); |
| 509 | |||
| 510 |
1/2✓ Branch 12 → 13 taken 8654 times.
✗ Branch 12 → 19 not taken.
|
8654 | return concludeNode(typeLstNode); |
| 511 | } | ||
| 512 | |||
| 513 | 1115 | std::any ASTBuilder::visitTypeLstWithEllipsis(SpiceParser::TypeLstWithEllipsisContext *ctx) { | |
| 514 | 1115 | const auto typeLstWithEllipsisNode = createNode<TypeLstWithEllipsisNode>(ctx); | |
| 515 | |||
| 516 | // Visit children | ||
| 517 |
3/6✓ Branch 3 → 4 taken 1115 times.
✗ Branch 3 → 20 not taken.
✓ Branch 4 → 5 taken 1115 times.
✗ Branch 4 → 20 not taken.
✓ Branch 5 → 6 taken 1115 times.
✗ Branch 5 → 18 not taken.
|
1115 | typeLstWithEllipsisNode->typeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst())); |
| 518 | |||
| 519 | // Set some flags | ||
| 520 | 1115 | typeLstWithEllipsisNode->hasEllipsis = ctx->ELLIPSIS() != nullptr; | |
| 521 | |||
| 522 |
1/2✓ Branch 14 → 15 taken 1115 times.
✗ Branch 14 → 21 not taken.
|
1115 | return concludeNode(typeLstWithEllipsisNode); |
| 523 | } | ||
| 524 | |||
| 525 | 1059 | std::any ASTBuilder::visitTypeAltsLst(SpiceParser::TypeAltsLstContext *ctx) { | |
| 526 | 1059 | const auto typeAltsLstNode = createNode<TypeAltsLstNode>(ctx); | |
| 527 | |||
| 528 | // Visit children | ||
| 529 |
2/4✓ Branch 3 → 4 taken 1059 times.
✗ Branch 3 → 18 not taken.
✓ Branch 4 → 5 taken 1059 times.
✗ Branch 4 → 16 not taken.
|
1059 | fetchChildrenIntoVector(typeAltsLstNode->dataTypes, ctx->dataType()); |
| 530 | |||
| 531 |
1/2✓ Branch 12 → 13 taken 1059 times.
✗ Branch 12 → 19 not taken.
|
1059 | return concludeNode(typeAltsLstNode); |
| 532 | } | ||
| 533 | |||
| 534 | 10325 | std::any ASTBuilder::visitParamLst(SpiceParser::ParamLstContext *ctx) { | |
| 535 | 10325 | const auto paramLstNode = createNode<ParamLstNode>(ctx); | |
| 536 | |||
| 537 | // Visit children | ||
| 538 |
2/4✓ Branch 3 → 4 taken 10325 times.
✗ Branch 3 → 24 not taken.
✓ Branch 4 → 5 taken 10325 times.
✗ Branch 4 → 22 not taken.
|
10325 | fetchChildrenIntoVector(paramLstNode->params, ctx->declStmt()); |
| 539 | |||
| 540 | // Set some flags to later detect that the decl statements are parameters | ||
| 541 |
2/2✓ Branch 11 → 8 taken 15751 times.
✓ Branch 11 → 12 taken 10325 times.
|
26076 | for (DeclStmtNode *declStmt : paramLstNode->params) { |
| 542 | 15751 | declStmt->isFctParam = true; | |
| 543 | 15751 | declStmt->dataType->isParamType = true; | |
| 544 | } | ||
| 545 | |||
| 546 |
1/2✓ Branch 18 → 19 taken 10325 times.
✗ Branch 18 → 25 not taken.
|
10325 | return concludeNode(paramLstNode); |
| 547 | } | ||
| 548 | |||
| 549 | 17000 | std::any ASTBuilder::visitArgLst(SpiceParser::ArgLstContext *ctx) { | |
| 550 | 17000 | const auto argLstNode = createNode<ArgLstNode>(ctx); | |
| 551 | |||
| 552 | // Visit children | ||
| 553 |
2/4✓ Branch 3 → 4 taken 17000 times.
✗ Branch 3 → 20 not taken.
✓ Branch 4 → 5 taken 17000 times.
✗ Branch 4 → 18 not taken.
|
17000 | fetchChildrenIntoVector(argLstNode->args, ctx->assignExpr()); |
| 554 | 17000 | argLstNode->argInfos.reserve(argLstNode->args.size()); | |
| 555 | |||
| 556 |
1/2✓ Branch 14 → 15 taken 17000 times.
✗ Branch 14 → 21 not taken.
|
17000 | return concludeNode(argLstNode); |
| 557 | } | ||
| 558 | |||
| 559 | 78 | std::any ASTBuilder::visitEnumItemLst(SpiceParser::EnumItemLstContext *ctx) { | |
| 560 | 78 | const auto enumItemLstNode = createNode<EnumItemLstNode>(ctx); | |
| 561 | |||
| 562 | // Visit children | ||
| 563 |
2/4✓ Branch 3 → 4 taken 78 times.
✗ Branch 3 → 18 not taken.
✓ Branch 4 → 5 taken 78 times.
✗ Branch 4 → 16 not taken.
|
78 | fetchChildrenIntoVector(enumItemLstNode->items, ctx->enumItem()); |
| 564 | |||
| 565 |
1/2✓ Branch 12 → 13 taken 78 times.
✗ Branch 12 → 19 not taken.
|
78 | return concludeNode(enumItemLstNode); |
| 566 | } | ||
| 567 | |||
| 568 | 1186 | std::any ASTBuilder::visitEnumItem(SpiceParser::EnumItemContext *ctx) { | |
| 569 | 1186 | const auto enumItemNode = createNode<EnumItemNode>(ctx); | |
| 570 | |||
| 571 | // Enrich | ||
| 572 |
2/4✓ Branch 3 → 4 taken 1186 times.
✗ Branch 3 → 22 not taken.
✓ Branch 4 → 5 taken 1186 times.
✗ Branch 4 → 22 not taken.
|
1186 | enumItemNode->itemName = getIdentifier(ctx->TYPE_IDENTIFIER(), false); |
| 573 |
2/2✓ Branch 8 → 9 taken 856 times.
✓ Branch 8 → 12 taken 330 times.
|
1186 | if (ctx->ASSIGN()) { |
| 574 | 856 | enumItemNode->itemValue = parseInt(ctx->INT_LIT()); | |
| 575 | 856 | enumItemNode->hasValue = true; | |
| 576 | } | ||
| 577 | |||
| 578 |
1/2✓ Branch 18 → 19 taken 1186 times.
✗ Branch 18 → 23 not taken.
|
1186 | return concludeNode(enumItemNode); |
| 579 | } | ||
| 580 | |||
| 581 | 1689 | std::any ASTBuilder::visitField(SpiceParser::FieldContext *ctx) { | |
| 582 | 1689 | const auto fieldNode = createNode<FieldNode>(ctx); | |
| 583 | |||
| 584 | // Enrich | ||
| 585 |
2/4✓ Branch 3 → 4 taken 1689 times.
✗ Branch 3 → 29 not taken.
✓ Branch 4 → 5 taken 1689 times.
✗ Branch 4 → 29 not taken.
|
1689 | fieldNode->fieldName = getIdentifier(ctx->IDENTIFIER(), false); |
| 586 | |||
| 587 | // Visit children | ||
| 588 |
3/6✓ Branch 7 → 8 taken 1689 times.
✗ Branch 7 → 32 not taken.
✓ Branch 8 → 9 taken 1689 times.
✗ Branch 8 → 32 not taken.
✓ Branch 9 → 10 taken 1689 times.
✗ Branch 9 → 30 not taken.
|
1689 | fieldNode->dataType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 589 | 1689 | fieldNode->dataType->setFieldTypeRecursive(); | |
| 590 |
2/2✓ Branch 13 → 14 taken 240 times.
✓ Branch 13 → 19 taken 1449 times.
|
1689 | if (ctx->ternaryExpr()) |
| 591 |
3/6✓ Branch 14 → 15 taken 240 times.
✗ Branch 14 → 35 not taken.
✓ Branch 15 → 16 taken 240 times.
✗ Branch 15 → 35 not taken.
✓ Branch 16 → 17 taken 240 times.
✗ Branch 16 → 33 not taken.
|
240 | fieldNode->defaultValue = std::any_cast<ExprNode *>(visit(ctx->ternaryExpr())); |
| 592 | |||
| 593 |
1/2✓ Branch 25 → 26 taken 1689 times.
✗ Branch 25 → 36 not taken.
|
1689 | return concludeNode(fieldNode); |
| 594 | } | ||
| 595 | |||
| 596 | 249 | std::any ASTBuilder::visitSignature(SpiceParser::SignatureContext *ctx) { | |
| 597 | 249 | const auto signatureNode = createNode<SignatureNode>(ctx); | |
| 598 | |||
| 599 | // Extract method name | ||
| 600 |
2/4✓ Branch 3 → 4 taken 249 times.
✗ Branch 3 → 73 not taken.
✓ Branch 4 → 5 taken 249 times.
✗ Branch 4 → 73 not taken.
|
249 | signatureNode->methodName = getIdentifier(ctx->IDENTIFIER(), false); |
| 601 | |||
| 602 | // Visit children | ||
| 603 |
2/2✓ Branch 8 → 9 taken 15 times.
✓ Branch 8 → 14 taken 234 times.
|
249 | if (ctx->qualifierLst()) { |
| 604 |
3/6✓ Branch 9 → 10 taken 15 times.
✗ Branch 9 → 76 not taken.
✓ Branch 10 → 11 taken 15 times.
✗ Branch 10 → 76 not taken.
✓ Branch 11 → 12 taken 15 times.
✗ Branch 11 → 74 not taken.
|
15 | signatureNode->qualifierLst = std::any_cast<QualifierLstNode *>(visit(ctx->qualifierLst())); |
| 605 | } | ||
| 606 |
2/2✓ Branch 15 → 16 taken 194 times.
✓ Branch 15 → 22 taken 55 times.
|
249 | if (ctx->F()) { |
| 607 | 194 | signatureNode->hasReturnType = true; | |
| 608 | 194 | signatureNode->signatureType = SignatureNode::SignatureType::TYPE_FUNCTION; | |
| 609 | 194 | signatureNode->signatureQualifiers = TypeQualifiers::of(TY_FUNCTION); | |
| 610 |
3/6✓ Branch 17 → 18 taken 194 times.
✗ Branch 17 → 79 not taken.
✓ Branch 18 → 19 taken 194 times.
✗ Branch 18 → 79 not taken.
✓ Branch 19 → 20 taken 194 times.
✗ Branch 19 → 77 not taken.
|
194 | signatureNode->returnType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 611 | } else { | ||
| 612 | 55 | signatureNode->signatureType = SignatureNode::SignatureType::TYPE_PROCEDURE; | |
| 613 | 55 | signatureNode->signatureQualifiers = TypeQualifiers::of(TY_PROCEDURE); | |
| 614 | } | ||
| 615 |
10/16✓ Branch 24 → 25 taken 194 times.
✓ Branch 24 → 28 taken 55 times.
✓ Branch 25 → 26 taken 194 times.
✗ Branch 25 → 80 not taken.
✓ Branch 28 → 29 taken 55 times.
✗ Branch 28 → 80 not taken.
✓ Branch 31 → 32 taken 55 times.
✓ Branch 31 → 33 taken 194 times.
✓ Branch 33 → 34 taken 194 times.
✓ Branch 33 → 35 taken 55 times.
✓ Branch 35 → 36 taken 126 times.
✓ Branch 35 → 41 taken 123 times.
✗ Branch 80 → 81 not taken.
✗ Branch 80 → 82 not taken.
✗ Branch 84 → 85 not taken.
✗ Branch 84 → 86 not taken.
|
249 | if (ctx->F() ? ctx->LESS().size() == 2 : ctx->LESS().size() == 1) { |
| 616 | 126 | signatureNode->hasTemplateTypes = true; | |
| 617 |
3/6✓ Branch 36 → 37 taken 126 times.
✗ Branch 36 → 90 not taken.
✓ Branch 37 → 38 taken 126 times.
✗ Branch 37 → 90 not taken.
✓ Branch 38 → 39 taken 126 times.
✗ Branch 38 → 88 not taken.
|
126 | signatureNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst(0))); |
| 618 | } | ||
| 619 |
13/20✓ Branch 41 → 42 taken 249 times.
✗ Branch 41 → 91 not taken.
✓ Branch 43 → 44 taken 247 times.
✓ Branch 43 → 48 taken 2 times.
✓ Branch 44 → 45 taken 247 times.
✗ Branch 44 → 91 not taken.
✓ Branch 46 → 47 taken 131 times.
✓ Branch 46 → 49 taken 116 times.
✓ Branch 47 → 48 taken 7 times.
✓ Branch 47 → 49 taken 124 times.
✓ Branch 50 → 51 taken 247 times.
✓ Branch 50 → 52 taken 2 times.
✓ Branch 52 → 53 taken 249 times.
✗ Branch 52 → 54 not taken.
✓ Branch 54 → 55 taken 9 times.
✓ Branch 54 → 63 taken 240 times.
✗ Branch 91 → 92 not taken.
✗ Branch 91 → 93 not taken.
✗ Branch 95 → 96 not taken.
✗ Branch 95 → 97 not taken.
|
249 | if (ctx->typeLst().size() == 2 || (ctx->typeLst().size() == 1 && !signatureNode->hasTemplateTypes)) { |
| 620 | 9 | signatureNode->hasParams = true; | |
| 621 |
5/8✓ Branch 55 → 56 taken 2 times.
✓ Branch 55 → 57 taken 7 times.
✓ Branch 58 → 59 taken 9 times.
✗ Branch 58 → 101 not taken.
✓ Branch 59 → 60 taken 9 times.
✗ Branch 59 → 101 not taken.
✓ Branch 60 → 61 taken 9 times.
✗ Branch 60 → 99 not taken.
|
9 | signatureNode->paramTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst(signatureNode->hasTemplateTypes ? 1 : 0))); |
| 622 | } | ||
| 623 | |||
| 624 |
1/2✓ Branch 69 → 70 taken 249 times.
✗ Branch 69 → 102 not taken.
|
249 | return concludeNode(signatureNode); |
| 625 | } | ||
| 626 | |||
| 627 | 34170 | std::any ASTBuilder::visitStmt(SpiceParser::StmtContext *ctx) { | |
| 628 |
2/2✓ Branch 3 → 4 taken 6088 times.
✓ Branch 3 → 11 taken 28082 times.
|
34170 | if (ctx->declStmt()) |
| 629 |
5/8✓ Branch 4 → 5 taken 6088 times.
✗ Branch 4 → 60 not taken.
✓ Branch 5 → 6 taken 6084 times.
✓ Branch 5 → 60 taken 4 times.
✓ Branch 6 → 7 taken 6084 times.
✗ Branch 6 → 58 not taken.
✓ Branch 7 → 8 taken 6084 times.
✗ Branch 7 → 58 not taken.
|
6088 | return static_cast<StmtNode *>(std::any_cast<DeclStmtNode *>(visit(ctx->declStmt()))); |
| 630 |
2/2✓ Branch 12 → 13 taken 17112 times.
✓ Branch 12 → 20 taken 10970 times.
|
28082 | if (ctx->exprStmt()) |
| 631 |
4/8✓ Branch 13 → 14 taken 17112 times.
✗ Branch 13 → 64 not taken.
✓ Branch 14 → 15 taken 17112 times.
✗ Branch 14 → 64 not taken.
✓ Branch 15 → 16 taken 17112 times.
✗ Branch 15 → 62 not taken.
✓ Branch 16 → 17 taken 17112 times.
✗ Branch 16 → 62 not taken.
|
17112 | return static_cast<StmtNode *>(std::any_cast<ExprStmtNode *>(visit(ctx->exprStmt()))); |
| 632 |
2/2✓ Branch 21 → 22 taken 10608 times.
✓ Branch 21 → 29 taken 362 times.
|
10970 | if (ctx->returnStmt()) |
| 633 |
4/8✓ Branch 22 → 23 taken 10608 times.
✗ Branch 22 → 68 not taken.
✓ Branch 23 → 24 taken 10608 times.
✗ Branch 23 → 68 not taken.
✓ Branch 24 → 25 taken 10608 times.
✗ Branch 24 → 66 not taken.
✓ Branch 25 → 26 taken 10608 times.
✗ Branch 25 → 66 not taken.
|
10608 | return static_cast<StmtNode *>(std::any_cast<ReturnStmtNode *>(visit(ctx->returnStmt()))); |
| 634 |
2/2✓ Branch 30 → 31 taken 133 times.
✓ Branch 30 → 38 taken 229 times.
|
362 | if (ctx->breakStmt()) |
| 635 |
4/8✓ Branch 31 → 32 taken 133 times.
✗ Branch 31 → 72 not taken.
✓ Branch 32 → 33 taken 133 times.
✗ Branch 32 → 72 not taken.
✓ Branch 33 → 34 taken 133 times.
✗ Branch 33 → 70 not taken.
✓ Branch 34 → 35 taken 133 times.
✗ Branch 34 → 70 not taken.
|
133 | return static_cast<StmtNode *>(std::any_cast<BreakStmtNode *>(visit(ctx->breakStmt()))); |
| 636 |
2/2✓ Branch 39 → 40 taken 223 times.
✓ Branch 39 → 47 taken 6 times.
|
229 | if (ctx->continueStmt()) |
| 637 |
4/8✓ Branch 40 → 41 taken 223 times.
✗ Branch 40 → 76 not taken.
✓ Branch 41 → 42 taken 223 times.
✗ Branch 41 → 76 not taken.
✓ Branch 42 → 43 taken 223 times.
✗ Branch 42 → 74 not taken.
✓ Branch 43 → 44 taken 223 times.
✗ Branch 43 → 74 not taken.
|
223 | 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.
|
6 | 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 | 23524 | std::any ASTBuilder::visitDeclStmt(SpiceParser::DeclStmtContext *ctx) { | |
| 645 | 23524 | const auto declStmtNode = createNode<DeclStmtNode>(ctx); | |
| 646 | |||
| 647 | // Enrich | ||
| 648 |
3/4✓ Branch 3 → 4 taken 23524 times.
✗ Branch 3 → 28 not taken.
✓ Branch 4 → 5 taken 23523 times.
✓ Branch 4 → 28 taken 1 time.
|
23524 | declStmtNode->varName = getIdentifier(ctx->IDENTIFIER(), false); |
| 649 | |||
| 650 | // Visit children | ||
| 651 |
4/6✓ Branch 7 → 8 taken 23523 times.
✗ Branch 7 → 31 not taken.
✓ Branch 8 → 9 taken 23522 times.
✓ Branch 8 → 31 taken 1 time.
✓ Branch 9 → 10 taken 23522 times.
✗ Branch 9 → 29 not taken.
|
23523 | declStmtNode->dataType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 652 |
2/2✓ Branch 12 → 13 taken 8384 times.
✓ Branch 12 → 18 taken 15138 times.
|
23522 | if (ctx->assignExpr()) { |
| 653 | 8384 | declStmtNode->hasAssignment = true; | |
| 654 |
4/6✓ Branch 13 → 14 taken 8384 times.
✗ Branch 13 → 34 not taken.
✓ Branch 14 → 15 taken 8382 times.
✓ Branch 14 → 34 taken 2 times.
✓ Branch 15 → 16 taken 8382 times.
✗ Branch 15 → 32 not taken.
|
8384 | declStmtNode->assignExpr = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 655 | } | ||
| 656 | |||
| 657 |
1/2✓ Branch 24 → 25 taken 23520 times.
✗ Branch 24 → 35 not taken.
|
23520 | return concludeNode(declStmtNode); |
| 658 | } | ||
| 659 | |||
| 660 | 17112 | std::any ASTBuilder::visitExprStmt(SpiceParser::ExprStmtContext *ctx) { | |
| 661 | 17112 | const auto exprStmtNode = createNode<ExprStmtNode>(ctx); | |
| 662 | |||
| 663 | // Enrich | ||
| 664 |
3/6✓ Branch 3 → 4 taken 17112 times.
✗ Branch 3 → 19 not taken.
✓ Branch 4 → 5 taken 17112 times.
✗ Branch 4 → 19 not taken.
✓ Branch 5 → 6 taken 17112 times.
✗ Branch 5 → 17 not taken.
|
17112 | exprStmtNode->expr = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 665 | |||
| 666 |
1/2✓ Branch 13 → 14 taken 17112 times.
✗ Branch 13 → 20 not taken.
|
17112 | return concludeNode(exprStmtNode); |
| 667 | } | ||
| 668 | |||
| 669 | 34774 | std::any ASTBuilder::visitQualifierLst(SpiceParser::QualifierLstContext *ctx) { | |
| 670 | 34774 | const auto qualifierLstNode = createNode<QualifierLstNode>(ctx); | |
| 671 | |||
| 672 | // Visit children | ||
| 673 |
2/4✓ Branch 3 → 4 taken 34774 times.
✗ Branch 3 → 37 not taken.
✓ Branch 4 → 5 taken 34774 times.
✗ Branch 4 → 35 not taken.
|
34774 | fetchChildrenIntoVector(qualifierLstNode->qualifiers, ctx->qualifier()); |
| 674 | |||
| 675 | // Check if qualifier combination is invalid | ||
| 676 | 34774 | bool seenSignedOrUnsigned = false; | |
| 677 |
2/2✓ Branch 24 → 8 taken 41872 times.
✓ Branch 24 → 25 taken 34773 times.
|
76645 | for (const QualifierNode *qualifier : qualifierLstNode->qualifiers) { |
| 678 | // Check if we have both, signed and unsigned qualifier | ||
| 679 |
2/2✓ Branch 9 → 10 taken 41865 times.
✓ Branch 9 → 12 taken 7 times.
|
41872 | if (qualifier->type != QualifierNode::QualifierType::TY_SIGNED && |
| 680 |
2/2✓ Branch 10 → 11 taken 31371 times.
✓ Branch 10 → 12 taken 10494 times.
|
41865 | qualifier->type != QualifierNode::QualifierType::TY_UNSIGNED) |
| 681 | 31371 | continue; | |
| 682 |
2/2✓ Branch 12 → 13 taken 1 time.
✓ Branch 12 → 21 taken 10500 times.
|
10501 | if (seenSignedOrUnsigned) |
| 683 |
2/4✓ Branch 16 → 17 taken 1 time.
✗ Branch 16 → 41 not taken.
✓ Branch 17 → 18 taken 1 time.
✗ Branch 17 → 38 not taken.
|
3 | throw ParserError(qualifier->codeLoc, INVALID_QUALIFIER_COMBINATION, "A variable can not be signed and unsigned"); |
| 684 | 10500 | seenSignedOrUnsigned = true; | |
| 685 | } | ||
| 686 | |||
| 687 |
1/2✓ Branch 31 → 32 taken 34773 times.
✗ Branch 31 → 48 not taken.
|
34773 | return concludeNode(qualifierLstNode); |
| 688 | } | ||
| 689 | |||
| 690 | 41872 | std::any ASTBuilder::visitQualifier(SpiceParser::QualifierContext *ctx) { | |
| 691 | 41872 | const auto qualifierNode = createNode<QualifierNode>(ctx); | |
| 692 | |||
| 693 |
3/4✓ Branch 6 → 7 taken 41872 times.
✗ Branch 6 → 8 not taken.
✓ Branch 32 → 5 taken 41872 times.
✓ Branch 32 → 33 taken 41872 times.
|
83744 | for (ParserRuleContext::ParseTree *subTree : ctx->children) { |
| 694 | 41872 | const auto token = spice_pointer_cast<TerminalNode *>(subTree); | |
| 695 |
2/4✓ Branch 13 → 14 taken 41872 times.
✗ Branch 13 → 43 not taken.
✓ Branch 14 → 15 taken 41872 times.
✗ Branch 14 → 43 not taken.
|
41872 | const size_t symbolType = token->getSymbol()->getType(); |
| 696 |
2/2✓ Branch 15 → 16 taken 8930 times.
✓ Branch 15 → 17 taken 32942 times.
|
41872 | if (symbolType == SpiceParser::CONST) |
| 697 | 8930 | qualifierNode->type = QualifierNode::QualifierType::TY_CONST; | |
| 698 |
2/2✓ Branch 17 → 18 taken 7 times.
✓ Branch 17 → 19 taken 32935 times.
|
32942 | else if (symbolType == SpiceParser::SIGNED) |
| 699 | 7 | qualifierNode->type = QualifierNode::QualifierType::TY_SIGNED; | |
| 700 |
2/2✓ Branch 19 → 20 taken 10494 times.
✓ Branch 19 → 21 taken 22441 times.
|
32935 | else if (symbolType == SpiceParser::UNSIGNED) |
| 701 | 10494 | qualifierNode->type = QualifierNode::QualifierType::TY_UNSIGNED; | |
| 702 |
2/2✓ Branch 21 → 22 taken 3682 times.
✓ Branch 21 → 23 taken 18759 times.
|
22441 | else if (symbolType == SpiceParser::INLINE) |
| 703 | 3682 | qualifierNode->type = QualifierNode::QualifierType::TY_INLINE; | |
| 704 |
2/2✓ Branch 23 → 24 taken 14330 times.
✓ Branch 23 → 25 taken 4429 times.
|
18759 | else if (symbolType == SpiceParser::PUBLIC) |
| 705 | 14330 | qualifierNode->type = QualifierNode::QualifierType::TY_PUBLIC; | |
| 706 |
2/2✓ Branch 25 → 26 taken 4416 times.
✓ Branch 25 → 27 taken 13 times.
|
4429 | else if (symbolType == SpiceParser::HEAP) |
| 707 | 4416 | qualifierNode->type = QualifierNode::QualifierType::TY_HEAP; | |
| 708 |
1/2✓ Branch 27 → 28 taken 13 times.
✗ Branch 27 → 29 not taken.
|
13 | else if (symbolType == SpiceParser::COMPOSE) |
| 709 | 13 | qualifierNode->type = QualifierNode::QualifierType::TY_COMPOSITION; | |
| 710 | else | ||
| 711 | − | assert_fail("Unknown qualifier type"); // GCOV_EXCL_LINE | |
| 712 | } | ||
| 713 | |||
| 714 |
1/2✓ Branch 39 → 40 taken 41872 times.
✗ Branch 39 → 44 not taken.
|
41872 | return concludeNode(qualifierNode); |
| 715 | } | ||
| 716 | |||
| 717 | 407 | std::any ASTBuilder::visitModAttr(SpiceParser::ModAttrContext *ctx) { | |
| 718 | 407 | const auto modAttrNode = createNode<ModAttrNode>(ctx); | |
| 719 | |||
| 720 | // Visit children | ||
| 721 |
4/6✓ Branch 3 → 4 taken 407 times.
✗ Branch 3 → 25 not taken.
✓ Branch 4 → 5 taken 406 times.
✓ Branch 4 → 25 taken 1 time.
✓ Branch 5 → 6 taken 406 times.
✗ Branch 5 → 23 not taken.
|
407 | modAttrNode->attrLst = std::any_cast<AttrLstNode *>(visit(ctx->attrLst())); |
| 722 | |||
| 723 | // Tell the attributes that they are module attributes | ||
| 724 |
2/2✓ Branch 12 → 9 taken 694 times.
✓ Branch 12 → 13 taken 406 times.
|
1100 | for (AttrNode *attr : modAttrNode->attrLst->attributes) |
| 725 | 694 | attr->target = AttrNode::TARGET_MODULE; | |
| 726 | |||
| 727 |
1/2✓ Branch 19 → 20 taken 406 times.
✗ Branch 19 → 26 not taken.
|
406 | return concludeNode(modAttrNode); |
| 728 | } | ||
| 729 | |||
| 730 | 509 | std::any ASTBuilder::visitTopLevelDefAttr(SpiceParser::TopLevelDefAttrContext *ctx) { | |
| 731 | 509 | const auto fctAttrNode = createNode<TopLevelDefinitionAttrNode>(ctx); | |
| 732 | |||
| 733 | // Visit children | ||
| 734 |
3/6✓ Branch 3 → 4 taken 509 times.
✗ Branch 3 → 19 not taken.
✓ Branch 4 → 5 taken 509 times.
✗ Branch 4 → 19 not taken.
✓ Branch 5 → 6 taken 509 times.
✗ Branch 5 → 17 not taken.
|
509 | fctAttrNode->attrLst = std::any_cast<AttrLstNode *>(visit(ctx->attrLst())); |
| 735 | |||
| 736 |
1/2✓ Branch 13 → 14 taken 509 times.
✗ Branch 13 → 20 not taken.
|
509 | return concludeNode(fctAttrNode); |
| 737 | } | ||
| 738 | |||
| 739 | 5 | std::any ASTBuilder::visitLambdaAttr(SpiceParser::LambdaAttrContext *ctx) { | |
| 740 | 5 | const auto lambdaAttrNode = createNode<LambdaAttrNode>(ctx); | |
| 741 | |||
| 742 | // Visit children | ||
| 743 |
3/6✓ Branch 3 → 4 taken 5 times.
✗ Branch 3 → 25 not taken.
✓ Branch 4 → 5 taken 5 times.
✗ Branch 4 → 25 not taken.
✓ Branch 5 → 6 taken 5 times.
✗ Branch 5 → 23 not taken.
|
5 | lambdaAttrNode->attrLst = std::any_cast<AttrLstNode *>(visit(ctx->attrLst())); |
| 744 | |||
| 745 | // Tell the attributes that they are module attributes | ||
| 746 |
2/2✓ Branch 12 → 9 taken 5 times.
✓ Branch 12 → 13 taken 5 times.
|
10 | for (AttrNode *attr : lambdaAttrNode->attrLst->attributes) |
| 747 | 5 | attr->target = AttrNode::TARGET_LAMBDA; | |
| 748 | |||
| 749 |
1/2✓ Branch 19 → 20 taken 5 times.
✗ Branch 19 → 26 not taken.
|
5 | return concludeNode(lambdaAttrNode); |
| 750 | } | ||
| 751 | |||
| 752 | 921 | std::any ASTBuilder::visitAttrLst(SpiceParser::AttrLstContext *ctx) { | |
| 753 | 921 | const auto attrLstNode = createNode<AttrLstNode>(ctx); | |
| 754 | |||
| 755 | // Visit children | ||
| 756 |
3/4✓ Branch 3 → 4 taken 921 times.
✗ Branch 3 → 18 not taken.
✓ Branch 4 → 5 taken 920 times.
✓ Branch 4 → 16 taken 1 time.
|
922 | fetchChildrenIntoVector(attrLstNode->attributes, ctx->attr()); |
| 757 | |||
| 758 |
1/2✓ Branch 12 → 13 taken 920 times.
✗ Branch 12 → 19 not taken.
|
920 | return concludeNode(attrLstNode); |
| 759 | } | ||
| 760 | |||
| 761 | 1214 | std::any ASTBuilder::visitAttr(SpiceParser::AttrContext *ctx) { | |
| 762 |
1/2✓ Branch 2 → 3 taken 1214 times.
✗ Branch 2 → 83 not taken.
|
1214 | const auto attrNode = createNode<AttrNode>(ctx); |
| 763 | |||
| 764 | // Extract key | ||
| 765 |
1/2✓ Branch 3 → 4 taken 1214 times.
✗ Branch 3 → 83 not taken.
|
1214 | std::stringstream key; |
| 766 |
3/4✓ Branch 12 → 13 taken 4181 times.
✗ Branch 12 → 66 not taken.
✓ Branch 15 → 5 taken 2967 times.
✓ Branch 15 → 16 taken 1214 times.
|
4181 | for (size_t i = 0; i < ctx->IDENTIFIER().size(); i++) { |
| 767 |
2/2✓ Branch 5 → 6 taken 1753 times.
✓ Branch 5 → 7 taken 1214 times.
|
2967 | if (i > 0) |
| 768 |
1/2✓ Branch 6 → 7 taken 1753 times.
✗ Branch 6 → 81 not taken.
|
1753 | key << MEMBER_ACCESS_TOKEN; |
| 769 |
3/6✓ Branch 7 → 8 taken 2967 times.
✗ Branch 7 → 65 not taken.
✓ Branch 8 → 9 taken 2967 times.
✗ Branch 8 → 65 not taken.
✓ Branch 9 → 10 taken 2967 times.
✗ Branch 9 → 63 not taken.
|
2967 | key << ctx->IDENTIFIER(i)->getText(); |
| 770 | } | ||
| 771 |
1/2✓ Branch 16 → 17 taken 1214 times.
✗ Branch 16 → 67 not taken.
|
1214 | attrNode->key = key.str(); |
| 772 | |||
| 773 | // Visit children | ||
| 774 |
3/4✓ Branch 19 → 20 taken 1214 times.
✗ Branch 19 → 81 not taken.
✓ Branch 20 → 21 taken 844 times.
✓ Branch 20 → 51 taken 370 times.
|
1214 | if (ctx->constant()) { |
| 775 |
3/6✓ Branch 21 → 22 taken 844 times.
✗ Branch 21 → 70 not taken.
✓ Branch 22 → 23 taken 844 times.
✗ Branch 22 → 70 not taken.
✓ Branch 23 → 24 taken 844 times.
✗ Branch 23 → 68 not taken.
|
844 | attrNode->value = std::any_cast<ConstantNode *>(visit(ctx->constant())); |
| 776 | |||
| 777 |
4/6✓ Branch 25 → 26 taken 844 times.
✗ Branch 25 → 81 not taken.
✓ Branch 26 → 27 taken 844 times.
✗ Branch 26 → 81 not taken.
✓ Branch 27 → 28 taken 301 times.
✓ Branch 27 → 29 taken 543 times.
|
844 | if (ctx->constant()->STRING_LIT()) |
| 778 | 301 | attrNode->type = AttrNode::AttrType::TYPE_STRING; | |
| 779 |
4/6✓ Branch 29 → 30 taken 543 times.
✗ Branch 29 → 81 not taken.
✓ Branch 30 → 31 taken 543 times.
✗ Branch 30 → 81 not taken.
✓ Branch 31 → 32 taken 80 times.
✓ Branch 31 → 33 taken 463 times.
|
543 | else if (ctx->constant()->INT_LIT()) |
| 780 | 80 | attrNode->type = AttrNode::AttrType::TYPE_INT; | |
| 781 |
10/14✓ Branch 33 → 34 taken 463 times.
✗ Branch 33 → 81 not taken.
✓ Branch 34 → 35 taken 463 times.
✗ Branch 34 → 81 not taken.
✓ Branch 35 → 36 taken 5 times.
✓ Branch 35 → 39 taken 458 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 462 times.
✓ Branch 41 → 43 taken 1 time.
|
463 | else if (ctx->constant()->TRUE() || ctx->constant()->FALSE()) |
| 782 | 462 | 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 | 370 | attrNode->type = AttrNode::AttrType::TYPE_BOOL; | |
| 788 | } | ||
| 789 | |||
| 790 |
1/2✓ Branch 58 → 59 taken 1213 times.
✗ Branch 58 → 80 not taken.
|
2426 | return concludeNode(attrNode); |
| 791 | 1214 | } | |
| 792 | |||
| 793 | 70 | std::any ASTBuilder::visitCaseConstant(SpiceParser::CaseConstantContext *ctx) { | |
| 794 | 70 | const auto caseConstantNode = createNode<CaseConstantNode>(ctx); | |
| 795 | |||
| 796 | // Visit children | ||
| 797 |
2/2✓ Branch 4 → 5 taken 18 times.
✓ Branch 4 → 10 taken 52 times.
|
70 | if (ctx->constant()) { |
| 798 |
3/6✓ Branch 5 → 6 taken 18 times.
✗ Branch 5 → 57 not taken.
✓ Branch 6 → 7 taken 18 times.
✗ Branch 6 → 57 not taken.
✓ Branch 7 → 8 taken 18 times.
✗ Branch 7 → 55 not taken.
|
18 | caseConstantNode->constant = std::any_cast<ConstantNode *>(visit(ctx->constant())); |
| 799 |
2/4✓ Branch 10 → 11 taken 52 times.
✗ Branch 10 → 58 not taken.
✓ Branch 13 → 14 taken 52 times.
✗ Branch 13 → 44 not taken.
|
52 | } else if (!ctx->TYPE_IDENTIFIER().empty()) { |
| 800 |
1/2✓ Branch 14 → 15 taken 52 times.
✗ Branch 14 → 67 not taken.
|
52 | std::stringstream fqIdentifier; |
| 801 |
2/2✓ Branch 38 → 17 taken 126 times.
✓ Branch 38 → 39 taken 52 times.
|
178 | for (antlr4::tree::ParseTree *parseTree : ctx->children) { |
| 802 |
1/2✓ Branch 18 → 19 taken 126 times.
✗ Branch 18 → 20 not taken.
|
126 | const auto terminal = dynamic_cast<TerminalNode *>(parseTree); |
| 803 |
1/2✗ Branch 21 → 22 not taken.
✓ Branch 21 → 23 taken 126 times.
|
126 | if (!terminal) |
| 804 | ✗ | continue; | |
| 805 | |||
| 806 |
2/4✓ Branch 23 → 24 taken 126 times.
✗ Branch 23 → 63 not taken.
✓ Branch 24 → 25 taken 126 times.
✗ Branch 24 → 63 not taken.
|
126 | const size_t terminalType = terminal->getSymbol()->getType(); |
| 807 |
3/4✓ Branch 25 → 26 taken 126 times.
✗ Branch 25 → 27 not taken.
✓ Branch 26 → 27 taken 89 times.
✓ Branch 26 → 36 taken 37 times.
|
126 | if (terminalType == SpiceParser::IDENTIFIER || terminalType == SpiceParser::TYPE_IDENTIFIER) { |
| 808 |
1/2✓ Branch 27 → 28 taken 89 times.
✗ Branch 27 → 62 not taken.
|
89 | const std::string fragment = getIdentifier(terminal, false); |
| 809 |
1/2✓ Branch 28 → 29 taken 89 times.
✗ Branch 28 → 60 not taken.
|
89 | caseConstantNode->identifierFragments.push_back(fragment); |
| 810 |
3/4✓ Branch 29 → 30 taken 89 times.
✗ Branch 29 → 59 not taken.
✓ Branch 31 → 32 taken 37 times.
✓ Branch 31 → 33 taken 52 times.
|
89 | if (fqIdentifier.tellp() != 0) |
| 811 |
1/2✓ Branch 32 → 33 taken 37 times.
✗ Branch 32 → 60 not taken.
|
37 | fqIdentifier << SCOPE_ACCESS_TOKEN; |
| 812 |
1/2✓ Branch 33 → 34 taken 89 times.
✗ Branch 33 → 60 not taken.
|
89 | fqIdentifier << fragment; |
| 813 | 89 | } | |
| 814 | } | ||
| 815 |
1/2✓ Branch 39 → 40 taken 52 times.
✗ Branch 39 → 64 not taken.
|
52 | caseConstantNode->fqIdentifier = fqIdentifier.str(); |
| 816 | 52 | } else { | |
| 817 | − | assert_fail("Unknown case constant type"); // GCOV_EXCL_LINE | |
| 818 | } | ||
| 819 | |||
| 820 |
1/2✓ Branch 51 → 52 taken 70 times.
✗ Branch 51 → 68 not taken.
|
70 | return concludeNode(caseConstantNode); |
| 821 | } | ||
| 822 | |||
| 823 | 10608 | std::any ASTBuilder::visitReturnStmt(SpiceParser::ReturnStmtContext *ctx) { | |
| 824 | 10608 | const auto returnStmtNode = createNode<ReturnStmtNode>(ctx); | |
| 825 | |||
| 826 | // Visit children | ||
| 827 |
2/2✓ Branch 4 → 5 taken 10331 times.
✓ Branch 4 → 10 taken 277 times.
|
10608 | if (ctx->assignExpr()) { |
| 828 | 10331 | returnStmtNode->hasReturnValue = true; | |
| 829 |
3/6✓ Branch 5 → 6 taken 10331 times.
✗ Branch 5 → 22 not taken.
✓ Branch 6 → 7 taken 10331 times.
✗ Branch 6 → 22 not taken.
✓ Branch 7 → 8 taken 10331 times.
✗ Branch 7 → 20 not taken.
|
10331 | returnStmtNode->assignExpr = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 830 | } | ||
| 831 | |||
| 832 |
1/2✓ Branch 16 → 17 taken 10608 times.
✗ Branch 16 → 23 not taken.
|
10608 | return concludeNode(returnStmtNode); |
| 833 | } | ||
| 834 | |||
| 835 | 133 | std::any ASTBuilder::visitBreakStmt(SpiceParser::BreakStmtContext *ctx) { | |
| 836 | 133 | const auto breakStmtNode = createNode<BreakStmtNode>(ctx); | |
| 837 | |||
| 838 | // Extract number of breaks | ||
| 839 |
2/2✓ Branch 4 → 5 taken 6 times.
✓ Branch 4 → 10 taken 127 times.
|
133 | if (ctx->INT_LIT()) |
| 840 |
3/6✓ Branch 5 → 6 taken 6 times.
✗ Branch 5 → 24 not taken.
✓ Branch 6 → 7 taken 6 times.
✗ Branch 6 → 24 not taken.
✓ Branch 7 → 8 taken 6 times.
✗ Branch 7 → 22 not taken.
|
6 | breakStmtNode->breakTimes = std::stoi(ctx->INT_LIT()->toString()); |
| 841 | |||
| 842 | // Visit children | ||
| 843 |
1/2✓ Branch 10 → 11 taken 133 times.
✗ Branch 10 → 25 not taken.
|
133 | visitChildren(ctx); |
| 844 | |||
| 845 |
1/2✓ Branch 18 → 19 taken 133 times.
✗ Branch 18 → 26 not taken.
|
133 | return concludeNode(breakStmtNode); |
| 846 | } | ||
| 847 | |||
| 848 | 223 | std::any ASTBuilder::visitContinueStmt(SpiceParser::ContinueStmtContext *ctx) { | |
| 849 | 223 | const auto continueStmtNode = createNode<ContinueStmtNode>(ctx); | |
| 850 | |||
| 851 | // Extract number of continues | ||
| 852 |
2/2✓ Branch 4 → 5 taken 220 times.
✓ Branch 4 → 10 taken 3 times.
|
223 | if (ctx->INT_LIT()) |
| 853 |
3/6✓ Branch 5 → 6 taken 220 times.
✗ Branch 5 → 24 not taken.
✓ Branch 6 → 7 taken 220 times.
✗ Branch 6 → 24 not taken.
✓ Branch 7 → 8 taken 220 times.
✗ Branch 7 → 22 not taken.
|
220 | continueStmtNode->continueTimes = std::stoi(ctx->INT_LIT()->toString()); |
| 854 | |||
| 855 | // Visit children | ||
| 856 |
1/2✓ Branch 10 → 11 taken 223 times.
✗ Branch 10 → 25 not taken.
|
223 | visitChildren(ctx); |
| 857 | |||
| 858 |
1/2✓ Branch 18 → 19 taken 223 times.
✗ Branch 18 → 26 not taken.
|
223 | 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 |
1/2✓ Branch 3 → 4 taken 6 times.
✗ Branch 3 → 15 not taken.
|
6 | visitChildren(ctx); |
| 866 | |||
| 867 |
1/2✓ Branch 11 → 12 taken 6 times.
✗ Branch 11 → 16 not taken.
|
6 | return concludeNode(fallthroughStmtNode); |
| 868 | } | ||
| 869 | |||
| 870 | 843 | std::any ASTBuilder::visitAssertStmt(SpiceParser::AssertStmtContext *ctx) { | |
| 871 |
1/2✓ Branch 2 → 3 taken 843 times.
✗ Branch 2 → 30 not taken.
|
843 | const auto assertStmtNode = createNode<AssertStmtNode>(ctx); |
| 872 | |||
| 873 | // Enrich | ||
| 874 |
5/10✓ Branch 3 → 4 taken 843 times.
✗ Branch 3 → 30 not taken.
✓ Branch 4 → 5 taken 843 times.
✗ Branch 4 → 30 not taken.
✓ Branch 5 → 6 taken 843 times.
✗ Branch 5 → 30 not taken.
✓ Branch 6 → 7 taken 843 times.
✗ Branch 6 → 30 not taken.
✓ Branch 7 → 8 taken 843 times.
✗ Branch 7 → 30 not taken.
|
843 | const antlr4::misc::Interval interval(ctx->assignExpr()->start->getStartIndex(), ctx->assignExpr()->stop->getStopIndex()); |
| 875 |
1/2✓ Branch 8 → 9 taken 843 times.
✗ Branch 8 → 25 not taken.
|
843 | assertStmtNode->expressionString = inputStream->getText(interval); |
| 876 | |||
| 877 | // Visit children | ||
| 878 |
3/6✓ Branch 11 → 12 taken 843 times.
✗ Branch 11 → 28 not taken.
✓ Branch 12 → 13 taken 843 times.
✗ Branch 12 → 28 not taken.
✓ Branch 13 → 14 taken 843 times.
✗ Branch 13 → 26 not taken.
|
843 | assertStmtNode->assignExpr = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 879 | |||
| 880 |
1/2✓ Branch 21 → 22 taken 843 times.
✗ Branch 21 → 29 not taken.
|
843 | return concludeNode(assertStmtNode); |
| 881 | } | ||
| 882 | |||
| 883 | 89964 | std::any ASTBuilder::visitAssignExpr(SpiceParser::AssignExprContext *ctx) { | |
| 884 |
2/2✓ Branch 3 → 4 taken 81009 times.
✓ Branch 3 → 6 taken 8955 times.
|
89964 | if (!ctx->assignOp()) |
| 885 | 81009 | return visit(ctx->ternaryExpr()); | |
| 886 | |||
| 887 | 8955 | const auto assignExprNode = createNode<AssignExprNode>(ctx); | |
| 888 | |||
| 889 | // Visit children | ||
| 890 |
1/2✗ Branch 8 → 9 not taken.
✓ Branch 8 → 14 taken 8955 times.
|
8955 | if (ctx->ternaryExpr()) { |
| 891 | ✗ | assignExprNode->ternaryExpr = std::any_cast<ExprNode *>(visit(ctx->ternaryExpr())); | |
| 892 |
1/2✓ Branch 15 → 16 taken 8955 times.
✗ Branch 15 → 28 not taken.
|
8955 | } else if (ctx->prefixUnaryExpr()) { |
| 893 |
3/6✓ Branch 16 → 17 taken 8955 times.
✗ Branch 16 → 44 not taken.
✓ Branch 17 → 18 taken 8955 times.
✗ Branch 17 → 44 not taken.
✓ Branch 18 → 19 taken 8955 times.
✗ Branch 18 → 42 not taken.
|
8955 | assignExprNode->lhs = std::any_cast<ExprNode *>(visit(ctx->prefixUnaryExpr())); |
| 894 |
2/4✓ Branch 20 → 21 taken 8955 times.
✗ Branch 20 → 45 not taken.
✓ Branch 21 → 22 taken 8955 times.
✗ Branch 21 → 45 not taken.
|
8955 | visit(ctx->assignOp()); |
| 895 |
3/6✓ Branch 23 → 24 taken 8955 times.
✗ Branch 23 → 48 not taken.
✓ Branch 24 → 25 taken 8955 times.
✗ Branch 24 → 48 not taken.
✓ Branch 25 → 26 taken 8955 times.
✗ Branch 25 → 46 not taken.
|
8955 | 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 8955 times.
✗ Branch 35 → 49 not taken.
|
8955 | return concludeExprNode(assignExprNode); |
| 901 | } | ||
| 902 | |||
| 903 | 81249 | std::any ASTBuilder::visitTernaryExpr(SpiceParser::TernaryExprContext *ctx) { | |
| 904 |
3/4✓ Branch 2 → 3 taken 81249 times.
✗ Branch 2 → 45 not taken.
✓ Branch 5 → 6 taken 80722 times.
✓ Branch 5 → 8 taken 527 times.
|
81249 | if (ctx->logicalOrExpr().size() == 1) |
| 905 | 80722 | return visit(ctx->logicalOrExpr(0)); | |
| 906 | |||
| 907 | 527 | const auto ternaryExprNode = createNode<TernaryExprNode>(ctx); | |
| 908 | |||
| 909 |
3/6✓ Branch 9 → 10 taken 527 times.
✗ Branch 9 → 48 not taken.
✓ Branch 10 → 11 taken 527 times.
✗ Branch 10 → 48 not taken.
✓ Branch 11 → 12 taken 527 times.
✗ Branch 11 → 46 not taken.
|
527 | ternaryExprNode->condition = std::any_cast<ExprNode *>(visit(ctx->logicalOrExpr(0))); |
| 910 |
3/4✓ Branch 13 → 14 taken 527 times.
✗ Branch 13 → 49 not taken.
✓ Branch 16 → 17 taken 526 times.
✓ Branch 16 → 26 taken 1 time.
|
527 | if (ctx->logicalOrExpr().size() == 3) { |
| 911 |
3/6✓ Branch 17 → 18 taken 526 times.
✗ Branch 17 → 52 not taken.
✓ Branch 18 → 19 taken 526 times.
✗ Branch 18 → 52 not taken.
✓ Branch 19 → 20 taken 526 times.
✗ Branch 19 → 50 not taken.
|
526 | ternaryExprNode->trueExpr = std::any_cast<ExprNode *>(visit(ctx->logicalOrExpr(1))); |
| 912 |
3/6✓ Branch 21 → 22 taken 526 times.
✗ Branch 21 → 55 not taken.
✓ Branch 22 → 23 taken 526 times.
✗ Branch 22 → 55 not taken.
✓ Branch 23 → 24 taken 526 times.
✗ Branch 23 → 53 not taken.
|
526 | 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 527 times.
✗ Branch 41 → 60 not taken.
|
527 | return concludeExprNode(ternaryExprNode); |
| 919 | } | ||
| 920 | |||
| 921 | 82302 | std::any ASTBuilder::visitLogicalOrExpr(SpiceParser::LogicalOrExprContext *ctx) { | |
| 922 |
3/4✓ Branch 2 → 3 taken 82302 times.
✗ Branch 2 → 22 not taken.
✓ Branch 5 → 6 taken 81220 times.
✓ Branch 5 → 8 taken 1082 times.
|
82302 | if (ctx->logicalAndExpr().size() == 1) |
| 923 | 81220 | return visit(ctx->logicalAndExpr(0)); | |
| 924 | |||
| 925 | 1082 | const auto logicalOrExprNode = createNode<LogicalOrExprNode>(ctx); | |
| 926 | |||
| 927 | // Visit children | ||
| 928 |
2/4✓ Branch 9 → 10 taken 1082 times.
✗ Branch 9 → 25 not taken.
✓ Branch 10 → 11 taken 1082 times.
✗ Branch 10 → 23 not taken.
|
1082 | fetchChildrenIntoVector(logicalOrExprNode->operands, ctx->logicalAndExpr()); |
| 929 | |||
| 930 |
1/2✓ Branch 18 → 19 taken 1082 times.
✗ Branch 18 → 26 not taken.
|
1082 | return concludeExprNode(logicalOrExprNode); |
| 931 | } | ||
| 932 | |||
| 933 | 83703 | std::any ASTBuilder::visitLogicalAndExpr(SpiceParser::LogicalAndExprContext *ctx) { | |
| 934 |
3/4✓ Branch 2 → 3 taken 83703 times.
✗ Branch 2 → 22 not taken.
✓ Branch 5 → 6 taken 83425 times.
✓ Branch 5 → 8 taken 278 times.
|
83703 | if (ctx->bitwiseOrExpr().size() == 1) |
| 935 | 83425 | return visit(ctx->bitwiseOrExpr(0)); | |
| 936 | |||
| 937 | 278 | const auto logicalAndExprNode = createNode<LogicalAndExprNode>(ctx); | |
| 938 | |||
| 939 | // Visit children | ||
| 940 |
2/4✓ Branch 9 → 10 taken 278 times.
✗ Branch 9 → 25 not taken.
✓ Branch 10 → 11 taken 278 times.
✗ Branch 10 → 23 not taken.
|
278 | fetchChildrenIntoVector(logicalAndExprNode->operands, ctx->bitwiseOrExpr()); |
| 941 | |||
| 942 |
1/2✓ Branch 18 → 19 taken 278 times.
✗ Branch 18 → 26 not taken.
|
278 | return concludeExprNode(logicalAndExprNode); |
| 943 | } | ||
| 944 | |||
| 945 | 84015 | std::any ASTBuilder::visitBitwiseOrExpr(SpiceParser::BitwiseOrExprContext *ctx) { | |
| 946 |
3/4✓ Branch 2 → 3 taken 84015 times.
✗ Branch 2 → 22 not taken.
✓ Branch 5 → 6 taken 83915 times.
✓ Branch 5 → 8 taken 100 times.
|
84015 | if (ctx->bitwiseXorExpr().size() == 1) |
| 947 | 83915 | return visit(ctx->bitwiseXorExpr(0)); | |
| 948 | |||
| 949 | 100 | const auto bitwiseOrExprNode = createNode<BitwiseOrExprNode>(ctx); | |
| 950 | |||
| 951 | // Visit children | ||
| 952 |
2/4✓ Branch 9 → 10 taken 100 times.
✗ Branch 9 → 25 not taken.
✓ Branch 10 → 11 taken 100 times.
✗ Branch 10 → 23 not taken.
|
100 | fetchChildrenIntoVector(bitwiseOrExprNode->operands, ctx->bitwiseXorExpr()); |
| 953 | |||
| 954 |
1/2✓ Branch 18 → 19 taken 100 times.
✗ Branch 18 → 26 not taken.
|
100 | return concludeExprNode(bitwiseOrExprNode); |
| 955 | } | ||
| 956 | |||
| 957 | 84116 | std::any ASTBuilder::visitBitwiseXorExpr(SpiceParser::BitwiseXorExprContext *ctx) { | |
| 958 |
3/4✓ Branch 2 → 3 taken 84116 times.
✗ Branch 2 → 22 not taken.
✓ Branch 5 → 6 taken 84104 times.
✓ Branch 5 → 8 taken 12 times.
|
84116 | if (ctx->bitwiseAndExpr().size() == 1) |
| 959 | 84104 | return visit(ctx->bitwiseAndExpr(0)); | |
| 960 | |||
| 961 | 12 | const auto bitwiseXorExprNode = createNode<BitwiseXorExprNode>(ctx); | |
| 962 | |||
| 963 | // Visit children | ||
| 964 |
2/4✓ Branch 9 → 10 taken 12 times.
✗ Branch 9 → 25 not taken.
✓ Branch 10 → 11 taken 12 times.
✗ Branch 10 → 23 not taken.
|
12 | fetchChildrenIntoVector(bitwiseXorExprNode->operands, ctx->bitwiseAndExpr()); |
| 965 | |||
| 966 |
1/2✓ Branch 18 → 19 taken 12 times.
✗ Branch 18 → 26 not taken.
|
12 | return concludeExprNode(bitwiseXorExprNode); |
| 967 | } | ||
| 968 | |||
| 969 | 84129 | std::any ASTBuilder::visitBitwiseAndExpr(SpiceParser::BitwiseAndExprContext *ctx) { | |
| 970 |
3/4✓ Branch 2 → 3 taken 84129 times.
✗ Branch 2 → 22 not taken.
✓ Branch 5 → 6 taken 84095 times.
✓ Branch 5 → 8 taken 34 times.
|
84129 | if (ctx->equalityExpr().size() == 1) |
| 971 | 84095 | return visit(ctx->equalityExpr(0)); | |
| 972 | |||
| 973 | 34 | const auto bitwiseAndExprNode = createNode<BitwiseAndExprNode>(ctx); | |
| 974 | |||
| 975 | // Visit children | ||
| 976 |
2/4✓ Branch 9 → 10 taken 34 times.
✗ Branch 9 → 25 not taken.
✓ Branch 10 → 11 taken 34 times.
✗ Branch 10 → 23 not taken.
|
34 | fetchChildrenIntoVector(bitwiseAndExprNode->operands, ctx->equalityExpr()); |
| 977 | |||
| 978 |
1/2✓ Branch 18 → 19 taken 34 times.
✗ Branch 18 → 26 not taken.
|
34 | return concludeExprNode(bitwiseAndExprNode); |
| 979 | } | ||
| 980 | |||
| 981 | 84164 | std::any ASTBuilder::visitEqualityExpr(SpiceParser::EqualityExprContext *ctx) { | |
| 982 |
3/4✓ Branch 2 → 3 taken 84164 times.
✗ Branch 2 → 28 not taken.
✓ Branch 5 → 6 taken 78353 times.
✓ Branch 5 → 8 taken 5811 times.
|
84164 | if (ctx->relationalExpr().size() == 1) |
| 983 | 78353 | return visit(ctx->relationalExpr(0)); | |
| 984 | |||
| 985 | 5811 | const auto equalityExprNode = createNode<EqualityExprNode>(ctx); | |
| 986 | |||
| 987 | // Visit children | ||
| 988 |
2/4✓ Branch 9 → 10 taken 5811 times.
✗ Branch 9 → 31 not taken.
✓ Branch 10 → 11 taken 5811 times.
✗ Branch 10 → 29 not taken.
|
5811 | fetchChildrenIntoVector(equalityExprNode->operands, ctx->relationalExpr()); |
| 989 | |||
| 990 | // Extract operator | ||
| 991 |
2/2✓ Branch 13 → 14 taken 4289 times.
✓ Branch 13 → 15 taken 1522 times.
|
5811 | if (ctx->EQUAL()) |
| 992 | 4289 | equalityExprNode->op = EqualityExprNode::EqualityOp::OP_EQUAL; | |
| 993 |
1/2✓ Branch 16 → 17 taken 1522 times.
✗ Branch 16 → 18 not taken.
|
1522 | else if (ctx->NOT_EQUAL()) |
| 994 | 1522 | equalityExprNode->op = EqualityExprNode::EqualityOp::OP_NOT_EQUAL; | |
| 995 | |||
| 996 |
1/2✓ Branch 24 → 25 taken 5811 times.
✗ Branch 24 → 32 not taken.
|
5811 | return concludeExprNode(equalityExprNode); |
| 997 | } | ||
| 998 | |||
| 999 | 89975 | std::any ASTBuilder::visitRelationalExpr(SpiceParser::RelationalExprContext *ctx) { | |
| 1000 |
3/4✓ Branch 2 → 3 taken 89975 times.
✗ Branch 2 → 34 not taken.
✓ Branch 5 → 6 taken 85595 times.
✓ Branch 5 → 8 taken 4380 times.
|
89975 | if (ctx->shiftExpr().size() == 1) |
| 1001 | 85595 | return visit(ctx->shiftExpr(0)); | |
| 1002 | |||
| 1003 | 4380 | const auto relationalExprNode = createNode<RelationalExprNode>(ctx); | |
| 1004 | |||
| 1005 | // Visit children | ||
| 1006 |
2/4✓ Branch 9 → 10 taken 4380 times.
✗ Branch 9 → 37 not taken.
✓ Branch 10 → 11 taken 4380 times.
✗ Branch 10 → 35 not taken.
|
4380 | fetchChildrenIntoVector(relationalExprNode->operands, ctx->shiftExpr()); |
| 1007 | |||
| 1008 | // Extract operator | ||
| 1009 |
2/2✓ Branch 13 → 14 taken 2290 times.
✓ Branch 13 → 15 taken 2090 times.
|
4380 | if (ctx->LESS()) |
| 1010 | 2290 | relationalExprNode->op = RelationalExprNode::RelationalOp::OP_LESS; | |
| 1011 |
2/2✓ Branch 16 → 17 taken 794 times.
✓ Branch 16 → 18 taken 1296 times.
|
2090 | else if (ctx->GREATER()) |
| 1012 | 794 | relationalExprNode->op = RelationalExprNode::RelationalOp::OP_GREATER; | |
| 1013 |
2/2✓ Branch 19 → 20 taken 381 times.
✓ Branch 19 → 21 taken 915 times.
|
1296 | else if (ctx->LESS_EQUAL()) |
| 1014 | 381 | relationalExprNode->op = RelationalExprNode::RelationalOp::OP_LESS_EQUAL; | |
| 1015 |
1/2✓ Branch 22 → 23 taken 915 times.
✗ Branch 22 → 24 not taken.
|
915 | else if (ctx->GREATER_EQUAL()) |
| 1016 | 915 | relationalExprNode->op = RelationalExprNode::RelationalOp::OP_GREATER_EQUAL; | |
| 1017 | |||
| 1018 |
1/2✓ Branch 30 → 31 taken 4380 times.
✗ Branch 30 → 38 not taken.
|
4380 | return concludeExprNode(relationalExprNode); |
| 1019 | } | ||
| 1020 | |||
| 1021 | 94355 | std::any ASTBuilder::visitShiftExpr(SpiceParser::ShiftExprContext *ctx) { | |
| 1022 |
3/4✓ Branch 2 → 3 taken 94355 times.
✗ Branch 2 → 52 not taken.
✓ Branch 5 → 6 taken 94242 times.
✓ Branch 5 → 8 taken 113 times.
|
94355 | if (ctx->additiveExpr().size() == 1) |
| 1023 | 94242 | return visit(ctx->additiveExpr(0)); | |
| 1024 | |||
| 1025 | 113 | const auto shiftExprNode = createNode<ShiftExprNode>(ctx); | |
| 1026 | |||
| 1027 | // Visit children | ||
| 1028 |
2/4✓ Branch 9 → 10 taken 113 times.
✗ Branch 9 → 55 not taken.
✓ Branch 10 → 11 taken 113 times.
✗ Branch 10 → 53 not taken.
|
113 | fetchChildrenIntoVector(shiftExprNode->operands, ctx->additiveExpr()); |
| 1029 | |||
| 1030 | 113 | bool seenFirstLess = false; | |
| 1031 | 113 | bool seenFirstGreater = false; | |
| 1032 |
2/2✓ Branch 37 → 14 taken 575 times.
✓ Branch 37 → 38 taken 113 times.
|
688 | for (ParserRuleContext::ParseTree *subTree : ctx->children) { |
| 1033 |
1/2✓ Branch 15 → 16 taken 575 times.
✗ Branch 15 → 17 not taken.
|
575 | const auto terminal = dynamic_cast<TerminalNode *>(subTree); |
| 1034 |
2/2✓ Branch 18 → 19 taken 267 times.
✓ Branch 18 → 20 taken 308 times.
|
575 | if (!terminal) |
| 1035 | 267 | continue; | |
| 1036 | |||
| 1037 |
4/6✓ Branch 20 → 21 taken 308 times.
✗ Branch 20 → 60 not taken.
✓ Branch 21 → 22 taken 308 times.
✗ Branch 21 → 60 not taken.
✓ Branch 22 → 23 taken 184 times.
✓ Branch 22 → 27 taken 124 times.
|
308 | if (terminal->getSymbol()->getType() == SpiceParser::LESS) { |
| 1038 |
2/2✓ Branch 23 → 24 taken 92 times.
✓ Branch 23 → 26 taken 92 times.
|
184 | if (seenFirstLess) |
| 1039 |
1/2✓ Branch 24 → 25 taken 92 times.
✗ Branch 24 → 56 not taken.
|
92 | shiftExprNode->opQueue.emplace(ShiftExprNode::ShiftOp::OP_SHIFT_LEFT, TY_INVALID); |
| 1040 | 184 | seenFirstLess = !seenFirstLess; | |
| 1041 | 184 | continue; | |
| 1042 | } | ||
| 1043 | |||
| 1044 |
3/6✓ Branch 27 → 28 taken 124 times.
✗ Branch 27 → 60 not taken.
✓ Branch 28 → 29 taken 124 times.
✗ Branch 28 → 60 not taken.
✓ Branch 29 → 30 taken 124 times.
✗ Branch 29 → 34 not taken.
|
124 | if (terminal->getSymbol()->getType() == SpiceParser::GREATER) { |
| 1045 |
2/2✓ Branch 30 → 31 taken 62 times.
✓ Branch 30 → 33 taken 62 times.
|
124 | if (seenFirstGreater) |
| 1046 |
1/2✓ Branch 31 → 32 taken 62 times.
✗ Branch 31 → 58 not taken.
|
62 | shiftExprNode->opQueue.emplace(ShiftExprNode::ShiftOp::OP_SHIFT_RIGHT, TY_INVALID); |
| 1047 | 124 | seenFirstGreater = !seenFirstGreater; | |
| 1048 | 124 | continue; | |
| 1049 | } | ||
| 1050 | |||
| 1051 | − | assert_fail("Invalid terminal symbol for additive expression"); // GCOV_EXCL_LINE | |
| 1052 | } | ||
| 1053 |
2/4✓ Branch 38 → 39 taken 113 times.
✗ Branch 38 → 41 not taken.
✓ Branch 39 → 40 taken 113 times.
✗ Branch 39 → 41 not taken.
|
113 | assert(!seenFirstLess && !seenFirstGreater); |
| 1054 | |||
| 1055 |
1/2✓ Branch 48 → 49 taken 113 times.
✗ Branch 48 → 61 not taken.
|
113 | return concludeExprNode(shiftExprNode); |
| 1056 | } | ||
| 1057 | |||
| 1058 | 94509 | std::any ASTBuilder::visitAdditiveExpr(SpiceParser::AdditiveExprContext *ctx) { | |
| 1059 |
3/4✓ Branch 2 → 3 taken 94509 times.
✗ Branch 2 → 44 not taken.
✓ Branch 5 → 6 taken 90150 times.
✓ Branch 5 → 8 taken 4359 times.
|
94509 | if (ctx->multiplicativeExpr().size() == 1) |
| 1060 | 90150 | return visit(ctx->multiplicativeExpr(0)); | |
| 1061 | |||
| 1062 | 4359 | const auto additiveExprNode = createNode<AdditiveExprNode>(ctx); | |
| 1063 | |||
| 1064 | // Visit children | ||
| 1065 |
2/4✓ Branch 9 → 10 taken 4359 times.
✗ Branch 9 → 47 not taken.
✓ Branch 10 → 11 taken 4359 times.
✗ Branch 10 → 45 not taken.
|
4359 | fetchChildrenIntoVector(additiveExprNode->operands, ctx->multiplicativeExpr()); |
| 1066 | |||
| 1067 |
2/2✓ Branch 33 → 14 taken 14013 times.
✓ Branch 33 → 34 taken 4359 times.
|
18372 | for (ParserRuleContext::ParseTree *subTree : ctx->children) { |
| 1068 |
1/2✓ Branch 15 → 16 taken 14013 times.
✗ Branch 15 → 17 not taken.
|
14013 | const auto terminal = dynamic_cast<TerminalNode *>(subTree); |
| 1069 |
2/2✓ Branch 18 → 19 taken 9186 times.
✓ Branch 18 → 20 taken 4827 times.
|
14013 | if (!terminal) |
| 1070 | 9186 | continue; | |
| 1071 | |||
| 1072 |
4/6✓ Branch 20 → 21 taken 4827 times.
✗ Branch 20 → 52 not taken.
✓ Branch 21 → 22 taken 4827 times.
✗ Branch 21 → 52 not taken.
✓ Branch 22 → 23 taken 2986 times.
✓ Branch 22 → 25 taken 1841 times.
|
4827 | if (terminal->getSymbol()->getType() == SpiceParser::PLUS) |
| 1073 |
1/2✓ Branch 23 → 24 taken 2986 times.
✗ Branch 23 → 48 not taken.
|
2986 | additiveExprNode->opQueue.emplace(AdditiveExprNode::AdditiveOp::OP_PLUS, TY_INVALID); |
| 1074 |
3/6✓ Branch 25 → 26 taken 1841 times.
✗ Branch 25 → 52 not taken.
✓ Branch 26 → 27 taken 1841 times.
✗ Branch 26 → 52 not taken.
✓ Branch 27 → 28 taken 1841 times.
✗ Branch 27 → 30 not taken.
|
1841 | else if (terminal->getSymbol()->getType() == SpiceParser::MINUS) |
| 1075 |
1/2✓ Branch 28 → 29 taken 1841 times.
✗ Branch 28 → 50 not taken.
|
1841 | 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 40 → 41 taken 4359 times.
✗ Branch 40 → 53 not taken.
|
4359 | return concludeExprNode(additiveExprNode); |
| 1081 | } | ||
| 1082 | |||
| 1083 | 99336 | std::any ASTBuilder::visitMultiplicativeExpr(SpiceParser::MultiplicativeExprContext *ctx) { | |
| 1084 |
3/4✓ Branch 2 → 3 taken 99336 times.
✗ Branch 2 → 49 not taken.
✓ Branch 5 → 6 taken 97808 times.
✓ Branch 5 → 8 taken 1528 times.
|
99336 | if (ctx->castExpr().size() == 1) |
| 1085 | 97808 | return visit(ctx->castExpr(0)); | |
| 1086 | |||
| 1087 | 1528 | const auto multiplicativeExprNode = createNode<MultiplicativeExprNode>(ctx); | |
| 1088 | |||
| 1089 | // Visit children | ||
| 1090 |
2/4✓ Branch 9 → 10 taken 1528 times.
✗ Branch 9 → 52 not taken.
✓ Branch 10 → 11 taken 1528 times.
✗ Branch 10 → 50 not taken.
|
1528 | fetchChildrenIntoVector(multiplicativeExprNode->operands, ctx->castExpr()); |
| 1091 | |||
| 1092 |
2/2✓ Branch 38 → 14 taken 4624 times.
✓ Branch 38 → 39 taken 1528 times.
|
6152 | for (ParserRuleContext::ParseTree *subTree : ctx->children) { |
| 1093 |
1/2✓ Branch 15 → 16 taken 4624 times.
✗ Branch 15 → 17 not taken.
|
4624 | const auto terminal = dynamic_cast<TerminalNode *>(subTree); |
| 1094 |
2/2✓ Branch 18 → 19 taken 3076 times.
✓ Branch 18 → 20 taken 1548 times.
|
4624 | if (!terminal) |
| 1095 | 3076 | continue; | |
| 1096 | |||
| 1097 |
4/6✓ Branch 20 → 21 taken 1548 times.
✗ Branch 20 → 59 not taken.
✓ Branch 21 → 22 taken 1548 times.
✗ Branch 21 → 59 not taken.
✓ Branch 22 → 23 taken 1167 times.
✓ Branch 22 → 25 taken 381 times.
|
1548 | if (terminal->getSymbol()->getType() == SpiceParser::MUL) |
| 1098 |
1/2✓ Branch 23 → 24 taken 1167 times.
✗ Branch 23 → 53 not taken.
|
1167 | multiplicativeExprNode->opQueue.emplace(MultiplicativeExprNode::MultiplicativeOp::OP_MUL, TY_INVALID); |
| 1099 |
4/6✓ Branch 25 → 26 taken 381 times.
✗ Branch 25 → 59 not taken.
✓ Branch 26 → 27 taken 381 times.
✗ Branch 26 → 59 not taken.
✓ Branch 27 → 28 taken 156 times.
✓ Branch 27 → 30 taken 225 times.
|
381 | else if (terminal->getSymbol()->getType() == SpiceParser::DIV) |
| 1100 |
1/2✓ Branch 28 → 29 taken 156 times.
✗ Branch 28 → 55 not taken.
|
156 | multiplicativeExprNode->opQueue.emplace(MultiplicativeExprNode::MultiplicativeOp::OP_DIV, TY_INVALID); |
| 1101 |
3/6✓ Branch 30 → 31 taken 225 times.
✗ Branch 30 → 59 not taken.
✓ Branch 31 → 32 taken 225 times.
✗ Branch 31 → 59 not taken.
✓ Branch 32 → 33 taken 225 times.
✗ Branch 32 → 35 not taken.
|
225 | else if (terminal->getSymbol()->getType() == SpiceParser::REM) |
| 1102 |
1/2✓ Branch 33 → 34 taken 225 times.
✗ Branch 33 → 57 not taken.
|
225 | 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 45 → 46 taken 1528 times.
✗ Branch 45 → 60 not taken.
|
1528 | return concludeExprNode(multiplicativeExprNode); |
| 1108 | } | ||
| 1109 | |||
| 1110 | 100884 | std::any ASTBuilder::visitCastExpr(SpiceParser::CastExprContext *ctx) { | |
| 1111 |
2/2✓ Branch 3 → 4 taken 97898 times.
✓ Branch 3 → 6 taken 2986 times.
|
100884 | if (!ctx->CAST()) |
| 1112 | 97898 | return visit(ctx->prefixUnaryExpr()); | |
| 1113 | |||
| 1114 | 2986 | const auto castExprNode = createNode<CastExprNode>(ctx); | |
| 1115 | |||
| 1116 | // Visit children | ||
| 1117 |
1/2✓ Branch 8 → 9 taken 2986 times.
✗ Branch 8 → 18 not taken.
|
2986 | if (ctx->dataType()) { |
| 1118 |
3/6✓ Branch 9 → 10 taken 2986 times.
✗ Branch 9 → 35 not taken.
✓ Branch 10 → 11 taken 2986 times.
✗ Branch 10 → 35 not taken.
✓ Branch 11 → 12 taken 2986 times.
✗ Branch 11 → 33 not taken.
|
2986 | castExprNode->dataType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 1119 |
3/6✓ Branch 13 → 14 taken 2986 times.
✗ Branch 13 → 38 not taken.
✓ Branch 14 → 15 taken 2986 times.
✗ Branch 14 → 38 not taken.
✓ Branch 15 → 16 taken 2986 times.
✗ Branch 15 → 36 not taken.
|
2986 | castExprNode->assignExpr = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 1120 | 2986 | castExprNode->isCast = true; | |
| 1121 | } else { | ||
| 1122 | ✗ | castExprNode->prefixUnaryExpr = std::any_cast<ExprNode *>(visit(ctx->prefixUnaryExpr())); | |
| 1123 | } | ||
| 1124 | |||
| 1125 |
1/2✓ Branch 29 → 30 taken 2986 times.
✗ Branch 29 → 42 not taken.
|
2986 | return concludeExprNode(castExprNode); |
| 1126 | } | ||
| 1127 | |||
| 1128 | 108475 | std::any ASTBuilder::visitPrefixUnaryExpr(SpiceParser::PrefixUnaryExprContext *ctx) { | |
| 1129 |
2/2✓ Branch 3 → 4 taken 106853 times.
✓ Branch 3 → 6 taken 1622 times.
|
108475 | if (!ctx->prefixUnaryExpr()) |
| 1130 | 106853 | return visit(ctx->postfixUnaryExpr()); | |
| 1131 | |||
| 1132 | 1622 | const auto prefixUnaryExprNode = createNode<PrefixUnaryExprNode>(ctx); | |
| 1133 | |||
| 1134 | // Visit children | ||
| 1135 |
1/2✗ Branch 8 → 9 not taken.
✓ Branch 8 → 14 taken 1622 times.
|
1622 | if (ctx->postfixUnaryExpr()) { |
| 1136 | ✗ | prefixUnaryExprNode->postfixUnaryExpr = std::any_cast<ExprNode *>(visit(ctx->postfixUnaryExpr())); | |
| 1137 |
1/2✓ Branch 15 → 16 taken 1622 times.
✗ Branch 15 → 42 not taken.
|
1622 | } else if (ctx->prefixUnaryExpr()) { |
| 1138 | // Extract operator | ||
| 1139 |
2/2✓ Branch 17 → 18 taken 82 times.
✓ Branch 17 → 19 taken 1540 times.
|
1622 | if (ctx->MINUS()) |
| 1140 | 82 | prefixUnaryExprNode->op = PrefixUnaryExprNode::PrefixUnaryOp::OP_MINUS; | |
| 1141 |
2/2✓ Branch 20 → 21 taken 24 times.
✓ Branch 20 → 22 taken 1516 times.
|
1540 | else if (ctx->PLUS_PLUS()) |
| 1142 | 24 | prefixUnaryExprNode->op = PrefixUnaryExprNode::PrefixUnaryOp::OP_PLUS_PLUS; | |
| 1143 |
2/2✓ Branch 23 → 24 taken 11 times.
✓ Branch 23 → 25 taken 1505 times.
|
1516 | else if (ctx->MINUS_MINUS()) |
| 1144 | 11 | prefixUnaryExprNode->op = PrefixUnaryExprNode::PrefixUnaryOp::OP_MINUS_MINUS; | |
| 1145 |
2/2✓ Branch 26 → 27 taken 969 times.
✓ Branch 26 → 28 taken 536 times.
|
1505 | else if (ctx->NOT()) |
| 1146 | 969 | prefixUnaryExprNode->op = PrefixUnaryExprNode::PrefixUnaryOp::OP_NOT; | |
| 1147 |
2/2✓ Branch 29 → 30 taken 2 times.
✓ Branch 29 → 31 taken 534 times.
|
536 | else if (ctx->BITWISE_NOT()) |
| 1148 | 2 | prefixUnaryExprNode->op = PrefixUnaryExprNode::PrefixUnaryOp::OP_BITWISE_NOT; | |
| 1149 |
2/2✓ Branch 32 → 33 taken 292 times.
✓ Branch 32 → 34 taken 242 times.
|
534 | else if (ctx->MUL()) |
| 1150 | 292 | prefixUnaryExprNode->op = PrefixUnaryExprNode::PrefixUnaryOp::OP_DEREFERENCE; | |
| 1151 |
1/2✓ Branch 35 → 36 taken 242 times.
✗ Branch 35 → 37 not taken.
|
242 | else if (ctx->BITWISE_AND()) |
| 1152 | 242 | prefixUnaryExprNode->op = PrefixUnaryExprNode::PrefixUnaryOp::OP_ADDRESS_OF; | |
| 1153 | |||
| 1154 |
3/6✓ Branch 37 → 38 taken 1622 times.
✗ Branch 37 → 58 not taken.
✓ Branch 38 → 39 taken 1622 times.
✗ Branch 38 → 58 not taken.
✓ Branch 39 → 40 taken 1622 times.
✗ Branch 39 → 56 not taken.
|
1622 | 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 1622 times.
✗ Branch 49 → 59 not taken.
|
1622 | return concludeExprNode(prefixUnaryExprNode); |
| 1160 | } | ||
| 1161 | |||
| 1162 | 135843 | std::any ASTBuilder::visitPostfixUnaryExpr(SpiceParser::PostfixUnaryExprContext *ctx) { | |
| 1163 |
2/2✓ Branch 3 → 4 taken 106853 times.
✓ Branch 3 → 6 taken 28990 times.
|
135843 | if (!ctx->postfixUnaryExpr()) |
| 1164 | 106853 | return visit(ctx->atomicExpr()); | |
| 1165 | |||
| 1166 | 28990 | const auto postfixUnaryExprNode = createNode<PostfixUnaryExprNode>(ctx); | |
| 1167 | |||
| 1168 |
1/2✗ Branch 8 → 9 not taken.
✓ Branch 8 → 14 taken 28990 times.
|
28990 | if (ctx->atomicExpr()) { |
| 1169 | ✗ | postfixUnaryExprNode->atomicExpr = std::any_cast<ExprNode *>(visit(ctx->atomicExpr())); | |
| 1170 |
1/2✓ Branch 15 → 16 taken 28990 times.
✗ Branch 15 → 40 not taken.
|
28990 | } else if (ctx->postfixUnaryExpr()) { |
| 1171 |
3/6✓ Branch 16 → 17 taken 28990 times.
✗ Branch 16 → 56 not taken.
✓ Branch 17 → 18 taken 28990 times.
✗ Branch 17 → 56 not taken.
✓ Branch 18 → 19 taken 28990 times.
✗ Branch 18 → 54 not taken.
|
28990 | postfixUnaryExprNode->postfixUnaryExpr = std::any_cast<ExprNode *>(visit(ctx->postfixUnaryExpr())); |
| 1172 | |||
| 1173 | // Extract operator | ||
| 1174 |
2/2✓ Branch 21 → 22 taken 4638 times.
✓ Branch 21 → 27 taken 24352 times.
|
28990 | if (ctx->assignExpr()) { |
| 1175 | 4638 | postfixUnaryExprNode->op = PostfixUnaryExprNode::PostfixUnaryOp::OP_SUBSCRIPT; | |
| 1176 |
3/6✓ Branch 22 → 23 taken 4638 times.
✗ Branch 22 → 59 not taken.
✓ Branch 23 → 24 taken 4638 times.
✗ Branch 23 → 59 not taken.
✓ Branch 24 → 25 taken 4638 times.
✗ Branch 24 → 57 not taken.
|
4638 | postfixUnaryExprNode->subscriptIndexExpr = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 1177 |
2/2✓ Branch 28 → 29 taken 21675 times.
✓ Branch 28 → 34 taken 2677 times.
|
24352 | } else if (ctx->IDENTIFIER()) { |
| 1178 | 21675 | postfixUnaryExprNode->op = PostfixUnaryExprNode::PostfixUnaryOp::OP_MEMBER_ACCESS; | |
| 1179 |
2/4✓ Branch 29 → 30 taken 21675 times.
✗ Branch 29 → 60 not taken.
✓ Branch 30 → 31 taken 21675 times.
✗ Branch 30 → 60 not taken.
|
21675 | postfixUnaryExprNode->identifier = getIdentifier(ctx->IDENTIFIER(), false); |
| 1180 |
2/2✓ Branch 35 → 36 taken 2117 times.
✓ Branch 35 → 37 taken 560 times.
|
2677 | } else if (ctx->PLUS_PLUS()) { |
| 1181 | 2117 | postfixUnaryExprNode->op = PostfixUnaryExprNode::PostfixUnaryOp::OP_PLUS_PLUS; | |
| 1182 |
1/2✓ Branch 38 → 39 taken 560 times.
✗ Branch 38 → 41 not taken.
|
560 | } else if (ctx->MINUS_MINUS()) { |
| 1183 | 560 | 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 28990 times.
✗ Branch 47 → 61 not taken.
|
28990 | return concludeExprNode(postfixUnaryExprNode); |
| 1190 | } | ||
| 1191 | |||
| 1192 | 106853 | std::any ASTBuilder::visitAtomicExpr(SpiceParser::AtomicExprContext *ctx) { | |
| 1193 | 106853 | const auto atomicExprNode = createNode<AtomicExprNode>(ctx); | |
| 1194 | |||
| 1195 | // Visit children | ||
| 1196 |
2/2✓ Branch 4 → 5 taken 20647 times.
✓ Branch 4 → 10 taken 86206 times.
|
106853 | if (ctx->constant()) { |
| 1197 |
4/6✓ Branch 5 → 6 taken 20647 times.
✗ Branch 5 → 80 not taken.
✓ Branch 6 → 7 taken 20645 times.
✓ Branch 6 → 80 taken 2 times.
✓ Branch 7 → 8 taken 20645 times.
✗ Branch 7 → 78 not taken.
|
20647 | atomicExprNode->constant = std::any_cast<ConstantNode *>(visit(ctx->constant())); |
| 1198 |
2/2✓ Branch 11 → 12 taken 23178 times.
✓ Branch 11 → 17 taken 63028 times.
|
86206 | } else if (ctx->value()) { |
| 1199 |
3/6✓ Branch 12 → 13 taken 23178 times.
✗ Branch 12 → 83 not taken.
✓ Branch 13 → 14 taken 23178 times.
✗ Branch 13 → 83 not taken.
✓ Branch 14 → 15 taken 23178 times.
✗ Branch 14 → 81 not taken.
|
23178 | atomicExprNode->value = std::any_cast<ValueNode *>(visit(ctx->value())); |
| 1200 |
11/18✓ Branch 17 → 18 taken 63028 times.
✗ Branch 17 → 84 not taken.
✓ Branch 19 → 20 taken 2617 times.
✓ Branch 19 → 23 taken 60411 times.
✓ Branch 20 → 21 taken 2617 times.
✗ Branch 20 → 84 not taken.
✓ Branch 22 → 23 taken 1935 times.
✓ Branch 22 → 24 taken 682 times.
✓ Branch 25 → 26 taken 2617 times.
✓ Branch 25 → 27 taken 60411 times.
✓ Branch 27 → 28 taken 63028 times.
✗ Branch 27 → 29 not taken.
✓ Branch 29 → 30 taken 62346 times.
✓ Branch 29 → 60 taken 682 times.
✗ Branch 84 → 85 not taken.
✗ Branch 84 → 86 not taken.
✗ Branch 88 → 89 not taken.
✗ Branch 88 → 90 not taken.
|
63028 | } else if (!ctx->IDENTIFIER().empty() || !ctx->TYPE_IDENTIFIER().empty()) { |
| 1201 |
1/2✓ Branch 30 → 31 taken 62346 times.
✗ Branch 30 → 100 not taken.
|
62346 | std::stringstream fqIdentifier; |
| 1202 |
2/2✓ Branch 54 → 33 taken 62998 times.
✓ Branch 54 → 55 taken 62346 times.
|
125344 | for (ParserRuleContext::ParseTree *subTree : ctx->children) { |
| 1203 |
1/2✓ Branch 34 → 35 taken 62998 times.
✗ Branch 34 → 36 not taken.
|
62998 | const auto terminal = dynamic_cast<TerminalNode *>(subTree); |
| 1204 |
1/2✗ Branch 37 → 38 not taken.
✓ Branch 37 → 39 taken 62998 times.
|
62998 | if (!terminal) |
| 1205 | ✗ | continue; | |
| 1206 | |||
| 1207 |
2/4✓ Branch 39 → 40 taken 62998 times.
✗ Branch 39 → 96 not taken.
✓ Branch 40 → 41 taken 62998 times.
✗ Branch 40 → 96 not taken.
|
62998 | const size_t terminalType = terminal->getSymbol()->getType(); |
| 1208 |
4/4✓ Branch 41 → 42 taken 2587 times.
✓ Branch 41 → 43 taken 60411 times.
✓ Branch 42 → 43 taken 2261 times.
✓ Branch 42 → 52 taken 326 times.
|
62998 | if (terminalType == SpiceParser::IDENTIFIER || terminalType == SpiceParser::TYPE_IDENTIFIER) { |
| 1209 |
1/2✓ Branch 43 → 44 taken 62672 times.
✗ Branch 43 → 95 not taken.
|
62672 | const std::string fragment = getIdentifier(terminal, false); |
| 1210 |
1/2✓ Branch 44 → 45 taken 62672 times.
✗ Branch 44 → 93 not taken.
|
62672 | atomicExprNode->identifierFragments.push_back(fragment); |
| 1211 |
3/4✓ Branch 45 → 46 taken 62672 times.
✗ Branch 45 → 92 not taken.
✓ Branch 47 → 48 taken 326 times.
✓ Branch 47 → 49 taken 62346 times.
|
62672 | if (fqIdentifier.tellp() != 0) |
| 1212 |
1/2✓ Branch 48 → 49 taken 326 times.
✗ Branch 48 → 93 not taken.
|
326 | fqIdentifier << SCOPE_ACCESS_TOKEN; |
| 1213 |
1/2✓ Branch 49 → 50 taken 62672 times.
✗ Branch 49 → 93 not taken.
|
62672 | fqIdentifier << fragment; |
| 1214 | 62672 | } | |
| 1215 | } | ||
| 1216 |
1/2✓ Branch 55 → 56 taken 62346 times.
✗ Branch 55 → 97 not taken.
|
62346 | atomicExprNode->fqIdentifier = fqIdentifier.str(); |
| 1217 |
1/2✓ Branch 61 → 62 taken 682 times.
✗ Branch 61 → 67 not taken.
|
63028 | } else if (ctx->assignExpr()) { |
| 1218 |
3/6✓ Branch 62 → 63 taken 682 times.
✗ Branch 62 → 103 not taken.
✓ Branch 63 → 64 taken 682 times.
✗ Branch 63 → 103 not taken.
✓ Branch 64 → 65 taken 682 times.
✗ Branch 64 → 101 not taken.
|
682 | 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 74 → 75 taken 106851 times.
✗ Branch 74 → 104 not taken.
|
106851 | return concludeExprNode(atomicExprNode); |
| 1224 | } | ||
| 1225 | |||
| 1226 | 23178 | std::any ASTBuilder::visitValue(SpiceParser::ValueContext *ctx) { | |
| 1227 | 23178 | const auto valueNode = createNode<ValueNode>(ctx); | |
| 1228 | |||
| 1229 | // Visit children | ||
| 1230 |
2/2✓ Branch 4 → 5 taken 21219 times.
✓ Branch 4 → 10 taken 1959 times.
|
23178 | if (ctx->fctCall()) { |
| 1231 |
3/6✓ Branch 5 → 6 taken 21219 times.
✗ Branch 5 → 65 not taken.
✓ Branch 6 → 7 taken 21219 times.
✗ Branch 6 → 65 not taken.
✓ Branch 7 → 8 taken 21219 times.
✗ Branch 7 → 63 not taken.
|
21219 | valueNode->fctCall = std::any_cast<FctCallNode *>(visit(ctx->fctCall())); |
| 1232 |
2/2✓ Branch 11 → 12 taken 77 times.
✓ Branch 11 → 17 taken 1882 times.
|
1959 | } else if (ctx->arrayInitialization()) { |
| 1233 |
3/6✓ Branch 12 → 13 taken 77 times.
✗ Branch 12 → 68 not taken.
✓ Branch 13 → 14 taken 77 times.
✗ Branch 13 → 68 not taken.
✓ Branch 14 → 15 taken 77 times.
✗ Branch 14 → 66 not taken.
|
77 | valueNode->arrayInitialization = std::any_cast<ArrayInitializationNode *>(visit(ctx->arrayInitialization())); |
| 1234 |
2/2✓ Branch 18 → 19 taken 228 times.
✓ Branch 18 → 24 taken 1654 times.
|
1882 | } else if (ctx->structInstantiation()) { |
| 1235 |
3/6✓ Branch 19 → 20 taken 228 times.
✗ Branch 19 → 71 not taken.
✓ Branch 20 → 21 taken 228 times.
✗ Branch 20 → 71 not taken.
✓ Branch 21 → 22 taken 228 times.
✗ Branch 21 → 69 not taken.
|
228 | valueNode->structInstantiation = std::any_cast<StructInstantiationNode *>(visit(ctx->structInstantiation())); |
| 1236 |
2/2✓ Branch 25 → 26 taken 16 times.
✓ Branch 25 → 31 taken 1638 times.
|
1654 | } else if (ctx->lambdaFunc()) { |
| 1237 |
3/6✓ Branch 26 → 27 taken 16 times.
✗ Branch 26 → 74 not taken.
✓ Branch 27 → 28 taken 16 times.
✗ Branch 27 → 74 not taken.
✓ Branch 28 → 29 taken 16 times.
✗ Branch 28 → 72 not taken.
|
16 | valueNode->lambdaFunc = std::any_cast<LambdaFuncNode *>(visit(ctx->lambdaFunc())); |
| 1238 |
2/2✓ Branch 32 → 33 taken 20 times.
✓ Branch 32 → 38 taken 1618 times.
|
1638 | } else if (ctx->lambdaProc()) { |
| 1239 |
3/6✓ Branch 33 → 34 taken 20 times.
✗ Branch 33 → 77 not taken.
✓ Branch 34 → 35 taken 20 times.
✗ Branch 34 → 77 not taken.
✓ Branch 35 → 36 taken 20 times.
✗ Branch 35 → 75 not taken.
|
20 | valueNode->lambdaProc = std::any_cast<LambdaProcNode *>(visit(ctx->lambdaProc())); |
| 1240 |
2/2✓ Branch 39 → 40 taken 1 time.
✓ Branch 39 → 45 taken 1617 times.
|
1618 | } 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 1617 times.
✗ Branch 46 → 52 not taken.
|
1617 | } else if (ctx->dataType()) { |
| 1243 | 1617 | valueNode->isNil = true; | |
| 1244 |
3/6✓ Branch 47 → 48 taken 1617 times.
✗ Branch 47 → 83 not taken.
✓ Branch 48 → 49 taken 1617 times.
✗ Branch 48 → 83 not taken.
✓ Branch 49 → 50 taken 1617 times.
✗ Branch 49 → 81 not taken.
|
1617 | 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 23178 times.
✗ Branch 59 → 84 not taken.
|
23178 | return concludeNode(valueNode); |
| 1250 | } | ||
| 1251 | |||
| 1252 | 22783 | std::any ASTBuilder::visitConstant(SpiceParser::ConstantContext *ctx) { | |
| 1253 | 22783 | const auto constantNode = createNode<ConstantNode>(ctx); | |
| 1254 | |||
| 1255 | // Enrich | ||
| 1256 |
2/2✓ Branch 4 → 5 taken 703 times.
✓ Branch 4 → 10 taken 22080 times.
|
22783 | if (ctx->DOUBLE_LIT()) { |
| 1257 | 703 | constantNode->type = ConstantNode::PrimitiveValueType::TYPE_DOUBLE; | |
| 1258 |
3/6✓ Branch 5 → 6 taken 703 times.
✗ Branch 5 → 59 not taken.
✓ Branch 6 → 7 taken 703 times.
✗ Branch 6 → 59 not taken.
✓ Branch 7 → 8 taken 703 times.
✗ Branch 7 → 57 not taken.
|
703 | constantNode->compileTimeValue.doubleValue = std::stod(ctx->DOUBLE_LIT()->toString()); |
| 1259 |
2/2✓ Branch 11 → 12 taken 4868 times.
✓ Branch 11 → 15 taken 17212 times.
|
22080 | } else if (ctx->INT_LIT()) { |
| 1260 | 4868 | constantNode->type = ConstantNode::PrimitiveValueType::TYPE_INT; | |
| 1261 | 4868 | constantNode->compileTimeValue.intValue = parseInt(ctx->INT_LIT()); | |
| 1262 |
2/2✓ Branch 16 → 17 taken 884 times.
✓ Branch 16 → 20 taken 16328 times.
|
17212 | } else if (ctx->SHORT_LIT()) { |
| 1263 | 884 | constantNode->type = ConstantNode::PrimitiveValueType::TYPE_SHORT; | |
| 1264 | 884 | constantNode->compileTimeValue.shortValue = parseShort(ctx->SHORT_LIT()); | |
| 1265 |
2/2✓ Branch 21 → 22 taken 7042 times.
✓ Branch 21 → 25 taken 9286 times.
|
16328 | } else if (ctx->LONG_LIT()) { |
| 1266 | 7042 | constantNode->type = ConstantNode::PrimitiveValueType::TYPE_LONG; | |
| 1267 | 7042 | constantNode->compileTimeValue.longValue = parseLong(ctx->LONG_LIT()); | |
| 1268 |
2/2✓ Branch 26 → 27 taken 3141 times.
✓ Branch 26 → 30 taken 6145 times.
|
9286 | } else if (ctx->CHAR_LIT()) { |
| 1269 | 3141 | constantNode->type = ConstantNode::PrimitiveValueType::TYPE_CHAR; | |
| 1270 | 3141 | constantNode->compileTimeValue.charValue = parseChar(ctx->CHAR_LIT()); | |
| 1271 |
2/2✓ Branch 31 → 32 taken 3749 times.
✓ Branch 31 → 40 taken 2396 times.
|
6145 | } else if (ctx->STRING_LIT()) { |
| 1272 | // Save a pointer to the string in the compile time value | ||
| 1273 | 3749 | constantNode->type = ConstantNode::PrimitiveValueType::TYPE_STRING; | |
| 1274 | 3749 | constantNode->compileTimeValue.stringValueOffset = resourceManager.compileTimeStringValues.size(); | |
| 1275 | // Add the string to the global compile time string list | ||
| 1276 |
4/8✓ Branch 33 → 34 taken 3749 times.
✗ Branch 33 → 64 not taken.
✓ Branch 34 → 35 taken 3749 times.
✗ Branch 34 → 64 not taken.
✓ Branch 35 → 36 taken 3749 times.
✗ Branch 35 → 62 not taken.
✓ Branch 36 → 37 taken 3749 times.
✗ Branch 36 → 60 not taken.
|
3749 | resourceManager.compileTimeStringValues.push_back(parseString(ctx->STRING_LIT()->toString())); |
| 1277 |
2/2✓ Branch 41 → 42 taken 1237 times.
✓ Branch 41 → 43 taken 1159 times.
|
2396 | } else if (ctx->TRUE()) { |
| 1278 | 1237 | constantNode->type = ConstantNode::PrimitiveValueType::TYPE_BOOL; | |
| 1279 | 1237 | constantNode->compileTimeValue.boolValue = true; | |
| 1280 |
1/2✓ Branch 44 → 45 taken 1159 times.
✗ Branch 44 → 46 not taken.
|
1159 | } else if (ctx->FALSE()) { |
| 1281 | 1159 | constantNode->type = ConstantNode::PrimitiveValueType::TYPE_BOOL; | |
| 1282 | 1159 | constantNode->compileTimeValue.boolValue = false; | |
| 1283 | } else { | ||
| 1284 | − | assert_fail("Unknown constant type"); // GCOV_EXCL_LINE | |
| 1285 | } | ||
| 1286 | |||
| 1287 |
1/2✓ Branch 53 → 54 taken 22781 times.
✗ Branch 53 → 66 not taken.
|
22781 | return concludeNode(constantNode); |
| 1288 | } | ||
| 1289 | |||
| 1290 | 21219 | std::any ASTBuilder::visitFctCall(SpiceParser::FctCallContext *ctx) { | |
| 1291 |
1/2✓ Branch 2 → 3 taken 21219 times.
✗ Branch 2 → 84 not taken.
|
21219 | const auto fctCallNode = createNode<FctCallNode>(ctx); |
| 1292 | |||
| 1293 |
1/2✓ Branch 3 → 4 taken 21219 times.
✗ Branch 3 → 84 not taken.
|
21219 | std::stringstream fqFunctionName; |
| 1294 |
2/2✓ Branch 38 → 6 taken 102683 times.
✓ Branch 38 → 39 taken 21219 times.
|
123902 | for (antlr4::ParserRuleContext::ParseTree *subTree : ctx->children) { |
| 1295 |
1/2✓ Branch 7 → 8 taken 102683 times.
✗ Branch 7 → 9 not taken.
|
102683 | const auto terminal = dynamic_cast<antlr4::tree::TerminalNode *>(subTree); |
| 1296 |
2/2✓ Branch 10 → 11 taken 18180 times.
✓ Branch 10 → 12 taken 84503 times.
|
102683 | if (!terminal) |
| 1297 | 18180 | continue; | |
| 1298 | |||
| 1299 |
4/6✓ Branch 12 → 13 taken 84503 times.
✗ Branch 12 → 73 not taken.
✓ Branch 13 → 14 taken 84503 times.
✗ Branch 13 → 73 not taken.
✓ Branch 14 → 15 taken 26929 times.
✓ Branch 14 → 20 taken 57574 times.
|
84503 | if (terminal->getSymbol()->getType() == SpiceParser::IDENTIFIER) { |
| 1300 |
1/2✓ Branch 15 → 16 taken 26929 times.
✗ Branch 15 → 69 not taken.
|
26929 | const std::string fragment = terminal->toString(); |
| 1301 |
1/2✓ Branch 16 → 17 taken 26929 times.
✗ Branch 16 → 67 not taken.
|
26929 | fctCallNode->functionNameFragments.push_back(fragment); |
| 1302 |
1/2✓ Branch 17 → 18 taken 26929 times.
✗ Branch 17 → 67 not taken.
|
26929 | fqFunctionName << fragment; |
| 1303 |
4/6✓ Branch 20 → 21 taken 57574 times.
✗ Branch 20 → 73 not taken.
✓ Branch 21 → 22 taken 57574 times.
✗ Branch 21 → 73 not taken.
✓ Branch 22 → 23 taken 3246 times.
✓ Branch 22 → 28 taken 54328 times.
|
84503 | } else if (terminal->getSymbol()->getType() == SpiceParser::TYPE_IDENTIFIER) { |
| 1304 |
1/2✓ Branch 23 → 24 taken 3246 times.
✗ Branch 23 → 72 not taken.
|
3246 | const std::string fragment = terminal->toString(); |
| 1305 |
1/2✓ Branch 24 → 25 taken 3246 times.
✗ Branch 24 → 70 not taken.
|
3246 | fctCallNode->functionNameFragments.push_back(fragment); |
| 1306 |
1/2✓ Branch 25 → 26 taken 3246 times.
✗ Branch 25 → 70 not taken.
|
3246 | fqFunctionName << fragment; |
| 1307 |
4/6✓ Branch 28 → 29 taken 54328 times.
✗ Branch 28 → 73 not taken.
✓ Branch 29 → 30 taken 54328 times.
✗ Branch 29 → 73 not taken.
✓ Branch 30 → 31 taken 62 times.
✓ Branch 30 → 32 taken 54266 times.
|
57574 | } else if (terminal->getSymbol()->getType() == SpiceParser::SCOPE_ACCESS) { |
| 1308 |
1/2✓ Branch 31 → 36 taken 62 times.
✗ Branch 31 → 73 not taken.
|
62 | fqFunctionName << SCOPE_ACCESS_TOKEN; |
| 1309 |
4/6✓ Branch 32 → 33 taken 54266 times.
✗ Branch 32 → 73 not taken.
✓ Branch 33 → 34 taken 54266 times.
✗ Branch 33 → 73 not taken.
✓ Branch 34 → 35 taken 8894 times.
✓ Branch 34 → 36 taken 45372 times.
|
54266 | } else if (terminal->getSymbol()->getType() == SpiceParser::DOT) { |
| 1310 |
1/2✓ Branch 35 → 36 taken 8894 times.
✗ Branch 35 → 73 not taken.
|
8894 | fqFunctionName << MEMBER_ACCESS_TOKEN; |
| 1311 | } | ||
| 1312 | } | ||
| 1313 |
1/2✓ Branch 39 → 40 taken 21219 times.
✗ Branch 39 → 74 not taken.
|
21219 | fctCallNode->fqFunctionName = fqFunctionName.str(); |
| 1314 | |||
| 1315 | // Visit children | ||
| 1316 |
3/4✓ Branch 42 → 43 taken 21219 times.
✗ Branch 42 → 82 not taken.
✓ Branch 43 → 44 taken 1467 times.
✓ Branch 43 → 49 taken 19752 times.
|
21219 | if (ctx->typeLst()) { |
| 1317 | 1467 | fctCallNode->hasTemplateTypes = true; | |
| 1318 |
3/6✓ Branch 44 → 45 taken 1467 times.
✗ Branch 44 → 77 not taken.
✓ Branch 45 → 46 taken 1467 times.
✗ Branch 45 → 77 not taken.
✓ Branch 46 → 47 taken 1467 times.
✗ Branch 46 → 75 not taken.
|
1467 | fctCallNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst())); |
| 1319 | } | ||
| 1320 |
3/4✓ Branch 49 → 50 taken 21219 times.
✗ Branch 49 → 82 not taken.
✓ Branch 50 → 51 taken 16713 times.
✓ Branch 50 → 56 taken 4506 times.
|
21219 | if (ctx->argLst()) { |
| 1321 | 16713 | fctCallNode->hasArgs = true; | |
| 1322 |
3/6✓ Branch 51 → 52 taken 16713 times.
✗ Branch 51 → 80 not taken.
✓ Branch 52 → 53 taken 16713 times.
✗ Branch 52 → 80 not taken.
✓ Branch 53 → 54 taken 16713 times.
✗ Branch 53 → 78 not taken.
|
16713 | fctCallNode->argLst = std::any_cast<ArgLstNode *>(visit(ctx->argLst())); |
| 1323 | } | ||
| 1324 | |||
| 1325 |
1/2✓ Branch 62 → 63 taken 21219 times.
✗ Branch 62 → 81 not taken.
|
42438 | return concludeNode(fctCallNode); |
| 1326 | 21219 | } | |
| 1327 | |||
| 1328 | 77 | std::any ASTBuilder::visitArrayInitialization(SpiceParser::ArrayInitializationContext *ctx) { | |
| 1329 | 77 | const auto arrayInitializationNode = createNode<ArrayInitializationNode>(ctx); | |
| 1330 | |||
| 1331 | // Visit children | ||
| 1332 |
2/2✓ Branch 4 → 5 taken 76 times.
✓ Branch 4 → 10 taken 1 time.
|
77 | if (ctx->argLst()) |
| 1333 |
3/6✓ Branch 5 → 6 taken 76 times.
✗ Branch 5 → 22 not taken.
✓ Branch 6 → 7 taken 76 times.
✗ Branch 6 → 22 not taken.
✓ Branch 7 → 8 taken 76 times.
✗ Branch 7 → 20 not taken.
|
76 | arrayInitializationNode->itemLst = std::any_cast<ArgLstNode *>(visit(ctx->argLst())); |
| 1334 | |||
| 1335 |
1/2✓ Branch 16 → 17 taken 77 times.
✗ Branch 16 → 23 not taken.
|
77 | return concludeNode(arrayInitializationNode); |
| 1336 | } | ||
| 1337 | |||
| 1338 | 228 | std::any ASTBuilder::visitStructInstantiation(SpiceParser::StructInstantiationContext *ctx) { | |
| 1339 |
1/2✓ Branch 2 → 3 taken 228 times.
✗ Branch 2 → 77 not taken.
|
228 | const auto structInstantiationNode = createNode<StructInstantiationNode>(ctx); |
| 1340 | |||
| 1341 | // Enrich | ||
| 1342 |
1/2✓ Branch 3 → 4 taken 228 times.
✗ Branch 3 → 77 not taken.
|
228 | std::stringstream fqStructName; |
| 1343 |
2/2✓ Branch 31 → 6 taken 946 times.
✓ Branch 31 → 32 taken 228 times.
|
1174 | for (antlr4::ParserRuleContext::ParseTree *subTree : ctx->children) { |
| 1344 |
1/2✓ Branch 7 → 8 taken 946 times.
✗ Branch 7 → 9 not taken.
|
946 | const auto terminal = dynamic_cast<antlr4::tree::TerminalNode *>(subTree); |
| 1345 |
2/2✓ Branch 10 → 11 taken 226 times.
✓ Branch 10 → 12 taken 720 times.
|
946 | if (!terminal) |
| 1346 | 226 | continue; | |
| 1347 | |||
| 1348 |
4/6✓ Branch 12 → 13 taken 720 times.
✗ Branch 12 → 66 not taken.
✓ Branch 13 → 14 taken 720 times.
✗ Branch 13 → 66 not taken.
✓ Branch 14 → 15 taken 3 times.
✓ Branch 14 → 21 taken 717 times.
|
720 | if (terminal->getSymbol()->getType() == SpiceParser::IDENTIFIER) { |
| 1349 |
1/2✓ Branch 15 → 16 taken 3 times.
✗ Branch 15 → 62 not taken.
|
3 | const std::string fragment = terminal->toString(); |
| 1350 |
1/2✓ Branch 16 → 17 taken 3 times.
✗ Branch 16 → 60 not taken.
|
3 | structInstantiationNode->structNameFragments.push_back(fragment); |
| 1351 |
2/4✓ Branch 17 → 18 taken 3 times.
✗ Branch 17 → 60 not taken.
✓ Branch 18 → 19 taken 3 times.
✗ Branch 18 → 60 not taken.
|
3 | fqStructName << fragment << SCOPE_ACCESS_TOKEN; |
| 1352 |
4/6✓ Branch 21 → 22 taken 717 times.
✗ Branch 21 → 66 not taken.
✓ Branch 22 → 23 taken 717 times.
✗ Branch 22 → 66 not taken.
✓ Branch 23 → 24 taken 228 times.
✓ Branch 23 → 29 taken 489 times.
|
720 | } else if (terminal->getSymbol()->getType() == SpiceParser::TYPE_IDENTIFIER) { |
| 1353 |
1/2✓ Branch 24 → 25 taken 228 times.
✗ Branch 24 → 65 not taken.
|
228 | const std::string fragment = terminal->toString(); |
| 1354 |
1/2✓ Branch 25 → 26 taken 228 times.
✗ Branch 25 → 63 not taken.
|
228 | structInstantiationNode->structNameFragments.push_back(fragment); |
| 1355 |
1/2✓ Branch 26 → 27 taken 228 times.
✗ Branch 26 → 63 not taken.
|
228 | fqStructName << fragment; |
| 1356 | 228 | } | |
| 1357 | } | ||
| 1358 |
1/2✓ Branch 32 → 33 taken 228 times.
✗ Branch 32 → 67 not taken.
|
228 | structInstantiationNode->fqStructName = fqStructName.str(); |
| 1359 | |||
| 1360 | // Visit children | ||
| 1361 |
3/4✓ Branch 35 → 36 taken 228 times.
✗ Branch 35 → 75 not taken.
✓ Branch 36 → 37 taken 15 times.
✓ Branch 36 → 42 taken 213 times.
|
228 | if (ctx->typeLst()) { |
| 1362 | 15 | structInstantiationNode->hasTemplateTypes = true; | |
| 1363 |
3/6✓ Branch 37 → 38 taken 15 times.
✗ Branch 37 → 70 not taken.
✓ Branch 38 → 39 taken 15 times.
✗ Branch 38 → 70 not taken.
✓ Branch 39 → 40 taken 15 times.
✗ Branch 39 → 68 not taken.
|
15 | structInstantiationNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst())); |
| 1364 | } | ||
| 1365 |
3/4✓ Branch 42 → 43 taken 228 times.
✗ Branch 42 → 75 not taken.
✓ Branch 43 → 44 taken 211 times.
✓ Branch 43 → 49 taken 17 times.
|
228 | if (ctx->argLst()) |
| 1366 |
3/6✓ Branch 44 → 45 taken 211 times.
✗ Branch 44 → 73 not taken.
✓ Branch 45 → 46 taken 211 times.
✗ Branch 45 → 73 not taken.
✓ Branch 46 → 47 taken 211 times.
✗ Branch 46 → 71 not taken.
|
211 | structInstantiationNode->fieldLst = std::any_cast<ArgLstNode *>(visit(ctx->argLst())); |
| 1367 | |||
| 1368 |
1/2✓ Branch 55 → 56 taken 228 times.
✗ Branch 55 → 74 not taken.
|
456 | return concludeNode(structInstantiationNode); |
| 1369 | 228 | } | |
| 1370 | |||
| 1371 | 16 | std::any ASTBuilder::visitLambdaFunc(SpiceParser::LambdaFuncContext *ctx) { | |
| 1372 | 16 | const auto lambdaFuncNode = createNode<LambdaFuncNode>(ctx); | |
| 1373 | |||
| 1374 | // Visit children | ||
| 1375 |
3/6✓ Branch 3 → 4 taken 16 times.
✗ Branch 3 → 37 not taken.
✓ Branch 4 → 5 taken 16 times.
✗ Branch 4 → 37 not taken.
✓ Branch 5 → 6 taken 16 times.
✗ Branch 5 → 35 not taken.
|
16 | lambdaFuncNode->returnType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 1376 |
2/2✓ Branch 8 → 9 taken 12 times.
✓ Branch 8 → 14 taken 4 times.
|
16 | if (ctx->paramLst()) { |
| 1377 | 12 | lambdaFuncNode->hasParams = true; | |
| 1378 |
3/6✓ Branch 9 → 10 taken 12 times.
✗ Branch 9 → 40 not taken.
✓ Branch 10 → 11 taken 12 times.
✗ Branch 10 → 40 not taken.
✓ Branch 11 → 12 taken 12 times.
✗ Branch 11 → 38 not taken.
|
12 | lambdaFuncNode->paramLst = std::any_cast<ParamLstNode *>(visit(ctx->paramLst())); |
| 1379 | } | ||
| 1380 |
1/2✗ Branch 15 → 16 not taken.
✓ Branch 15 → 21 taken 16 times.
|
16 | if (ctx->lambdaAttr()) |
| 1381 | ✗ | lambdaFuncNode->lambdaAttr = std::any_cast<LambdaAttrNode *>(visit(ctx->lambdaAttr())); | |
| 1382 |
3/6✓ Branch 21 → 22 taken 16 times.
✗ Branch 21 → 46 not taken.
✓ Branch 22 → 23 taken 16 times.
✗ Branch 22 → 46 not taken.
✓ Branch 23 → 24 taken 16 times.
✗ Branch 23 → 44 not taken.
|
16 | lambdaFuncNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 1383 | |||
| 1384 |
1/2✓ Branch 31 → 32 taken 16 times.
✗ Branch 31 → 47 not taken.
|
16 | return concludeNode(lambdaFuncNode); |
| 1385 | } | ||
| 1386 | |||
| 1387 | 20 | std::any ASTBuilder::visitLambdaProc(SpiceParser::LambdaProcContext *ctx) { | |
| 1388 | 20 | const auto lambdaProcNode = createNode<LambdaProcNode>(ctx); | |
| 1389 | |||
| 1390 | // Visit children | ||
| 1391 |
2/2✓ Branch 4 → 5 taken 11 times.
✓ Branch 4 → 10 taken 9 times.
|
20 | if (ctx->paramLst()) { |
| 1392 | 11 | lambdaProcNode->hasParams = true; | |
| 1393 |
3/6✓ Branch 5 → 6 taken 11 times.
✗ Branch 5 → 33 not taken.
✓ Branch 6 → 7 taken 11 times.
✗ Branch 6 → 33 not taken.
✓ Branch 7 → 8 taken 11 times.
✗ Branch 7 → 31 not taken.
|
11 | lambdaProcNode->paramLst = std::any_cast<ParamLstNode *>(visit(ctx->paramLst())); |
| 1394 | } | ||
| 1395 |
2/2✓ Branch 11 → 12 taken 5 times.
✓ Branch 11 → 17 taken 15 times.
|
20 | if (ctx->lambdaAttr()) |
| 1396 |
3/6✓ Branch 12 → 13 taken 5 times.
✗ Branch 12 → 36 not taken.
✓ Branch 13 → 14 taken 5 times.
✗ Branch 13 → 36 not taken.
✓ Branch 14 → 15 taken 5 times.
✗ Branch 14 → 34 not taken.
|
5 | lambdaProcNode->lambdaAttr = std::any_cast<LambdaAttrNode *>(visit(ctx->lambdaAttr())); |
| 1397 |
3/6✓ Branch 17 → 18 taken 20 times.
✗ Branch 17 → 39 not taken.
✓ Branch 18 → 19 taken 20 times.
✗ Branch 18 → 39 not taken.
✓ Branch 19 → 20 taken 20 times.
✗ Branch 19 → 37 not taken.
|
20 | lambdaProcNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
| 1398 | |||
| 1399 |
1/2✓ Branch 27 → 28 taken 20 times.
✗ Branch 27 → 40 not taken.
|
20 | return concludeNode(lambdaProcNode); |
| 1400 | } | ||
| 1401 | |||
| 1402 | 1 | std::any ASTBuilder::visitLambdaExpr(SpiceParser::LambdaExprContext *ctx) { | |
| 1403 | 1 | const auto lambdaExprNode = createNode<LambdaExprNode>(ctx); | |
| 1404 | |||
| 1405 | // Visit children | ||
| 1406 |
1/2✓ Branch 4 → 5 taken 1 time.
✗ Branch 4 → 10 not taken.
|
1 | if (ctx->paramLst()) { |
| 1407 | 1 | lambdaExprNode->hasParams = true; | |
| 1408 |
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())); |
| 1409 | } | ||
| 1410 |
3/6✓ Branch 10 → 11 taken 1 time.
✗ Branch 10 → 29 not taken.
✓ Branch 11 → 12 taken 1 time.
✗ Branch 11 → 29 not taken.
✓ Branch 12 → 13 taken 1 time.
✗ Branch 12 → 27 not taken.
|
1 | lambdaExprNode->lambdaExpr = std::any_cast<ExprNode *>(visit(ctx->assignExpr())); |
| 1411 | |||
| 1412 |
1/2✓ Branch 20 → 21 taken 1 time.
✗ Branch 20 → 30 not taken.
|
1 | return concludeNode(lambdaExprNode); |
| 1413 | } | ||
| 1414 | |||
| 1415 | 54882 | std::any ASTBuilder::visitDataType(SpiceParser::DataTypeContext *ctx) { | |
| 1416 | 54882 | const auto dataTypeNode = createNode<DataTypeNode>(ctx); | |
| 1417 | |||
| 1418 | // Visit children | ||
| 1419 |
2/2✓ Branch 4 → 5 taken 21306 times.
✓ Branch 4 → 10 taken 33576 times.
|
54882 | if (ctx->qualifierLst()) |
| 1420 |
4/6✓ Branch 5 → 6 taken 21306 times.
✗ Branch 5 → 73 not taken.
✓ Branch 6 → 7 taken 21305 times.
✓ Branch 6 → 73 taken 1 time.
✓ Branch 7 → 8 taken 21305 times.
✗ Branch 7 → 71 not taken.
|
21306 | dataTypeNode->qualifierLst = std::any_cast<QualifierLstNode *>(visit(ctx->qualifierLst())); |
| 1421 |
3/6✓ Branch 10 → 11 taken 54881 times.
✗ Branch 10 → 76 not taken.
✓ Branch 11 → 12 taken 54881 times.
✗ Branch 11 → 76 not taken.
✓ Branch 12 → 13 taken 54881 times.
✗ Branch 12 → 74 not taken.
|
54881 | dataTypeNode->baseDataType = std::any_cast<BaseDataTypeNode *>(visit(ctx->baseDataType())); |
| 1422 | |||
| 1423 | // Enrich | ||
| 1424 |
2/2✓ Branch 60 → 15 taken 89269 times.
✓ Branch 60 → 61 taken 54881 times.
|
144150 | for (size_t i = 0; i < ctx->children.size(); i++) { |
| 1425 | 89269 | antlr4::tree::ParseTree *subTree = ctx->children.at(i); | |
| 1426 |
1/2✓ Branch 16 → 17 taken 89269 times.
✗ Branch 16 → 18 not taken.
|
89269 | auto terminal = dynamic_cast<TerminalNode *>(subTree); |
| 1427 |
2/2✓ Branch 19 → 20 taken 76186 times.
✓ Branch 19 → 21 taken 13083 times.
|
89269 | if (!terminal) |
| 1428 | 76186 | continue; | |
| 1429 | |||
| 1430 |
2/2✓ Branch 23 → 24 taken 6644 times.
✓ Branch 23 → 26 taken 6439 times.
|
13083 | if (terminal->getSymbol()->getType() == SpiceParser::MUL) { |
| 1431 |
1/2✓ Branch 24 → 25 taken 6644 times.
✗ Branch 24 → 77 not taken.
|
6644 | dataTypeNode->tmQueue.emplace(DataTypeNode::TypeModifierType::TYPE_PTR, false, 0); |
| 1432 |
2/2✓ Branch 28 → 29 taken 6326 times.
✓ Branch 28 → 31 taken 113 times.
|
6439 | } else if (terminal->getSymbol()->getType() == SpiceParser::BITWISE_AND) { |
| 1433 |
1/2✓ Branch 29 → 30 taken 6326 times.
✗ Branch 29 → 80 not taken.
|
6326 | dataTypeNode->tmQueue.emplace(DataTypeNode::TypeModifierType::TYPE_REF, false, 0); |
| 1434 |
1/2✓ Branch 33 → 34 taken 113 times.
✗ Branch 33 → 58 not taken.
|
113 | } else if (terminal->getSymbol()->getType() == SpiceParser::LBRACKET) { |
| 1435 | 113 | i++; // Consume LBRACKET | |
| 1436 |
1/2✓ Branch 34 → 35 taken 113 times.
✗ Branch 34 → 92 not taken.
|
113 | subTree = ctx->children.at(i); |
| 1437 |
1/2✓ Branch 35 → 36 taken 113 times.
✗ Branch 35 → 37 not taken.
|
113 | terminal = dynamic_cast<TerminalNode *>(subTree); |
| 1438 | 113 | bool hasSize = false; | |
| 1439 | 113 | unsigned int hardCodedSize = 0; | |
| 1440 | 113 | std::string sizeVarName; | |
| 1441 |
4/6✓ Branch 39 → 40 taken 113 times.
✗ Branch 39 → 90 not taken.
✓ Branch 40 → 41 taken 113 times.
✗ Branch 40 → 90 not taken.
✓ Branch 41 → 42 taken 53 times.
✓ Branch 41 → 46 taken 60 times.
|
113 | if (terminal->getSymbol()->getType() == SpiceParser::INT_LIT) { |
| 1442 | 53 | hasSize = true; | |
| 1443 |
2/4✓ Branch 42 → 43 taken 53 times.
✗ Branch 42 → 85 not taken.
✓ Branch 43 → 44 taken 53 times.
✗ Branch 43 → 83 not taken.
|
53 | hardCodedSize = std::stoi(terminal->getText()); |
| 1444 | 53 | i++; // Consume INT_LIT | |
| 1445 |
4/6✓ Branch 46 → 47 taken 60 times.
✗ Branch 46 → 90 not taken.
✓ Branch 47 → 48 taken 60 times.
✗ Branch 47 → 90 not taken.
✓ Branch 48 → 49 taken 24 times.
✓ Branch 48 → 53 taken 36 times.
|
60 | } else if (terminal->getSymbol()->getType() == SpiceParser::TYPE_IDENTIFIER) { |
| 1446 | 24 | hasSize = true; | |
| 1447 |
1/2✓ Branch 49 → 50 taken 24 times.
✗ Branch 49 → 86 not taken.
|
24 | sizeVarName = getIdentifier(terminal, true); |
| 1448 | 24 | i++; // Consume TYPE_IDENTIFIER | |
| 1449 | } | ||
| 1450 |
1/2✓ Branch 54 → 55 taken 113 times.
✗ Branch 54 → 87 not taken.
|
113 | dataTypeNode->tmQueue.push({DataTypeNode::TypeModifierType::TYPE_ARRAY, hasSize, hardCodedSize, sizeVarName}); |
| 1451 | 113 | } | |
| 1452 | } | ||
| 1453 | |||
| 1454 |
1/2✓ Branch 67 → 68 taken 54881 times.
✗ Branch 67 → 93 not taken.
|
54881 | return concludeNode(dataTypeNode); |
| 1455 |
1/2✓ Branch 53 → 54 taken 113 times.
✗ Branch 53 → 89 not taken.
|
113 | } |
| 1456 | |||
| 1457 | 54881 | std::any ASTBuilder::visitBaseDataType(SpiceParser::BaseDataTypeContext *ctx) { | |
| 1458 | 54881 | const auto baseDataTypeNode = createNode<BaseDataTypeNode>(ctx); | |
| 1459 | |||
| 1460 | // Enrich | ||
| 1461 |
2/2✓ Branch 4 → 5 taken 642 times.
✓ Branch 4 → 6 taken 54239 times.
|
54881 | if (ctx->TYPE_DOUBLE()) { |
| 1462 | 642 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_DOUBLE; | |
| 1463 |
2/2✓ Branch 7 → 8 taken 3678 times.
✓ Branch 7 → 9 taken 50561 times.
|
54239 | } else if (ctx->TYPE_INT()) { |
| 1464 | 3678 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_INT; | |
| 1465 |
2/2✓ Branch 10 → 11 taken 1237 times.
✓ Branch 10 → 12 taken 49324 times.
|
50561 | } else if (ctx->TYPE_SHORT()) { |
| 1466 | 1237 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_SHORT; | |
| 1467 |
2/2✓ Branch 13 → 14 taken 10493 times.
✓ Branch 13 → 15 taken 38831 times.
|
49324 | } else if (ctx->TYPE_LONG()) { |
| 1468 | 10493 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_LONG; | |
| 1469 |
2/2✓ Branch 16 → 17 taken 2984 times.
✓ Branch 16 → 18 taken 35847 times.
|
38831 | } else if (ctx->TYPE_BYTE()) { |
| 1470 | 2984 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_BYTE; | |
| 1471 |
2/2✓ Branch 19 → 20 taken 5859 times.
✓ Branch 19 → 21 taken 29988 times.
|
35847 | } else if (ctx->TYPE_CHAR()) { |
| 1472 | 5859 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_CHAR; | |
| 1473 |
2/2✓ Branch 22 → 23 taken 4553 times.
✓ Branch 22 → 24 taken 25435 times.
|
29988 | } else if (ctx->TYPE_STRING()) { |
| 1474 | 4553 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_STRING; | |
| 1475 |
2/2✓ Branch 25 → 26 taken 4405 times.
✓ Branch 25 → 27 taken 21030 times.
|
25435 | } else if (ctx->TYPE_BOOL()) { |
| 1476 | 4405 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_BOOL; | |
| 1477 |
2/2✓ Branch 28 → 29 taken 525 times.
✓ Branch 28 → 30 taken 20505 times.
|
21030 | } else if (ctx->TYPE_DYN()) { |
| 1478 | 525 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_DYN; | |
| 1479 |
2/2✓ Branch 31 → 32 taken 20403 times.
✓ Branch 31 → 37 taken 102 times.
|
20505 | } else if (ctx->customDataType()) { |
| 1480 | 20403 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_CUSTOM; | |
| 1481 |
3/6✓ Branch 32 → 33 taken 20403 times.
✗ Branch 32 → 57 not taken.
✓ Branch 33 → 34 taken 20403 times.
✗ Branch 33 → 57 not taken.
✓ Branch 34 → 35 taken 20403 times.
✗ Branch 34 → 55 not taken.
|
20403 | baseDataTypeNode->customDataType = std::any_cast<CustomDataTypeNode *>(visit(ctx->customDataType())); |
| 1482 |
1/2✓ Branch 38 → 39 taken 102 times.
✗ Branch 38 → 44 not taken.
|
102 | } else if (ctx->functionDataType()) { |
| 1483 | 102 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_FUNCTION; | |
| 1484 |
3/6✓ Branch 39 → 40 taken 102 times.
✗ Branch 39 → 60 not taken.
✓ Branch 40 → 41 taken 102 times.
✗ Branch 40 → 60 not taken.
✓ Branch 41 → 42 taken 102 times.
✗ Branch 41 → 58 not taken.
|
102 | baseDataTypeNode->functionDataType = std::any_cast<FunctionDataTypeNode *>(visit(ctx->functionDataType())); |
| 1485 | } else { | ||
| 1486 | ✗ | assert_fail("Unknown base data type"); | |
| 1487 | } | ||
| 1488 | |||
| 1489 |
1/2✓ Branch 51 → 52 taken 54881 times.
✗ Branch 51 → 61 not taken.
|
54881 | return concludeNode(baseDataTypeNode); |
| 1490 | } | ||
| 1491 | |||
| 1492 | 20403 | std::any ASTBuilder::visitCustomDataType(SpiceParser::CustomDataTypeContext *ctx) { | |
| 1493 |
1/2✓ Branch 2 → 3 taken 20403 times.
✗ Branch 2 → 67 not taken.
|
20403 | const auto customDataTypeNode = createNode<CustomDataTypeNode>(ctx); |
| 1494 | |||
| 1495 | // Enrich | ||
| 1496 |
1/2✓ Branch 3 → 4 taken 20403 times.
✗ Branch 3 → 67 not taken.
|
20403 | std::stringstream fqTypeName; |
| 1497 |
2/2✓ Branch 31 → 6 taken 29322 times.
✓ Branch 31 → 32 taken 20403 times.
|
49725 | for (ParserRuleContext::ParseTree *subTree : ctx->children) { |
| 1498 |
1/2✓ Branch 7 → 8 taken 29322 times.
✗ Branch 7 → 9 not taken.
|
29322 | const auto terminal = dynamic_cast<TerminalNode *>(subTree); |
| 1499 |
2/2✓ Branch 10 → 11 taken 2955 times.
✓ Branch 10 → 12 taken 26367 times.
|
29322 | if (!terminal) |
| 1500 | 2955 | continue; | |
| 1501 | |||
| 1502 |
4/6✓ Branch 12 → 13 taken 26367 times.
✗ Branch 12 → 59 not taken.
✓ Branch 13 → 14 taken 26367 times.
✗ Branch 13 → 59 not taken.
✓ Branch 14 → 15 taken 27 times.
✓ Branch 14 → 21 taken 26340 times.
|
26367 | if (terminal->getSymbol()->getType() == SpiceParser::IDENTIFIER) { |
| 1503 |
1/2✓ Branch 15 → 16 taken 27 times.
✗ Branch 15 → 55 not taken.
|
27 | const std::string fragment = terminal->toString(); |
| 1504 |
1/2✓ Branch 16 → 17 taken 27 times.
✗ Branch 16 → 53 not taken.
|
27 | customDataTypeNode->typeNameFragments.push_back(fragment); |
| 1505 |
2/4✓ Branch 17 → 18 taken 27 times.
✗ Branch 17 → 53 not taken.
✓ Branch 18 → 19 taken 27 times.
✗ Branch 18 → 53 not taken.
|
27 | fqTypeName << fragment << SCOPE_ACCESS_TOKEN; |
| 1506 |
4/6✓ Branch 21 → 22 taken 26340 times.
✗ Branch 21 → 59 not taken.
✓ Branch 22 → 23 taken 26340 times.
✗ Branch 22 → 59 not taken.
✓ Branch 23 → 24 taken 20403 times.
✓ Branch 23 → 29 taken 5937 times.
|
26367 | } else if (terminal->getSymbol()->getType() == SpiceParser::TYPE_IDENTIFIER) { |
| 1507 |
1/2✓ Branch 24 → 25 taken 20403 times.
✗ Branch 24 → 58 not taken.
|
20403 | const std::string fragment = terminal->toString(); |
| 1508 |
1/2✓ Branch 25 → 26 taken 20403 times.
✗ Branch 25 → 56 not taken.
|
20403 | customDataTypeNode->typeNameFragments.push_back(fragment); |
| 1509 |
1/2✓ Branch 26 → 27 taken 20403 times.
✗ Branch 26 → 56 not taken.
|
20403 | fqTypeName << fragment; |
| 1510 | 20403 | } | |
| 1511 | } | ||
| 1512 |
1/2✓ Branch 32 → 33 taken 20403 times.
✗ Branch 32 → 60 not taken.
|
20403 | customDataTypeNode->fqTypeName = fqTypeName.str(); |
| 1513 | |||
| 1514 | // Visit children | ||
| 1515 |
3/4✓ Branch 35 → 36 taken 20403 times.
✗ Branch 35 → 65 not taken.
✓ Branch 36 → 37 taken 2955 times.
✓ Branch 36 → 42 taken 17448 times.
|
20403 | if (ctx->typeLst()) |
| 1516 |
3/6✓ Branch 37 → 38 taken 2955 times.
✗ Branch 37 → 63 not taken.
✓ Branch 38 → 39 taken 2955 times.
✗ Branch 38 → 63 not taken.
✓ Branch 39 → 40 taken 2955 times.
✗ Branch 39 → 61 not taken.
|
2955 | customDataTypeNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst())); |
| 1517 | |||
| 1518 |
1/2✓ Branch 48 → 49 taken 20403 times.
✗ Branch 48 → 64 not taken.
|
40806 | return concludeNode(customDataTypeNode); |
| 1519 | 20403 | } | |
| 1520 | |||
| 1521 | 102 | std::any ASTBuilder::visitFunctionDataType(SpiceParser::FunctionDataTypeContext *ctx) { | |
| 1522 | 102 | const auto functionDataTypeNode = createNode<FunctionDataTypeNode>(ctx); | |
| 1523 | |||
| 1524 | // Enrich | ||
| 1525 |
2/2✓ Branch 4 → 5 taken 32 times.
✓ Branch 4 → 11 taken 70 times.
|
102 | if (ctx->dataType()) { |
| 1526 | 32 | functionDataTypeNode->isFunction = ctx->dataType(); | |
| 1527 |
3/6✓ Branch 6 → 7 taken 32 times.
✗ Branch 6 → 30 not taken.
✓ Branch 7 → 8 taken 32 times.
✗ Branch 7 → 30 not taken.
✓ Branch 8 → 9 taken 32 times.
✗ Branch 8 → 28 not taken.
|
32 | functionDataTypeNode->returnType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
| 1528 | } | ||
| 1529 |
2/2✓ Branch 12 → 13 taken 72 times.
✓ Branch 12 → 18 taken 30 times.
|
102 | if (ctx->typeLst()) |
| 1530 |
3/6✓ Branch 13 → 14 taken 72 times.
✗ Branch 13 → 33 not taken.
✓ Branch 14 → 15 taken 72 times.
✗ Branch 14 → 33 not taken.
✓ Branch 15 → 16 taken 72 times.
✗ Branch 15 → 31 not taken.
|
72 | functionDataTypeNode->paramTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst())); |
| 1531 | |||
| 1532 |
1/2✓ Branch 24 → 25 taken 102 times.
✗ Branch 24 → 34 not taken.
|
102 | return concludeNode(functionDataTypeNode); |
| 1533 | } | ||
| 1534 | |||
| 1535 | 8955 | std::any ASTBuilder::visitAssignOp(SpiceParser::AssignOpContext *ctx) { | |
| 1536 | 8955 | const auto assignExprNode = resumeForExpansion<AssignExprNode>(); | |
| 1537 | |||
| 1538 | // Extract assign operator | ||
| 1539 |
2/2✓ Branch 13 → 14 taken 7971 times.
✓ Branch 13 → 15 taken 984 times.
|
8955 | if (ctx->ASSIGN()) |
| 1540 | 7971 | assignExprNode->op = AssignExprNode::AssignOp::OP_ASSIGN; | |
| 1541 |
2/2✓ Branch 16 → 17 taken 420 times.
✓ Branch 16 → 18 taken 564 times.
|
984 | else if (ctx->PLUS_EQUAL()) |
| 1542 | 420 | assignExprNode->op = AssignExprNode::AssignOp::OP_PLUS_EQUAL; | |
| 1543 |
2/2✓ Branch 19 → 20 taken 72 times.
✓ Branch 19 → 21 taken 492 times.
|
564 | else if (ctx->MINUS_EQUAL()) |
| 1544 | 72 | assignExprNode->op = AssignExprNode::AssignOp::OP_MINUS_EQUAL; | |
| 1545 |
2/2✓ Branch 22 → 23 taken 49 times.
✓ Branch 22 → 24 taken 443 times.
|
492 | else if (ctx->MUL_EQUAL()) |
| 1546 | 49 | assignExprNode->op = AssignExprNode::AssignOp::OP_MUL_EQUAL; | |
| 1547 |
2/2✓ Branch 25 → 26 taken 44 times.
✓ Branch 25 → 27 taken 399 times.
|
443 | else if (ctx->DIV_EQUAL()) |
| 1548 | 44 | assignExprNode->op = AssignExprNode::AssignOp::OP_DIV_EQUAL; | |
| 1549 |
2/2✓ Branch 28 → 29 taken 8 times.
✓ Branch 28 → 30 taken 391 times.
|
399 | else if (ctx->REM_EQUAL()) |
| 1550 | 8 | assignExprNode->op = AssignExprNode::AssignOp::OP_REM_EQUAL; | |
| 1551 |
2/2✓ Branch 31 → 32 taken 3 times.
✓ Branch 31 → 33 taken 388 times.
|
391 | else if (ctx->SHL_EQUAL()) |
| 1552 | 3 | assignExprNode->op = AssignExprNode::AssignOp::OP_SHL_EQUAL; | |
| 1553 |
2/2✓ Branch 34 → 35 taken 4 times.
✓ Branch 34 → 36 taken 384 times.
|
388 | else if (ctx->SHR_EQUAL()) |
| 1554 | 4 | assignExprNode->op = AssignExprNode::AssignOp::OP_SHR_EQUAL; | |
| 1555 |
2/2✓ Branch 37 → 38 taken 2 times.
✓ Branch 37 → 39 taken 382 times.
|
384 | else if (ctx->AND_EQUAL()) |
| 1556 | 2 | assignExprNode->op = AssignExprNode::AssignOp::OP_AND_EQUAL; | |
| 1557 |
2/2✓ Branch 40 → 41 taken 2 times.
✓ Branch 40 → 42 taken 380 times.
|
382 | else if (ctx->OR_EQUAL()) |
| 1558 | 2 | assignExprNode->op = AssignExprNode::AssignOp::OP_OR_EQUAL; | |
| 1559 |
1/2✓ Branch 43 → 44 taken 380 times.
✗ Branch 43 → 45 not taken.
|
380 | else if (ctx->XOR_EQUAL()) |
| 1560 | 380 | assignExprNode->op = AssignExprNode::AssignOp::OP_XOR_EQUAL; | |
| 1561 | else | ||
| 1562 | ✗ | assert_fail("Unknown assign operator"); | |
| 1563 | |||
| 1564 |
1/2✓ Branch 46 → 47 taken 8955 times.
✗ Branch 46 → 49 not taken.
|
8955 | return nullptr; |
| 1565 | } | ||
| 1566 | |||
| 1567 | 2066 | std::any ASTBuilder::visitOverloadableOp(SpiceParser::OverloadableOpContext *ctx) { | |
| 1568 | 2066 | const auto fctNameNode = resumeForExpansion<FctNameNode>(); | |
| 1569 | |||
| 1570 | // Enrich | ||
| 1571 |
2/2✓ Branch 13 → 14 taken 103 times.
✓ Branch 13 → 15 taken 1963 times.
|
2066 | if (ctx->PLUS()) |
| 1572 | 103 | fctNameNode->name = OP_FCT_PLUS; | |
| 1573 |
2/2✓ Branch 16 → 17 taken 1 time.
✓ Branch 16 → 18 taken 1962 times.
|
1963 | else if (ctx->MINUS()) |
| 1574 | 1 | fctNameNode->name = OP_FCT_MINUS; | |
| 1575 |
2/2✓ Branch 19 → 20 taken 205 times.
✓ Branch 19 → 21 taken 1757 times.
|
1962 | else if (ctx->MUL()) |
| 1576 | 205 | fctNameNode->name = OP_FCT_MUL; | |
| 1577 |
2/2✓ Branch 22 → 23 taken 22 times.
✓ Branch 22 → 24 taken 1735 times.
|
1757 | else if (ctx->DIV()) |
| 1578 | 22 | fctNameNode->name = OP_FCT_DIV; | |
| 1579 |
2/2✓ Branch 25 → 26 taken 460 times.
✓ Branch 25 → 27 taken 1275 times.
|
1735 | else if (ctx->EQUAL()) |
| 1580 | 460 | fctNameNode->name = OP_FCT_EQUAL; | |
| 1581 |
2/2✓ Branch 28 → 29 taken 456 times.
✓ Branch 28 → 30 taken 819 times.
|
1275 | else if (ctx->NOT_EQUAL()) |
| 1582 | 456 | fctNameNode->name = OP_FCT_NOT_EQUAL; | |
| 1583 |
3/4✓ Branch 30 → 31 taken 819 times.
✗ Branch 30 → 70 not taken.
✓ Branch 33 → 34 taken 16 times.
✓ Branch 33 → 35 taken 803 times.
|
819 | else if (ctx->LESS().size() == 2) |
| 1584 | 16 | fctNameNode->name = OP_FCT_SHL; | |
| 1585 |
3/4✓ Branch 35 → 36 taken 803 times.
✗ Branch 35 → 71 not taken.
✓ Branch 38 → 39 taken 1 time.
✓ Branch 38 → 40 taken 802 times.
|
803 | else if (ctx->GREATER().size() == 2) |
| 1586 | 1 | fctNameNode->name = OP_FCT_SHR; | |
| 1587 |
2/2✓ Branch 41 → 42 taken 146 times.
✓ Branch 41 → 43 taken 656 times.
|
802 | else if (ctx->PLUS_EQUAL()) |
| 1588 | 146 | fctNameNode->name = OP_FCT_PLUS_EQUAL; | |
| 1589 |
2/2✓ Branch 44 → 45 taken 44 times.
✓ Branch 44 → 46 taken 612 times.
|
656 | else if (ctx->MINUS_EQUAL()) |
| 1590 | 44 | fctNameNode->name = OP_FCT_MINUS_EQUAL; | |
| 1591 |
2/2✓ Branch 47 → 48 taken 103 times.
✓ Branch 47 → 49 taken 509 times.
|
612 | else if (ctx->MUL_EQUAL()) |
| 1592 | 103 | fctNameNode->name = OP_FCT_MUL_EQUAL; | |
| 1593 |
2/2✓ Branch 50 → 51 taken 22 times.
✓ Branch 50 → 52 taken 487 times.
|
509 | else if (ctx->DIV_EQUAL()) |
| 1594 | 22 | fctNameNode->name = OP_FCT_DIV_EQUAL; | |
| 1595 |
2/2✓ Branch 53 → 54 taken 55 times.
✓ Branch 53 → 55 taken 432 times.
|
487 | else if (ctx->PLUS_PLUS()) |
| 1596 | 55 | fctNameNode->name = OP_FCT_POSTFIX_PLUS_PLUS; | |
| 1597 |
2/2✓ Branch 56 → 57 taken 44 times.
✓ Branch 56 → 58 taken 388 times.
|
432 | else if (ctx->MINUS_MINUS()) |
| 1598 | 44 | fctNameNode->name = OP_FCT_POSTFIX_MINUS_MINUS; | |
| 1599 |
2/2✓ Branch 59 → 60 taken 257 times.
✓ Branch 59 → 61 taken 131 times.
|
388 | else if (ctx->LBRACKET()) |
| 1600 | 257 | fctNameNode->name = OP_FCT_SUBSCRIPT; | |
| 1601 |
1/2✓ Branch 62 → 63 taken 131 times.
✗ Branch 62 → 64 not taken.
|
131 | else if (ctx->ASSIGN()) |
| 1602 | 131 | fctNameNode->name = OP_FCT_ASSIGN; | |
| 1603 | else | ||
| 1604 | − | assert_fail("Unsupported overloadable operator"); // GCOV_EXCL_LINE | |
| 1605 | |||
| 1606 | 2066 | fctNameNode->fqName = fctNameNode->name; | |
| 1607 | 2066 | fctNameNode->nameFragments.push_back(fctNameNode->name); | |
| 1608 | |||
| 1609 |
1/2✓ Branch 67 → 68 taken 2066 times.
✗ Branch 67 → 72 not taken.
|
2066 | return nullptr; |
| 1610 | } | ||
| 1611 | |||
| 1612 | 5724 | int32_t ASTBuilder::parseInt(TerminalNode *terminal) { | |
| 1613 | 11448 | const NumericParserCallback<int32_t> cb = [](const std::string &substr, short base, bool isSigned) -> int32_t { | |
| 1614 | // Prepare limits | ||
| 1615 |
2/2✓ Branch 2 → 3 taken 5716 times.
✓ Branch 2 → 4 taken 8 times.
|
5724 | const int64_t upperLimit = isSigned ? INT32_MAX : UINT32_MAX; |
| 1616 |
2/2✓ Branch 5 → 6 taken 5716 times.
✓ Branch 5 → 7 taken 8 times.
|
5724 | const int64_t lowerLimit = isSigned ? INT32_MIN : 0; |
| 1617 | // Parse number and check for limits | ||
| 1618 | 5724 | const int64_t number = std::stoll(substr, nullptr, base); | |
| 1619 |
2/4✓ Branch 9 → 10 taken 5723 times.
✗ Branch 9 → 11 not taken.
✗ Branch 10 → 11 not taken.
✓ Branch 10 → 14 taken 5723 times.
|
5723 | if (number < lowerLimit || number > upperLimit) |
| 1620 | ✗ | throw std::out_of_range("Number out of range"); | |
| 1621 | 5723 | return static_cast<int32_t>(number); | |
| 1622 | 5724 | }; | |
| 1623 |
2/2✓ Branch 3 → 4 taken 5723 times.
✓ Branch 3 → 8 taken 1 time.
|
11447 | return parseNumeric(terminal, cb); |
| 1624 | 5724 | } | |
| 1625 | |||
| 1626 | 884 | int16_t ASTBuilder::parseShort(TerminalNode *terminal) { | |
| 1627 | 1768 | const NumericParserCallback<int16_t> cb = [](const std::string &substr, short base, bool isSigned) -> int16_t { | |
| 1628 | // Prepare limits | ||
| 1629 |
2/2✓ Branch 2 → 3 taken 550 times.
✓ Branch 2 → 4 taken 334 times.
|
884 | const int64_t upperLimit = isSigned ? INT16_MAX : UINT16_MAX; |
| 1630 |
2/2✓ Branch 5 → 6 taken 550 times.
✓ Branch 5 → 7 taken 334 times.
|
884 | const int64_t lowerLimit = isSigned ? INT16_MIN : 0; |
| 1631 | // Parse number and check for limits | ||
| 1632 | 884 | const int64_t number = std::stoll(substr, nullptr, base); | |
| 1633 |
2/4✓ Branch 9 → 10 taken 884 times.
✗ Branch 9 → 11 not taken.
✗ Branch 10 → 11 not taken.
✓ Branch 10 → 14 taken 884 times.
|
884 | if (number < lowerLimit || number > upperLimit) |
| 1634 | ✗ | throw std::out_of_range("Number out of range"); | |
| 1635 | 884 | return static_cast<int16_t>(number); | |
| 1636 | 884 | }; | |
| 1637 |
1/2✓ Branch 3 → 4 taken 884 times.
✗ Branch 3 → 8 not taken.
|
1768 | return parseNumeric(terminal, cb); |
| 1638 | 884 | } | |
| 1639 | |||
| 1640 | 7042 | int64_t ASTBuilder::parseLong(TerminalNode *terminal) { | |
| 1641 | 14084 | const NumericParserCallback<int64_t> cb = [](const std::string &substr, short base, bool isSigned) -> int64_t { | |
| 1642 |
2/2✓ Branch 2 → 3 taken 6837 times.
✓ Branch 2 → 5 taken 205 times.
|
7042 | return isSigned ? std::stoll(substr, nullptr, base) : static_cast<int64_t>(std::stoull(substr, nullptr, base)); |
| 1643 | 7042 | }; | |
| 1644 |
1/2✓ Branch 3 → 4 taken 7042 times.
✗ Branch 3 → 8 not taken.
|
14084 | return parseNumeric(terminal, cb); |
| 1645 | 7042 | } | |
| 1646 | |||
| 1647 | 3141 | int8_t ASTBuilder::parseChar(TerminalNode *terminal) const { | |
| 1648 |
1/2✓ Branch 2 → 3 taken 3141 times.
✗ Branch 2 → 59 not taken.
|
3141 | const std::string input = terminal->toString(); |
| 1649 |
2/2✓ Branch 4 → 5 taken 1982 times.
✓ Branch 4 → 7 taken 1159 times.
|
3141 | if (input.length() == 3) // Normal char literals |
| 1650 | 1982 | return input[1]; | |
| 1651 | |||
| 1652 |
3/6✓ Branch 8 → 9 taken 1159 times.
✗ Branch 8 → 12 not taken.
✓ Branch 10 → 11 taken 1159 times.
✗ Branch 10 → 12 not taken.
✓ Branch 13 → 14 taken 1159 times.
✗ Branch 13 → 34 not taken.
|
1159 | if (input.length() == 4 && input[1] == '\\') { // Char literals with escape sequence |
| 1653 |
7/11✓ Branch 15 → 16 taken 5 times.
✗ Branch 15 → 17 not taken.
✓ Branch 15 → 18 taken 11 times.
✓ Branch 15 → 19 taken 120 times.
✓ Branch 15 → 20 taken 102 times.
✓ Branch 15 → 21 taken 102 times.
✗ Branch 15 → 22 not taken.
✗ Branch 15 → 23 not taken.
✗ Branch 15 → 24 not taken.
✓ Branch 15 → 25 taken 818 times.
✓ Branch 15 → 26 taken 1 time.
|
1159 | switch (input[2]) { |
| 1654 | 5 | case '\'': | |
| 1655 | 5 | return '\''; | |
| 1656 | ✗ | case '"': | |
| 1657 | ✗ | return '\"'; | |
| 1658 | 11 | case '\\': | |
| 1659 | 11 | return '\\'; | |
| 1660 | 120 | case 'n': | |
| 1661 | 120 | return '\n'; | |
| 1662 | 102 | case 'r': | |
| 1663 | 102 | return '\r'; | |
| 1664 | 102 | case 't': | |
| 1665 | 102 | return '\t'; | |
| 1666 | ✗ | case 'b': | |
| 1667 | ✗ | return '\b'; | |
| 1668 | ✗ | case 'f': | |
| 1669 | ✗ | return '\f'; | |
| 1670 | ✗ | case 'v': | |
| 1671 | ✗ | return '\v'; | |
| 1672 | 818 | case '0': | |
| 1673 | 818 | return '\0'; | |
| 1674 | 1 | default: | |
| 1675 |
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); |
| 1676 |
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); |
| 1677 | } | ||
| 1678 | } | ||
| 1679 | |||
| 1680 | ✗ | const CodeLoc codeLoc(terminal->getSymbol(), sourceFile); | |
| 1681 | ✗ | throw ParserError(codeLoc, INVALID_CHAR_LITERAL, "Invalid char literal " + input); | |
| 1682 | 3141 | } | |
| 1683 | |||
| 1684 | 3749 | std::string ASTBuilder::parseString(std::string input) { | |
| 1685 |
1/2✓ Branch 3 → 4 taken 3749 times.
✗ Branch 3 → 9 not taken.
|
3749 | input = input.substr(1, input.size() - 2); |
| 1686 | 3749 | replaceEscapeChars(input); | |
| 1687 | 3749 | return input; | |
| 1688 | } | ||
| 1689 | |||
| 1690 | 13650 | template <typename T> T ASTBuilder::parseNumeric(TerminalNode *terminal, const NumericParserCallback<T> &cb) { | |
| 1691 |
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 5724 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 7042 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 884 times.
✗ Branch 2 → 87 not taken.
|
13650 | const std::string input = terminal->toString(); |
| 1692 | |||
| 1693 | // Set to signed if the input string does not end with 'u' | ||
| 1694 |
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 5716 times.
✓ Branch 4 → 9 taken 8 times.
✓ Branch 6 → 7 taken 5716 times.
✗ Branch 6 → 9 not taken.
✗ Branch 8 → 9 not taken.
✓ Branch 8 → 10 taken 5716 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 7042 times.
✗ Branch 4 → 9 not taken.
✓ Branch 6 → 7 taken 7042 times.
✗ Branch 6 → 9 not taken.
✓ Branch 8 → 9 taken 205 times.
✓ Branch 8 → 10 taken 6837 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 884 times.
✗ Branch 4 → 9 not taken.
✓ Branch 6 → 7 taken 550 times.
✓ Branch 6 → 9 taken 334 times.
✗ Branch 8 → 9 not taken.
✓ Branch 8 → 10 taken 550 times.
|
13650 | const bool isUnsigned = input.ends_with('u') || input.ends_with("us") || input.ends_with("ul"); |
| 1695 | |||
| 1696 | try { | ||
| 1697 |
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 965 times.
✓ Branch 12 → 30 taken 4759 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 1710 times.
✓ Branch 12 → 30 taken 5332 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 684 times.
✓ Branch 12 → 30 taken 200 times.
|
13650 | if (input.length() >= 3) { |
| 1698 |
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 219 times.
✓ Branch 14 → 30 taken 746 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 90 times.
✓ Branch 14 → 30 taken 1620 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 121 times.
✓ Branch 14 → 30 taken 563 times.
|
3359 | if (input[0] == '0') { |
| 1699 |
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 219 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 90 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 121 times.
✗ Branch 15 → 37 not taken.
|
430 | const std::string subStr = input.substr(2); |
| 1700 |
5/15int spice::compiler::ASTBuilder::parseNumeric<int>(antlr4::tree::TerminalNode*, std::function<int (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✗ Branch 17 → 18 not taken.
✗ Branch 17 → 20 not taken.
✗ Branch 17 → 22 not taken.
✓ Branch 17 → 24 taken 219 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 43 times.
✗ Branch 17 → 24 not taken.
✓ Branch 17 → 26 taken 47 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 120 times.
✓ Branch 17 → 26 taken 1 time.
|
430 | switch (input[1]) { |
| 1701 | ✗ | case 'd': // fall-through | |
| 1702 | case 'D': | ||
| 1703 | ✗ | return cb(subStr, 10, !isUnsigned); | |
| 1704 | ✗ | case 'b': // fall-through | |
| 1705 | case 'B': | ||
| 1706 | ✗ | return cb(subStr, 2, !isUnsigned); | |
| 1707 | 43 | case 'h': // fall-through | |
| 1708 | case 'H': // fall-through | ||
| 1709 | case 'x': // fall-through | ||
| 1710 | case 'X': | ||
| 1711 |
1/6int spice::compiler::ASTBuilder::parseNumeric<int>(antlr4::tree::TerminalNode*, std::function<int (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✗ Branch 22 → 23 not taken.
✗ Branch 22 → 35 not taken.
long spice::compiler::ASTBuilder::parseNumeric<long>(antlr4::tree::TerminalNode*, std::function<long (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✓ Branch 22 → 23 taken 43 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.
|
43 | return cb(subStr, 16, !isUnsigned); |
| 1712 | 339 | case 'o': // fall-through | |
| 1713 | case 'O': | ||
| 1714 |
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 219 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 120 times.
✗ Branch 24 → 35 not taken.
|
339 | return cb(subStr, 8, !isUnsigned); |
| 1715 | 48 | default: // default is decimal | |
| 1716 |
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 47 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.
|
48 | return cb(input, 10, !isUnsigned); |
| 1717 | } | ||
| 1718 | 430 | } | |
| 1719 | } | ||
| 1720 |
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 5504 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 6952 times.
✗ Branch 30 → 38 not taken.
short spice::compiler::ASTBuilder::parseNumeric<short>(antlr4::tree::TerminalNode*, std::function<short (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✓ Branch 30 → 31 taken 763 times.
✗ Branch 30 → 38 not taken.
|
13220 | return cb(input, 10, !isUnsigned); |
| 1721 |
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 &) { |
| 1722 |
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); |
| 1723 |
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"); |
| 1724 | ✗ | } catch (std::invalid_argument &) { | |
| 1725 | ✗ | const CodeLoc codeLoc(terminal->getSymbol(), sourceFile); | |
| 1726 | ✗ | throw ParserError(codeLoc, NUMBER_OUT_OF_RANGE, "You tried to parse '" + input + "' as an integer, but it was no integer"); | |
| 1727 | } | ||
| 1728 | 13650 | } | |
| 1729 | |||
| 1730 | 3749 | void ASTBuilder::replaceEscapeChars(std::string &input) { | |
| 1731 | const std::unordered_map<char, char> escapeMap = { | ||
| 1732 | {'a', '\a'}, {'b', '\b'}, {'f', '\f'}, {'n', '\n'}, {'r', '\r'}, {'t', '\t'}, | ||
| 1733 | {'v', '\v'}, {'\\', '\\'}, {'?', '\?'}, {'\'', '\''}, {'"', '\"'}, | ||
| 1734 |
1/2✓ Branch 4 → 5 taken 3749 times.
✗ Branch 4 → 40 not taken.
|
7498 | }; |
| 1735 | |||
| 1736 | 3749 | size_t writeIndex = 0; | |
| 1737 | 3749 | size_t readIndex = 0; | |
| 1738 | 3749 | const size_t len = input.length(); | |
| 1739 | |||
| 1740 |
2/2✓ Branch 36 → 8 taken 56863 times.
✓ Branch 36 → 37 taken 3749 times.
|
60612 | while (readIndex < len) { |
| 1741 | 56863 | const char c = input[readIndex]; | |
| 1742 |
3/4✓ Branch 9 → 10 taken 773 times.
✓ Branch 9 → 33 taken 56090 times.
✓ Branch 10 → 11 taken 773 times.
✗ Branch 10 → 33 not taken.
|
56863 | if (c == '\\' && readIndex + 1 < len) { |
| 1743 | 773 | char next = input[readIndex + 1]; | |
| 1744 |
1/2✓ Branch 12 → 13 taken 773 times.
✗ Branch 12 → 45 not taken.
|
773 | auto it = escapeMap.find(next); |
| 1745 |
2/2✓ Branch 15 → 16 taken 764 times.
✓ Branch 15 → 19 taken 9 times.
|
773 | if (it != escapeMap.end()) { |
| 1746 | 764 | input[writeIndex++] = it->second; | |
| 1747 | 764 | readIndex += 2; | |
| 1748 | 770 | continue; | |
| 1749 | } | ||
| 1750 | |||
| 1751 | // Handle octal escape sequences (up to 3 digits) | ||
| 1752 |
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') { |
| 1753 | 6 | int value = 0; | |
| 1754 | 6 | size_t octalDigits = 0; | |
| 1755 | |||
| 1756 | // Look ahead up to 3 digits | ||
| 1757 |
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) { |
| 1758 | 18 | const char oc = input[readIndex + i]; | |
| 1759 |
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') { |
| 1760 | 18 | value = value << 3 | (oc - '0'); // multiply by 8 and add digit | |
| 1761 | 18 | octalDigits++; | |
| 1762 | } else { | ||
| 1763 | break; | ||
| 1764 | } | ||
| 1765 | } | ||
| 1766 | |||
| 1767 |
1/2✓ Branch 28 → 29 taken 6 times.
✗ Branch 28 → 31 not taken.
|
6 | if (octalDigits > 0) { |
| 1768 | 6 | input[writeIndex++] = static_cast<char>(value); | |
| 1769 | 6 | readIndex += 1 + octalDigits; // backslash + octal digits | |
| 1770 | 6 | continue; | |
| 1771 | } | ||
| 1772 | } | ||
| 1773 | } | ||
| 1774 | |||
| 1775 | // Copy current character | ||
| 1776 | 56093 | input[writeIndex++] = c; | |
| 1777 | 56093 | readIndex++; | |
| 1778 | } | ||
| 1779 | |||
| 1780 |
1/2✓ Branch 37 → 38 taken 3749 times.
✗ Branch 37 → 46 not taken.
|
3749 | input.resize(writeIndex); |
| 1781 | 3749 | } | |
| 1782 | |||
| 1783 | 134454 | std::string ASTBuilder::getIdentifier(TerminalNode *terminal, bool isTypeIdentifier) const { | |
| 1784 | 134454 | const std::string identifier = terminal->getText(); | |
| 1785 | |||
| 1786 | // Check if the list of reserved keywords contains the given identifier | ||
| 1787 |
3/4✓ Branch 3 → 4 taken 134454 times.
✗ Branch 3 → 56 not taken.
✓ Branch 6 → 7 taken 1 time.
✓ Branch 6 → 16 taken 134453 times.
|
268908 | if (std::ranges::find(RESERVED_KEYWORDS, identifier) != std::end(RESERVED_KEYWORDS)) { |
| 1788 |
2/4✓ Branch 7 → 8 taken 1 time.
✗ Branch 7 → 45 not taken.
✓ Branch 8 → 9 taken 1 time.
✗ Branch 8 → 45 not taken.
|
1 | const CodeLoc codeLoc(terminal->getSymbol(), sourceFile); |
| 1789 |
3/6✓ Branch 10 → 11 taken 1 time.
✗ Branch 10 → 41 not taken.
✓ Branch 11 → 12 taken 1 time.
✗ Branch 11 → 39 not taken.
✓ Branch 12 → 13 taken 1 time.
✗ Branch 12 → 36 not taken.
|
1 | throw ParserError(codeLoc, RESERVED_KEYWORD, "'" + identifier + "' is a reserved keyword. Please use another name instead"); |
| 1790 | } | ||
| 1791 | |||
| 1792 | // Check if the identifier is a type identifier and is reserved | ||
| 1793 |
6/6✓ Branch 16 → 17 taken 10781 times.
✓ Branch 16 → 23 taken 123672 times.
✓ Branch 17 → 18 taken 484 times.
✓ Branch 17 → 23 taken 10297 times.
✓ Branch 24 → 25 taken 1 time.
✓ Branch 24 → 34 taken 134452 times.
|
134937 | if (isTypeIdentifier && !sourceFile->isStdFile && |
| 1794 |
3/4✓ Branch 18 → 19 taken 484 times.
✗ Branch 18 → 56 not taken.
✓ Branch 21 → 22 taken 1 time.
✓ Branch 21 → 23 taken 483 times.
|
968 | std::ranges::find(RESERVED_TYPE_NAMES, identifier) != std::end(RESERVED_TYPE_NAMES)) { |
| 1795 |
2/4✓ Branch 25 → 26 taken 1 time.
✗ Branch 25 → 55 not taken.
✓ Branch 26 → 27 taken 1 time.
✗ Branch 26 → 55 not taken.
|
1 | const CodeLoc codeLoc(terminal->getSymbol(), sourceFile); |
| 1796 |
3/6✓ Branch 28 → 29 taken 1 time.
✗ Branch 28 → 51 not taken.
✓ Branch 29 → 30 taken 1 time.
✗ Branch 29 → 49 not taken.
✓ Branch 30 → 31 taken 1 time.
✗ Branch 30 → 46 not taken.
|
1 | throw ParserError(codeLoc, RESERVED_TYPENAME, "'" + identifier + "' is a reserved type name. Please use another one instead"); |
| 1797 | } | ||
| 1798 | |||
| 1799 | 134452 | return identifier; | |
| 1800 | 2 | } | |
| 1801 | |||
| 1802 | } // namespace spice::compiler | ||
| 1803 |