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