GCC Code Coverage Report


Directory: ../
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 94.8% 1072 / 16 / 1147
Functions: 100.0% 96 / 0 / 96
Branches: 59.1% 1480 / 4 / 2509

src/ast/ASTBuilder.cpp
Line Branch Exec Source
1 // Copyright (c) 2021-2026 ChilliBits. All rights reserved.
2
3 #include "ASTBuilder.h"
4
5 #include <regex>
6
7 #include <SourceFile.h>
8 #include <ast/ASTNodes.h>
9 #include <ast/Attributes.h>
10 #include <exception/ParserError.h>
11 #include <typechecker/OpRuleManager.h>
12 #include <util/GlobalDefinitions.h>
13
14 namespace spice::compiler {
15
16 1234 ASTBuilder::ASTBuilder(GlobalResourceManager &resourceManager, SourceFile *sourceFile, antlr4::ANTLRInputStream *inputStream)
17
1/2
✓ Branch 4 → 5 taken 1234 times.
✗ Branch 4 → 6 not taken.
1234 : CompilerPass(resourceManager, sourceFile), inputStream(inputStream) {}
18
19 1232 std::any ASTBuilder::visitEntry(SpiceParser::EntryContext *ctx) {
20 1232 const auto entryNode = createNode<EntryNode>(ctx);
21
22 // Visit children
23
2/2
✓ Branch 127 → 5 taken 19264 times.
✓ Branch 127 → 128 taken 1226 times.
20490 for (ParserRuleContext::ParseTree *child : ctx->children) {
24
3/4
✓ Branch 6 → 7 taken 19264 times.
✗ Branch 6 → 8 not taken.
✓ Branch 9 → 10 taken 444 times.
✓ Branch 9 → 15 taken 18820 times.
19264 if (auto *mainFctDefCtx = dynamic_cast<SpiceParser::MainFunctionDefContext *>(child))
25
4/6
✓ Branch 10 → 11 taken 440 times.
✓ Branch 10 → 140 taken 4 times.
✓ Branch 11 → 12 taken 440 times.
✗ Branch 11 → 138 not taken.
✓ Branch 12 → 13 taken 440 times.
✗ Branch 12 → 138 not taken.
444 entryNode->topLevelDefs.push_back(std::any_cast<MainFctDefNode *>(visit(mainFctDefCtx)));
26
3/4
✓ Branch 15 → 16 taken 18820 times.
✗ Branch 15 → 17 not taken.
✓ Branch 18 → 19 taken 8182 times.
✓ Branch 18 → 24 taken 10638 times.
18820 else if (auto *fctDefCtx = dynamic_cast<SpiceParser::FunctionDefContext *>(child))
27
3/6
✓ Branch 19 → 20 taken 8182 times.
✗ Branch 19 → 144 not taken.
✓ Branch 20 → 21 taken 8182 times.
✗ Branch 20 → 142 not taken.
✓ Branch 21 → 22 taken 8182 times.
✗ Branch 21 → 142 not taken.
8182 entryNode->topLevelDefs.push_back(std::any_cast<FctDefNode *>(visit(fctDefCtx)));
28
3/4
✓ Branch 24 → 25 taken 10638 times.
✗ Branch 24 → 26 not taken.
✓ Branch 27 → 28 taken 4217 times.
✓ Branch 27 → 33 taken 6421 times.
10638 else if (auto *procDefCtx = dynamic_cast<SpiceParser::ProcedureDefContext *>(child))
29
3/6
✓ Branch 28 → 29 taken 4217 times.
✗ Branch 28 → 148 not taken.
✓ Branch 29 → 30 taken 4217 times.
✗ Branch 29 → 146 not taken.
✓ Branch 30 → 31 taken 4217 times.
✗ Branch 30 → 146 not taken.
4217 entryNode->topLevelDefs.push_back(std::any_cast<ProcDefNode *>(visit(procDefCtx)));
30
3/4
✓ Branch 33 → 34 taken 6421 times.
✗ Branch 33 → 35 not taken.
✓ Branch 36 → 37 taken 732 times.
✓ Branch 36 → 42 taken 5689 times.
6421 else if (auto *structDefCtx = dynamic_cast<SpiceParser::StructDefContext *>(child))
31
4/6
✓ Branch 37 → 38 taken 731 times.
✓ Branch 37 → 152 taken 1 time.
✓ Branch 38 → 39 taken 731 times.
✗ Branch 38 → 150 not taken.
✓ Branch 39 → 40 taken 731 times.
✗ Branch 39 → 150 not taken.
732 entryNode->topLevelDefs.push_back(std::any_cast<StructDefNode *>(visit(structDefCtx)));
32
3/4
✓ Branch 42 → 43 taken 5689 times.
✗ Branch 42 → 44 not taken.
✓ Branch 45 → 46 taken 107 times.
✓ Branch 45 → 51 taken 5582 times.
5689 else if (auto *interfaceDefCtx = dynamic_cast<SpiceParser::InterfaceDefContext *>(child))
33
3/6
✓ Branch 46 → 47 taken 107 times.
✗ Branch 46 → 156 not taken.
✓ Branch 47 → 48 taken 107 times.
✗ Branch 47 → 154 not taken.
✓ Branch 48 → 49 taken 107 times.
✗ Branch 48 → 154 not taken.
107 entryNode->topLevelDefs.push_back(std::any_cast<InterfaceDefNode *>(visit(interfaceDefCtx)));
34
3/4
✓ Branch 51 → 52 taken 5582 times.
✗ Branch 51 → 53 not taken.
✓ Branch 54 → 55 taken 68 times.
✓ Branch 54 → 60 taken 5514 times.
5582 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 5514 times.
✗ Branch 60 → 62 not taken.
✓ Branch 63 → 64 taken 988 times.
✓ Branch 63 → 69 taken 4526 times.
5514 else if (auto *genericTypeDefCtx = dynamic_cast<SpiceParser::GenericTypeDefContext *>(child))
37
3/6
✓ Branch 64 → 65 taken 988 times.
✗ Branch 64 → 164 not taken.
✓ Branch 65 → 66 taken 988 times.
✗ Branch 65 → 162 not taken.
✓ Branch 66 → 67 taken 988 times.
✗ Branch 66 → 162 not taken.
988 entryNode->topLevelDefs.push_back(std::any_cast<GenericTypeDefNode *>(visit(genericTypeDefCtx)));
38
3/4
✓ Branch 69 → 70 taken 4526 times.
✗ Branch 69 → 71 not taken.
✓ Branch 72 → 73 taken 70 times.
✓ Branch 72 → 78 taken 4456 times.
4526 else if (auto *aliasDefCtx = dynamic_cast<SpiceParser::AliasDefContext *>(child))
39
3/6
✓ Branch 73 → 74 taken 70 times.
✗ Branch 73 → 168 not taken.
✓ Branch 74 → 75 taken 70 times.
✗ Branch 74 → 166 not taken.
✓ Branch 75 → 76 taken 70 times.
✗ Branch 75 → 166 not taken.
70 entryNode->topLevelDefs.push_back(std::any_cast<AliasDefNode *>(visit(aliasDefCtx)));
40
3/4
✓ Branch 78 → 79 taken 4456 times.
✗ Branch 78 → 80 not taken.
✓ Branch 81 → 82 taken 1197 times.
✓ Branch 81 → 87 taken 3259 times.
4456 else if (auto *globalVarDefCtx = dynamic_cast<SpiceParser::GlobalVarDefContext *>(child))
41
3/6
✓ Branch 82 → 83 taken 1197 times.
✗ Branch 82 → 172 not taken.
✓ Branch 83 → 84 taken 1197 times.
✗ Branch 83 → 170 not taken.
✓ Branch 84 → 85 taken 1197 times.
✗ Branch 84 → 170 not taken.
1197 entryNode->topLevelDefs.push_back(std::any_cast<GlobalVarDefNode *>(visit(globalVarDefCtx)));
42
3/4
✓ Branch 87 → 88 taken 3259 times.
✗ Branch 87 → 89 not taken.
✓ Branch 90 → 91 taken 638 times.
✓ Branch 90 → 96 taken 2621 times.
3259 else if (auto *importDefCtx = dynamic_cast<SpiceParser::ImportDefContext *>(child))
43
3/6
✓ Branch 91 → 92 taken 638 times.
✗ Branch 91 → 176 not taken.
✓ Branch 92 → 93 taken 638 times.
✗ Branch 92 → 174 not taken.
✓ Branch 93 → 94 taken 638 times.
✗ Branch 93 → 174 not taken.
638 entryNode->importDefs.push_back(std::any_cast<ImportDefNode *>(visit(importDefCtx)));
44
3/4
✓ Branch 96 → 97 taken 2621 times.
✗ Branch 96 → 98 not taken.
✓ Branch 99 → 100 taken 1028 times.
✓ Branch 99 → 105 taken 1593 times.
2621 else if (auto *extDeclCtx = dynamic_cast<SpiceParser::ExtDeclContext *>(child))
45
3/6
✓ Branch 100 → 101 taken 1028 times.
✗ Branch 100 → 180 not taken.
✓ Branch 101 → 102 taken 1028 times.
✗ Branch 101 → 178 not taken.
✓ Branch 102 → 103 taken 1028 times.
✗ Branch 102 → 178 not taken.
1028 entryNode->topLevelDefs.push_back(std::any_cast<ExtDeclNode *>(visit(extDeclCtx)));
46
3/4
✓ Branch 105 → 106 taken 1593 times.
✗ Branch 105 → 107 not taken.
✓ Branch 108 → 109 taken 367 times.
✓ Branch 108 → 114 taken 1226 times.
1593 else if (auto *modAttrCtx = dynamic_cast<SpiceParser::ModAttrContext *>(child))
47
4/6
✓ Branch 109 → 110 taken 366 times.
✓ Branch 109 → 184 taken 1 time.
✓ Branch 110 → 111 taken 366 times.
✗ Branch 110 → 182 not taken.
✓ Branch 111 → 112 taken 366 times.
✗ Branch 111 → 182 not taken.
367 entryNode->modAttrs.push_back(std::any_cast<ModAttrNode *>(visit(modAttrCtx)));
48
1/2
✓ Branch 114 → 115 taken 1226 times.
✗ Branch 114 → 116 not taken.
1226 else if (const auto *eofCtx = dynamic_cast<TerminalNode *>(child);
49
5/10
✓ Branch 117 → 118 taken 1226 times.
✗ Branch 117 → 121 not taken.
✓ Branch 118 → 119 taken 1226 times.
✗ Branch 118 → 186 not taken.
✓ Branch 119 → 120 taken 1226 times.
✗ Branch 119 → 186 not taken.
✗ Branch 120 → 121 not taken.
✓ Branch 120 → 122 taken 1226 times.
✗ Branch 123 → 124 not taken.
✓ Branch 123 → 125 taken 1226 times.
1226 !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 1226 times.
✗ Branch 134 → 187 not taken.
1226 return concludeNode(entryNode);
54 }
55
56 444 std::any ASTBuilder::visitMainFunctionDef(SpiceParser::MainFunctionDefContext *ctx) {
57 444 const auto mainFctDefNode = createNode<MainFctDefNode>(ctx);
58
59 // Visit children
60
2/2
✓ Branch 4 → 5 taken 1 time.
✓ Branch 4 → 10 taken 443 times.
444 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 440 times.
444 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 444 times.
✗ Branch 17 → 39 not taken.
✓ Branch 18 → 19 taken 440 times.
✓ Branch 18 → 39 taken 4 times.
✓ Branch 19 → 20 taken 440 times.
✗ Branch 19 → 37 not taken.
444 mainFctDefNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst()));
67
68
1/2
✓ Branch 27 → 28 taken 440 times.
✗ Branch 27 → 40 not taken.
440 return concludeNode(mainFctDefNode);
69 }
70
71 8182 std::any ASTBuilder::visitFunctionDef(SpiceParser::FunctionDefContext *ctx) {
72 8182 const auto fctDefNode = createNode<FctDefNode>(ctx);
73
74 // Visit children
75
2/2
✓ Branch 4 → 5 taken 338 times.
✓ Branch 4 → 16 taken 7844 times.
8182 if (ctx->topLevelDefAttr()) {
76
3/6
✓ Branch 5 → 6 taken 338 times.
✗ Branch 5 → 62 not taken.
✓ Branch 6 → 7 taken 338 times.
✗ Branch 6 → 62 not taken.
✓ Branch 7 → 8 taken 338 times.
✗ Branch 7 → 60 not taken.
338 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 343 times.
✓ Branch 14 → 15 taken 338 times.
681 for (AttrNode *attr : fctDefNode->attrs->attrLst->attributes)
79 343 attr->target = AttrNode::TARGET_FCT_PROC;
80 }
81
2/2
✓ Branch 17 → 18 taken 7983 times.
✓ Branch 17 → 23 taken 199 times.
8182 if (ctx->qualifierLst())
82
3/6
✓ Branch 18 → 19 taken 7983 times.
✗ Branch 18 → 65 not taken.
✓ Branch 19 → 20 taken 7983 times.
✗ Branch 19 → 65 not taken.
✓ Branch 20 → 21 taken 7983 times.
✗ Branch 20 → 63 not taken.
7983 fctDefNode->qualifierLst = std::any_cast<QualifierLstNode *>(visit(ctx->qualifierLst()));
83
3/6
✓ Branch 23 → 24 taken 8182 times.
✗ Branch 23 → 68 not taken.
✓ Branch 24 → 25 taken 8182 times.
✗ Branch 24 → 68 not taken.
✓ Branch 25 → 26 taken 8182 times.
✗ Branch 25 → 66 not taken.
8182 fctDefNode->returnType = std::any_cast<DataTypeNode *>(visit(ctx->dataType()));
84 8182 fctDefNode->returnType->isReturnType = true;
85
3/6
✓ Branch 27 → 28 taken 8182 times.
✗ Branch 27 → 71 not taken.
✓ Branch 28 → 29 taken 8182 times.
✗ Branch 28 → 71 not taken.
✓ Branch 29 → 30 taken 8182 times.
✗ Branch 29 → 69 not taken.
8182 fctDefNode->name = std::any_cast<FctNameNode *>(visit(ctx->fctName()));
86 8182 fctDefNode->isMethod = fctDefNode->name->nameFragments.size() > 1;
87
2/2
✓ Branch 33 → 34 taken 1094 times.
✓ Branch 33 → 39 taken 7088 times.
8182 if (ctx->typeLst()) {
88 1094 fctDefNode->hasTemplateTypes = true;
89
3/6
✓ Branch 34 → 35 taken 1094 times.
✗ Branch 34 → 74 not taken.
✓ Branch 35 → 36 taken 1094 times.
✗ Branch 35 → 74 not taken.
✓ Branch 36 → 37 taken 1094 times.
✗ Branch 36 → 72 not taken.
1094 fctDefNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst()));
90 }
91
2/2
✓ Branch 40 → 41 taken 6321 times.
✓ Branch 40 → 46 taken 1861 times.
8182 if (ctx->paramLst()) {
92 6321 fctDefNode->hasParams = true;
93
3/6
✓ Branch 41 → 42 taken 6321 times.
✗ Branch 41 → 77 not taken.
✓ Branch 42 → 43 taken 6321 times.
✗ Branch 42 → 77 not taken.
✓ Branch 43 → 44 taken 6321 times.
✗ Branch 43 → 75 not taken.
6321 fctDefNode->paramLst = std::any_cast<ParamLstNode *>(visit(ctx->paramLst()));
94 }
95
3/6
✓ Branch 46 → 47 taken 8182 times.
✗ Branch 46 → 80 not taken.
✓ Branch 47 → 48 taken 8182 times.
✗ Branch 47 → 80 not taken.
✓ Branch 48 → 49 taken 8182 times.
✗ Branch 48 → 78 not taken.
8182 fctDefNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst()));
96
97
1/2
✓ Branch 56 → 57 taken 8182 times.
✗ Branch 56 → 81 not taken.
8182 return concludeNode(fctDefNode);
98 }
99
100 4217 std::any ASTBuilder::visitProcedureDef(SpiceParser::ProcedureDefContext *ctx) {
101 4217 const auto procDefNode = createNode<ProcDefNode>(ctx);
102
103 // Visit children
104
2/2
✓ Branch 4 → 5 taken 1 time.
✓ Branch 4 → 16 taken 4216 times.
4217 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 3647 times.
✓ Branch 17 → 23 taken 570 times.
4217 if (ctx->qualifierLst())
111
3/6
✓ Branch 18 → 19 taken 3647 times.
✗ Branch 18 → 61 not taken.
✓ Branch 19 → 20 taken 3647 times.
✗ Branch 19 → 61 not taken.
✓ Branch 20 → 21 taken 3647 times.
✗ Branch 20 → 59 not taken.
3647 procDefNode->qualifierLst = std::any_cast<QualifierLstNode *>(visit(ctx->qualifierLst()));
112
3/6
✓ Branch 23 → 24 taken 4217 times.
✗ Branch 23 → 64 not taken.
✓ Branch 24 → 25 taken 4217 times.
✗ Branch 24 → 64 not taken.
✓ Branch 25 → 26 taken 4217 times.
✗ Branch 25 → 62 not taken.
4217 procDefNode->name = std::any_cast<FctNameNode *>(visit(ctx->fctName()));
113 4217 procDefNode->isMethod = procDefNode->name->nameFragments.size() > 1;
114
2/2
✓ Branch 29 → 30 taken 1186 times.
✓ Branch 29 → 35 taken 3031 times.
4217 if (ctx->typeLst()) {
115 1186 procDefNode->hasTemplateTypes = true;
116
3/6
✓ Branch 30 → 31 taken 1186 times.
✗ Branch 30 → 67 not taken.
✓ Branch 31 → 32 taken 1186 times.
✗ Branch 31 → 67 not taken.
✓ Branch 32 → 33 taken 1186 times.
✗ Branch 32 → 65 not taken.
1186 procDefNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst()));
117 }
118
2/2
✓ Branch 36 → 37 taken 3121 times.
✓ Branch 36 → 42 taken 1096 times.
4217 if (ctx->paramLst()) {
119 3121 procDefNode->hasParams = true;
120
3/6
✓ Branch 37 → 38 taken 3121 times.
✗ Branch 37 → 70 not taken.
✓ Branch 38 → 39 taken 3121 times.
✗ Branch 38 → 70 not taken.
✓ Branch 39 → 40 taken 3121 times.
✗ Branch 39 → 68 not taken.
3121 procDefNode->paramLst = std::any_cast<ParamLstNode *>(visit(ctx->paramLst()));
121 }
122
3/6
✓ Branch 42 → 43 taken 4217 times.
✗ Branch 42 → 73 not taken.
✓ Branch 43 → 44 taken 4217 times.
✗ Branch 43 → 73 not taken.
✓ Branch 44 → 45 taken 4217 times.
✗ Branch 44 → 71 not taken.
4217 procDefNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst()));
123
124
1/2
✓ Branch 52 → 53 taken 4217 times.
✗ Branch 52 → 74 not taken.
4217 return concludeNode(procDefNode);
125 }
126
127 12399 std::any ASTBuilder::visitFctName(SpiceParser::FctNameContext *ctx) {
128 12399 const auto fctNameNode = createNode<FctNameNode>(ctx);
129
130 // Extract function name
131
2/2
✓ Branch 4 → 5 taken 6745 times.
✓ Branch 4 → 14 taken 5654 times.
12399 if (ctx->TYPE_IDENTIFIER()) {
132
2/4
✓ Branch 5 → 6 taken 6745 times.
✗ Branch 5 → 42 not taken.
✓ Branch 6 → 7 taken 6745 times.
✗ Branch 6 → 42 not taken.
6745 const std::string typeIdentifier = getIdentifier(ctx->TYPE_IDENTIFIER(), true);
133
1/2
✓ Branch 7 → 8 taken 6745 times.
✗ Branch 7 → 40 not taken.
6745 fctNameNode->structName = typeIdentifier;
134
1/2
✓ Branch 8 → 9 taken 6745 times.
✗ Branch 8 → 39 not taken.
6745 fctNameNode->fqName = typeIdentifier + MEMBER_ACCESS_TOKEN;
135
1/2
✓ Branch 11 → 12 taken 6745 times.
✗ Branch 11 → 40 not taken.
6745 fctNameNode->nameFragments.push_back(typeIdentifier);
136 6745 }
137
2/2
✓ Branch 15 → 16 taken 10568 times.
✓ Branch 15 → 23 taken 1831 times.
12399 if (ctx->IDENTIFIER()) {
138
2/4
✓ Branch 16 → 17 taken 10568 times.
✗ Branch 16 → 45 not taken.
✓ Branch 17 → 18 taken 10568 times.
✗ Branch 17 → 45 not taken.
10568 const std::string fctIdentifier = getIdentifier(ctx->IDENTIFIER(), false);
139
1/2
✓ Branch 18 → 19 taken 10568 times.
✗ Branch 18 → 43 not taken.
10568 fctNameNode->name = fctIdentifier;
140
1/2
✓ Branch 19 → 20 taken 10568 times.
✗ Branch 19 → 43 not taken.
10568 fctNameNode->fqName += fctIdentifier;
141
1/2
✓ Branch 20 → 21 taken 10568 times.
✗ Branch 20 → 43 not taken.
10568 fctNameNode->nameFragments.push_back(fctIdentifier);
142 10568 }
143
144 // Visit children
145
2/2
✓ Branch 24 → 25 taken 1831 times.
✓ Branch 24 → 29 taken 10568 times.
12399 if (ctx->overloadableOp())
146
2/4
✓ Branch 25 → 26 taken 1831 times.
✗ Branch 25 → 46 not taken.
✓ Branch 26 → 27 taken 1831 times.
✗ Branch 26 → 46 not taken.
1831 visit(ctx->overloadableOp());
147
148
1/2
✓ Branch 35 → 36 taken 12399 times.
✗ Branch 35 → 47 not taken.
12399 return concludeNode(fctNameNode);
149 }
150
151 732 std::any ASTBuilder::visitStructDef(SpiceParser::StructDefContext *ctx) {
152 732 const auto structDefNode = createNode<StructDefNode>(ctx);
153
154 // Enrich
155
3/4
✓ Branch 3 → 4 taken 732 times.
✗ Branch 3 → 87 not taken.
✓ Branch 4 → 5 taken 731 times.
✓ Branch 4 → 87 taken 1 time.
732 structDefNode->structName = getIdentifier(ctx->TYPE_IDENTIFIER(), true);
156 731 structDefNode->typeId = resourceManager.getNextCustomTypeId();
157
158 // Visit children
159
2/2
✓ Branch 9 → 10 taken 65 times.
✓ Branch 9 → 41 taken 666 times.
731 if (ctx->topLevelDefAttr()) {
160
3/6
✓ Branch 10 → 11 taken 65 times.
✗ Branch 10 → 90 not taken.
✓ Branch 11 → 12 taken 65 times.
✗ Branch 11 → 90 not taken.
✓ Branch 12 → 13 taken 65 times.
✗ Branch 12 → 88 not taken.
65 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 65 times.
✓ Branch 19 → 20 taken 65 times.
130 for (AttrNode *attr : structDefNode->attrs->attrLst->attributes)
164 65 attr->target = AttrNode::TARGET_STRUCT;
165
166 // Check if a custom type id was set
167
7/18
✓ Branch 20 → 21 taken 65 times.
✗ Branch 20 → 27 not taken.
✓ Branch 23 → 24 taken 65 times.
✗ Branch 23 → 91 not taken.
✓ Branch 24 → 25 taken 65 times.
✗ Branch 24 → 91 not taken.
✗ Branch 25 → 26 not taken.
✓ Branch 25 → 27 taken 65 times.
✓ Branch 28 → 29 taken 65 times.
✗ Branch 28 → 30 not taken.
✓ Branch 30 → 31 taken 65 times.
✗ Branch 30 → 33 not taken.
✗ Branch 33 → 34 not taken.
✓ Branch 33 → 41 taken 65 times.
✗ Branch 91 → 92 not taken.
✗ Branch 91 → 93 not taken.
✗ Branch 95 → 96 not taken.
✗ Branch 95 → 98 not taken.
195 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 565 times.
✓ Branch 42 → 48 taken 166 times.
731 if (ctx->qualifierLst())
171
3/6
✓ Branch 43 → 44 taken 565 times.
✗ Branch 43 → 108 not taken.
✓ Branch 44 → 45 taken 565 times.
✗ Branch 44 → 108 not taken.
✓ Branch 45 → 46 taken 565 times.
✗ Branch 45 → 106 not taken.
565 structDefNode->qualifierLst = std::any_cast<QualifierLstNode *>(visit(ctx->qualifierLst()));
172
2/2
✓ Branch 49 → 50 taken 255 times.
✓ Branch 49 → 55 taken 476 times.
731 if (ctx->LESS()) {
173 255 structDefNode->hasTemplateTypes = true;
174
3/6
✓ Branch 50 → 51 taken 255 times.
✗ Branch 50 → 111 not taken.
✓ Branch 51 → 52 taken 255 times.
✗ Branch 51 → 111 not taken.
✓ Branch 52 → 53 taken 255 times.
✗ Branch 52 → 109 not taken.
255 structDefNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst(0)));
175 }
176
2/2
✓ Branch 56 → 57 taken 142 times.
✓ Branch 56 → 65 taken 589 times.
731 if (ctx->COLON()) {
177 142 structDefNode->hasInterfaces = true;
178
5/8
✓ Branch 57 → 58 taken 119 times.
✓ Branch 57 → 59 taken 23 times.
✓ Branch 60 → 61 taken 142 times.
✗ Branch 60 → 114 not taken.
✓ Branch 61 → 62 taken 142 times.
✗ Branch 61 → 114 not taken.
✓ Branch 62 → 63 taken 142 times.
✗ Branch 62 → 112 not taken.
142 structDefNode->interfaceTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst(structDefNode->hasTemplateTypes ? 1 : 0)));
179 }
180
3/4
✓ Branch 65 → 66 taken 731 times.
✗ Branch 65 → 121 not taken.
✓ Branch 75 → 68 taken 1548 times.
✓ Branch 75 → 76 taken 731 times.
2279 for (SpiceParser::FieldContext *field : ctx->field())
181
3/6
✓ Branch 69 → 70 taken 1548 times.
✗ Branch 69 → 117 not taken.
✓ Branch 70 → 71 taken 1548 times.
✗ Branch 70 → 115 not taken.
✓ Branch 71 → 72 taken 1548 times.
✗ Branch 71 → 115 not taken.
2279 structDefNode->fields.push_back(std::any_cast<FieldNode *>(visit(field)));
182
183
1/2
✓ Branch 83 → 84 taken 731 times.
✗ Branch 83 → 122 not taken.
731 return concludeNode(structDefNode);
184 }
185
186 107 std::any ASTBuilder::visitInterfaceDef(SpiceParser::InterfaceDefContext *ctx) {
187 107 const auto interfaceDefNode = createNode<InterfaceDefNode>(ctx);
188
189 // Enrich
190
2/4
✓ Branch 3 → 4 taken 107 times.
✗ Branch 3 → 77 not taken.
✓ Branch 4 → 5 taken 107 times.
✗ Branch 4 → 77 not taken.
107 interfaceDefNode->interfaceName = getIdentifier(ctx->TYPE_IDENTIFIER(), true);
191 107 interfaceDefNode->typeId = resourceManager.getNextCustomTypeId();
192
193 // Visit children
194
2/2
✓ Branch 9 → 10 taken 77 times.
✓ Branch 9 → 41 taken 30 times.
107 if (ctx->topLevelDefAttr()) {
195
3/6
✓ Branch 10 → 11 taken 77 times.
✗ Branch 10 → 80 not taken.
✓ Branch 11 → 12 taken 77 times.
✗ Branch 11 → 80 not taken.
✓ Branch 12 → 13 taken 77 times.
✗ Branch 12 → 78 not taken.
77 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 77 times.
✓ Branch 19 → 20 taken 77 times.
154 for (AttrNode *attr : interfaceDefNode->attrs->attrLst->attributes)
199 77 attr->target = AttrNode::TARGET_INTERFACE;
200
201 // Check if a custom type id was set
202
7/18
✓ Branch 20 → 21 taken 77 times.
✗ Branch 20 → 27 not taken.
✓ Branch 23 → 24 taken 77 times.
✗ Branch 23 → 81 not taken.
✓ Branch 24 → 25 taken 77 times.
✗ Branch 24 → 81 not taken.
✓ Branch 25 → 26 taken 77 times.
✗ Branch 25 → 27 not taken.
✓ Branch 28 → 29 taken 77 times.
✗ Branch 28 → 30 not taken.
✓ Branch 30 → 31 taken 77 times.
✗ Branch 30 → 33 not taken.
✓ Branch 33 → 34 taken 77 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.
231 if (interfaceDefNode->attrs && interfaceDefNode->attrs->attrLst->hasAttr(ATTR_CORE_COMPILER_FIXED_TYPE_ID))
203
2/4
✓ Branch 36 → 37 taken 77 times.
✗ Branch 36 → 92 not taken.
✓ Branch 37 → 38 taken 77 times.
✗ Branch 37 → 90 not taken.
231 interfaceDefNode->typeId = interfaceDefNode->attrs->attrLst->getAttrValueByName(ATTR_CORE_COMPILER_FIXED_TYPE_ID)->intValue;
204 }
205
2/2
✓ Branch 42 → 43 taken 89 times.
✓ Branch 42 → 48 taken 18 times.
107 if (ctx->qualifierLst())
206
3/6
✓ Branch 43 → 44 taken 89 times.
✗ Branch 43 → 98 not taken.
✓ Branch 44 → 45 taken 89 times.
✗ Branch 44 → 98 not taken.
✓ Branch 45 → 46 taken 89 times.
✗ Branch 45 → 96 not taken.
89 interfaceDefNode->qualifierLst = std::any_cast<QualifierLstNode *>(visit(ctx->qualifierLst()));
207
2/2
✓ Branch 49 → 50 taken 80 times.
✓ Branch 49 → 55 taken 27 times.
107 if (ctx->LESS()) {
208 80 interfaceDefNode->hasTemplateTypes = true;
209
3/6
✓ Branch 50 → 51 taken 80 times.
✗ Branch 50 → 101 not taken.
✓ Branch 51 → 52 taken 80 times.
✗ Branch 51 → 101 not taken.
✓ Branch 52 → 53 taken 80 times.
✗ Branch 52 → 99 not taken.
80 interfaceDefNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst()));
210 }
211
3/4
✓ Branch 55 → 56 taken 107 times.
✗ Branch 55 → 108 not taken.
✓ Branch 65 → 58 taken 243 times.
✓ Branch 65 → 66 taken 107 times.
350 for (SpiceParser::SignatureContext *signature : ctx->signature())
212
3/6
✓ Branch 59 → 60 taken 243 times.
✗ Branch 59 → 104 not taken.
✓ Branch 60 → 61 taken 243 times.
✗ Branch 60 → 102 not taken.
✓ Branch 61 → 62 taken 243 times.
✗ Branch 61 → 102 not taken.
350 interfaceDefNode->signatures.push_back(std::any_cast<SignatureNode *>(visit(signature)));
213
214
1/2
✓ Branch 73 → 74 taken 107 times.
✗ Branch 73 → 109 not taken.
107 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 739 times.
✓ Branch 24 → 25 taken 68 times.
807 for (EnumItemNode *enumItem : enumDefNode->itemLst->items)
231 739 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 988 std::any ASTBuilder::visitGenericTypeDef(SpiceParser::GenericTypeDefContext *ctx) {
237 988 const auto genericTypeDefNode = createNode<GenericTypeDefNode>(ctx);
238
239 // Enrich
240
2/4
✓ Branch 3 → 4 taken 988 times.
✗ Branch 3 → 21 not taken.
✓ Branch 4 → 5 taken 988 times.
✗ Branch 4 → 21 not taken.
988 genericTypeDefNode->typeName = getIdentifier(ctx->TYPE_IDENTIFIER(), true);
241
242 // Visit children
243
3/6
✓ Branch 7 → 8 taken 988 times.
✗ Branch 7 → 24 not taken.
✓ Branch 8 → 9 taken 988 times.
✗ Branch 8 → 24 not taken.
✓ Branch 9 → 10 taken 988 times.
✗ Branch 9 → 22 not taken.
988 genericTypeDefNode->typeAltsLst = std::any_cast<TypeAltsLstNode *>(visit(ctx->typeAltsLst()));
244
245
1/2
✓ Branch 17 → 18 taken 988 times.
✗ Branch 17 → 25 not taken.
988 return concludeNode(genericTypeDefNode);
246 }
247
248 70 std::any ASTBuilder::visitAliasDef(SpiceParser::AliasDefContext *ctx) {
249 70 const auto aliasDefNode = createNode<AliasDefNode>(ctx);
250
251 // Enrich
252
2/4
✓ Branch 3 → 4 taken 70 times.
✗ Branch 3 → 33 not taken.
✓ Branch 4 → 5 taken 70 times.
✗ Branch 4 → 33 not taken.
70 aliasDefNode->aliasName = getIdentifier(ctx->TYPE_IDENTIFIER(), true);
253
2/4
✓ Branch 7 → 8 taken 70 times.
✗ Branch 7 → 34 not taken.
✓ Branch 8 → 9 taken 70 times.
✗ Branch 8 → 34 not taken.
70 aliasDefNode->dataTypeString = ctx->dataType()->getText();
254 70 aliasDefNode->typeId = resourceManager.getNextCustomTypeId();
255
256 // Visit children
257
2/2
✓ Branch 13 → 14 taken 21 times.
✓ Branch 13 → 19 taken 49 times.
70 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 70 times.
✗ Branch 19 → 40 not taken.
✓ Branch 20 → 21 taken 70 times.
✗ Branch 20 → 40 not taken.
✓ Branch 21 → 22 taken 70 times.
✗ Branch 21 → 38 not taken.
70 aliasDefNode->dataType = std::any_cast<DataTypeNode *>(visit(ctx->dataType()));
260
261
1/2
✓ Branch 29 → 30 taken 70 times.
✗ Branch 29 → 41 not taken.
70 return concludeNode(aliasDefNode);
262 }
263
264 1197 std::any ASTBuilder::visitGlobalVarDef(SpiceParser::GlobalVarDefContext *ctx) {
265 1197 const auto globalVarDefNode = createNode<GlobalVarDefNode>(ctx);
266
267 // Enrich
268
2/4
✓ Branch 3 → 4 taken 1197 times.
✗ Branch 3 → 28 not taken.
✓ Branch 4 → 5 taken 1197 times.
✗ Branch 4 → 28 not taken.
1197 globalVarDefNode->varName = getIdentifier(ctx->TYPE_IDENTIFIER(), true);
269
270 // Visit children
271
3/6
✓ Branch 7 → 8 taken 1197 times.
✗ Branch 7 → 31 not taken.
✓ Branch 8 → 9 taken 1197 times.
✗ Branch 8 → 31 not taken.
✓ Branch 9 → 10 taken 1197 times.
✗ Branch 9 → 29 not taken.
1197 globalVarDefNode->dataType = std::any_cast<DataTypeNode *>(visit(ctx->dataType()));
272 1197 globalVarDefNode->dataType->isGlobalType = true;
273
2/2
✓ Branch 12 → 13 taken 1195 times.
✓ Branch 12 → 18 taken 2 times.
1197 if (ctx->constant()) {
274 1195 globalVarDefNode->hasValue = true;
275
3/6
✓ Branch 13 → 14 taken 1195 times.
✗ Branch 13 → 34 not taken.
✓ Branch 14 → 15 taken 1195 times.
✗ Branch 14 → 34 not taken.
✓ Branch 15 → 16 taken 1195 times.
✗ Branch 15 → 32 not taken.
1195 globalVarDefNode->constant = std::any_cast<ConstantNode *>(visit(ctx->constant()));
276 }
277
278
1/2
✓ Branch 24 → 25 taken 1197 times.
✗ Branch 24 → 35 not taken.
1197 return concludeNode(globalVarDefNode);
279 }
280
281 1028 std::any ASTBuilder::visitExtDecl(SpiceParser::ExtDeclContext *ctx) {
282 1028 const auto extDeclNode = createNode<ExtDeclNode>(ctx);
283
284 // Enrich
285
6/10
✓ Branch 3 → 4 taken 1028 times.
✗ Branch 3 → 49 not taken.
✓ Branch 4 → 5 taken 776 times.
✓ Branch 4 → 7 taken 252 times.
✓ Branch 5 → 6 taken 776 times.
✗ Branch 5 → 49 not taken.
✓ Branch 7 → 8 taken 252 times.
✗ Branch 7 → 49 not taken.
✓ Branch 9 → 10 taken 1028 times.
✗ Branch 9 → 49 not taken.
1028 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 1027 times.
1028 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 670 times.
✓ Branch 26 → 32 taken 358 times.
1028 if (ctx->F()) {
296
3/6
✓ Branch 27 → 28 taken 670 times.
✗ Branch 27 → 55 not taken.
✓ Branch 28 → 29 taken 670 times.
✗ Branch 28 → 55 not taken.
✓ Branch 29 → 30 taken 670 times.
✗ Branch 29 → 53 not taken.
670 extDeclNode->returnType = std::any_cast<DataTypeNode *>(visit(ctx->dataType()));
297 670 extDeclNode->returnType->isReturnType = true;
298 }
299
2/2
✓ Branch 33 → 34 taken 990 times.
✓ Branch 33 → 39 taken 38 times.
1028 if (ctx->typeLstWithEllipsis()) {
300 990 extDeclNode->hasArgs = true;
301
3/6
✓ Branch 34 → 35 taken 990 times.
✗ Branch 34 → 58 not taken.
✓ Branch 35 → 36 taken 990 times.
✗ Branch 35 → 58 not taken.
✓ Branch 36 → 37 taken 990 times.
✗ Branch 36 → 56 not taken.
990 extDeclNode->argTypeLst = std::any_cast<TypeLstWithEllipsisNode *>(visit(ctx->typeLstWithEllipsis()));
302 }
303
304
1/2
✓ Branch 45 → 46 taken 1028 times.
✗ Branch 45 → 59 not taken.
1028 return concludeNode(extDeclNode);
305 }
306
307 638 std::any ASTBuilder::visitImportDef(SpiceParser::ImportDefContext *ctx) {
308
1/2
✓ Branch 2 → 3 taken 638 times.
✗ Branch 2 → 32 not taken.
638 const auto importDefNode = createNode<ImportDefNode>(ctx);
309
310 // Extract path
311
2/4
✓ Branch 3 → 4 taken 638 times.
✗ Branch 3 → 32 not taken.
✓ Branch 4 → 5 taken 638 times.
✗ Branch 4 → 32 not taken.
638 const std::string pathStr = ctx->STRING_LIT()->getText();
312
1/2
✓ Branch 6 → 7 taken 638 times.
✗ Branch 6 → 27 not taken.
638 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 638 times.
✗ Branch 9 → 28 not taken.
✓ Branch 10 → 11 taken 33 times.
✓ Branch 10 → 13 taken 605 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 605 times.
✗ Branch 13 → 28 not taken.
638 importDefNode->importName = ctx->AS() ? getIdentifier(ctx->IDENTIFIER(), false) : importDefNode->importPath;
316
317
1/2
✓ Branch 22 → 23 taken 638 times.
✗ Branch 22 → 29 not taken.
1276 return concludeNode(importDefNode);
318 638 }
319
320 2689 std::any ASTBuilder::visitUnsafeBlock(SpiceParser::UnsafeBlockContext *ctx) {
321 2689 const auto unsafeBlockDefNode = createNode<UnsafeBlockNode>(ctx);
322
323 // Visit children
324
3/6
✓ Branch 3 → 4 taken 2689 times.
✗ Branch 3 → 19 not taken.
✓ Branch 4 → 5 taken 2689 times.
✗ Branch 4 → 19 not taken.
✓ Branch 5 → 6 taken 2689 times.
✗ Branch 5 → 17 not taken.
2689 unsafeBlockDefNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst()));
325
326
1/2
✓ Branch 13 → 14 taken 2689 times.
✗ Branch 13 → 20 not taken.
2689 return concludeNode(unsafeBlockDefNode);
327 }
328
329 1445 std::any ASTBuilder::visitForLoop(SpiceParser::ForLoopContext *ctx) {
330 1445 const auto forLoopNode = createNode<ForLoopNode>(ctx);
331
332
2/4
✓ Branch 3 → 4 taken 1445 times.
✗ Branch 3 → 20 not taken.
✓ Branch 4 → 5 taken 1445 times.
✗ Branch 4 → 20 not taken.
1445 visit(ctx->forHead());
333
3/6
✓ Branch 6 → 7 taken 1445 times.
✗ Branch 6 → 23 not taken.
✓ Branch 7 → 8 taken 1445 times.
✗ Branch 7 → 23 not taken.
✓ Branch 8 → 9 taken 1445 times.
✗ Branch 8 → 21 not taken.
1445 forLoopNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst()));
334
335
1/2
✓ Branch 16 → 17 taken 1445 times.
✗ Branch 16 → 24 not taken.
1445 return concludeNode(forLoopNode);
336 }
337
338 1445 std::any ASTBuilder::visitForHead(SpiceParser::ForHeadContext *ctx) {
339 1445 const auto forLoopNode = resumeForExpansion<ForLoopNode>();
340
341 // Visit children
342
3/6
✓ Branch 12 → 13 taken 1445 times.
✗ Branch 12 → 29 not taken.
✓ Branch 13 → 14 taken 1445 times.
✗ Branch 13 → 29 not taken.
✓ Branch 14 → 15 taken 1445 times.
✗ Branch 14 → 27 not taken.
1445 forLoopNode->initDecl = std::any_cast<DeclStmtNode *>(visit(ctx->declStmt()));
343
3/6
✓ Branch 16 → 17 taken 1445 times.
✗ Branch 16 → 32 not taken.
✓ Branch 17 → 18 taken 1445 times.
✗ Branch 17 → 32 not taken.
✓ Branch 18 → 19 taken 1445 times.
✗ Branch 18 → 30 not taken.
1445 forLoopNode->condAssign = std::any_cast<AssignExprNode *>(visit(ctx->assignExpr(0)));
344
3/6
✓ Branch 20 → 21 taken 1445 times.
✗ Branch 20 → 35 not taken.
✓ Branch 21 → 22 taken 1445 times.
✗ Branch 21 → 35 not taken.
✓ Branch 22 → 23 taken 1445 times.
✗ Branch 22 → 33 not taken.
1445 forLoopNode->incAssign = std::any_cast<AssignExprNode *>(visit(ctx->assignExpr(1)));
345
346
1/2
✓ Branch 24 → 25 taken 1445 times.
✗ Branch 24 → 36 not taken.
1445 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 821 std::any ASTBuilder::visitWhileLoop(SpiceParser::WhileLoopContext *ctx) {
380 821 const auto whileLoopNode = createNode<WhileLoopNode>(ctx);
381
382 // Visit children
383
3/6
✓ Branch 3 → 4 taken 821 times.
✗ Branch 3 → 23 not taken.
✓ Branch 4 → 5 taken 821 times.
✗ Branch 4 → 23 not taken.
✓ Branch 5 → 6 taken 821 times.
✗ Branch 5 → 21 not taken.
821 whileLoopNode->condition = std::any_cast<AssignExprNode *>(visit(ctx->assignExpr()));
384
3/6
✓ Branch 7 → 8 taken 821 times.
✗ Branch 7 → 26 not taken.
✓ Branch 8 → 9 taken 821 times.
✗ Branch 8 → 26 not taken.
✓ Branch 9 → 10 taken 821 times.
✗ Branch 9 → 24 not taken.
821 whileLoopNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst()));
385
386
1/2
✓ Branch 17 → 18 taken 821 times.
✗ Branch 17 → 27 not taken.
821 return concludeNode(whileLoopNode);
387 }
388
389 8 std::any ASTBuilder::visitDoWhileLoop(SpiceParser::DoWhileLoopContext *ctx) {
390 8 const auto doWhileLoopNode = createNode<DoWhileLoopNode>(ctx);
391
392 // Visit children
393
3/6
✓ Branch 3 → 4 taken 8 times.
✗ Branch 3 → 23 not taken.
✓ Branch 4 → 5 taken 8 times.
✗ Branch 4 → 23 not taken.
✓ Branch 5 → 6 taken 8 times.
✗ Branch 5 → 21 not taken.
8 doWhileLoopNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst()));
394
3/6
✓ Branch 7 → 8 taken 8 times.
✗ Branch 7 → 26 not taken.
✓ Branch 8 → 9 taken 8 times.
✗ Branch 8 → 26 not taken.
✓ Branch 9 → 10 taken 8 times.
✗ Branch 9 → 24 not taken.
8 doWhileLoopNode->condition = std::any_cast<AssignExprNode *>(visit(ctx->assignExpr()));
395
396
1/2
✓ Branch 17 → 18 taken 8 times.
✗ Branch 17 → 27 not taken.
8 return concludeNode(doWhileLoopNode);
397 }
398
399 4374 std::any ASTBuilder::visitIfStmt(SpiceParser::IfStmtContext *ctx) {
400 4374 const auto ifStmtNode = createNode<IfStmtNode>(ctx);
401
402 // Visit children
403
3/6
✓ Branch 3 → 4 taken 4374 times.
✗ Branch 3 → 30 not taken.
✓ Branch 4 → 5 taken 4374 times.
✗ Branch 4 → 30 not taken.
✓ Branch 5 → 6 taken 4374 times.
✗ Branch 5 → 28 not taken.
4374 ifStmtNode->condition = std::any_cast<AssignExprNode *>(visit(ctx->assignExpr()));
404
3/6
✓ Branch 7 → 8 taken 4374 times.
✗ Branch 7 → 33 not taken.
✓ Branch 8 → 9 taken 4374 times.
✗ Branch 8 → 33 not taken.
✓ Branch 9 → 10 taken 4374 times.
✗ Branch 9 → 31 not taken.
4374 ifStmtNode->thenBody = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst()));
405
2/2
✓ Branch 12 → 13 taken 250 times.
✓ Branch 12 → 18 taken 4124 times.
4374 if (ctx->elseStmt())
406
3/6
✓ Branch 13 → 14 taken 250 times.
✗ Branch 13 → 36 not taken.
✓ Branch 14 → 15 taken 250 times.
✗ Branch 14 → 36 not taken.
✓ Branch 15 → 16 taken 250 times.
✗ Branch 15 → 34 not taken.
250 ifStmtNode->elseStmt = std::any_cast<ElseStmtNode *>(visit(ctx->elseStmt()));
407
408
1/2
✓ Branch 24 → 25 taken 4374 times.
✗ Branch 24 → 37 not taken.
4374 return concludeNode(ifStmtNode);
409 }
410
411 250 std::any ASTBuilder::visitElseStmt(SpiceParser::ElseStmtContext *ctx) {
412 250 const auto elseStmtNode = createNode<ElseStmtNode>(ctx);
413
414 // Visit children
415
2/2
✓ Branch 4 → 5 taken 73 times.
✓ Branch 4 → 10 taken 177 times.
250 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 177 times.
✗ Branch 10 → 30 not taken.
✓ Branch 11 → 12 taken 177 times.
✗ Branch 11 → 30 not taken.
✓ Branch 12 → 13 taken 177 times.
✗ Branch 12 → 28 not taken.
177 elseStmtNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst()));
420 }
421
422
1/2
✓ Branch 21 → 22 taken 250 times.
✗ Branch 21 → 31 not taken.
250 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 22608 std::any ASTBuilder::visitStmtLst(SpiceParser::StmtLstContext *ctx) {
468 22608 const auto stmtLstNode = createNode<StmtLstNode>(ctx);
469
470 // Enrich
471
2/4
✓ Branch 3 → 4 taken 22608 times.
✗ Branch 3 → 116 not taken.
✓ Branch 4 → 5 taken 22608 times.
✗ Branch 4 → 116 not taken.
22608 stmtLstNode->closingBraceCodeLoc = CodeLoc(ctx->getStop(), sourceFile);
472
473 // Visit children
474
2/2
✓ Branch 105 → 7 taken 86697 times.
✓ Branch 105 → 106 taken 22604 times.
109301 for (ParserRuleContext::ParseTree *stmt : ctx->children) {
475
3/4
✓ Branch 8 → 9 taken 86697 times.
✗ Branch 8 → 10 not taken.
✓ Branch 11 → 12 taken 31280 times.
✓ Branch 11 → 17 taken 55417 times.
86697 if (auto *stmtCtx = dynamic_cast<SpiceParser::StmtContext *>(stmt))
476
4/6
✓ Branch 12 → 13 taken 31276 times.
✓ Branch 12 → 119 taken 4 times.
✓ Branch 13 → 14 taken 31276 times.
✗ Branch 13 → 117 not taken.
✓ Branch 14 → 15 taken 31276 times.
✗ Branch 14 → 117 not taken.
31280 stmtLstNode->statements.push_back(std::any_cast<StmtNode *>(visit(stmtCtx)));
477
3/4
✓ Branch 17 → 18 taken 55417 times.
✗ Branch 17 → 19 not taken.
✓ Branch 20 → 21 taken 1445 times.
✓ Branch 20 → 26 taken 53972 times.
55417 else if (auto *forLoopCtx = dynamic_cast<SpiceParser::ForLoopContext *>(stmt))
478
3/6
✓ Branch 21 → 22 taken 1445 times.
✗ Branch 21 → 123 not taken.
✓ Branch 22 → 23 taken 1445 times.
✗ Branch 22 → 121 not taken.
✓ Branch 23 → 24 taken 1445 times.
✗ Branch 23 → 121 not taken.
1445 stmtLstNode->statements.push_back(std::any_cast<ForLoopNode *>(visit(forLoopCtx)));
479
3/4
✓ Branch 26 → 27 taken 53972 times.
✗ Branch 26 → 28 not taken.
✓ Branch 29 → 30 taken 124 times.
✓ Branch 29 → 35 taken 53848 times.
53972 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 53848 times.
✗ Branch 35 → 37 not taken.
✓ Branch 38 → 39 taken 821 times.
✓ Branch 38 → 44 taken 53027 times.
53848 else if (auto *whileLoopCtx = dynamic_cast<SpiceParser::WhileLoopContext *>(stmt))
482
3/6
✓ Branch 39 → 40 taken 821 times.
✗ Branch 39 → 131 not taken.
✓ Branch 40 → 41 taken 821 times.
✗ Branch 40 → 129 not taken.
✓ Branch 41 → 42 taken 821 times.
✗ Branch 41 → 129 not taken.
821 stmtLstNode->statements.push_back(std::any_cast<WhileLoopNode *>(visit(whileLoopCtx)));
483
3/4
✓ Branch 44 → 45 taken 53027 times.
✗ Branch 44 → 46 not taken.
✓ Branch 47 → 48 taken 8 times.
✓ Branch 47 → 53 taken 53019 times.
53027 else if (auto *doWhileLoopCtx = dynamic_cast<SpiceParser::DoWhileLoopContext *>(stmt))
484
3/6
✓ Branch 48 → 49 taken 8 times.
✗ Branch 48 → 135 not taken.
✓ Branch 49 → 50 taken 8 times.
✗ Branch 49 → 133 not taken.
✓ Branch 50 → 51 taken 8 times.
✗ Branch 50 → 133 not taken.
8 stmtLstNode->statements.push_back(std::any_cast<DoWhileLoopNode *>(visit(doWhileLoopCtx)));
485
3/4
✓ Branch 53 → 54 taken 53019 times.
✗ Branch 53 → 55 not taken.
✓ Branch 56 → 57 taken 4301 times.
✓ Branch 56 → 62 taken 48718 times.
53019 else if (auto *ifStmtCtx = dynamic_cast<SpiceParser::IfStmtContext *>(stmt))
486
3/6
✓ Branch 57 → 58 taken 4301 times.
✗ Branch 57 → 139 not taken.
✓ Branch 58 → 59 taken 4301 times.
✗ Branch 58 → 137 not taken.
✓ Branch 59 → 60 taken 4301 times.
✗ Branch 59 → 137 not taken.
4301 stmtLstNode->statements.push_back(std::any_cast<IfStmtNode *>(visit(ifStmtCtx)));
487
3/4
✓ Branch 62 → 63 taken 48718 times.
✗ Branch 62 → 64 not taken.
✓ Branch 65 → 66 taken 12 times.
✓ Branch 65 → 71 taken 48706 times.
48718 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 48706 times.
✗ Branch 71 → 73 not taken.
✓ Branch 74 → 75 taken 773 times.
✓ Branch 74 → 80 taken 47933 times.
48706 else if (auto *assetStmtCtx = dynamic_cast<SpiceParser::AssertStmtContext *>(stmt))
490
3/6
✓ Branch 75 → 76 taken 773 times.
✗ Branch 75 → 147 not taken.
✓ Branch 76 → 77 taken 773 times.
✗ Branch 76 → 145 not taken.
✓ Branch 77 → 78 taken 773 times.
✗ Branch 77 → 145 not taken.
773 stmtLstNode->statements.push_back(std::any_cast<AssertStmtNode *>(visit(assetStmtCtx)));
491
3/4
✓ Branch 80 → 81 taken 47933 times.
✗ Branch 80 → 82 not taken.
✓ Branch 83 → 84 taken 2689 times.
✓ Branch 83 → 89 taken 45244 times.
47933 else if (auto *unsafeBlockCtx = dynamic_cast<SpiceParser::UnsafeBlockContext *>(stmt))
492
3/6
✓ Branch 84 → 85 taken 2689 times.
✗ Branch 84 → 151 not taken.
✓ Branch 85 → 86 taken 2689 times.
✗ Branch 85 → 149 not taken.
✓ Branch 86 → 87 taken 2689 times.
✗ Branch 86 → 149 not taken.
2689 stmtLstNode->statements.push_back(std::any_cast<UnsafeBlockNode *>(visit(unsafeBlockCtx)));
493
3/4
✓ Branch 89 → 90 taken 45244 times.
✗ Branch 89 → 91 not taken.
✓ Branch 92 → 93 taken 32 times.
✓ Branch 92 → 98 taken 45212 times.
45244 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 22604 times.
✗ Branch 112 → 158 not taken.
22604 return concludeNode(stmtLstNode);
500 }
501
502 7946 std::any ASTBuilder::visitTypeLst(SpiceParser::TypeLstContext *ctx) {
503 7946 const auto typeLstNode = createNode<TypeLstNode>(ctx);
504
505 // Visit children
506
2/4
✓ Branch 3 → 4 taken 7946 times.
✗ Branch 3 → 18 not taken.
✓ Branch 4 → 5 taken 7946 times.
✗ Branch 4 → 16 not taken.
7946 fetchChildrenIntoVector(typeLstNode->dataTypes, ctx->dataType());
507
508
1/2
✓ Branch 12 → 13 taken 7946 times.
✗ Branch 12 → 19 not taken.
7946 return concludeNode(typeLstNode);
509 }
510
511 990 std::any ASTBuilder::visitTypeLstWithEllipsis(SpiceParser::TypeLstWithEllipsisContext *ctx) {
512 990 const auto typeLstWithEllipsisNode = createNode<TypeLstWithEllipsisNode>(ctx);
513
514 // Visit children
515
3/6
✓ Branch 3 → 4 taken 990 times.
✗ Branch 3 → 20 not taken.
✓ Branch 4 → 5 taken 990 times.
✗ Branch 4 → 20 not taken.
✓ Branch 5 → 6 taken 990 times.
✗ Branch 5 → 18 not taken.
990 typeLstWithEllipsisNode->typeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst()));
516
517 // Set some flags
518 990 typeLstWithEllipsisNode->hasEllipsis = ctx->ELLIPSIS() != nullptr;
519
520
1/2
✓ Branch 14 → 15 taken 990 times.
✗ Branch 14 → 21 not taken.
990 return concludeNode(typeLstWithEllipsisNode);
521 }
522
523 988 std::any ASTBuilder::visitTypeAltsLst(SpiceParser::TypeAltsLstContext *ctx) {
524 988 const auto typeAltsLstNode = createNode<TypeAltsLstNode>(ctx);
525
526 // Visit children
527
2/4
✓ Branch 3 → 4 taken 988 times.
✗ Branch 3 → 18 not taken.
✓ Branch 4 → 5 taken 988 times.
✗ Branch 4 → 16 not taken.
988 fetchChildrenIntoVector(typeAltsLstNode->dataTypes, ctx->dataType());
528
529
1/2
✓ Branch 12 → 13 taken 988 times.
✗ Branch 12 → 19 not taken.
988 return concludeNode(typeAltsLstNode);
530 }
531
532 9470 std::any ASTBuilder::visitParamLst(SpiceParser::ParamLstContext *ctx) {
533 9470 const auto paramLstNode = createNode<ParamLstNode>(ctx);
534
535 // Visit children
536
2/4
✓ Branch 3 → 4 taken 9470 times.
✗ Branch 3 → 24 not taken.
✓ Branch 4 → 5 taken 9470 times.
✗ Branch 4 → 22 not taken.
9470 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 14431 times.
✓ Branch 11 → 12 taken 9470 times.
23901 for (DeclStmtNode *declStmt : paramLstNode->params) {
540 14431 declStmt->isFctParam = true;
541 14431 declStmt->dataType->isParamType = true;
542 }
543
544
1/2
✓ Branch 18 → 19 taken 9470 times.
✗ Branch 18 → 25 not taken.
9470 return concludeNode(paramLstNode);
545 }
546
547 15700 std::any ASTBuilder::visitArgLst(SpiceParser::ArgLstContext *ctx) {
548 15700 const auto argLstNode = createNode<ArgLstNode>(ctx);
549
550 // Visit children
551
2/4
✓ Branch 3 → 4 taken 15700 times.
✗ Branch 3 → 20 not taken.
✓ Branch 4 → 5 taken 15700 times.
✗ Branch 4 → 18 not taken.
15700 fetchChildrenIntoVector(argLstNode->args, ctx->assignExpr());
552 15700 argLstNode->argInfos.reserve(argLstNode->args.size());
553
554
1/2
✓ Branch 14 → 15 taken 15700 times.
✗ Branch 14 → 21 not taken.
15700 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 739 std::any ASTBuilder::visitEnumItem(SpiceParser::EnumItemContext *ctx) {
567 739 const auto enumItemNode = createNode<EnumItemNode>(ctx);
568
569 // Enrich
570
2/4
✓ Branch 3 → 4 taken 739 times.
✗ Branch 3 → 22 not taken.
✓ Branch 4 → 5 taken 739 times.
✗ Branch 4 → 22 not taken.
739 enumItemNode->itemName = getIdentifier(ctx->TYPE_IDENTIFIER(), false);
571
2/2
✓ Branch 8 → 9 taken 409 times.
✓ Branch 8 → 12 taken 330 times.
739 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 739 times.
✗ Branch 18 → 23 not taken.
739 return concludeNode(enumItemNode);
577 }
578
579 1548 std::any ASTBuilder::visitField(SpiceParser::FieldContext *ctx) {
580 1548 const auto fieldNode = createNode<FieldNode>(ctx);
581
582 // Enrich
583
2/4
✓ Branch 3 → 4 taken 1548 times.
✗ Branch 3 → 29 not taken.
✓ Branch 4 → 5 taken 1548 times.
✗ Branch 4 → 29 not taken.
1548 fieldNode->fieldName = getIdentifier(ctx->IDENTIFIER(), false);
584
585 // Visit children
586
3/6
✓ Branch 7 → 8 taken 1548 times.
✗ Branch 7 → 32 not taken.
✓ Branch 8 → 9 taken 1548 times.
✗ Branch 8 → 32 not taken.
✓ Branch 9 → 10 taken 1548 times.
✗ Branch 9 → 30 not taken.
1548 fieldNode->dataType = std::any_cast<DataTypeNode *>(visit(ctx->dataType()));
587 1548 fieldNode->dataType->setFieldTypeRecursive();
588
2/2
✓ Branch 13 → 14 taken 224 times.
✓ Branch 13 → 19 taken 1324 times.
1548 if (ctx->ternaryExpr())
589
3/6
✓ Branch 14 → 15 taken 224 times.
✗ Branch 14 → 35 not taken.
✓ Branch 15 → 16 taken 224 times.
✗ Branch 15 → 35 not taken.
✓ Branch 16 → 17 taken 224 times.
✗ Branch 16 → 33 not taken.
224 fieldNode->defaultValue = std::any_cast<TernaryExprNode *>(visit(ctx->ternaryExpr()));
590
591
1/2
✓ Branch 25 → 26 taken 1548 times.
✗ Branch 25 → 36 not taken.
1548 return concludeNode(fieldNode);
592 }
593
594 243 std::any ASTBuilder::visitSignature(SpiceParser::SignatureContext *ctx) {
595 243 const auto signatureNode = createNode<SignatureNode>(ctx);
596
597 // Extract method name
598
2/4
✓ Branch 3 → 4 taken 243 times.
✗ Branch 3 → 73 not taken.
✓ Branch 4 → 5 taken 243 times.
✗ Branch 4 → 73 not taken.
243 signatureNode->methodName = getIdentifier(ctx->IDENTIFIER(), false);
599
600 // Visit children
601
2/2
✓ Branch 8 → 9 taken 14 times.
✓ Branch 8 → 14 taken 229 times.
243 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 189 times.
✓ Branch 15 → 22 taken 54 times.
243 if (ctx->F()) {
605 189 signatureNode->hasReturnType = true;
606 189 signatureNode->signatureType = SignatureNode::SignatureType::TYPE_FUNCTION;
607 189 signatureNode->signatureQualifiers = TypeQualifiers::of(TY_FUNCTION);
608
3/6
✓ Branch 17 → 18 taken 189 times.
✗ Branch 17 → 79 not taken.
✓ Branch 18 → 19 taken 189 times.
✗ Branch 18 → 79 not taken.
✓ Branch 19 → 20 taken 189 times.
✗ Branch 19 → 77 not taken.
189 signatureNode->returnType = std::any_cast<DataTypeNode *>(visit(ctx->dataType()));
609 } else {
610 54 signatureNode->signatureType = SignatureNode::SignatureType::TYPE_PROCEDURE;
611 54 signatureNode->signatureQualifiers = TypeQualifiers::of(TY_PROCEDURE);
612 }
613
10/16
✓ Branch 24 → 25 taken 189 times.
✓ Branch 24 → 28 taken 54 times.
✓ Branch 25 → 26 taken 189 times.
✗ Branch 25 → 80 not taken.
✓ Branch 28 → 29 taken 54 times.
✗ Branch 28 → 80 not taken.
✓ Branch 31 → 32 taken 54 times.
✓ Branch 31 → 33 taken 189 times.
✓ Branch 33 → 34 taken 189 times.
✓ Branch 33 → 35 taken 54 times.
✓ Branch 35 → 36 taken 123 times.
✓ Branch 35 → 41 taken 120 times.
✗ Branch 80 → 81 not taken.
✗ Branch 80 → 82 not taken.
✗ Branch 84 → 85 not taken.
✗ Branch 84 → 86 not taken.
243 if (ctx->F() ? ctx->LESS().size() == 2 : ctx->LESS().size() == 1) {
614 123 signatureNode->hasTemplateTypes = true;
615
3/6
✓ Branch 36 → 37 taken 123 times.
✗ Branch 36 → 90 not taken.
✓ Branch 37 → 38 taken 123 times.
✗ Branch 37 → 90 not taken.
✓ Branch 38 → 39 taken 123 times.
✗ Branch 38 → 88 not taken.
123 signatureNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst(0)));
616 }
617
13/20
✓ Branch 41 → 42 taken 243 times.
✗ Branch 41 → 91 not taken.
✓ Branch 43 → 44 taken 241 times.
✓ Branch 43 → 48 taken 2 times.
✓ Branch 44 → 45 taken 241 times.
✗ Branch 44 → 91 not taken.
✓ Branch 46 → 47 taken 128 times.
✓ Branch 46 → 49 taken 113 times.
✓ Branch 47 → 48 taken 7 times.
✓ Branch 47 → 49 taken 121 times.
✓ Branch 50 → 51 taken 241 times.
✓ Branch 50 → 52 taken 2 times.
✓ Branch 52 → 53 taken 243 times.
✗ Branch 52 → 54 not taken.
✓ Branch 54 → 55 taken 9 times.
✓ Branch 54 → 63 taken 234 times.
✗ Branch 91 → 92 not taken.
✗ Branch 91 → 93 not taken.
✗ Branch 95 → 96 not taken.
✗ Branch 95 → 97 not taken.
243 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 243 times.
✗ Branch 69 → 102 not taken.
243 return concludeNode(signatureNode);
623 }
624
625 31280 std::any ASTBuilder::visitStmt(SpiceParser::StmtContext *ctx) {
626
2/2
✓ Branch 3 → 4 taken 5587 times.
✓ Branch 3 → 11 taken 25693 times.
31280 if (ctx->declStmt())
627
5/8
✓ Branch 4 → 5 taken 5587 times.
✗ Branch 4 → 60 not taken.
✓ Branch 5 → 6 taken 5583 times.
✓ Branch 5 → 60 taken 4 times.
✓ Branch 6 → 7 taken 5583 times.
✗ Branch 6 → 58 not taken.
✓ Branch 7 → 8 taken 5583 times.
✗ Branch 7 → 58 not taken.
5587 return static_cast<StmtNode *>(std::any_cast<DeclStmtNode *>(visit(ctx->declStmt())));
628
2/2
✓ Branch 12 → 13 taken 15435 times.
✓ Branch 12 → 20 taken 10258 times.
25693 if (ctx->exprStmt())
629
4/8
✓ Branch 13 → 14 taken 15435 times.
✗ Branch 13 → 64 not taken.
✓ Branch 14 → 15 taken 15435 times.
✗ Branch 14 → 64 not taken.
✓ Branch 15 → 16 taken 15435 times.
✗ Branch 15 → 62 not taken.
✓ Branch 16 → 17 taken 15435 times.
✗ Branch 16 → 62 not taken.
15435 return static_cast<StmtNode *>(std::any_cast<ExprStmtNode *>(visit(ctx->exprStmt())));
630
2/2
✓ Branch 21 → 22 taken 9919 times.
✓ Branch 21 → 29 taken 339 times.
10258 if (ctx->returnStmt())
631
4/8
✓ Branch 22 → 23 taken 9919 times.
✗ Branch 22 → 68 not taken.
✓ Branch 23 → 24 taken 9919 times.
✗ Branch 23 → 68 not taken.
✓ Branch 24 → 25 taken 9919 times.
✗ Branch 24 → 66 not taken.
✓ Branch 25 → 26 taken 9919 times.
✗ Branch 25 → 66 not taken.
9919 return static_cast<StmtNode *>(std::any_cast<ReturnStmtNode *>(visit(ctx->returnStmt())));
632
2/2
✓ Branch 30 → 31 taken 124 times.
✓ Branch 30 → 38 taken 215 times.
339 if (ctx->breakStmt())
633
4/8
✓ Branch 31 → 32 taken 124 times.
✗ Branch 31 → 72 not taken.
✓ Branch 32 → 33 taken 124 times.
✗ Branch 32 → 72 not taken.
✓ Branch 33 → 34 taken 124 times.
✗ Branch 33 → 70 not taken.
✓ Branch 34 → 35 taken 124 times.
✗ Branch 34 → 70 not taken.
124 return static_cast<StmtNode *>(std::any_cast<BreakStmtNode *>(visit(ctx->breakStmt())));
634
2/2
✓ Branch 39 → 40 taken 209 times.
✓ Branch 39 → 47 taken 6 times.
215 if (ctx->continueStmt())
635
4/8
✓ Branch 40 → 41 taken 209 times.
✗ Branch 40 → 76 not taken.
✓ Branch 41 → 42 taken 209 times.
✗ Branch 41 → 76 not taken.
✓ Branch 42 → 43 taken 209 times.
✗ Branch 42 → 74 not taken.
✓ Branch 43 → 44 taken 209 times.
✗ Branch 43 → 74 not taken.
209 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 21593 std::any ASTBuilder::visitDeclStmt(SpiceParser::DeclStmtContext *ctx) {
643 21593 const auto declStmtNode = createNode<DeclStmtNode>(ctx);
644
645 // Enrich
646
3/4
✓ Branch 3 → 4 taken 21593 times.
✗ Branch 3 → 28 not taken.
✓ Branch 4 → 5 taken 21592 times.
✓ Branch 4 → 28 taken 1 time.
21593 declStmtNode->varName = getIdentifier(ctx->IDENTIFIER(), false);
647
648 // Visit children
649
4/6
✓ Branch 7 → 8 taken 21592 times.
✗ Branch 7 → 31 not taken.
✓ Branch 8 → 9 taken 21591 times.
✓ Branch 8 → 31 taken 1 time.
✓ Branch 9 → 10 taken 21591 times.
✗ Branch 9 → 29 not taken.
21592 declStmtNode->dataType = std::any_cast<DataTypeNode *>(visit(ctx->dataType()));
650
2/2
✓ Branch 12 → 13 taken 7720 times.
✓ Branch 12 → 18 taken 13871 times.
21591 if (ctx->assignExpr()) {
651 7720 declStmtNode->hasAssignment = true;
652
4/6
✓ Branch 13 → 14 taken 7720 times.
✗ Branch 13 → 34 not taken.
✓ Branch 14 → 15 taken 7718 times.
✓ Branch 14 → 34 taken 2 times.
✓ Branch 15 → 16 taken 7718 times.
✗ Branch 15 → 32 not taken.
7720 declStmtNode->assignExpr = std::any_cast<AssignExprNode *>(visit(ctx->assignExpr()));
653 }
654
655
1/2
✓ Branch 24 → 25 taken 21589 times.
✗ Branch 24 → 35 not taken.
21589 return concludeNode(declStmtNode);
656 }
657
658 15435 std::any ASTBuilder::visitExprStmt(SpiceParser::ExprStmtContext *ctx) {
659 15435 const auto exprStmtNode = createNode<ExprStmtNode>(ctx);
660
661 // Enrich
662
3/6
✓ Branch 3 → 4 taken 15435 times.
✗ Branch 3 → 19 not taken.
✓ Branch 4 → 5 taken 15435 times.
✗ Branch 4 → 19 not taken.
✓ Branch 5 → 6 taken 15435 times.
✗ Branch 5 → 17 not taken.
15435 exprStmtNode->expr = std::any_cast<AssignExprNode *>(visit(ctx->assignExpr()));
663
664
1/2
✓ Branch 13 → 14 taken 15435 times.
✗ Branch 13 → 20 not taken.
15435 return concludeNode(exprStmtNode);
665 }
666
667 32228 std::any ASTBuilder::visitQualifierLst(SpiceParser::QualifierLstContext *ctx) {
668 32228 const auto qualifierLstNode = createNode<QualifierLstNode>(ctx);
669
670 // Visit children
671
2/4
✓ Branch 3 → 4 taken 32228 times.
✗ Branch 3 → 37 not taken.
✓ Branch 4 → 5 taken 32228 times.
✗ Branch 4 → 35 not taken.
32228 fetchChildrenIntoVector(qualifierLstNode->qualifiers, ctx->qualifier());
672
673 // Check if qualifier combination is invalid
674 32228 bool seenSignedOrUnsigned = false;
675
2/2
✓ Branch 24 → 8 taken 38770 times.
✓ Branch 24 → 25 taken 32227 times.
70997 for (const QualifierNode *qualifier : qualifierLstNode->qualifiers) {
676 // Check if we have both, signed and unsigned qualifier
677
2/2
✓ Branch 9 → 10 taken 38763 times.
✓ Branch 9 → 12 taken 7 times.
38770 if (qualifier->type != QualifierNode::QualifierType::TY_SIGNED &&
678
2/2
✓ Branch 10 → 11 taken 29088 times.
✓ Branch 10 → 12 taken 9675 times.
38763 qualifier->type != QualifierNode::QualifierType::TY_UNSIGNED)
679 29088 continue;
680
2/2
✓ Branch 12 → 13 taken 1 time.
✓ Branch 12 → 21 taken 9681 times.
9682 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 9681 seenSignedOrUnsigned = true;
683 }
684
685
1/2
✓ Branch 31 → 32 taken 32227 times.
✗ Branch 31 → 48 not taken.
32227 return concludeNode(qualifierLstNode);
686 }
687
688 38770 std::any ASTBuilder::visitQualifier(SpiceParser::QualifierContext *ctx) {
689 38770 const auto qualifierNode = createNode<QualifierNode>(ctx);
690
691
3/4
✓ Branch 6 → 7 taken 38770 times.
✗ Branch 6 → 8 not taken.
✓ Branch 32 → 5 taken 38770 times.
✓ Branch 32 → 33 taken 38770 times.
77540 for (ParserRuleContext::ParseTree *subTree : ctx->children) {
692 38770 const auto token = spice_pointer_cast<TerminalNode *>(subTree);
693
2/4
✓ Branch 13 → 14 taken 38770 times.
✗ Branch 13 → 43 not taken.
✓ Branch 14 → 15 taken 38770 times.
✗ Branch 14 → 43 not taken.
38770 const size_t symbolType = token->getSymbol()->getType();
694
2/2
✓ Branch 15 → 16 taken 8226 times.
✓ Branch 15 → 17 taken 30544 times.
38770 if (symbolType == SpiceParser::CONST)
695 8226 qualifierNode->type = QualifierNode::QualifierType::TY_CONST;
696
2/2
✓ Branch 17 → 18 taken 7 times.
✓ Branch 17 → 19 taken 30537 times.
30544 else if (symbolType == SpiceParser::SIGNED)
697 7 qualifierNode->type = QualifierNode::QualifierType::TY_SIGNED;
698
2/2
✓ Branch 19 → 20 taken 9675 times.
✓ Branch 19 → 21 taken 20862 times.
30537 else if (symbolType == SpiceParser::UNSIGNED)
699 9675 qualifierNode->type = QualifierNode::QualifierType::TY_UNSIGNED;
700
2/2
✓ Branch 21 → 22 taken 3363 times.
✓ Branch 21 → 23 taken 17499 times.
20862 else if (symbolType == SpiceParser::INLINE)
701 3363 qualifierNode->type = QualifierNode::QualifierType::TY_INLINE;
702
2/2
✓ Branch 23 → 24 taken 13186 times.
✓ Branch 23 → 25 taken 4313 times.
17499 else if (symbolType == SpiceParser::PUBLIC)
703 13186 qualifierNode->type = QualifierNode::QualifierType::TY_PUBLIC;
704
2/2
✓ Branch 25 → 26 taken 4306 times.
✓ Branch 25 → 27 taken 7 times.
4313 else if (symbolType == SpiceParser::HEAP)
705 4306 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 38770 times.
✗ Branch 39 → 44 not taken.
38770 return concludeNode(qualifierNode);
713 }
714
715 367 std::any ASTBuilder::visitModAttr(SpiceParser::ModAttrContext *ctx) {
716 367 const auto modAttrNode = createNode<ModAttrNode>(ctx);
717
718 // Visit children
719
4/6
✓ Branch 3 → 4 taken 367 times.
✗ Branch 3 → 25 not taken.
✓ Branch 4 → 5 taken 366 times.
✓ Branch 4 → 25 taken 1 time.
✓ Branch 5 → 6 taken 366 times.
✗ Branch 5 → 23 not taken.
367 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 648 times.
✓ Branch 12 → 13 taken 366 times.
1014 for (AttrNode *attr : modAttrNode->attrLst->attributes)
723 648 attr->target = AttrNode::TARGET_MODULE;
724
725
1/2
✓ Branch 19 → 20 taken 366 times.
✗ Branch 19 → 26 not taken.
366 return concludeNode(modAttrNode);
726 }
727
728 483 std::any ASTBuilder::visitTopLevelDefAttr(SpiceParser::TopLevelDefAttrContext *ctx) {
729 483 const auto fctAttrNode = createNode<TopLevelDefinitionAttrNode>(ctx);
730
731 // Visit children
732
3/6
✓ Branch 3 → 4 taken 483 times.
✗ Branch 3 → 19 not taken.
✓ Branch 4 → 5 taken 483 times.
✗ Branch 4 → 19 not taken.
✓ Branch 5 → 6 taken 483 times.
✗ Branch 5 → 17 not taken.
483 fctAttrNode->attrLst = std::any_cast<AttrLstNode *>(visit(ctx->attrLst()));
733
734
1/2
✓ Branch 13 → 14 taken 483 times.
✗ Branch 13 → 20 not taken.
483 return concludeNode(fctAttrNode);
735 }
736
737 5 std::any ASTBuilder::visitLambdaAttr(SpiceParser::LambdaAttrContext *ctx) {
738 5 const auto lambdaAttrNode = createNode<LambdaAttrNode>(ctx);
739
740 // Visit children
741
3/6
✓ Branch 3 → 4 taken 5 times.
✗ Branch 3 → 25 not taken.
✓ Branch 4 → 5 taken 5 times.
✗ Branch 4 → 25 not taken.
✓ Branch 5 → 6 taken 5 times.
✗ Branch 5 → 23 not taken.
5 lambdaAttrNode->attrLst = std::any_cast<AttrLstNode *>(visit(ctx->attrLst()));
742
743 // Tell the attributes that they are module attributes
744
2/2
✓ Branch 12 → 9 taken 5 times.
✓ Branch 12 → 13 taken 5 times.
10 for (AttrNode *attr : lambdaAttrNode->attrLst->attributes)
745 5 attr->target = AttrNode::TARGET_LAMBDA;
746
747
1/2
✓ Branch 19 → 20 taken 5 times.
✗ Branch 19 → 26 not taken.
5 return concludeNode(lambdaAttrNode);
748 }
749
750 855 std::any ASTBuilder::visitAttrLst(SpiceParser::AttrLstContext *ctx) {
751 855 const auto attrLstNode = createNode<AttrLstNode>(ctx);
752
753 // Visit children
754
3/4
✓ Branch 3 → 4 taken 855 times.
✗ Branch 3 → 18 not taken.
✓ Branch 4 → 5 taken 854 times.
✓ Branch 4 → 16 taken 1 time.
856 fetchChildrenIntoVector(attrLstNode->attributes, ctx->attr());
755
756
1/2
✓ Branch 12 → 13 taken 854 times.
✗ Branch 12 → 19 not taken.
854 return concludeNode(attrLstNode);
757 }
758
759 1142 std::any ASTBuilder::visitAttr(SpiceParser::AttrContext *ctx) {
760 1142 const auto attrNode = createNode<AttrNode>(ctx);
761
762 // Extract key
763
3/4
✓ Branch 3 → 4 taken 1142 times.
✗ Branch 3 → 66 not taken.
✓ Branch 16 → 6 taken 2785 times.
✓ Branch 16 → 17 taken 1142 times.
3927 for (const TerminalNode *keyFragment : ctx->IDENTIFIER()) {
764
2/2
✓ Branch 8 → 9 taken 1643 times.
✓ Branch 8 → 10 taken 1142 times.
2785 if (!attrNode->key.empty())
765
1/2
✓ Branch 9 → 10 taken 1643 times.
✗ Branch 9 → 64 not taken.
1643 attrNode->key += MEMBER_ACCESS_TOKEN;
766
3/6
✓ Branch 10 → 11 taken 2785 times.
✗ Branch 10 → 63 not taken.
✓ Branch 11 → 12 taken 2785 times.
✗ Branch 11 → 63 not taken.
✓ Branch 12 → 13 taken 2785 times.
✗ Branch 12 → 61 not taken.
2785 attrNode->key += keyFragment->getSymbol()->getText();
767 1142 }
768
769 // Visit children
770
2/2
✓ Branch 19 → 20 taken 798 times.
✓ Branch 19 → 50 taken 344 times.
1142 if (ctx->constant()) {
771
3/6
✓ Branch 20 → 21 taken 798 times.
✗ Branch 20 → 69 not taken.
✓ Branch 21 → 22 taken 798 times.
✗ Branch 21 → 69 not taken.
✓ Branch 22 → 23 taken 798 times.
✗ Branch 22 → 67 not taken.
798 attrNode->value = std::any_cast<ConstantNode *>(visit(ctx->constant()));
772
773
2/2
✓ Branch 26 → 27 taken 292 times.
✓ Branch 26 → 28 taken 506 times.
798 if (ctx->constant()->STRING_LIT())
774 292 attrNode->type = AttrNode::AttrType::TYPE_STRING;
775
2/2
✓ Branch 30 → 31 taken 78 times.
✓ Branch 30 → 32 taken 428 times.
506 else if (ctx->constant()->INT_LIT())
776 78 attrNode->type = AttrNode::AttrType::TYPE_INT;
777
6/6
✓ Branch 34 → 35 taken 5 times.
✓ Branch 34 → 38 taken 423 times.
✓ Branch 37 → 38 taken 4 times.
✓ Branch 37 → 39 taken 1 time.
✓ Branch 40 → 41 taken 427 times.
✓ Branch 40 → 42 taken 1 time.
428 else if (ctx->constant()->TRUE() || ctx->constant()->FALSE())
778 427 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 344 attrNode->type = AttrNode::AttrType::TYPE_BOOL;
784 }
785
786
1/2
✓ Branch 57 → 58 taken 1141 times.
✗ Branch 57 → 79 not taken.
1141 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 9919 std::any ASTBuilder::visitReturnStmt(SpiceParser::ReturnStmtContext *ctx) {
823 9919 const auto returnStmtNode = createNode<ReturnStmtNode>(ctx);
824
825 // Visit children
826
2/2
✓ Branch 4 → 5 taken 9672 times.
✓ Branch 4 → 10 taken 247 times.
9919 if (ctx->assignExpr()) {
827 9672 returnStmtNode->hasReturnValue = true;
828
3/6
✓ Branch 5 → 6 taken 9672 times.
✗ Branch 5 → 22 not taken.
✓ Branch 6 → 7 taken 9672 times.
✗ Branch 6 → 22 not taken.
✓ Branch 7 → 8 taken 9672 times.
✗ Branch 7 → 20 not taken.
9672 returnStmtNode->assignExpr = std::any_cast<AssignExprNode *>(visit(ctx->assignExpr()));
829 }
830
831
1/2
✓ Branch 16 → 17 taken 9919 times.
✗ Branch 16 → 23 not taken.
9919 return concludeNode(returnStmtNode);
832 }
833
834 124 std::any ASTBuilder::visitBreakStmt(SpiceParser::BreakStmtContext *ctx) {
835 124 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 118 times.
124 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 124 times.
✗ Branch 10 → 25 not taken.
124 visitChildren(ctx);
843
844
1/2
✓ Branch 18 → 19 taken 124 times.
✗ Branch 18 → 26 not taken.
124 return concludeNode(breakStmtNode);
845 }
846
847 209 std::any ASTBuilder::visitContinueStmt(SpiceParser::ContinueStmtContext *ctx) {
848 209 const auto continueStmtNode = createNode<ContinueStmtNode>(ctx);
849
850 // Extract number of continues
851
2/2
✓ Branch 4 → 5 taken 208 times.
✓ Branch 4 → 10 taken 1 time.
209 if (ctx->INT_LIT())
852
3/6
✓ Branch 5 → 6 taken 208 times.
✗ Branch 5 → 24 not taken.
✓ Branch 6 → 7 taken 208 times.
✗ Branch 6 → 24 not taken.
✓ Branch 7 → 8 taken 208 times.
✗ Branch 7 → 22 not taken.
208 continueStmtNode->continueTimes = std::stoi(ctx->INT_LIT()->toString());
853
854 // Visit children
855
1/2
✓ Branch 10 → 11 taken 209 times.
✗ Branch 10 → 25 not taken.
209 visitChildren(ctx);
856
857
1/2
✓ Branch 18 → 19 taken 209 times.
✗ Branch 18 → 26 not taken.
209 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 773 std::any ASTBuilder::visitAssertStmt(SpiceParser::AssertStmtContext *ctx) {
870
1/2
✓ Branch 2 → 3 taken 773 times.
✗ Branch 2 → 30 not taken.
773 const auto assertStmtNode = createNode<AssertStmtNode>(ctx);
871
872 // Enrich
873
5/10
✓ Branch 3 → 4 taken 773 times.
✗ Branch 3 → 30 not taken.
✓ Branch 4 → 5 taken 773 times.
✗ Branch 4 → 30 not taken.
✓ Branch 5 → 6 taken 773 times.
✗ Branch 5 → 30 not taken.
✓ Branch 6 → 7 taken 773 times.
✗ Branch 6 → 30 not taken.
✓ Branch 7 → 8 taken 773 times.
✗ Branch 7 → 30 not taken.
773 const antlr4::misc::Interval interval(ctx->assignExpr()->start->getStartIndex(), ctx->assignExpr()->stop->getStopIndex());
874
1/2
✓ Branch 8 → 9 taken 773 times.
✗ Branch 8 → 25 not taken.
773 assertStmtNode->expressionString = inputStream->getText(interval);
875
876 // Visit children
877
3/6
✓ Branch 11 → 12 taken 773 times.
✗ Branch 11 → 28 not taken.
✓ Branch 12 → 13 taken 773 times.
✗ Branch 12 → 28 not taken.
✓ Branch 13 → 14 taken 773 times.
✗ Branch 13 → 26 not taken.
773 assertStmtNode->assignExpr = std::any_cast<AssignExprNode *>(visit(ctx->assignExpr()));
878
879
1/2
✓ Branch 21 → 22 taken 773 times.
✗ Branch 21 → 29 not taken.
773 return concludeNode(assertStmtNode);
880 }
881
882 82815 std::any ASTBuilder::visitAssignExpr(SpiceParser::AssignExprContext *ctx) {
883 82815 const auto assignExprNode = createNode<AssignExprNode>(ctx);
884
885 // Visit children
886
2/2
✓ Branch 4 → 5 taken 74784 times.
✓ Branch 4 → 10 taken 8031 times.
82815 if (ctx->ternaryExpr()) {
887
4/6
✓ Branch 5 → 6 taken 74784 times.
✗ Branch 5 → 37 not taken.
✓ Branch 6 → 7 taken 74782 times.
✓ Branch 6 → 37 taken 2 times.
✓ Branch 7 → 8 taken 74782 times.
✗ Branch 7 → 35 not taken.
74784 assignExprNode->ternaryExpr = std::any_cast<TernaryExprNode *>(visit(ctx->ternaryExpr()));
888
1/2
✓ Branch 11 → 12 taken 8031 times.
✗ Branch 11 → 24 not taken.
8031 } else if (ctx->prefixUnaryExpr()) {
889
3/6
✓ Branch 12 → 13 taken 8031 times.
✗ Branch 12 → 40 not taken.
✓ Branch 13 → 14 taken 8031 times.
✗ Branch 13 → 40 not taken.
✓ Branch 14 → 15 taken 8031 times.
✗ Branch 14 → 38 not taken.
8031 assignExprNode->lhs = std::any_cast<PrefixUnaryExprNode *>(visit(ctx->prefixUnaryExpr()));
890
2/4
✓ Branch 16 → 17 taken 8031 times.
✗ Branch 16 → 41 not taken.
✓ Branch 17 → 18 taken 8031 times.
✗ Branch 17 → 41 not taken.
8031 visit(ctx->assignOp());
891
3/6
✓ Branch 19 → 20 taken 8031 times.
✗ Branch 19 → 44 not taken.
✓ Branch 20 → 21 taken 8031 times.
✗ Branch 20 → 44 not taken.
✓ Branch 21 → 22 taken 8031 times.
✗ Branch 21 → 42 not taken.
8031 assignExprNode->rhs = std::any_cast<AssignExprNode *>(visit(ctx->assignExpr()));
892 } else {
893 assert_fail("Invalid assign expression"); // GCOV_EXCL_LINE
894 }
895
896
1/2
✓ Branch 31 → 32 taken 82813 times.
✗ Branch 31 → 45 not taken.
82813 return concludeNode(assignExprNode);
897 }
898
899 75008 std::any ASTBuilder::visitTernaryExpr(SpiceParser::TernaryExprContext *ctx) {
900 75008 const auto ternaryExprNode = createNode<TernaryExprNode>(ctx);
901
902
4/6
✓ Branch 3 → 4 taken 75008 times.
✗ Branch 3 → 41 not taken.
✓ Branch 4 → 5 taken 75006 times.
✓ Branch 4 → 41 taken 2 times.
✓ Branch 5 → 6 taken 75006 times.
✗ Branch 5 → 39 not taken.
75008 ternaryExprNode->condition = std::any_cast<LogicalOrExprNode *>(visit(ctx->logicalOrExpr(0)));
903
3/4
✓ Branch 7 → 8 taken 75006 times.
✗ Branch 7 → 42 not taken.
✓ Branch 10 → 11 taken 470 times.
✓ Branch 10 → 20 taken 74536 times.
75006 if (ctx->logicalOrExpr().size() == 3) {
904
3/6
✓ Branch 11 → 12 taken 470 times.
✗ Branch 11 → 45 not taken.
✓ Branch 12 → 13 taken 470 times.
✗ Branch 12 → 45 not taken.
✓ Branch 13 → 14 taken 470 times.
✗ Branch 13 → 43 not taken.
470 ternaryExprNode->trueExpr = std::any_cast<LogicalOrExprNode *>(visit(ctx->logicalOrExpr(1)));
905
3/6
✓ Branch 15 → 16 taken 470 times.
✗ Branch 15 → 48 not taken.
✓ Branch 16 → 17 taken 470 times.
✗ Branch 16 → 48 not taken.
✓ Branch 17 → 18 taken 470 times.
✗ Branch 17 → 46 not taken.
470 ternaryExprNode->falseExpr = std::any_cast<LogicalOrExprNode *>(visit(ctx->logicalOrExpr(2)));
906
3/4
✓ Branch 20 → 21 taken 74536 times.
✗ Branch 20 → 49 not taken.
✓ Branch 23 → 24 taken 1 time.
✓ Branch 23 → 29 taken 74535 times.
74536 } else if (ctx->logicalOrExpr().size() == 2) {
907 1 ternaryExprNode->isShortened = true;
908
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)));
909 }
910
911
1/2
✓ Branch 35 → 36 taken 75006 times.
✗ Branch 35 → 53 not taken.
75006 return concludeNode(ternaryExprNode);
912 }
913
914 75949 std::any ASTBuilder::visitLogicalOrExpr(SpiceParser::LogicalOrExprContext *ctx) {
915 75949 const auto logicalOrExprNode = createNode<LogicalOrExprNode>(ctx);
916
917 // Visit children
918
3/4
✓ Branch 3 → 4 taken 75949 times.
✗ Branch 3 → 18 not taken.
✓ Branch 4 → 5 taken 75947 times.
✓ Branch 4 → 16 taken 2 times.
75951 fetchChildrenIntoVector(logicalOrExprNode->operands, ctx->logicalAndExpr());
919
920
1/2
✓ Branch 12 → 13 taken 75947 times.
✗ Branch 12 → 19 not taken.
75947 return concludeNode(logicalOrExprNode);
921 }
922
923 77292 std::any ASTBuilder::visitLogicalAndExpr(SpiceParser::LogicalAndExprContext *ctx) {
924 77292 const auto logicalAndExprNode = createNode<LogicalAndExprNode>(ctx);
925
926 // Visit children
927
3/4
✓ Branch 3 → 4 taken 77292 times.
✗ Branch 3 → 18 not taken.
✓ Branch 4 → 5 taken 77290 times.
✓ Branch 4 → 16 taken 2 times.
77294 fetchChildrenIntoVector(logicalAndExprNode->operands, ctx->bitwiseOrExpr());
928
929
1/2
✓ Branch 12 → 13 taken 77290 times.
✗ Branch 12 → 19 not taken.
77290 return concludeNode(logicalAndExprNode);
930 }
931
932 77591 std::any ASTBuilder::visitBitwiseOrExpr(SpiceParser::BitwiseOrExprContext *ctx) {
933 77591 const auto bitwiseOrExprNode = createNode<BitwiseOrExprNode>(ctx);
934
935 // Visit children
936
3/4
✓ Branch 3 → 4 taken 77591 times.
✗ Branch 3 → 18 not taken.
✓ Branch 4 → 5 taken 77589 times.
✓ Branch 4 → 16 taken 2 times.
77593 fetchChildrenIntoVector(bitwiseOrExprNode->operands, ctx->bitwiseXorExpr());
937
938
1/2
✓ Branch 12 → 13 taken 77589 times.
✗ Branch 12 → 19 not taken.
77589 return concludeNode(bitwiseOrExprNode);
939 }
940
941 77678 std::any ASTBuilder::visitBitwiseXorExpr(SpiceParser::BitwiseXorExprContext *ctx) {
942 77678 const auto bitwiseXorExprNode = createNode<BitwiseXorExprNode>(ctx);
943
944 // Visit children
945
3/4
✓ Branch 3 → 4 taken 77678 times.
✗ Branch 3 → 18 not taken.
✓ Branch 4 → 5 taken 77676 times.
✓ Branch 4 → 16 taken 2 times.
77680 fetchChildrenIntoVector(bitwiseXorExprNode->operands, ctx->bitwiseAndExpr());
946
947
1/2
✓ Branch 12 → 13 taken 77676 times.
✗ Branch 12 → 19 not taken.
77676 return concludeNode(bitwiseXorExprNode);
948 }
949
950 77690 std::any ASTBuilder::visitBitwiseAndExpr(SpiceParser::BitwiseAndExprContext *ctx) {
951 77690 const auto bitwiseAndExprNode = createNode<BitwiseAndExprNode>(ctx);
952
953 // Visit children
954
3/4
✓ Branch 3 → 4 taken 77690 times.
✗ Branch 3 → 18 not taken.
✓ Branch 4 → 5 taken 77688 times.
✓ Branch 4 → 16 taken 2 times.
77692 fetchChildrenIntoVector(bitwiseAndExprNode->operands, ctx->equalityExpr());
955
956
1/2
✓ Branch 12 → 13 taken 77688 times.
✗ Branch 12 → 19 not taken.
77688 return concludeNode(bitwiseAndExprNode);
957 }
958
959 77725 std::any ASTBuilder::visitEqualityExpr(SpiceParser::EqualityExprContext *ctx) {
960 77725 const auto equalityExprNode = createNode<EqualityExprNode>(ctx);
961
962 // Visit children
963
3/4
✓ Branch 3 → 4 taken 77725 times.
✗ Branch 3 → 24 not taken.
✓ Branch 4 → 5 taken 77723 times.
✓ Branch 4 → 22 taken 2 times.
77727 fetchChildrenIntoVector(equalityExprNode->operands, ctx->relationalExpr());
964
965 // Extract operator
966
2/2
✓ Branch 7 → 8 taken 4026 times.
✓ Branch 7 → 9 taken 73697 times.
77723 if (ctx->EQUAL())
967 4026 equalityExprNode->op = EqualityExprNode::EqualityOp::OP_EQUAL;
968
2/2
✓ Branch 10 → 11 taken 1417 times.
✓ Branch 10 → 12 taken 72280 times.
73697 else if (ctx->NOT_EQUAL())
969 1417 equalityExprNode->op = EqualityExprNode::EqualityOp::OP_NOT_EQUAL;
970
971
1/2
✓ Branch 18 → 19 taken 77723 times.
✗ Branch 18 → 25 not taken.
77723 return concludeNode(equalityExprNode);
972 }
973
974 83168 std::any ASTBuilder::visitRelationalExpr(SpiceParser::RelationalExprContext *ctx) {
975 83168 const auto relationalExprNode = createNode<RelationalExprNode>(ctx);
976
977 // Visit children
978
3/4
✓ Branch 3 → 4 taken 83168 times.
✗ Branch 3 → 30 not taken.
✓ Branch 4 → 5 taken 83166 times.
✓ Branch 4 → 28 taken 2 times.
83170 fetchChildrenIntoVector(relationalExprNode->operands, ctx->shiftExpr());
979
980 // Extract operator
981
2/2
✓ Branch 7 → 8 taken 2173 times.
✓ Branch 7 → 9 taken 80993 times.
83166 if (ctx->LESS())
982 2173 relationalExprNode->op = RelationalExprNode::RelationalOp::OP_LESS;
983
2/2
✓ Branch 10 → 11 taken 716 times.
✓ Branch 10 → 12 taken 80277 times.
80993 else if (ctx->GREATER())
984 716 relationalExprNode->op = RelationalExprNode::RelationalOp::OP_GREATER;
985
2/2
✓ Branch 13 → 14 taken 359 times.
✓ Branch 13 → 15 taken 79918 times.
80277 else if (ctx->LESS_EQUAL())
986 359 relationalExprNode->op = RelationalExprNode::RelationalOp::OP_LESS_EQUAL;
987
2/2
✓ Branch 16 → 17 taken 866 times.
✓ Branch 16 → 18 taken 79052 times.
79918 else if (ctx->GREATER_EQUAL())
988 866 relationalExprNode->op = RelationalExprNode::RelationalOp::OP_GREATER_EQUAL;
989
990
1/2
✓ Branch 24 → 25 taken 83166 times.
✗ Branch 24 → 31 not taken.
83166 return concludeNode(relationalExprNode);
991 }
992
993 87282 std::any ASTBuilder::visitShiftExpr(SpiceParser::ShiftExprContext *ctx) {
994 87282 const auto shiftExprNode = createNode<ShiftExprNode>(ctx);
995
996 // Visit children
997
3/4
✓ Branch 3 → 4 taken 87282 times.
✗ Branch 3 → 48 not taken.
✓ Branch 4 → 5 taken 87280 times.
✓ Branch 4 → 46 taken 2 times.
87284 fetchChildrenIntoVector(shiftExprNode->operands, ctx->additiveExpr());
998
999 87280 bool seenFirstLess = false;
1000 87280 bool seenFirstGreater = false;
1001
2/2
✓ Branch 31 → 8 taken 87679 times.
✓ Branch 31 → 32 taken 87280 times.
174959 for (ParserRuleContext::ParseTree *subTree : ctx->children) {
1002
1/2
✓ Branch 9 → 10 taken 87679 times.
✗ Branch 9 → 11 not taken.
87679 const auto terminal = dynamic_cast<TerminalNode *>(subTree);
1003
2/2
✓ Branch 12 → 13 taken 87413 times.
✓ Branch 12 → 14 taken 266 times.
87679 if (!terminal)
1004 87413 continue;
1005
1006
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) {
1007
2/2
✓ Branch 17 → 18 taken 78 times.
✓ Branch 17 → 20 taken 78 times.
156 if (seenFirstLess)
1008
1/2
✓ Branch 18 → 19 taken 78 times.
✗ Branch 18 → 49 not taken.
78 shiftExprNode->opQueue.emplace(ShiftExprNode::ShiftOp::OP_SHIFT_LEFT, TY_INVALID);
1009 156 seenFirstLess = !seenFirstLess;
1010 156 continue;
1011 }
1012
1013
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) {
1014
2/2
✓ Branch 24 → 25 taken 55 times.
✓ Branch 24 → 27 taken 55 times.
110 if (seenFirstGreater)
1015
1/2
✓ Branch 25 → 26 taken 55 times.
✗ Branch 25 → 51 not taken.
55 shiftExprNode->opQueue.emplace(ShiftExprNode::ShiftOp::OP_SHIFT_RIGHT, TY_INVALID);
1016 110 seenFirstGreater = !seenFirstGreater;
1017 110 continue;
1018 }
1019
1020 assert_fail("Invalid terminal symbol for additive expression"); // GCOV_EXCL_LINE
1021 }
1022
2/4
✓ Branch 32 → 33 taken 87280 times.
✗ Branch 32 → 35 not taken.
✓ Branch 33 → 34 taken 87280 times.
✗ Branch 33 → 35 not taken.
87280 assert(!seenFirstLess && !seenFirstGreater);
1023
1024
1/2
✓ Branch 42 → 43 taken 87280 times.
✗ Branch 42 → 54 not taken.
87280 return concludeNode(shiftExprNode);
1025 }
1026
1027 87415 std::any ASTBuilder::visitAdditiveExpr(SpiceParser::AdditiveExprContext *ctx) {
1028 87415 const auto additiveExprNode = createNode<AdditiveExprNode>(ctx);
1029
1030 // Visit children
1031
3/4
✓ Branch 3 → 4 taken 87415 times.
✗ Branch 3 → 40 not taken.
✓ Branch 4 → 5 taken 87413 times.
✓ Branch 4 → 38 taken 2 times.
87417 fetchChildrenIntoVector(additiveExprNode->operands, ctx->multiplicativeExpr());
1032
1033
2/2
✓ Branch 27 → 8 taken 96053 times.
✓ Branch 27 → 28 taken 87413 times.
183466 for (ParserRuleContext::ParseTree *subTree : ctx->children) {
1034
1/2
✓ Branch 9 → 10 taken 96053 times.
✗ Branch 9 → 11 not taken.
96053 const auto terminal = dynamic_cast<TerminalNode *>(subTree);
1035
2/2
✓ Branch 12 → 13 taken 91733 times.
✓ Branch 12 → 14 taken 4320 times.
96053 if (!terminal)
1036 91733 continue;
1037
1038
4/6
✓ Branch 14 → 15 taken 4320 times.
✗ Branch 14 → 45 not taken.
✓ Branch 15 → 16 taken 4320 times.
✗ Branch 15 → 45 not taken.
✓ Branch 16 → 17 taken 2608 times.
✓ Branch 16 → 19 taken 1712 times.
4320 if (terminal->getSymbol()->getType() == SpiceParser::PLUS)
1039
1/2
✓ Branch 17 → 18 taken 2608 times.
✗ Branch 17 → 41 not taken.
2608 additiveExprNode->opQueue.emplace(AdditiveExprNode::AdditiveOp::OP_PLUS, TY_INVALID);
1040
3/6
✓ Branch 19 → 20 taken 1712 times.
✗ Branch 19 → 45 not taken.
✓ Branch 20 → 21 taken 1712 times.
✗ Branch 20 → 45 not taken.
✓ Branch 21 → 22 taken 1712 times.
✗ Branch 21 → 24 not taken.
1712 else if (terminal->getSymbol()->getType() == SpiceParser::MINUS)
1041
1/2
✓ Branch 22 → 23 taken 1712 times.
✗ Branch 22 → 43 not taken.
1712 additiveExprNode->opQueue.emplace(AdditiveExprNode::AdditiveOp::OP_MINUS, TY_INVALID);
1042 else
1043 assert_fail("Invalid terminal symbol for additive expression"); // GCOV_EXCL_LINE
1044 }
1045
1046
1/2
✓ Branch 34 → 35 taken 87413 times.
✗ Branch 34 → 46 not taken.
87413 return concludeNode(additiveExprNode);
1047 }
1048
1049 91735 std::any ASTBuilder::visitMultiplicativeExpr(SpiceParser::MultiplicativeExprContext *ctx) {
1050 91735 const auto multiplicativeExprNode = createNode<MultiplicativeExprNode>(ctx);
1051
1052 // Visit children
1053
3/4
✓ Branch 3 → 4 taken 91735 times.
✗ Branch 3 → 45 not taken.
✓ Branch 4 → 5 taken 91733 times.
✓ Branch 4 → 43 taken 2 times.
91737 fetchChildrenIntoVector(multiplicativeExprNode->operands, ctx->castExpr());
1054
1055
2/2
✓ Branch 32 → 8 taken 94505 times.
✓ Branch 32 → 33 taken 91733 times.
186238 for (ParserRuleContext::ParseTree *subTree : ctx->children) {
1056
1/2
✓ Branch 9 → 10 taken 94505 times.
✗ Branch 9 → 11 not taken.
94505 const auto terminal = dynamic_cast<TerminalNode *>(subTree);
1057
2/2
✓ Branch 12 → 13 taken 93119 times.
✓ Branch 12 → 14 taken 1386 times.
94505 if (!terminal)
1058 93119 continue;
1059
1060
4/6
✓ Branch 14 → 15 taken 1386 times.
✗ Branch 14 → 52 not taken.
✓ Branch 15 → 16 taken 1386 times.
✗ Branch 15 → 52 not taken.
✓ Branch 16 → 17 taken 1036 times.
✓ Branch 16 → 19 taken 350 times.
1386 if (terminal->getSymbol()->getType() == SpiceParser::MUL)
1061
1/2
✓ Branch 17 → 18 taken 1036 times.
✗ Branch 17 → 46 not taken.
1036 multiplicativeExprNode->opQueue.emplace(MultiplicativeExprNode::MultiplicativeOp::OP_MUL, TY_INVALID);
1062
4/6
✓ Branch 19 → 20 taken 350 times.
✗ Branch 19 → 52 not taken.
✓ Branch 20 → 21 taken 350 times.
✗ Branch 20 → 52 not taken.
✓ Branch 21 → 22 taken 141 times.
✓ Branch 21 → 24 taken 209 times.
350 else if (terminal->getSymbol()->getType() == SpiceParser::DIV)
1063
1/2
✓ Branch 22 → 23 taken 141 times.
✗ Branch 22 → 48 not taken.
141 multiplicativeExprNode->opQueue.emplace(MultiplicativeExprNode::MultiplicativeOp::OP_DIV, TY_INVALID);
1064
3/6
✓ Branch 24 → 25 taken 209 times.
✗ Branch 24 → 52 not taken.
✓ Branch 25 → 26 taken 209 times.
✗ Branch 25 → 52 not taken.
✓ Branch 26 → 27 taken 209 times.
✗ Branch 26 → 29 not taken.
209 else if (terminal->getSymbol()->getType() == SpiceParser::REM)
1065
1/2
✓ Branch 27 → 28 taken 209 times.
✗ Branch 27 → 50 not taken.
209 multiplicativeExprNode->opQueue.emplace(MultiplicativeExprNode::MultiplicativeOp::OP_REM, TY_INVALID);
1066 else
1067 assert_fail("Invalid terminal symbol for multiplicative expression"); // GCOV_EXCL_LINE
1068 }
1069
1070
1/2
✓ Branch 39 → 40 taken 91733 times.
✗ Branch 39 → 53 not taken.
91733 return concludeNode(multiplicativeExprNode);
1071 }
1072
1073 93121 std::any ASTBuilder::visitCastExpr(SpiceParser::CastExprContext *ctx) {
1074 93121 const auto castExprNode = createNode<CastExprNode>(ctx);
1075
1076
2/2
✓ Branch 4 → 5 taken 2849 times.
✓ Branch 4 → 14 taken 90272 times.
93121 if (ctx->dataType()) {
1077
3/6
✓ Branch 5 → 6 taken 2849 times.
✗ Branch 5 → 31 not taken.
✓ Branch 6 → 7 taken 2849 times.
✗ Branch 6 → 31 not taken.
✓ Branch 7 → 8 taken 2849 times.
✗ Branch 7 → 29 not taken.
2849 castExprNode->dataType = std::any_cast<DataTypeNode *>(visit(ctx->dataType()));
1078
3/6
✓ Branch 9 → 10 taken 2849 times.
✗ Branch 9 → 34 not taken.
✓ Branch 10 → 11 taken 2849 times.
✗ Branch 10 → 34 not taken.
✓ Branch 11 → 12 taken 2849 times.
✗ Branch 11 → 32 not taken.
2849 castExprNode->assignExpr = std::any_cast<AssignExprNode *>(visit(ctx->assignExpr()));
1079 2849 castExprNode->isCast = true;
1080 } else {
1081
4/6
✓ Branch 14 → 15 taken 90272 times.
✗ Branch 14 → 37 not taken.
✓ Branch 15 → 16 taken 90270 times.
✓ Branch 15 → 37 taken 2 times.
✓ Branch 16 → 17 taken 90270 times.
✗ Branch 16 → 35 not taken.
90272 castExprNode->prefixUnaryExpr = std::any_cast<PrefixUnaryExprNode *>(visit(ctx->prefixUnaryExpr()));
1082 }
1083
1084
1/2
✓ Branch 25 → 26 taken 93119 times.
✗ Branch 25 → 38 not taken.
93119 return concludeNode(castExprNode);
1085 }
1086
1087 99785 std::any ASTBuilder::visitPrefixUnaryExpr(SpiceParser::PrefixUnaryExprContext *ctx) {
1088 99785 const auto prefixUnaryExprNode = createNode<PrefixUnaryExprNode>(ctx);
1089
1090 // Visit children
1091
2/2
✓ Branch 4 → 5 taken 98303 times.
✓ Branch 4 → 10 taken 1482 times.
99785 if (ctx->postfixUnaryExpr()) {
1092
4/6
✓ Branch 5 → 6 taken 98303 times.
✗ Branch 5 → 51 not taken.
✓ Branch 6 → 7 taken 98301 times.
✓ Branch 6 → 51 taken 2 times.
✓ Branch 7 → 8 taken 98301 times.
✗ Branch 7 → 49 not taken.
98303 prefixUnaryExprNode->postfixUnaryExpr = std::any_cast<PostfixUnaryExprNode *>(visit(ctx->postfixUnaryExpr()));
1093
1/2
✓ Branch 11 → 12 taken 1482 times.
✗ Branch 11 → 38 not taken.
1482 } else if (ctx->prefixUnaryExpr()) {
1094 // Extract operator
1095
2/2
✓ Branch 13 → 14 taken 78 times.
✓ Branch 13 → 15 taken 1404 times.
1482 if (ctx->MINUS())
1096 78 prefixUnaryExprNode->op = PrefixUnaryExprNode::PrefixUnaryOp::OP_MINUS;
1097
2/2
✓ Branch 16 → 17 taken 22 times.
✓ Branch 16 → 18 taken 1382 times.
1404 else if (ctx->PLUS_PLUS())
1098 22 prefixUnaryExprNode->op = PrefixUnaryExprNode::PrefixUnaryOp::OP_PLUS_PLUS;
1099
2/2
✓ Branch 19 → 20 taken 10 times.
✓ Branch 19 → 21 taken 1372 times.
1382 else if (ctx->MINUS_MINUS())
1100 10 prefixUnaryExprNode->op = PrefixUnaryExprNode::PrefixUnaryOp::OP_MINUS_MINUS;
1101
2/2
✓ Branch 22 → 23 taken 863 times.
✓ Branch 22 → 24 taken 509 times.
1372 else if (ctx->NOT())
1102 863 prefixUnaryExprNode->op = PrefixUnaryExprNode::PrefixUnaryOp::OP_NOT;
1103
2/2
✓ Branch 25 → 26 taken 2 times.
✓ Branch 25 → 27 taken 507 times.
509 else if (ctx->BITWISE_NOT())
1104 2 prefixUnaryExprNode->op = PrefixUnaryExprNode::PrefixUnaryOp::OP_BITWISE_NOT;
1105
2/2
✓ Branch 28 → 29 taken 252 times.
✓ Branch 28 → 30 taken 255 times.
507 else if (ctx->MUL())
1106 252 prefixUnaryExprNode->op = PrefixUnaryExprNode::PrefixUnaryOp::OP_DEREFERENCE;
1107
1/2
✓ Branch 31 → 32 taken 255 times.
✗ Branch 31 → 33 not taken.
255 else if (ctx->BITWISE_AND())
1108 255 prefixUnaryExprNode->op = PrefixUnaryExprNode::PrefixUnaryOp::OP_ADDRESS_OF;
1109
1110
3/6
✓ Branch 33 → 34 taken 1482 times.
✗ Branch 33 → 54 not taken.
✓ Branch 34 → 35 taken 1482 times.
✗ Branch 34 → 54 not taken.
✓ Branch 35 → 36 taken 1482 times.
✗ Branch 35 → 52 not taken.
1482 prefixUnaryExprNode->prefixUnaryExpr = std::any_cast<PrefixUnaryExprNode *>(visit(ctx->prefixUnaryExpr()));
1111 } else {
1112 assert_fail("Unknown prefix unary expression type"); // GCOV_EXCL_LINE
1113 }
1114
1115
1/2
✓ Branch 45 → 46 taken 99783 times.
✗ Branch 45 → 55 not taken.
99783 return concludeNode(prefixUnaryExprNode);
1116 }
1117
1118 124005 std::any ASTBuilder::visitPostfixUnaryExpr(SpiceParser::PostfixUnaryExprContext *ctx) {
1119 124005 const auto postfixUnaryExprNode = createNode<PostfixUnaryExprNode>(ctx);
1120
1121
2/2
✓ Branch 4 → 5 taken 98303 times.
✓ Branch 4 → 10 taken 25702 times.
124005 if (ctx->atomicExpr()) {
1122
4/6
✓ Branch 5 → 6 taken 98303 times.
✗ Branch 5 → 49 not taken.
✓ Branch 6 → 7 taken 98301 times.
✓ Branch 6 → 49 taken 2 times.
✓ Branch 7 → 8 taken 98301 times.
✗ Branch 7 → 47 not taken.
98303 postfixUnaryExprNode->atomicExpr = std::any_cast<AtomicExprNode *>(visit(ctx->atomicExpr()));
1123
1/2
✓ Branch 11 → 12 taken 25702 times.
✗ Branch 11 → 36 not taken.
25702 } else if (ctx->postfixUnaryExpr()) {
1124
3/6
✓ Branch 12 → 13 taken 25702 times.
✗ Branch 12 → 52 not taken.
✓ Branch 13 → 14 taken 25702 times.
✗ Branch 13 → 52 not taken.
✓ Branch 14 → 15 taken 25702 times.
✗ Branch 14 → 50 not taken.
25702 postfixUnaryExprNode->postfixUnaryExpr = std::any_cast<PostfixUnaryExprNode *>(visit(ctx->postfixUnaryExpr()));
1125
1126 // Extract operator
1127
2/2
✓ Branch 17 → 18 taken 4335 times.
✓ Branch 17 → 23 taken 21367 times.
25702 if (ctx->assignExpr()) {
1128 4335 postfixUnaryExprNode->op = PostfixUnaryExprNode::PostfixUnaryOp::OP_SUBSCRIPT;
1129
3/6
✓ Branch 18 → 19 taken 4335 times.
✗ Branch 18 → 55 not taken.
✓ Branch 19 → 20 taken 4335 times.
✗ Branch 19 → 55 not taken.
✓ Branch 20 → 21 taken 4335 times.
✗ Branch 20 → 53 not taken.
4335 postfixUnaryExprNode->subscriptIndexExpr = std::any_cast<AssignExprNode *>(visit(ctx->assignExpr()));
1130
2/2
✓ Branch 24 → 25 taken 18858 times.
✓ Branch 24 → 30 taken 2509 times.
21367 } else if (ctx->IDENTIFIER()) {
1131 18858 postfixUnaryExprNode->op = PostfixUnaryExprNode::PostfixUnaryOp::OP_MEMBER_ACCESS;
1132
2/4
✓ Branch 25 → 26 taken 18858 times.
✗ Branch 25 → 56 not taken.
✓ Branch 26 → 27 taken 18858 times.
✗ Branch 26 → 56 not taken.
18858 postfixUnaryExprNode->identifier = getIdentifier(ctx->IDENTIFIER(), false);
1133
2/2
✓ Branch 31 → 32 taken 1982 times.
✓ Branch 31 → 33 taken 527 times.
2509 } else if (ctx->PLUS_PLUS()) {
1134 1982 postfixUnaryExprNode->op = PostfixUnaryExprNode::PostfixUnaryOp::OP_PLUS_PLUS;
1135
1/2
✓ Branch 34 → 35 taken 527 times.
✗ Branch 34 → 37 not taken.
527 } else if (ctx->MINUS_MINUS()) {
1136 527 postfixUnaryExprNode->op = PostfixUnaryExprNode::PostfixUnaryOp::OP_MINUS_MINUS;
1137 }
1138 } else {
1139 assert_fail("Unknown postfix unary expression type"); // GCOV_EXCL_LINE
1140 }
1141
1142
1/2
✓ Branch 43 → 44 taken 124003 times.
✗ Branch 43 → 57 not taken.
124003 return concludeNode(postfixUnaryExprNode);
1143 }
1144
1145 98303 std::any ASTBuilder::visitAtomicExpr(SpiceParser::AtomicExprContext *ctx) {
1146 98303 const auto atomicExprNode = createNode<AtomicExprNode>(ctx);
1147
1148 // Visit children
1149
2/2
✓ Branch 4 → 5 taken 19276 times.
✓ Branch 4 → 10 taken 79027 times.
98303 if (ctx->constant()) {
1150
4/6
✓ Branch 5 → 6 taken 19276 times.
✗ Branch 5 → 84 not taken.
✓ Branch 6 → 7 taken 19274 times.
✓ Branch 6 → 84 taken 2 times.
✓ Branch 7 → 8 taken 19274 times.
✗ Branch 7 → 82 not taken.
19276 atomicExprNode->constant = std::any_cast<ConstantNode *>(visit(ctx->constant()));
1151
2/2
✓ Branch 11 → 12 taken 21505 times.
✓ Branch 11 → 17 taken 57522 times.
79027 } else if (ctx->value()) {
1152
3/6
✓ Branch 12 → 13 taken 21505 times.
✗ Branch 12 → 87 not taken.
✓ Branch 13 → 14 taken 21505 times.
✗ Branch 13 → 87 not taken.
✓ Branch 14 → 15 taken 21505 times.
✗ Branch 14 → 85 not taken.
21505 atomicExprNode->value = std::any_cast<ValueNode *>(visit(ctx->value()));
1153
11/18
✓ Branch 17 → 18 taken 57522 times.
✗ Branch 17 → 88 not taken.
✓ Branch 19 → 20 taken 2520 times.
✓ Branch 19 → 23 taken 55002 times.
✓ Branch 20 → 21 taken 2520 times.
✗ Branch 20 → 88 not taken.
✓ Branch 22 → 23 taken 1827 times.
✓ Branch 22 → 24 taken 693 times.
✓ Branch 25 → 26 taken 2520 times.
✓ Branch 25 → 27 taken 55002 times.
✓ Branch 27 → 28 taken 57522 times.
✗ Branch 27 → 29 not taken.
✓ Branch 29 → 30 taken 56829 times.
✓ Branch 29 → 64 taken 693 times.
✗ Branch 88 → 89 not taken.
✗ Branch 88 → 90 not taken.
✗ Branch 92 → 93 not taken.
✗ Branch 92 → 94 not taken.
57522 } else if (!ctx->IDENTIFIER().empty() || !ctx->TYPE_IDENTIFIER().empty()) {
1154
2/2
✓ Branch 62 → 32 taken 57457 times.
✓ Branch 62 → 63 taken 56829 times.
114286 for (ParserRuleContext::ParseTree *subTree : ctx->children) {
1155
1/2
✓ Branch 33 → 34 taken 57457 times.
✗ Branch 33 → 35 not taken.
57457 const auto terminal = dynamic_cast<TerminalNode *>(subTree);
1156
1/2
✗ Branch 36 → 37 not taken.
✓ Branch 36 → 38 taken 57457 times.
57457 if (!terminal)
1157 continue;
1158
1159
4/6
✓ Branch 38 → 39 taken 57457 times.
✗ Branch 38 → 102 not taken.
✓ Branch 39 → 40 taken 57457 times.
✗ Branch 39 → 102 not taken.
✓ Branch 40 → 41 taken 55002 times.
✓ Branch 40 → 49 taken 2455 times.
57457 if (terminal->getSymbol()->getType() == SpiceParser::IDENTIFIER) {
1160
1/2
✓ Branch 41 → 42 taken 55002 times.
✗ Branch 41 → 98 not taken.
55002 std::string fragment = getIdentifier(terminal, false);
1161
1/2
✓ Branch 42 → 43 taken 55002 times.
✗ Branch 42 → 96 not taken.
55002 atomicExprNode->identifierFragments.push_back(fragment);
1162
1/2
✗ Branch 44 → 45 not taken.
✓ Branch 44 → 46 taken 55002 times.
55002 if (!atomicExprNode->fqIdentifier.empty())
1163 atomicExprNode->fqIdentifier += SCOPE_ACCESS_TOKEN;
1164
1/2
✓ Branch 46 → 47 taken 55002 times.
✗ Branch 46 → 96 not taken.
55002 atomicExprNode->fqIdentifier += fragment;
1165
4/6
✓ Branch 49 → 50 taken 2455 times.
✗ Branch 49 → 102 not taken.
✓ Branch 50 → 51 taken 2455 times.
✗ Branch 50 → 102 not taken.
✓ Branch 51 → 52 taken 2141 times.
✓ Branch 51 → 60 taken 314 times.
57457 } else if (terminal->getSymbol()->getType() == SpiceParser::TYPE_IDENTIFIER) {
1166
1/2
✓ Branch 52 → 53 taken 2141 times.
✗ Branch 52 → 101 not taken.
2141 std::string fragment = getIdentifier(terminal, false);
1167
1/2
✓ Branch 53 → 54 taken 2141 times.
✗ Branch 53 → 99 not taken.
2141 atomicExprNode->identifierFragments.push_back(fragment);
1168
2/2
✓ Branch 55 → 56 taken 314 times.
✓ Branch 55 → 57 taken 1827 times.
2141 if (!atomicExprNode->fqIdentifier.empty())
1169
1/2
✓ Branch 56 → 57 taken 314 times.
✗ Branch 56 → 99 not taken.
314 atomicExprNode->fqIdentifier += SCOPE_ACCESS_TOKEN;
1170
1/2
✓ Branch 57 → 58 taken 2141 times.
✗ Branch 57 → 99 not taken.
2141 atomicExprNode->fqIdentifier += fragment;
1171 2141 }
1172 }
1173
1/2
✓ Branch 65 → 66 taken 693 times.
✗ Branch 65 → 71 not taken.
693 } else if (ctx->assignExpr()) {
1174
3/6
✓ Branch 66 → 67 taken 693 times.
✗ Branch 66 → 105 not taken.
✓ Branch 67 → 68 taken 693 times.
✗ Branch 67 → 105 not taken.
✓ Branch 68 → 69 taken 693 times.
✗ Branch 68 → 103 not taken.
693 atomicExprNode->assignExpr = std::any_cast<AssignExprNode *>(visit(ctx->assignExpr()));
1175 } else {
1176 assert_fail("Unknown atomic expression type"); // GCOV_EXCL_LINE
1177 }
1178
1179
1/2
✓ Branch 78 → 79 taken 98301 times.
✗ Branch 78 → 106 not taken.
98301 return concludeNode(atomicExprNode);
1180 }
1181
1182 21505 std::any ASTBuilder::visitValue(SpiceParser::ValueContext *ctx) {
1183 21505 const auto valueNode = createNode<ValueNode>(ctx);
1184
1185 // Visit children
1186
2/2
✓ Branch 4 → 5 taken 19644 times.
✓ Branch 4 → 10 taken 1861 times.
21505 if (ctx->fctCall()) {
1187
3/6
✓ Branch 5 → 6 taken 19644 times.
✗ Branch 5 → 65 not taken.
✓ Branch 6 → 7 taken 19644 times.
✗ Branch 6 → 65 not taken.
✓ Branch 7 → 8 taken 19644 times.
✗ Branch 7 → 63 not taken.
19644 valueNode->fctCall = std::any_cast<FctCallNode *>(visit(ctx->fctCall()));
1188
2/2
✓ Branch 11 → 12 taken 75 times.
✓ Branch 11 → 17 taken 1786 times.
1861 } else if (ctx->arrayInitialization()) {
1189
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()));
1190
2/2
✓ Branch 18 → 19 taken 224 times.
✓ Branch 18 → 24 taken 1562 times.
1786 } else if (ctx->structInstantiation()) {
1191
3/6
✓ Branch 19 → 20 taken 224 times.
✗ Branch 19 → 71 not taken.
✓ Branch 20 → 21 taken 224 times.
✗ Branch 20 → 71 not taken.
✓ Branch 21 → 22 taken 224 times.
✗ Branch 21 → 69 not taken.
224 valueNode->structInstantiation = std::any_cast<StructInstantiationNode *>(visit(ctx->structInstantiation()));
1192
2/2
✓ Branch 25 → 26 taken 16 times.
✓ Branch 25 → 31 taken 1546 times.
1562 } else if (ctx->lambdaFunc()) {
1193
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()));
1194
2/2
✓ Branch 32 → 33 taken 20 times.
✓ Branch 32 → 38 taken 1526 times.
1546 } else if (ctx->lambdaProc()) {
1195
3/6
✓ Branch 33 → 34 taken 20 times.
✗ Branch 33 → 77 not taken.
✓ Branch 34 → 35 taken 20 times.
✗ Branch 34 → 77 not taken.
✓ Branch 35 → 36 taken 20 times.
✗ Branch 35 → 75 not taken.
20 valueNode->lambdaProc = std::any_cast<LambdaProcNode *>(visit(ctx->lambdaProc()));
1196
2/2
✓ Branch 39 → 40 taken 1 time.
✓ Branch 39 → 45 taken 1525 times.
1526 } else if (ctx->lambdaExpr()) {
1197
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()));
1198
1/2
✓ Branch 46 → 47 taken 1525 times.
✗ Branch 46 → 52 not taken.
1525 } else if (ctx->dataType()) {
1199 1525 valueNode->isNil = true;
1200
3/6
✓ Branch 47 → 48 taken 1525 times.
✗ Branch 47 → 83 not taken.
✓ Branch 48 → 49 taken 1525 times.
✗ Branch 48 → 83 not taken.
✓ Branch 49 → 50 taken 1525 times.
✗ Branch 49 → 81 not taken.
1525 valueNode->nilType = std::any_cast<DataTypeNode *>(visit(ctx->dataType()));
1201 } else {
1202 assert_fail("Unknown value type"); // GCOV_EXCL_LINE
1203 }
1204
1205
1/2
✓ Branch 59 → 60 taken 21505 times.
✗ Branch 59 → 84 not taken.
21505 return concludeNode(valueNode);
1206 }
1207
1208 21287 std::any ASTBuilder::visitConstant(SpiceParser::ConstantContext *ctx) {
1209 21287 const auto constantNode = createNode<ConstantNode>(ctx);
1210
1211 // Enrich
1212
2/2
✓ Branch 4 → 5 taken 652 times.
✓ Branch 4 → 10 taken 20635 times.
21287 if (ctx->DOUBLE_LIT()) {
1213 652 constantNode->type = ConstantNode::PrimitiveValueType::TYPE_DOUBLE;
1214
3/6
✓ Branch 5 → 6 taken 652 times.
✗ Branch 5 → 59 not taken.
✓ Branch 6 → 7 taken 652 times.
✗ Branch 6 → 59 not taken.
✓ Branch 7 → 8 taken 652 times.
✗ Branch 7 → 57 not taken.
652 constantNode->compileTimeValue.doubleValue = std::stod(ctx->DOUBLE_LIT()->toString());
1215
2/2
✓ Branch 11 → 12 taken 4575 times.
✓ Branch 11 → 15 taken 16060 times.
20635 } else if (ctx->INT_LIT()) {
1216 4575 constantNode->type = ConstantNode::PrimitiveValueType::TYPE_INT;
1217 4575 constantNode->compileTimeValue.intValue = parseInt(ctx->INT_LIT());
1218
2/2
✓ Branch 16 → 17 taken 866 times.
✓ Branch 16 → 20 taken 15194 times.
16060 } else if (ctx->SHORT_LIT()) {
1219 866 constantNode->type = ConstantNode::PrimitiveValueType::TYPE_SHORT;
1220 866 constantNode->compileTimeValue.shortValue = parseShort(ctx->SHORT_LIT());
1221
2/2
✓ Branch 21 → 22 taken 6383 times.
✓ Branch 21 → 25 taken 8811 times.
15194 } else if (ctx->LONG_LIT()) {
1222 6383 constantNode->type = ConstantNode::PrimitiveValueType::TYPE_LONG;
1223 6383 constantNode->compileTimeValue.longValue = parseLong(ctx->LONG_LIT());
1224
2/2
✓ Branch 26 → 27 taken 2968 times.
✓ Branch 26 → 30 taken 5843 times.
8811 } else if (ctx->CHAR_LIT()) {
1225 2968 constantNode->type = ConstantNode::PrimitiveValueType::TYPE_CHAR;
1226 2968 constantNode->compileTimeValue.charValue = parseChar(ctx->CHAR_LIT());
1227
2/2
✓ Branch 31 → 32 taken 3571 times.
✓ Branch 31 → 40 taken 2272 times.
5843 } else if (ctx->STRING_LIT()) {
1228 // Save a pointer to the string in the compile time value
1229 3571 constantNode->type = ConstantNode::PrimitiveValueType::TYPE_STRING;
1230 3571 constantNode->compileTimeValue.stringValueOffset = resourceManager.compileTimeStringValues.size();
1231 // Add the string to the global compile time string list
1232
4/8
✓ Branch 33 → 34 taken 3571 times.
✗ Branch 33 → 64 not taken.
✓ Branch 34 → 35 taken 3571 times.
✗ Branch 34 → 64 not taken.
✓ Branch 35 → 36 taken 3571 times.
✗ Branch 35 → 62 not taken.
✓ Branch 36 → 37 taken 3571 times.
✗ Branch 36 → 60 not taken.
3571 resourceManager.compileTimeStringValues.push_back(parseString(ctx->STRING_LIT()->toString()));
1233
2/2
✓ Branch 41 → 42 taken 1168 times.
✓ Branch 41 → 43 taken 1104 times.
2272 } else if (ctx->TRUE()) {
1234 1168 constantNode->type = ConstantNode::PrimitiveValueType::TYPE_BOOL;
1235 1168 constantNode->compileTimeValue.boolValue = true;
1236
1/2
✓ Branch 44 → 45 taken 1104 times.
✗ Branch 44 → 46 not taken.
1104 } else if (ctx->FALSE()) {
1237 1104 constantNode->type = ConstantNode::PrimitiveValueType::TYPE_BOOL;
1238 1104 constantNode->compileTimeValue.boolValue = false;
1239 } else {
1240 assert_fail("Unknown constant type"); // GCOV_EXCL_LINE
1241 }
1242
1243
1/2
✓ Branch 53 → 54 taken 21285 times.
✗ Branch 53 → 66 not taken.
21285 return concludeNode(constantNode);
1244 }
1245
1246 19644 std::any ASTBuilder::visitFctCall(SpiceParser::FctCallContext *ctx) {
1247 19644 const auto fctCallNode = createNode<FctCallNode>(ctx);
1248
1249
2/2
✓ Branch 37 → 5 taken 94932 times.
✓ Branch 37 → 38 taken 19644 times.
114576 for (antlr4::ParserRuleContext::ParseTree *subTree : ctx->children) {
1250
1/2
✓ Branch 6 → 7 taken 94932 times.
✗ Branch 6 → 8 not taken.
94932 const auto terminal = dynamic_cast<antlr4::tree::TerminalNode *>(subTree);
1251
2/2
✓ Branch 9 → 10 taken 16788 times.
✓ Branch 9 → 11 taken 78144 times.
94932 if (!terminal)
1252 16788 continue;
1253
1254
4/6
✓ Branch 11 → 12 taken 78144 times.
✗ Branch 11 → 68 not taken.
✓ Branch 12 → 13 taken 78144 times.
✗ Branch 12 → 68 not taken.
✓ Branch 13 → 14 taken 24829 times.
✓ Branch 13 → 19 taken 53315 times.
78144 if (terminal->getSymbol()->getType() == SpiceParser::IDENTIFIER) {
1255
1/2
✓ Branch 14 → 15 taken 24829 times.
✗ Branch 14 → 64 not taken.
24829 const std::string fragment = terminal->toString();
1256
1/2
✓ Branch 15 → 16 taken 24829 times.
✗ Branch 15 → 62 not taken.
24829 fctCallNode->functionNameFragments.push_back(fragment);
1257
1/2
✓ Branch 16 → 17 taken 24829 times.
✗ Branch 16 → 62 not taken.
24829 fctCallNode->fqFunctionName += fragment;
1258
4/6
✓ Branch 19 → 20 taken 53315 times.
✗ Branch 19 → 68 not taken.
✓ Branch 20 → 21 taken 53315 times.
✗ Branch 20 → 68 not taken.
✓ Branch 21 → 22 taken 3052 times.
✓ Branch 21 → 27 taken 50263 times.
78144 } else if (terminal->getSymbol()->getType() == SpiceParser::TYPE_IDENTIFIER) {
1259
1/2
✓ Branch 22 → 23 taken 3052 times.
✗ Branch 22 → 67 not taken.
3052 const std::string fragment = terminal->toString();
1260
1/2
✓ Branch 23 → 24 taken 3052 times.
✗ Branch 23 → 65 not taken.
3052 fctCallNode->functionNameFragments.push_back(fragment);
1261
1/2
✓ Branch 24 → 25 taken 3052 times.
✗ Branch 24 → 65 not taken.
3052 fctCallNode->fqFunctionName += fragment;
1262
4/6
✓ Branch 27 → 28 taken 50263 times.
✗ Branch 27 → 68 not taken.
✓ Branch 28 → 29 taken 50263 times.
✗ Branch 28 → 68 not taken.
✓ Branch 29 → 30 taken 62 times.
✓ Branch 29 → 31 taken 50201 times.
53315 } else if (terminal->getSymbol()->getType() == SpiceParser::SCOPE_ACCESS) {
1263
1/2
✓ Branch 30 → 35 taken 62 times.
✗ Branch 30 → 68 not taken.
62 fctCallNode->fqFunctionName += SCOPE_ACCESS_TOKEN;
1264
4/6
✓ Branch 31 → 32 taken 50201 times.
✗ Branch 31 → 68 not taken.
✓ Branch 32 → 33 taken 50201 times.
✗ Branch 32 → 68 not taken.
✓ Branch 33 → 34 taken 8175 times.
✓ Branch 33 → 35 taken 42026 times.
50201 } else if (terminal->getSymbol()->getType() == SpiceParser::DOT) {
1265
1/2
✓ Branch 34 → 35 taken 8175 times.
✗ Branch 34 → 68 not taken.
8175 fctCallNode->fqFunctionName += MEMBER_ACCESS_TOKEN;
1266 }
1267 }
1268
1269 // Visit children
1270
2/2
✓ Branch 39 → 40 taken 1369 times.
✓ Branch 39 → 45 taken 18275 times.
19644 if (ctx->typeLst()) {
1271 1369 fctCallNode->hasTemplateTypes = true;
1272
3/6
✓ Branch 40 → 41 taken 1369 times.
✗ Branch 40 → 71 not taken.
✓ Branch 41 → 42 taken 1369 times.
✗ Branch 41 → 71 not taken.
✓ Branch 42 → 43 taken 1369 times.
✗ Branch 42 → 69 not taken.
1369 fctCallNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst()));
1273 }
1274
2/2
✓ Branch 46 → 47 taken 15419 times.
✓ Branch 46 → 52 taken 4225 times.
19644 if (ctx->argLst()) {
1275 15419 fctCallNode->hasArgs = true;
1276
3/6
✓ Branch 47 → 48 taken 15419 times.
✗ Branch 47 → 74 not taken.
✓ Branch 48 → 49 taken 15419 times.
✗ Branch 48 → 74 not taken.
✓ Branch 49 → 50 taken 15419 times.
✗ Branch 49 → 72 not taken.
15419 fctCallNode->argLst = std::any_cast<ArgLstNode *>(visit(ctx->argLst()));
1277 }
1278
1279
1/2
✓ Branch 58 → 59 taken 19644 times.
✗ Branch 58 → 75 not taken.
19644 return concludeNode(fctCallNode);
1280 }
1281
1282 75 std::any ASTBuilder::visitArrayInitialization(SpiceParser::ArrayInitializationContext *ctx) {
1283 75 const auto arrayInitializationNode = createNode<ArrayInitializationNode>(ctx);
1284
1285 // Visit children
1286
2/2
✓ Branch 4 → 5 taken 74 times.
✓ Branch 4 → 10 taken 1 time.
75 if (ctx->argLst())
1287
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()));
1288
1289
1/2
✓ Branch 16 → 17 taken 75 times.
✗ Branch 16 → 23 not taken.
75 return concludeNode(arrayInitializationNode);
1290 }
1291
1292 224 std::any ASTBuilder::visitStructInstantiation(SpiceParser::StructInstantiationContext *ctx) {
1293 224 const auto structInstantiationNode = createNode<StructInstantiationNode>(ctx);
1294
1295 // Enrich
1296
2/2
✓ Branch 31 → 5 taken 945 times.
✓ Branch 31 → 32 taken 224 times.
1169 for (antlr4::ParserRuleContext::ParseTree *subTree : ctx->children) {
1297
1/2
✓ Branch 6 → 7 taken 945 times.
✗ Branch 6 → 8 not taken.
945 const auto terminal = dynamic_cast<antlr4::tree::TerminalNode *>(subTree);
1298
2/2
✓ Branch 9 → 10 taken 227 times.
✓ Branch 9 → 11 taken 718 times.
945 if (!terminal)
1299 227 continue;
1300
1301
4/6
✓ Branch 11 → 12 taken 718 times.
✗ Branch 11 → 65 not taken.
✓ Branch 12 → 13 taken 718 times.
✗ Branch 12 → 65 not taken.
✓ Branch 13 → 14 taken 3 times.
✓ Branch 13 → 21 taken 715 times.
718 if (terminal->getSymbol()->getType() == SpiceParser::IDENTIFIER) {
1302
1/2
✓ Branch 14 → 15 taken 3 times.
✗ Branch 14 → 61 not taken.
3 const std::string fragment = terminal->toString();
1303
1/2
✓ Branch 15 → 16 taken 3 times.
✗ Branch 15 → 59 not taken.
3 structInstantiationNode->structNameFragments.push_back(fragment);
1304
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;
1305
4/6
✓ Branch 21 → 22 taken 715 times.
✗ Branch 21 → 65 not taken.
✓ Branch 22 → 23 taken 715 times.
✗ Branch 22 → 65 not taken.
✓ Branch 23 → 24 taken 224 times.
✓ Branch 23 → 29 taken 491 times.
718 } else if (terminal->getSymbol()->getType() == SpiceParser::TYPE_IDENTIFIER) {
1306
1/2
✓ Branch 24 → 25 taken 224 times.
✗ Branch 24 → 64 not taken.
224 const std::string fragment = terminal->toString();
1307
1/2
✓ Branch 25 → 26 taken 224 times.
✗ Branch 25 → 62 not taken.
224 structInstantiationNode->structNameFragments.push_back(fragment);
1308
1/2
✓ Branch 26 → 27 taken 224 times.
✗ Branch 26 → 62 not taken.
224 structInstantiationNode->fqStructName += fragment;
1309 224 }
1310 }
1311
1312 // Visit children
1313
2/2
✓ Branch 33 → 34 taken 20 times.
✓ Branch 33 → 39 taken 204 times.
224 if (ctx->typeLst()) {
1314 20 structInstantiationNode->hasTemplateTypes = true;
1315
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()));
1316 }
1317
2/2
✓ Branch 40 → 41 taken 207 times.
✓ Branch 40 → 46 taken 17 times.
224 if (ctx->argLst())
1318
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()));
1319
1320
1/2
✓ Branch 52 → 53 taken 224 times.
✗ Branch 52 → 72 not taken.
224 return concludeNode(structInstantiationNode);
1321 }
1322
1323 16 std::any ASTBuilder::visitLambdaFunc(SpiceParser::LambdaFuncContext *ctx) {
1324 16 const auto lambdaFuncNode = createNode<LambdaFuncNode>(ctx);
1325
1326 // Visit children
1327
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()));
1328
2/2
✓ Branch 8 → 9 taken 12 times.
✓ Branch 8 → 14 taken 4 times.
16 if (ctx->paramLst()) {
1329 12 lambdaFuncNode->hasParams = true;
1330
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()));
1331 }
1332
1/2
✗ Branch 15 → 16 not taken.
✓ Branch 15 → 21 taken 16 times.
16 if (ctx->lambdaAttr())
1333 lambdaFuncNode->lambdaAttr = std::any_cast<LambdaAttrNode *>(visit(ctx->lambdaAttr()));
1334
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()));
1335
1336
1/2
✓ Branch 31 → 32 taken 16 times.
✗ Branch 31 → 47 not taken.
16 return concludeNode(lambdaFuncNode);
1337 }
1338
1339 20 std::any ASTBuilder::visitLambdaProc(SpiceParser::LambdaProcContext *ctx) {
1340 20 const auto lambdaProcNode = createNode<LambdaProcNode>(ctx);
1341
1342 // Visit children
1343
2/2
✓ Branch 4 → 5 taken 11 times.
✓ Branch 4 → 10 taken 9 times.
20 if (ctx->paramLst()) {
1344 11 lambdaProcNode->hasParams = true;
1345
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()));
1346 }
1347
2/2
✓ Branch 11 → 12 taken 5 times.
✓ Branch 11 → 17 taken 15 times.
20 if (ctx->lambdaAttr())
1348
3/6
✓ Branch 12 → 13 taken 5 times.
✗ Branch 12 → 36 not taken.
✓ Branch 13 → 14 taken 5 times.
✗ Branch 13 → 36 not taken.
✓ Branch 14 → 15 taken 5 times.
✗ Branch 14 → 34 not taken.
5 lambdaProcNode->lambdaAttr = std::any_cast<LambdaAttrNode *>(visit(ctx->lambdaAttr()));
1349
3/6
✓ Branch 17 → 18 taken 20 times.
✗ Branch 17 → 39 not taken.
✓ Branch 18 → 19 taken 20 times.
✗ Branch 18 → 39 not taken.
✓ Branch 19 → 20 taken 20 times.
✗ Branch 19 → 37 not taken.
20 lambdaProcNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst()));
1350
1351
1/2
✓ Branch 27 → 28 taken 20 times.
✗ Branch 27 → 40 not taken.
20 return concludeNode(lambdaProcNode);
1352 }
1353
1354 1 std::any ASTBuilder::visitLambdaExpr(SpiceParser::LambdaExprContext *ctx) {
1355 1 const auto lambdaExprNode = createNode<LambdaExprNode>(ctx);
1356
1357 // Visit children
1358
1/2
✓ Branch 4 → 5 taken 1 time.
✗ Branch 4 → 10 not taken.
1 if (ctx->paramLst()) {
1359 1 lambdaExprNode->hasParams = true;
1360
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()));
1361 }
1362
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()));
1363
1364
1/2
✓ Branch 20 → 21 taken 1 time.
✗ Branch 20 → 30 not taken.
1 return concludeNode(lambdaExprNode);
1365 }
1366
1367 50756 std::any ASTBuilder::visitDataType(SpiceParser::DataTypeContext *ctx) {
1368 50756 const auto dataTypeNode = createNode<DataTypeNode>(ctx);
1369
1370 // Visit children
1371
2/2
✓ Branch 4 → 5 taken 19857 times.
✓ Branch 4 → 10 taken 30899 times.
50756 if (ctx->qualifierLst())
1372
4/6
✓ Branch 5 → 6 taken 19857 times.
✗ Branch 5 → 74 not taken.
✓ Branch 6 → 7 taken 19856 times.
✓ Branch 6 → 74 taken 1 time.
✓ Branch 7 → 8 taken 19856 times.
✗ Branch 7 → 72 not taken.
19857 dataTypeNode->qualifierLst = std::any_cast<QualifierLstNode *>(visit(ctx->qualifierLst()));
1373
3/6
✓ Branch 10 → 11 taken 50755 times.
✗ Branch 10 → 77 not taken.
✓ Branch 11 → 12 taken 50755 times.
✗ Branch 11 → 77 not taken.
✓ Branch 12 → 13 taken 50755 times.
✗ Branch 12 → 75 not taken.
50755 dataTypeNode->baseDataType = std::any_cast<BaseDataTypeNode *>(visit(ctx->baseDataType()));
1374
1375 // Enrich
1376
2/2
✓ Branch 61 → 15 taken 82782 times.
✓ Branch 61 → 62 taken 50755 times.
133537 for (size_t i = 0; i < ctx->children.size(); i++) {
1377 82782 antlr4::tree::ParseTree *subTree = ctx->children.at(i);
1378
1/2
✓ Branch 16 → 17 taken 82782 times.
✗ Branch 16 → 18 not taken.
82782 auto terminal = dynamic_cast<TerminalNode *>(subTree);
1379
2/2
✓ Branch 19 → 20 taken 70611 times.
✓ Branch 19 → 21 taken 12171 times.
82782 if (!terminal)
1380 70611 continue;
1381
1382
2/2
✓ Branch 23 → 24 taken 6386 times.
✓ Branch 23 → 26 taken 5785 times.
12171 if (terminal->getSymbol()->getType() == SpiceParser::MUL) {
1383
1/2
✓ Branch 24 → 25 taken 6386 times.
✗ Branch 24 → 78 not taken.
6386 dataTypeNode->tmQueue.emplace(DataTypeNode::TypeModifierType::TYPE_PTR, false, 0);
1384
2/2
✓ Branch 28 → 29 taken 5680 times.
✓ Branch 28 → 31 taken 105 times.
5785 } else if (terminal->getSymbol()->getType() == SpiceParser::BITWISE_AND) {
1385
1/2
✓ Branch 29 → 30 taken 5680 times.
✗ Branch 29 → 81 not taken.
5680 dataTypeNode->tmQueue.emplace(DataTypeNode::TypeModifierType::TYPE_REF, false, 0);
1386
1/2
✓ Branch 33 → 34 taken 105 times.
✗ Branch 33 → 59 not taken.
105 } else if (terminal->getSymbol()->getType() == SpiceParser::LBRACKET) {
1387 105 i++; // Consume LBRACKET
1388
1/2
✓ Branch 34 → 35 taken 105 times.
✗ Branch 34 → 93 not taken.
105 subTree = ctx->children.at(i);
1389
1/2
✓ Branch 35 → 36 taken 105 times.
✗ Branch 35 → 37 not taken.
105 terminal = dynamic_cast<TerminalNode *>(subTree);
1390 105 bool hasSize = false;
1391 105 unsigned int hardCodedSize = 0;
1392 105 std::string sizeVarName;
1393
4/6
✓ Branch 39 → 40 taken 105 times.
✗ Branch 39 → 91 not taken.
✓ Branch 40 → 41 taken 105 times.
✗ Branch 40 → 91 not taken.
✓ Branch 41 → 42 taken 51 times.
✓ Branch 41 → 47 taken 54 times.
105 if (terminal->getSymbol()->getType() == SpiceParser::INT_LIT) {
1394 51 hasSize = true;
1395
3/6
✓ Branch 42 → 43 taken 51 times.
✗ Branch 42 → 86 not taken.
✓ Branch 43 → 44 taken 51 times.
✗ Branch 43 → 86 not taken.
✓ Branch 44 → 45 taken 51 times.
✗ Branch 44 → 84 not taken.
51 hardCodedSize = std::stoi(terminal->getSymbol()->getText());
1396 51 i++; // Consume INT_LIT
1397
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) {
1398 24 hasSize = true;
1399
1/2
✓ Branch 50 → 51 taken 24 times.
✗ Branch 50 → 87 not taken.
24 sizeVarName = getIdentifier(terminal, true);
1400 24 i++; // Consume TYPE_IDENTIFIER
1401 }
1402
1/2
✓ Branch 55 → 56 taken 105 times.
✗ Branch 55 → 88 not taken.
105 dataTypeNode->tmQueue.push({DataTypeNode::TypeModifierType::TYPE_ARRAY, hasSize, hardCodedSize, sizeVarName});
1403 105 }
1404 }
1405
1406
1/2
✓ Branch 68 → 69 taken 50755 times.
✗ Branch 68 → 94 not taken.
50755 return concludeNode(dataTypeNode);
1407
1/2
✓ Branch 54 → 55 taken 105 times.
✗ Branch 54 → 90 not taken.
105 }
1408
1409 50755 std::any ASTBuilder::visitBaseDataType(SpiceParser::BaseDataTypeContext *ctx) {
1410 50755 const auto baseDataTypeNode = createNode<BaseDataTypeNode>(ctx);
1411
1412 // Enrich
1413
2/2
✓ Branch 4 → 5 taken 580 times.
✓ Branch 4 → 6 taken 50175 times.
50755 if (ctx->TYPE_DOUBLE()) {
1414 580 baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_DOUBLE;
1415
2/2
✓ Branch 7 → 8 taken 3369 times.
✓ Branch 7 → 9 taken 46806 times.
50175 } else if (ctx->TYPE_INT()) {
1416 3369 baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_INT;
1417
2/2
✓ Branch 10 → 11 taken 1172 times.
✓ Branch 10 → 12 taken 45634 times.
46806 } else if (ctx->TYPE_SHORT()) {
1418 1172 baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_SHORT;
1419
2/2
✓ Branch 13 → 14 taken 9638 times.
✓ Branch 13 → 15 taken 35996 times.
45634 } else if (ctx->TYPE_LONG()) {
1420 9638 baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_LONG;
1421
2/2
✓ Branch 16 → 17 taken 2840 times.
✓ Branch 16 → 18 taken 33156 times.
35996 } else if (ctx->TYPE_BYTE()) {
1422 2840 baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_BYTE;
1423
2/2
✓ Branch 19 → 20 taken 5474 times.
✓ Branch 19 → 21 taken 27682 times.
33156 } else if (ctx->TYPE_CHAR()) {
1424 5474 baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_CHAR;
1425
2/2
✓ Branch 22 → 23 taken 4222 times.
✓ Branch 22 → 24 taken 23460 times.
27682 } else if (ctx->TYPE_STRING()) {
1426 4222 baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_STRING;
1427
2/2
✓ Branch 25 → 26 taken 4116 times.
✓ Branch 25 → 27 taken 19344 times.
23460 } else if (ctx->TYPE_BOOL()) {
1428 4116 baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_BOOL;
1429
2/2
✓ Branch 28 → 29 taken 482 times.
✓ Branch 28 → 30 taken 18862 times.
19344 } else if (ctx->TYPE_DYN()) {
1430 482 baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_DYN;
1431
2/2
✓ Branch 31 → 32 taken 18766 times.
✓ Branch 31 → 37 taken 96 times.
18862 } else if (ctx->customDataType()) {
1432 18766 baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_CUSTOM;
1433
3/6
✓ Branch 32 → 33 taken 18766 times.
✗ Branch 32 → 57 not taken.
✓ Branch 33 → 34 taken 18766 times.
✗ Branch 33 → 57 not taken.
✓ Branch 34 → 35 taken 18766 times.
✗ Branch 34 → 55 not taken.
18766 baseDataTypeNode->customDataType = std::any_cast<CustomDataTypeNode *>(visit(ctx->customDataType()));
1434
1/2
✓ Branch 38 → 39 taken 96 times.
✗ Branch 38 → 44 not taken.
96 } else if (ctx->functionDataType()) {
1435 96 baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_FUNCTION;
1436
3/6
✓ Branch 39 → 40 taken 96 times.
✗ Branch 39 → 60 not taken.
✓ Branch 40 → 41 taken 96 times.
✗ Branch 40 → 60 not taken.
✓ Branch 41 → 42 taken 96 times.
✗ Branch 41 → 58 not taken.
96 baseDataTypeNode->functionDataType = std::any_cast<FunctionDataTypeNode *>(visit(ctx->functionDataType()));
1437 } else {
1438 assert_fail("Unknown base data type");
1439 }
1440
1441
1/2
✓ Branch 51 → 52 taken 50755 times.
✗ Branch 51 → 61 not taken.
50755 return concludeNode(baseDataTypeNode);
1442 }
1443
1444 18766 std::any ASTBuilder::visitCustomDataType(SpiceParser::CustomDataTypeContext *ctx) {
1445 18766 const auto customDataTypeNode = createNode<CustomDataTypeNode>(ctx);
1446
1447 // Enrich
1448
2/2
✓ Branch 31 → 5 taken 26656 times.
✓ Branch 31 → 32 taken 18766 times.
45422 for (ParserRuleContext::ParseTree *subTree : ctx->children) {
1449
1/2
✓ Branch 6 → 7 taken 26656 times.
✗ Branch 6 → 8 not taken.
26656 const auto terminal = dynamic_cast<TerminalNode *>(subTree);
1450
2/2
✓ Branch 9 → 10 taken 2612 times.
✓ Branch 9 → 11 taken 24044 times.
26656 if (!terminal)
1451 2612 continue;
1452
1453
4/6
✓ Branch 11 → 12 taken 24044 times.
✗ Branch 11 → 58 not taken.
✓ Branch 12 → 13 taken 24044 times.
✗ Branch 12 → 58 not taken.
✓ Branch 13 → 14 taken 27 times.
✓ Branch 13 → 21 taken 24017 times.
24044 if (terminal->getSymbol()->getType() == SpiceParser::IDENTIFIER) {
1454
1/2
✓ Branch 14 → 15 taken 27 times.
✗ Branch 14 → 54 not taken.
27 const std::string fragment = terminal->toString();
1455
1/2
✓ Branch 15 → 16 taken 27 times.
✗ Branch 15 → 52 not taken.
27 customDataTypeNode->typeNameFragments.push_back(fragment);
1456
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;
1457
4/6
✓ Branch 21 → 22 taken 24017 times.
✗ Branch 21 → 58 not taken.
✓ Branch 22 → 23 taken 24017 times.
✗ Branch 22 → 58 not taken.
✓ Branch 23 → 24 taken 18766 times.
✓ Branch 23 → 29 taken 5251 times.
24044 } else if (terminal->getSymbol()->getType() == SpiceParser::TYPE_IDENTIFIER) {
1458
1/2
✓ Branch 24 → 25 taken 18766 times.
✗ Branch 24 → 57 not taken.
18766 const std::string fragment = terminal->toString();
1459
1/2
✓ Branch 25 → 26 taken 18766 times.
✗ Branch 25 → 55 not taken.
18766 customDataTypeNode->typeNameFragments.push_back(fragment);
1460
1/2
✓ Branch 26 → 27 taken 18766 times.
✗ Branch 26 → 55 not taken.
18766 customDataTypeNode->fqTypeName += fragment;
1461 18766 }
1462 }
1463
1464 // Visit children
1465
2/2
✓ Branch 33 → 34 taken 2612 times.
✓ Branch 33 → 39 taken 16154 times.
18766 if (ctx->typeLst())
1466
3/6
✓ Branch 34 → 35 taken 2612 times.
✗ Branch 34 → 61 not taken.
✓ Branch 35 → 36 taken 2612 times.
✗ Branch 35 → 61 not taken.
✓ Branch 36 → 37 taken 2612 times.
✗ Branch 36 → 59 not taken.
2612 customDataTypeNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst()));
1467
1468
1/2
✓ Branch 45 → 46 taken 18766 times.
✗ Branch 45 → 62 not taken.
18766 return concludeNode(customDataTypeNode);
1469 }
1470
1471 96 std::any ASTBuilder::visitFunctionDataType(SpiceParser::FunctionDataTypeContext *ctx) {
1472 96 const auto functionDataTypeNode = createNode<FunctionDataTypeNode>(ctx);
1473
1474 // Enrich
1475
2/2
✓ Branch 4 → 5 taken 32 times.
✓ Branch 4 → 11 taken 64 times.
96 if (ctx->dataType()) {
1476 32 functionDataTypeNode->isFunction = ctx->dataType();
1477
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()));
1478 }
1479
2/2
✓ Branch 12 → 13 taken 66 times.
✓ Branch 12 → 18 taken 30 times.
96 if (ctx->typeLst())
1480
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()));
1481
1482
1/2
✓ Branch 24 → 25 taken 96 times.
✗ Branch 24 → 34 not taken.
96 return concludeNode(functionDataTypeNode);
1483 }
1484
1485 8031 std::any ASTBuilder::visitAssignOp(SpiceParser::AssignOpContext *ctx) {
1486 8031 const auto assignExprNode = resumeForExpansion<AssignExprNode>();
1487
1488 // Extract assign operator
1489
2/2
✓ Branch 13 → 14 taken 7116 times.
✓ Branch 13 → 15 taken 915 times.
8031 if (ctx->ASSIGN())
1490 7116 assignExprNode->op = AssignExprNode::AssignOp::OP_ASSIGN;
1491
2/2
✓ Branch 16 → 17 taken 389 times.
✓ Branch 16 → 18 taken 526 times.
915 else if (ctx->PLUS_EQUAL())
1492 389 assignExprNode->op = AssignExprNode::AssignOp::OP_PLUS_EQUAL;
1493
2/2
✓ Branch 19 → 20 taken 68 times.
✓ Branch 19 → 21 taken 458 times.
526 else if (ctx->MINUS_EQUAL())
1494 68 assignExprNode->op = AssignExprNode::AssignOp::OP_MINUS_EQUAL;
1495
2/2
✓ Branch 22 → 23 taken 42 times.
✓ Branch 22 → 24 taken 416 times.
458 else if (ctx->MUL_EQUAL())
1496 42 assignExprNode->op = AssignExprNode::AssignOp::OP_MUL_EQUAL;
1497
2/2
✓ Branch 25 → 26 taken 44 times.
✓ Branch 25 → 27 taken 372 times.
416 else if (ctx->DIV_EQUAL())
1498 44 assignExprNode->op = AssignExprNode::AssignOp::OP_DIV_EQUAL;
1499
2/2
✓ Branch 28 → 29 taken 8 times.
✓ Branch 28 → 30 taken 364 times.
372 else if (ctx->REM_EQUAL())
1500 8 assignExprNode->op = AssignExprNode::AssignOp::OP_REM_EQUAL;
1501
2/2
✓ Branch 31 → 32 taken 3 times.
✓ Branch 31 → 33 taken 361 times.
364 else if (ctx->SHL_EQUAL())
1502 3 assignExprNode->op = AssignExprNode::AssignOp::OP_SHL_EQUAL;
1503
2/2
✓ Branch 34 → 35 taken 4 times.
✓ Branch 34 → 36 taken 357 times.
361 else if (ctx->SHR_EQUAL())
1504 4 assignExprNode->op = AssignExprNode::AssignOp::OP_SHR_EQUAL;
1505
2/2
✓ Branch 37 → 38 taken 2 times.
✓ Branch 37 → 39 taken 355 times.
357 else if (ctx->AND_EQUAL())
1506 2 assignExprNode->op = AssignExprNode::AssignOp::OP_AND_EQUAL;
1507
2/2
✓ Branch 40 → 41 taken 2 times.
✓ Branch 40 → 42 taken 353 times.
355 else if (ctx->OR_EQUAL())
1508 2 assignExprNode->op = AssignExprNode::AssignOp::OP_OR_EQUAL;
1509
1/2
✓ Branch 43 → 44 taken 353 times.
✗ Branch 43 → 45 not taken.
353 else if (ctx->XOR_EQUAL())
1510 353 assignExprNode->op = AssignExprNode::AssignOp::OP_XOR_EQUAL;
1511 else
1512 assert_fail("Unknown assign operator");
1513
1514
1/2
✓ Branch 46 → 47 taken 8031 times.
✗ Branch 46 → 49 not taken.
8031 return nullptr;
1515 }
1516
1517 1831 std::any ASTBuilder::visitOverloadableOp(SpiceParser::OverloadableOpContext *ctx) {
1518 1831 const auto fctNameNode = resumeForExpansion<FctNameNode>();
1519
1520 // Enrich
1521
2/2
✓ Branch 13 → 14 taken 97 times.
✓ Branch 13 → 15 taken 1734 times.
1831 if (ctx->PLUS())
1522 97 fctNameNode->name = OP_FCT_PLUS;
1523
2/2
✓ Branch 16 → 17 taken 1 time.
✓ Branch 16 → 18 taken 1733 times.
1734 else if (ctx->MINUS())
1524 1 fctNameNode->name = OP_FCT_MINUS;
1525
2/2
✓ Branch 19 → 20 taken 193 times.
✓ Branch 19 → 21 taken 1540 times.
1733 else if (ctx->MUL())
1526 193 fctNameNode->name = OP_FCT_MUL;
1527
2/2
✓ Branch 22 → 23 taken 22 times.
✓ Branch 22 → 24 taken 1518 times.
1540 else if (ctx->DIV())
1528 22 fctNameNode->name = OP_FCT_DIV;
1529
2/2
✓ Branch 25 → 26 taken 436 times.
✓ Branch 25 → 27 taken 1082 times.
1518 else if (ctx->EQUAL())
1530 436 fctNameNode->name = OP_FCT_EQUAL;
1531
2/2
✓ Branch 28 → 29 taken 433 times.
✓ Branch 28 → 30 taken 649 times.
1082 else if (ctx->NOT_EQUAL())
1532 433 fctNameNode->name = OP_FCT_NOT_EQUAL;
1533
3/4
✓ Branch 30 → 31 taken 649 times.
✗ Branch 30 → 67 not taken.
✓ Branch 33 → 34 taken 13 times.
✓ Branch 33 → 35 taken 636 times.
649 else if (ctx->LESS().size() == 2)
1534 13 fctNameNode->name = OP_FCT_SHL;
1535
3/4
✓ Branch 35 → 36 taken 636 times.
✗ Branch 35 → 68 not taken.
✓ Branch 38 → 39 taken 1 time.
✓ Branch 38 → 40 taken 635 times.
636 else if (ctx->GREATER().size() == 2)
1536 1 fctNameNode->name = OP_FCT_SHR;
1537
2/2
✓ Branch 41 → 42 taken 138 times.
✓ Branch 41 → 43 taken 497 times.
635 else if (ctx->PLUS_EQUAL())
1538 138 fctNameNode->name = OP_FCT_PLUS_EQUAL;
1539
2/2
✓ Branch 44 → 45 taken 42 times.
✓ Branch 44 → 46 taken 455 times.
497 else if (ctx->MINUS_EQUAL())
1540 42 fctNameNode->name = OP_FCT_MINUS_EQUAL;
1541
2/2
✓ Branch 47 → 48 taken 97 times.
✓ Branch 47 → 49 taken 358 times.
455 else if (ctx->MUL_EQUAL())
1542 97 fctNameNode->name = OP_FCT_MUL_EQUAL;
1543
2/2
✓ Branch 50 → 51 taken 22 times.
✓ Branch 50 → 52 taken 336 times.
358 else if (ctx->DIV_EQUAL())
1544 22 fctNameNode->name = OP_FCT_DIV_EQUAL;
1545
2/2
✓ Branch 53 → 54 taken 52 times.
✓ Branch 53 → 55 taken 284 times.
336 else if (ctx->PLUS_PLUS())
1546 52 fctNameNode->name = OP_FCT_POSTFIX_PLUS_PLUS;
1547
2/2
✓ Branch 56 → 57 taken 42 times.
✓ Branch 56 → 58 taken 242 times.
284 else if (ctx->MINUS_MINUS())
1548 42 fctNameNode->name = OP_FCT_POSTFIX_MINUS_MINUS;
1549
1/2
✓ Branch 59 → 60 taken 242 times.
✗ Branch 59 → 61 not taken.
242 else if (ctx->LBRACKET())
1550 242 fctNameNode->name = OP_FCT_SUBSCRIPT;
1551 else
1552 assert_fail("Unsupported overloadable operator"); // GCOV_EXCL_LINE
1553
1554 1831 fctNameNode->fqName = fctNameNode->name;
1555 1831 fctNameNode->nameFragments.push_back(fctNameNode->name);
1556
1557
1/2
✓ Branch 64 → 65 taken 1831 times.
✗ Branch 64 → 69 not taken.
1831 return nullptr;
1558 }
1559
1560 4984 int32_t ASTBuilder::parseInt(TerminalNode *terminal) {
1561 9968 const NumericParserCallback<int32_t> cb = [](const std::string &substr, short base, bool isSigned) -> int32_t {
1562 // Prepare limits
1563
2/2
✓ Branch 2 → 3 taken 4977 times.
✓ Branch 2 → 4 taken 7 times.
4984 const int64_t upperLimit = isSigned ? INT32_MAX : UINT32_MAX;
1564
2/2
✓ Branch 5 → 6 taken 4977 times.
✓ Branch 5 → 7 taken 7 times.
4984 const int64_t lowerLimit = isSigned ? INT32_MIN : 0;
1565 // Parse number and check for limits
1566 4984 const int64_t number = std::stoll(substr, nullptr, base);
1567
2/4
✓ Branch 9 → 10 taken 4983 times.
✗ Branch 9 → 11 not taken.
✗ Branch 10 → 11 not taken.
✓ Branch 10 → 14 taken 4983 times.
4983 if (number < lowerLimit || number > upperLimit)
1568 throw std::out_of_range("Number out of range");
1569 4983 return static_cast<int32_t>(number);
1570 4984 };
1571
2/2
✓ Branch 3 → 4 taken 4983 times.
✓ Branch 3 → 8 taken 1 time.
9967 return parseNumeric(terminal, cb);
1572 4984 }
1573
1574 866 int16_t ASTBuilder::parseShort(TerminalNode *terminal) {
1575 1732 const NumericParserCallback<int16_t> cb = [](const std::string &substr, short base, bool isSigned) -> int16_t {
1576 // Prepare limits
1577
2/2
✓ Branch 2 → 3 taken 532 times.
✓ Branch 2 → 4 taken 334 times.
866 const int64_t upperLimit = isSigned ? INT16_MAX : UINT16_MAX;
1578
2/2
✓ Branch 5 → 6 taken 532 times.
✓ Branch 5 → 7 taken 334 times.
866 const int64_t lowerLimit = isSigned ? INT16_MIN : 0;
1579 // Parse number and check for limits
1580 866 const int64_t number = std::stoll(substr, nullptr, base);
1581
2/4
✓ Branch 9 → 10 taken 866 times.
✗ Branch 9 → 11 not taken.
✗ Branch 10 → 11 not taken.
✓ Branch 10 → 14 taken 866 times.
866 if (number < lowerLimit || number > upperLimit)
1582 throw std::out_of_range("Number out of range");
1583 866 return static_cast<int16_t>(number);
1584 866 };
1585
1/2
✓ Branch 3 → 4 taken 866 times.
✗ Branch 3 → 8 not taken.
1732 return parseNumeric(terminal, cb);
1586 866 }
1587
1588 6383 int64_t ASTBuilder::parseLong(TerminalNode *terminal) {
1589 12766 const NumericParserCallback<int64_t> cb = [](const std::string &substr, short base, bool isSigned) -> int64_t {
1590
2/2
✓ Branch 2 → 3 taken 6237 times.
✓ Branch 2 → 5 taken 146 times.
6383 return isSigned ? std::stoll(substr, nullptr, base) : static_cast<int64_t>(std::stoull(substr, nullptr, base));
1591 6383 };
1592
1/2
✓ Branch 3 → 4 taken 6383 times.
✗ Branch 3 → 8 not taken.
12766 return parseNumeric(terminal, cb);
1593 6383 }
1594
1595 2968 int8_t ASTBuilder::parseChar(TerminalNode *terminal) const {
1596
1/2
✓ Branch 2 → 3 taken 2968 times.
✗ Branch 2 → 59 not taken.
2968 const std::string input = terminal->toString();
1597
2/2
✓ Branch 4 → 5 taken 1877 times.
✓ Branch 4 → 7 taken 1091 times.
2968 if (input.length() == 3) // Normal char literals
1598 1877 return input[1];
1599
1600
3/6
✓ Branch 8 → 9 taken 1091 times.
✗ Branch 8 → 12 not taken.
✓ Branch 10 → 11 taken 1091 times.
✗ Branch 10 → 12 not taken.
✓ Branch 13 → 14 taken 1091 times.
✗ Branch 13 → 34 not taken.
1091 if (input.length() == 4 && input[1] == '\\') { // Char literals with escape sequence
1601
7/11
✓ Branch 15 → 16 taken 5 times.
✗ Branch 15 → 17 not taken.
✓ Branch 15 → 18 taken 11 times.
✓ Branch 15 → 19 taken 112 times.
✓ Branch 15 → 20 taken 96 times.
✓ Branch 15 → 21 taken 96 times.
✗ Branch 15 → 22 not taken.
✗ Branch 15 → 23 not taken.
✗ Branch 15 → 24 not taken.
✓ Branch 15 → 25 taken 770 times.
✓ Branch 15 → 26 taken 1 time.
1091 switch (input[2]) {
1602 5 case '\'':
1603 5 return '\'';
1604 case '"':
1605 return '\"';
1606 11 case '\\':
1607 11 return '\\';
1608 112 case 'n':
1609 112 return '\n';
1610 96 case 'r':
1611 96 return '\r';
1612 96 case 't':
1613 96 return '\t';
1614 case 'b':
1615 return '\b';
1616 case 'f':
1617 return '\f';
1618 case 'v':
1619 return '\v';
1620 770 case '0':
1621 770 return '\0';
1622 1 default:
1623
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);
1624
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);
1625 }
1626 }
1627
1628 const CodeLoc codeLoc(terminal->getSymbol(), sourceFile);
1629 throw ParserError(codeLoc, INVALID_CHAR_LITERAL, "Invalid char literal " + input);
1630 2968 }
1631
1632 3571 std::string ASTBuilder::parseString(std::string input) {
1633
1/2
✓ Branch 3 → 4 taken 3571 times.
✗ Branch 3 → 9 not taken.
3571 input = input.substr(1, input.size() - 2);
1634 3571 replaceEscapeChars(input);
1635 3571 return input;
1636 }
1637
1638 12233 template <typename T> T ASTBuilder::parseNumeric(TerminalNode *terminal, const NumericParserCallback<T> &cb) {
1639
3/6
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 4984 times.
✗ Branch 2 → 87 not taken.
long spice::compiler::ASTBuilder::parseNumeric<long>(antlr4::tree::TerminalNode*, std::function<long (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✓ Branch 2 → 3 taken 6383 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 866 times.
✗ Branch 2 → 87 not taken.
12233 const std::string input = terminal->toString();
1640
1641 // Set to signed if the input string does not end with 'u'
1642
12/18
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 4977 times.
✓ Branch 4 → 9 taken 7 times.
✓ Branch 6 → 7 taken 4977 times.
✗ Branch 6 → 9 not taken.
✗ Branch 8 → 9 not taken.
✓ Branch 8 → 10 taken 4977 times.
long spice::compiler::ASTBuilder::parseNumeric<long>(antlr4::tree::TerminalNode*, std::function<long (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✓ Branch 4 → 5 taken 6383 times.
✗ Branch 4 → 9 not taken.
✓ Branch 6 → 7 taken 6383 times.
✗ Branch 6 → 9 not taken.
✓ Branch 8 → 9 taken 146 times.
✓ Branch 8 → 10 taken 6237 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 866 times.
✗ Branch 4 → 9 not taken.
✓ Branch 6 → 7 taken 532 times.
✓ Branch 6 → 9 taken 334 times.
✗ Branch 8 → 9 not taken.
✓ Branch 8 → 10 taken 532 times.
12233 const bool isUnsigned = input.ends_with('u') || input.ends_with("us") || input.ends_with("ul");
1643
1644 try {
1645
6/6
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 664 times.
✓ Branch 12 → 30 taken 4320 times.
long spice::compiler::ASTBuilder::parseNumeric<long>(antlr4::tree::TerminalNode*, std::function<long (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✓ Branch 12 → 13 taken 1589 times.
✓ Branch 12 → 30 taken 4794 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 670 times.
✓ Branch 12 → 30 taken 196 times.
12233 if (input.length() >= 3) {
1646
6/6
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 465 times.
long spice::compiler::ASTBuilder::parseNumeric<long>(antlr4::tree::TerminalNode*, std::function<long (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✓ Branch 14 → 15 taken 50 times.
✓ Branch 14 → 30 taken 1539 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 561 times.
2923 if (input[0] == '0') {
1647
3/6
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.
long spice::compiler::ASTBuilder::parseNumeric<long>(antlr4::tree::TerminalNode*, std::function<long (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✓ Branch 15 → 16 taken 50 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.
358 const std::string subStr = input.substr(2);
1648
5/15
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.
long spice::compiler::ASTBuilder::parseNumeric<long>(antlr4::tree::TerminalNode*, std::function<long (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✗ Branch 17 → 18 not taken.
✗ Branch 17 → 20 not taken.
✓ Branch 17 → 22 taken 38 times.
✗ Branch 17 → 24 not taken.
✓ Branch 17 → 26 taken 12 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.
358 switch (input[1]) {
1649 case 'd': // fall-through
1650 case 'D':
1651 return cb(subStr, 10, !isUnsigned);
1652 case 'b': // fall-through
1653 case 'B':
1654 return cb(subStr, 2, !isUnsigned);
1655 38 case 'h': // fall-through
1656 case 'H': // fall-through
1657 case 'x': // fall-through
1658 case 'X':
1659
1/6
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.
long spice::compiler::ASTBuilder::parseNumeric<long>(antlr4::tree::TerminalNode*, std::function<long (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✓ Branch 22 → 23 taken 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.
38 return cb(subStr, 16, !isUnsigned);
1660 307 case 'o': // fall-through
1661 case 'O':
1662
2/6
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.
long spice::compiler::ASTBuilder::parseNumeric<long>(antlr4::tree::TerminalNode*, std::function<long (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✗ Branch 24 → 25 not taken.
✗ Branch 24 → 35 not taken.
short spice::compiler::ASTBuilder::parseNumeric<short>(antlr4::tree::TerminalNode*, std::function<short (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✓ Branch 24 → 25 taken 108 times.
✗ Branch 24 → 35 not taken.
307 return cb(subStr, 8, !isUnsigned);
1663 13 default: // default is decimal
1664
2/6
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.
long spice::compiler::ASTBuilder::parseNumeric<long>(antlr4::tree::TerminalNode*, std::function<long (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✓ Branch 26 → 27 taken 12 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.
13 return cb(input, 10, !isUnsigned);
1665 }
1666 358 }
1667 }
1668
4/6
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 4784 times.
✓ Branch 30 → 38 taken 1 time.
long spice::compiler::ASTBuilder::parseNumeric<long>(antlr4::tree::TerminalNode*, std::function<long (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✓ Branch 30 → 31 taken 6333 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 757 times.
✗ Branch 30 → 38 not taken.
11875 return cb(input, 10, !isUnsigned);
1669
1/9
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.
long spice::compiler::ASTBuilder::parseNumeric<long>(antlr4::tree::TerminalNode*, std::function<long (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✗ Branch 38 → 39 not taken.
✗ Branch 38 → 40 not taken.
✗ Branch 38 → 51 not taken.
short spice::compiler::ASTBuilder::parseNumeric<short>(antlr4::tree::TerminalNode*, std::function<short (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✗ Branch 38 → 39 not taken.
✗ Branch 38 → 40 not taken.
✗ Branch 38 → 51 not taken.
2 } catch (std::out_of_range &) {
1670
2/12
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.
long spice::compiler::ASTBuilder::parseNumeric<long>(antlr4::tree::TerminalNode*, std::function<long (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✗ Branch 41 → 42 not taken.
✗ Branch 41 → 70 not taken.
✗ Branch 42 → 43 not taken.
✗ Branch 42 → 70 not taken.
short spice::compiler::ASTBuilder::parseNumeric<short>(antlr4::tree::TerminalNode*, std::function<short (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✗ Branch 41 → 42 not taken.
✗ Branch 41 → 70 not taken.
✗ Branch 42 → 43 not taken.
✗ Branch 42 → 70 not taken.
1 const CodeLoc codeLoc(terminal->getSymbol(), sourceFile);
1671
2/12
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.
long spice::compiler::ASTBuilder::parseNumeric<long>(antlr4::tree::TerminalNode*, std::function<long (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✗ Branch 46 → 47 not taken.
✗ Branch 46 → 64 not taken.
✗ Branch 47 → 48 not taken.
✗ Branch 47 → 61 not taken.
short spice::compiler::ASTBuilder::parseNumeric<short>(antlr4::tree::TerminalNode*, std::function<short (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, short, bool)> const&):
✗ Branch 46 → 47 not taken.
✗ Branch 46 → 64 not taken.
✗ Branch 47 → 48 not taken.
✗ Branch 47 → 61 not taken.
3 throw ParserError(codeLoc, NUMBER_OUT_OF_RANGE, "The provided number is out of range");
1672 } catch (std::invalid_argument &) {
1673 const CodeLoc codeLoc(terminal->getSymbol(), sourceFile);
1674 throw ParserError(codeLoc, NUMBER_OUT_OF_RANGE, "You tried to parse '" + input + "' as an integer, but it was no integer");
1675 }
1676 12233 }
1677
1678 3571 void ASTBuilder::replaceEscapeChars(std::string &input) {
1679 const std::unordered_map<char, char> escapeMap = {
1680 {'a', '\a'}, {'b', '\b'}, {'f', '\f'}, {'n', '\n'}, {'r', '\r'}, {'t', '\t'},
1681 {'v', '\v'}, {'\\', '\\'}, {'?', '\?'}, {'\'', '\''}, {'"', '\"'},
1682
1/2
✓ Branch 4 → 5 taken 3571 times.
✗ Branch 4 → 40 not taken.
7142 };
1683
1684 3571 size_t writeIndex = 0;
1685 3571 size_t readIndex = 0;
1686 3571 const size_t len = input.length();
1687
1688
2/2
✓ Branch 36 → 8 taken 54505 times.
✓ Branch 36 → 37 taken 3571 times.
58076 while (readIndex < len) {
1689 54505 const char c = input[readIndex];
1690
3/4
✓ Branch 9 → 10 taken 701 times.
✓ Branch 9 → 33 taken 53804 times.
✓ Branch 10 → 11 taken 701 times.
✗ Branch 10 → 33 not taken.
54505 if (c == '\\' && readIndex + 1 < len) {
1691 701 char next = input[readIndex + 1];
1692
1/2
✓ Branch 12 → 13 taken 701 times.
✗ Branch 12 → 45 not taken.
701 auto it = escapeMap.find(next);
1693
2/2
✓ Branch 15 → 16 taken 692 times.
✓ Branch 15 → 19 taken 9 times.
701 if (it != escapeMap.end()) {
1694 692 input[writeIndex++] = it->second;
1695 692 readIndex += 2;
1696 698 continue;
1697 }
1698
1699 // Handle octal escape sequences (up to 3 digits)
1700
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') {
1701 6 int value = 0;
1702 6 size_t octalDigits = 0;
1703
1704 // Look ahead up to 3 digits
1705
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) {
1706 18 const char oc = input[readIndex + i];
1707
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') {
1708 18 value = value << 3 | (oc - '0'); // multiply by 8 and add digit
1709 18 octalDigits++;
1710 } else {
1711 break;
1712 }
1713 }
1714
1715
1/2
✓ Branch 28 → 29 taken 6 times.
✗ Branch 28 → 31 not taken.
6 if (octalDigits > 0) {
1716 6 input[writeIndex++] = static_cast<char>(value);
1717 6 readIndex += 1 + octalDigits; // backslash + octal digits
1718 6 continue;
1719 }
1720 }
1721 }
1722
1723 // Copy current character
1724 53807 input[writeIndex++] = c;
1725 53807 readIndex++;
1726 }
1727
1728
1/2
✓ Branch 37 → 38 taken 3571 times.
✗ Branch 37 → 46 not taken.
3571 input.resize(writeIndex);
1729 3571 }
1730
1731 121773 std::string ASTBuilder::getIdentifier(TerminalNode *terminal, bool isTypeIdentifier) const {
1732 121773 const std::string identifier = terminal->getText();
1733
1734 // Check if the list of reserved keywords contains the given identifier
1735
3/4
✓ Branch 3 → 4 taken 121773 times.
✗ Branch 3 → 56 not taken.
✓ Branch 6 → 7 taken 1 time.
✓ Branch 6 → 16 taken 121772 times.
243546 if (std::ranges::find(RESERVED_KEYWORDS, identifier) != std::end(RESERVED_KEYWORDS)) {
1736
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);
1737
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");
1738 }
1739
1740 // Check if the identifier is a type identifier and is reserved
1741
6/6
✓ Branch 16 → 17 taken 9931 times.
✓ Branch 16 → 23 taken 111841 times.
✓ Branch 17 → 18 taken 841 times.
✓ Branch 17 → 23 taken 9090 times.
✓ Branch 24 → 25 taken 1 time.
✓ Branch 24 → 34 taken 121771 times.
122613 if (isTypeIdentifier && !sourceFile->isStdFile &&
1742
3/4
✓ Branch 18 → 19 taken 841 times.
✗ Branch 18 → 56 not taken.
✓ Branch 21 → 22 taken 1 time.
✓ Branch 21 → 23 taken 840 times.
1682 std::ranges::find(RESERVED_TYPE_NAMES, identifier) != std::end(RESERVED_TYPE_NAMES)) {
1743
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);
1744
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");
1745 }
1746
1747 121771 return identifier;
1748 2 }
1749
1750 } // namespace spice::compiler
1751