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