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 | 1067 | ASTBuilder::ASTBuilder(GlobalResourceManager &resourceManager, SourceFile *sourceFile, antlr4::ANTLRInputStream *inputStream) | |
17 |
1/2✓ Branch 0 (4→5) taken 1067 times.
✗ Branch 1 (4→6) not taken.
|
1067 | : CompilerPass(resourceManager, sourceFile), inputStream(inputStream) {} |
18 | |||
19 | 1065 | std::any ASTBuilder::visitEntry(SpiceParser::EntryContext *ctx) { | |
20 | 1065 | const auto entryNode = createNode<EntryNode>(ctx); | |
21 | |||
22 | // Visit children | ||
23 |
2/2✓ Branch 0 (127→5) taken 15818 times.
✓ Branch 1 (127→128) taken 1059 times.
|
16877 | for (ParserRuleContext::ParseTree *child : ctx->children) { |
24 |
3/4✓ Branch 0 (6→7) taken 15818 times.
✗ Branch 1 (6→8) not taken.
✓ Branch 2 (9→10) taken 401 times.
✓ Branch 3 (9→15) taken 15417 times.
|
15818 | if (auto *mainFctDefCtx = dynamic_cast<SpiceParser::MainFunctionDefContext *>(child)) |
25 |
4/6✓ Branch 0 (10→11) taken 397 times.
✓ Branch 1 (10→140) taken 4 times.
✓ Branch 2 (11→12) taken 397 times.
✗ Branch 3 (11→138) not taken.
✓ Branch 4 (12→13) taken 397 times.
✗ Branch 5 (12→138) not taken.
|
401 | entryNode->topLevelDefs.push_back(std::any_cast<MainFctDefNode *>(visit(mainFctDefCtx))); |
26 |
3/4✓ Branch 0 (15→16) taken 15417 times.
✗ Branch 1 (15→17) not taken.
✓ Branch 2 (18→19) taken 6336 times.
✓ Branch 3 (18→24) taken 9081 times.
|
15417 | else if (auto *fctDefCtx = dynamic_cast<SpiceParser::FunctionDefContext *>(child)) |
27 |
3/6✓ Branch 0 (19→20) taken 6336 times.
✗ Branch 1 (19→144) not taken.
✓ Branch 2 (20→21) taken 6336 times.
✗ Branch 3 (20→142) not taken.
✓ Branch 4 (21→22) taken 6336 times.
✗ Branch 5 (21→142) not taken.
|
6336 | entryNode->topLevelDefs.push_back(std::any_cast<FctDefNode *>(visit(fctDefCtx))); |
28 |
3/4✓ Branch 0 (24→25) taken 9081 times.
✗ Branch 1 (24→26) not taken.
✓ Branch 2 (27→28) taken 3461 times.
✓ Branch 3 (27→33) taken 5620 times.
|
9081 | else if (auto *procDefCtx = dynamic_cast<SpiceParser::ProcedureDefContext *>(child)) |
29 |
3/6✓ Branch 0 (28→29) taken 3461 times.
✗ Branch 1 (28→148) not taken.
✓ Branch 2 (29→30) taken 3461 times.
✗ Branch 3 (29→146) not taken.
✓ Branch 4 (30→31) taken 3461 times.
✗ Branch 5 (30→146) not taken.
|
3461 | entryNode->topLevelDefs.push_back(std::any_cast<ProcDefNode *>(visit(procDefCtx))); |
30 |
3/4✓ Branch 0 (33→34) taken 5620 times.
✗ Branch 1 (33→35) not taken.
✓ Branch 2 (36→37) taken 616 times.
✓ Branch 3 (36→42) taken 5004 times.
|
5620 | else if (auto *structDefCtx = dynamic_cast<SpiceParser::StructDefContext *>(child)) |
31 |
4/6✓ Branch 0 (37→38) taken 615 times.
✓ Branch 1 (37→152) taken 1 times.
✓ Branch 2 (38→39) taken 615 times.
✗ Branch 3 (38→150) not taken.
✓ Branch 4 (39→40) taken 615 times.
✗ Branch 5 (39→150) not taken.
|
616 | entryNode->topLevelDefs.push_back(std::any_cast<StructDefNode *>(visit(structDefCtx))); |
32 |
3/4✓ Branch 0 (42→43) taken 5004 times.
✗ Branch 1 (42→44) not taken.
✓ Branch 2 (45→46) taken 85 times.
✓ Branch 3 (45→51) taken 4919 times.
|
5004 | 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 4919 times.
✗ Branch 1 (51→53) not taken.
✓ Branch 2 (54→55) taken 66 times.
✓ Branch 3 (54→60) taken 4853 times.
|
4919 | 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 4853 times.
✗ Branch 1 (60→62) not taken.
✓ Branch 2 (63→64) taken 818 times.
✓ Branch 3 (63→69) taken 4035 times.
|
4853 | else if (auto *genericTypeDefCtx = dynamic_cast<SpiceParser::GenericTypeDefContext *>(child)) |
37 |
3/6✓ Branch 0 (64→65) taken 818 times.
✗ Branch 1 (64→164) not taken.
✓ Branch 2 (65→66) taken 818 times.
✗ Branch 3 (65→162) not taken.
✓ Branch 4 (66→67) taken 818 times.
✗ Branch 5 (66→162) not taken.
|
818 | entryNode->topLevelDefs.push_back(std::any_cast<GenericTypeDefNode *>(visit(genericTypeDefCtx))); |
38 |
3/4✓ Branch 0 (69→70) taken 4035 times.
✗ Branch 1 (69→71) not taken.
✓ Branch 2 (72→73) taken 56 times.
✓ Branch 3 (72→78) taken 3979 times.
|
4035 | else if (auto *aliasDefCtx = dynamic_cast<SpiceParser::AliasDefContext *>(child)) |
39 |
3/6✓ Branch 0 (73→74) taken 56 times.
✗ Branch 1 (73→168) not taken.
✓ Branch 2 (74→75) taken 56 times.
✗ Branch 3 (74→166) not taken.
✓ Branch 4 (75→76) taken 56 times.
✗ Branch 5 (75→166) not taken.
|
56 | entryNode->topLevelDefs.push_back(std::any_cast<AliasDefNode *>(visit(aliasDefCtx))); |
40 |
3/4✓ Branch 0 (78→79) taken 3979 times.
✗ Branch 1 (78→80) not taken.
✓ Branch 2 (81→82) taken 1205 times.
✓ Branch 3 (81→87) taken 2774 times.
|
3979 | else if (auto *globalVarDefCtx = dynamic_cast<SpiceParser::GlobalVarDefContext *>(child)) |
41 |
3/6✓ Branch 0 (82→83) taken 1205 times.
✗ Branch 1 (82→172) not taken.
✓ Branch 2 (83→84) taken 1205 times.
✗ Branch 3 (83→170) not taken.
✓ Branch 4 (84→85) taken 1205 times.
✗ Branch 5 (84→170) not taken.
|
1205 | entryNode->topLevelDefs.push_back(std::any_cast<GlobalVarDefNode *>(visit(globalVarDefCtx))); |
42 |
3/4✓ Branch 0 (87→88) taken 2774 times.
✗ Branch 1 (87→89) not taken.
✓ Branch 2 (90→91) taken 526 times.
✓ Branch 3 (90→96) taken 2248 times.
|
2774 | else if (auto *importDefCtx = dynamic_cast<SpiceParser::ImportDefContext *>(child)) |
43 |
3/6✓ Branch 0 (91→92) taken 526 times.
✗ Branch 1 (91→176) not taken.
✓ Branch 2 (92→93) taken 526 times.
✗ Branch 3 (92→174) not taken.
✓ Branch 4 (93→94) taken 526 times.
✗ Branch 5 (93→174) not taken.
|
526 | entryNode->importDefs.push_back(std::any_cast<ImportDefNode *>(visit(importDefCtx))); |
44 |
3/4✓ Branch 0 (96→97) taken 2248 times.
✗ Branch 1 (96→98) not taken.
✓ Branch 2 (99→100) taken 884 times.
✓ Branch 3 (99→105) taken 1364 times.
|
2248 | else if (auto *extDeclCtx = dynamic_cast<SpiceParser::ExtDeclContext *>(child)) |
45 |
3/6✓ Branch 0 (100→101) taken 884 times.
✗ Branch 1 (100→180) not taken.
✓ Branch 2 (101→102) taken 884 times.
✗ Branch 3 (101→178) not taken.
✓ Branch 4 (102→103) taken 884 times.
✗ Branch 5 (102→178) not taken.
|
884 | entryNode->topLevelDefs.push_back(std::any_cast<ExtDeclNode *>(visit(extDeclCtx))); |
46 |
3/4✓ Branch 0 (105→106) taken 1364 times.
✗ Branch 1 (105→107) not taken.
✓ Branch 2 (108→109) taken 305 times.
✓ Branch 3 (108→114) taken 1059 times.
|
1364 | else if (auto *modAttrCtx = dynamic_cast<SpiceParser::ModAttrContext *>(child)) |
47 |
4/6✓ Branch 0 (109→110) taken 304 times.
✓ Branch 1 (109→184) taken 1 times.
✓ Branch 2 (110→111) taken 304 times.
✗ Branch 3 (110→182) not taken.
✓ Branch 4 (111→112) taken 304 times.
✗ Branch 5 (111→182) not taken.
|
305 | entryNode->modAttrs.push_back(std::any_cast<ModAttrNode *>(visit(modAttrCtx))); |
48 |
1/2✓ Branch 0 (114→115) taken 1059 times.
✗ Branch 1 (114→116) not taken.
|
1059 | else if (const auto *eofCtx = dynamic_cast<TerminalNode *>(child); |
49 |
5/10✓ Branch 0 (117→118) taken 1059 times.
✗ Branch 1 (117→121) not taken.
✓ Branch 2 (118→119) taken 1059 times.
✗ Branch 3 (118→186) not taken.
✓ Branch 4 (119→120) taken 1059 times.
✗ Branch 5 (119→186) not taken.
✗ Branch 6 (120→121) not taken.
✓ Branch 7 (120→122) taken 1059 times.
✗ Branch 8 (123→124) not taken.
✓ Branch 9 (123→125) taken 1059 times.
|
1059 | !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 1059 times.
✗ Branch 1 (134→187) not taken.
|
1059 | return concludeNode(entryNode); |
54 | } | ||
55 | |||
56 | 401 | std::any ASTBuilder::visitMainFunctionDef(SpiceParser::MainFunctionDefContext *ctx) { | |
57 | 401 | 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 400 times.
|
401 | 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 397 times.
|
401 | 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 401 times.
✗ Branch 1 (17→39) not taken.
✓ Branch 2 (18→19) taken 397 times.
✓ Branch 3 (18→39) taken 4 times.
✓ Branch 4 (19→20) taken 397 times.
✗ Branch 5 (19→37) not taken.
|
401 | mainFctDefNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
67 | |||
68 |
1/2✓ Branch 0 (27→28) taken 397 times.
✗ Branch 1 (27→40) not taken.
|
397 | return concludeNode(mainFctDefNode); |
69 | } | ||
70 | |||
71 | 6336 | std::any ASTBuilder::visitFunctionDef(SpiceParser::FunctionDefContext *ctx) { | |
72 | 6336 | const auto fctDefNode = createNode<FctDefNode>(ctx); | |
73 | |||
74 | // Visit children | ||
75 |
2/2✓ Branch 0 (4→5) taken 300 times.
✓ Branch 1 (4→16) taken 6036 times.
|
6336 | if (ctx->topLevelDefAttr()) { |
76 |
3/6✓ Branch 0 (5→6) taken 300 times.
✗ Branch 1 (5→62) not taken.
✓ Branch 2 (6→7) taken 300 times.
✗ Branch 3 (6→62) not taken.
✓ Branch 4 (7→8) taken 300 times.
✗ Branch 5 (7→60) not taken.
|
300 | 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 305 times.
✓ Branch 1 (14→15) taken 300 times.
|
605 | for (AttrNode *attr : fctDefNode->attrs->attrLst->attributes) |
79 | 305 | attr->target = AttrNode::TARGET_FCT_PROC; | |
80 | } | ||
81 |
2/2✓ Branch 0 (17→18) taken 6167 times.
✓ Branch 1 (17→23) taken 169 times.
|
6336 | if (ctx->qualifierLst()) |
82 |
3/6✓ Branch 0 (18→19) taken 6167 times.
✗ Branch 1 (18→65) not taken.
✓ Branch 2 (19→20) taken 6167 times.
✗ Branch 3 (19→65) not taken.
✓ Branch 4 (20→21) taken 6167 times.
✗ Branch 5 (20→63) not taken.
|
6167 | fctDefNode->qualifierLst = std::any_cast<QualifierLstNode *>(visit(ctx->qualifierLst())); |
83 |
3/6✓ Branch 0 (23→24) taken 6336 times.
✗ Branch 1 (23→68) not taken.
✓ Branch 2 (24→25) taken 6336 times.
✗ Branch 3 (24→68) not taken.
✓ Branch 4 (25→26) taken 6336 times.
✗ Branch 5 (25→66) not taken.
|
6336 | fctDefNode->returnType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
84 | 6336 | fctDefNode->returnType->isReturnType = true; | |
85 |
3/6✓ Branch 0 (27→28) taken 6336 times.
✗ Branch 1 (27→71) not taken.
✓ Branch 2 (28→29) taken 6336 times.
✗ Branch 3 (28→71) not taken.
✓ Branch 4 (29→30) taken 6336 times.
✗ Branch 5 (29→69) not taken.
|
6336 | fctDefNode->name = std::any_cast<FctNameNode *>(visit(ctx->fctName())); |
86 | 6336 | fctDefNode->isMethod = fctDefNode->name->nameFragments.size() > 1; | |
87 |
2/2✓ Branch 0 (33→34) taken 842 times.
✓ Branch 1 (33→39) taken 5494 times.
|
6336 | if (ctx->typeLst()) { |
88 | 842 | fctDefNode->hasTemplateTypes = true; | |
89 |
3/6✓ Branch 0 (34→35) taken 842 times.
✗ Branch 1 (34→74) not taken.
✓ Branch 2 (35→36) taken 842 times.
✗ Branch 3 (35→74) not taken.
✓ Branch 4 (36→37) taken 842 times.
✗ Branch 5 (36→72) not taken.
|
842 | fctDefNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst())); |
90 | } | ||
91 |
2/2✓ Branch 0 (40→41) taken 4814 times.
✓ Branch 1 (40→46) taken 1522 times.
|
6336 | if (ctx->paramLst()) { |
92 | 4814 | fctDefNode->hasParams = true; | |
93 |
3/6✓ Branch 0 (41→42) taken 4814 times.
✗ Branch 1 (41→77) not taken.
✓ Branch 2 (42→43) taken 4814 times.
✗ Branch 3 (42→77) not taken.
✓ Branch 4 (43→44) taken 4814 times.
✗ Branch 5 (43→75) not taken.
|
4814 | fctDefNode->paramLst = std::any_cast<ParamLstNode *>(visit(ctx->paramLst())); |
94 | } | ||
95 |
3/6✓ Branch 0 (46→47) taken 6336 times.
✗ Branch 1 (46→80) not taken.
✓ Branch 2 (47→48) taken 6336 times.
✗ Branch 3 (47→80) not taken.
✓ Branch 4 (48→49) taken 6336 times.
✗ Branch 5 (48→78) not taken.
|
6336 | fctDefNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
96 | |||
97 |
1/2✓ Branch 0 (56→57) taken 6336 times.
✗ Branch 1 (56→81) not taken.
|
6336 | return concludeNode(fctDefNode); |
98 | } | ||
99 | |||
100 | 3461 | std::any ASTBuilder::visitProcedureDef(SpiceParser::ProcedureDefContext *ctx) { | |
101 | 3461 | 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 3460 times.
|
3461 | 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 3061 times.
✓ Branch 1 (17→23) taken 400 times.
|
3461 | if (ctx->qualifierLst()) |
111 |
3/6✓ Branch 0 (18→19) taken 3061 times.
✗ Branch 1 (18→61) not taken.
✓ Branch 2 (19→20) taken 3061 times.
✗ Branch 3 (19→61) not taken.
✓ Branch 4 (20→21) taken 3061 times.
✗ Branch 5 (20→59) not taken.
|
3061 | procDefNode->qualifierLst = std::any_cast<QualifierLstNode *>(visit(ctx->qualifierLst())); |
112 |
3/6✓ Branch 0 (23→24) taken 3461 times.
✗ Branch 1 (23→64) not taken.
✓ Branch 2 (24→25) taken 3461 times.
✗ Branch 3 (24→64) not taken.
✓ Branch 4 (25→26) taken 3461 times.
✗ Branch 5 (25→62) not taken.
|
3461 | procDefNode->name = std::any_cast<FctNameNode *>(visit(ctx->fctName())); |
113 | 3461 | procDefNode->isMethod = procDefNode->name->nameFragments.size() > 1; | |
114 |
2/2✓ Branch 0 (29→30) taken 938 times.
✓ Branch 1 (29→35) taken 2523 times.
|
3461 | if (ctx->typeLst()) { |
115 | 938 | procDefNode->hasTemplateTypes = true; | |
116 |
3/6✓ Branch 0 (30→31) taken 938 times.
✗ Branch 1 (30→67) not taken.
✓ Branch 2 (31→32) taken 938 times.
✗ Branch 3 (31→67) not taken.
✓ Branch 4 (32→33) taken 938 times.
✗ Branch 5 (32→65) not taken.
|
938 | procDefNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst())); |
117 | } | ||
118 |
2/2✓ Branch 0 (36→37) taken 2554 times.
✓ Branch 1 (36→42) taken 907 times.
|
3461 | if (ctx->paramLst()) { |
119 | 2554 | procDefNode->hasParams = true; | |
120 |
3/6✓ Branch 0 (37→38) taken 2554 times.
✗ Branch 1 (37→70) not taken.
✓ Branch 2 (38→39) taken 2554 times.
✗ Branch 3 (38→70) not taken.
✓ Branch 4 (39→40) taken 2554 times.
✗ Branch 5 (39→68) not taken.
|
2554 | procDefNode->paramLst = std::any_cast<ParamLstNode *>(visit(ctx->paramLst())); |
121 | } | ||
122 |
3/6✓ Branch 0 (42→43) taken 3461 times.
✗ Branch 1 (42→73) not taken.
✓ Branch 2 (43→44) taken 3461 times.
✗ Branch 3 (43→73) not taken.
✓ Branch 4 (44→45) taken 3461 times.
✗ Branch 5 (44→71) not taken.
|
3461 | procDefNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
123 | |||
124 |
1/2✓ Branch 0 (52→53) taken 3461 times.
✗ Branch 1 (52→74) not taken.
|
3461 | return concludeNode(procDefNode); |
125 | } | ||
126 | |||
127 | 9797 | std::any ASTBuilder::visitFctName(SpiceParser::FctNameContext *ctx) { | |
128 | 9797 | const auto fctNameNode = createNode<FctNameNode>(ctx); | |
129 | |||
130 | // Extract function name | ||
131 |
2/2✓ Branch 0 (4→5) taken 5711 times.
✓ Branch 1 (4→14) taken 4086 times.
|
9797 | if (ctx->TYPE_IDENTIFIER()) { |
132 |
2/4✓ Branch 0 (5→6) taken 5711 times.
✗ Branch 1 (5→42) not taken.
✓ Branch 2 (6→7) taken 5711 times.
✗ Branch 3 (6→42) not taken.
|
5711 | const std::string typeIdentifier = getIdentifier(ctx->TYPE_IDENTIFIER(), true); |
133 |
1/2✓ Branch 0 (7→8) taken 5711 times.
✗ Branch 1 (7→40) not taken.
|
5711 | fctNameNode->structName = typeIdentifier; |
134 |
1/2✓ Branch 0 (8→9) taken 5711 times.
✗ Branch 1 (8→39) not taken.
|
5711 | fctNameNode->fqName = typeIdentifier + MEMBER_ACCESS_TOKEN; |
135 |
1/2✓ Branch 0 (11→12) taken 5711 times.
✗ Branch 1 (11→40) not taken.
|
5711 | fctNameNode->nameFragments.push_back(typeIdentifier); |
136 | 5711 | } | |
137 |
2/2✓ Branch 0 (15→16) taken 8225 times.
✓ Branch 1 (15→23) taken 1572 times.
|
9797 | if (ctx->IDENTIFIER()) { |
138 |
2/4✓ Branch 0 (16→17) taken 8225 times.
✗ Branch 1 (16→45) not taken.
✓ Branch 2 (17→18) taken 8225 times.
✗ Branch 3 (17→45) not taken.
|
8225 | const std::string fctIdentifier = getIdentifier(ctx->IDENTIFIER(), false); |
139 |
1/2✓ Branch 0 (18→19) taken 8225 times.
✗ Branch 1 (18→43) not taken.
|
8225 | fctNameNode->name = fctIdentifier; |
140 |
1/2✓ Branch 0 (19→20) taken 8225 times.
✗ Branch 1 (19→43) not taken.
|
8225 | fctNameNode->fqName += fctIdentifier; |
141 |
1/2✓ Branch 0 (20→21) taken 8225 times.
✗ Branch 1 (20→43) not taken.
|
8225 | fctNameNode->nameFragments.push_back(fctIdentifier); |
142 | 8225 | } | |
143 | |||
144 | // Visit children | ||
145 |
2/2✓ Branch 0 (24→25) taken 1572 times.
✓ Branch 1 (24→29) taken 8225 times.
|
9797 | if (ctx->overloadableOp()) |
146 |
2/4✓ Branch 0 (25→26) taken 1572 times.
✗ Branch 1 (25→46) not taken.
✓ Branch 2 (26→27) taken 1572 times.
✗ Branch 3 (26→46) not taken.
|
1572 | visit(ctx->overloadableOp()); |
147 | |||
148 |
1/2✓ Branch 0 (35→36) taken 9797 times.
✗ Branch 1 (35→47) not taken.
|
9797 | return concludeNode(fctNameNode); |
149 | } | ||
150 | |||
151 | 616 | std::any ASTBuilder::visitStructDef(SpiceParser::StructDefContext *ctx) { | |
152 | 616 | const auto structDefNode = createNode<StructDefNode>(ctx); | |
153 | |||
154 | // Enrich | ||
155 |
3/4✓ Branch 0 (3→4) taken 616 times.
✗ Branch 1 (3→87) not taken.
✓ Branch 2 (4→5) taken 615 times.
✓ Branch 3 (4→87) taken 1 times.
|
616 | structDefNode->structName = getIdentifier(ctx->TYPE_IDENTIFIER(), true); |
156 | 615 | structDefNode->typeId = resourceManager.getNextCustomTypeId(); | |
157 | |||
158 | // Visit children | ||
159 |
2/2✓ Branch 0 (9→10) taken 54 times.
✓ Branch 1 (9→41) taken 561 times.
|
615 | 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 472 times.
✓ Branch 1 (42→48) taken 143 times.
|
615 | if (ctx->qualifierLst()) |
171 |
3/6✓ Branch 0 (43→44) taken 472 times.
✗ Branch 1 (43→108) not taken.
✓ Branch 2 (44→45) taken 472 times.
✗ Branch 3 (44→108) not taken.
✓ Branch 4 (45→46) taken 472 times.
✗ Branch 5 (45→106) not taken.
|
472 | structDefNode->qualifierLst = std::any_cast<QualifierLstNode *>(visit(ctx->qualifierLst())); |
172 |
2/2✓ Branch 0 (49→50) taken 193 times.
✓ Branch 1 (49→55) taken 422 times.
|
615 | if (ctx->LESS()) { |
173 | 193 | structDefNode->hasTemplateTypes = true; | |
174 |
3/6✓ Branch 0 (50→51) taken 193 times.
✗ Branch 1 (50→111) not taken.
✓ Branch 2 (51→52) taken 193 times.
✗ Branch 3 (51→111) not taken.
✓ Branch 4 (52→53) taken 193 times.
✗ Branch 5 (52→109) not taken.
|
193 | 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 513 times.
|
615 | 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 615 times.
✗ Branch 1 (65→121) not taken.
✓ Branch 2 (75→68) taken 1324 times.
✓ Branch 3 (75→76) taken 615 times.
|
1939 | for (SpiceParser::FieldContext *field : ctx->field()) |
181 |
3/6✓ Branch 0 (69→70) taken 1324 times.
✗ Branch 1 (69→117) not taken.
✓ Branch 2 (70→71) taken 1324 times.
✗ Branch 3 (70→115) not taken.
✓ Branch 4 (71→72) taken 1324 times.
✗ Branch 5 (71→115) not taken.
|
1939 | structDefNode->fields.push_back(std::any_cast<FieldNode *>(visit(field))); |
182 | |||
183 |
1/2✓ Branch 0 (83→84) taken 615 times.
✗ Branch 1 (83→122) not taken.
|
615 | 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(), true); |
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(), true); |
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 | 818 | std::any ASTBuilder::visitGenericTypeDef(SpiceParser::GenericTypeDefContext *ctx) { | |
237 | 818 | const auto genericTypeDefNode = createNode<GenericTypeDefNode>(ctx); | |
238 | |||
239 | // Enrich | ||
240 |
2/4✓ Branch 0 (3→4) taken 818 times.
✗ Branch 1 (3→21) not taken.
✓ Branch 2 (4→5) taken 818 times.
✗ Branch 3 (4→21) not taken.
|
818 | genericTypeDefNode->typeName = getIdentifier(ctx->TYPE_IDENTIFIER(), true); |
241 | |||
242 | // Visit children | ||
243 |
3/6✓ Branch 0 (7→8) taken 818 times.
✗ Branch 1 (7→24) not taken.
✓ Branch 2 (8→9) taken 818 times.
✗ Branch 3 (8→24) not taken.
✓ Branch 4 (9→10) taken 818 times.
✗ Branch 5 (9→22) not taken.
|
818 | genericTypeDefNode->typeAltsLst = std::any_cast<TypeAltsLstNode *>(visit(ctx->typeAltsLst())); |
244 | |||
245 |
1/2✓ Branch 0 (17→18) taken 818 times.
✗ Branch 1 (17→25) not taken.
|
818 | return concludeNode(genericTypeDefNode); |
246 | } | ||
247 | |||
248 | 56 | std::any ASTBuilder::visitAliasDef(SpiceParser::AliasDefContext *ctx) { | |
249 | 56 | const auto aliasDefNode = createNode<AliasDefNode>(ctx); | |
250 | |||
251 | // Enrich | ||
252 |
2/4✓ Branch 0 (3→4) taken 56 times.
✗ Branch 1 (3→33) not taken.
✓ Branch 2 (4→5) taken 56 times.
✗ Branch 3 (4→33) not taken.
|
56 | aliasDefNode->aliasName = getIdentifier(ctx->TYPE_IDENTIFIER(), true); |
253 |
2/4✓ Branch 0 (7→8) taken 56 times.
✗ Branch 1 (7→34) not taken.
✓ Branch 2 (8→9) taken 56 times.
✗ Branch 3 (8→34) not taken.
|
56 | aliasDefNode->dataTypeString = ctx->dataType()->getText(); |
254 | 56 | aliasDefNode->typeId = resourceManager.getNextCustomTypeId(); | |
255 | |||
256 | // Visit children | ||
257 |
2/2✓ Branch 0 (13→14) taken 8 times.
✓ Branch 1 (13→19) taken 48 times.
|
56 | 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 56 times.
✗ Branch 1 (19→40) not taken.
✓ Branch 2 (20→21) taken 56 times.
✗ Branch 3 (20→40) not taken.
✓ Branch 4 (21→22) taken 56 times.
✗ Branch 5 (21→38) not taken.
|
56 | aliasDefNode->dataType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
260 | |||
261 |
1/2✓ Branch 0 (29→30) taken 56 times.
✗ Branch 1 (29→41) not taken.
|
56 | return concludeNode(aliasDefNode); |
262 | } | ||
263 | |||
264 | 1205 | std::any ASTBuilder::visitGlobalVarDef(SpiceParser::GlobalVarDefContext *ctx) { | |
265 | 1205 | const auto globalVarDefNode = createNode<GlobalVarDefNode>(ctx); | |
266 | |||
267 | // Enrich | ||
268 |
2/4✓ Branch 0 (3→4) taken 1205 times.
✗ Branch 1 (3→28) not taken.
✓ Branch 2 (4→5) taken 1205 times.
✗ Branch 3 (4→28) not taken.
|
1205 | globalVarDefNode->varName = getIdentifier(ctx->TYPE_IDENTIFIER(), true); |
269 | |||
270 | // Visit children | ||
271 |
3/6✓ Branch 0 (7→8) taken 1205 times.
✗ Branch 1 (7→31) not taken.
✓ Branch 2 (8→9) taken 1205 times.
✗ Branch 3 (8→31) not taken.
✓ Branch 4 (9→10) taken 1205 times.
✗ Branch 5 (9→29) not taken.
|
1205 | globalVarDefNode->dataType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
272 | 1205 | globalVarDefNode->dataType->isGlobalType = true; | |
273 |
2/2✓ Branch 0 (12→13) taken 1203 times.
✓ Branch 1 (12→18) taken 2 times.
|
1205 | if (ctx->constant()) { |
274 | 1203 | globalVarDefNode->hasValue = true; | |
275 |
3/6✓ Branch 0 (13→14) taken 1203 times.
✗ Branch 1 (13→34) not taken.
✓ Branch 2 (14→15) taken 1203 times.
✗ Branch 3 (14→34) not taken.
✓ Branch 4 (15→16) taken 1203 times.
✗ Branch 5 (15→32) not taken.
|
1203 | globalVarDefNode->constant = std::any_cast<ConstantNode *>(visit(ctx->constant())); |
276 | } | ||
277 | |||
278 |
1/2✓ Branch 0 (24→25) taken 1205 times.
✗ Branch 1 (24→35) not taken.
|
1205 | return concludeNode(globalVarDefNode); |
279 | } | ||
280 | |||
281 | 884 | std::any ASTBuilder::visitExtDecl(SpiceParser::ExtDeclContext *ctx) { | |
282 | 884 | const auto extDeclNode = createNode<ExtDeclNode>(ctx); | |
283 | |||
284 | // Enrich | ||
285 |
6/10✓ Branch 0 (3→4) taken 884 times.
✗ Branch 1 (3→50) not taken.
✓ Branch 2 (4→5) taken 642 times.
✓ Branch 3 (4→7) taken 242 times.
✓ Branch 4 (5→6) taken 642 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 884 times.
✗ Branch 9 (9→50) not taken.
|
884 | extDeclNode->extFunctionName = getIdentifier(ctx->IDENTIFIER() ? ctx->IDENTIFIER() : ctx->TYPE_IDENTIFIER(), false); |
286 | |||
287 | // Visit children | ||
288 |
2/2✓ Branch 0 (13→14) taken 1 times.
✓ Branch 1 (13→25) taken 883 times.
|
884 | 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 578 times.
✓ Branch 1 (26→32) taken 306 times.
|
884 | if (ctx->F()) { |
296 |
3/6✓ Branch 0 (27→28) taken 578 times.
✗ Branch 1 (27→56) not taken.
✓ Branch 2 (28→29) taken 578 times.
✗ Branch 3 (28→56) not taken.
✓ Branch 4 (29→30) taken 578 times.
✗ Branch 5 (29→54) not taken.
|
578 | extDeclNode->returnType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
297 | 578 | extDeclNode->returnType->isReturnType = true; | |
298 | } | ||
299 |
2/2✓ Branch 0 (33→34) taken 844 times.
✓ Branch 1 (33→39) taken 40 times.
|
884 | if (ctx->typeLst()) { |
300 | 844 | extDeclNode->hasArgs = true; | |
301 |
3/6✓ Branch 0 (34→35) taken 844 times.
✗ Branch 1 (34→59) not taken.
✓ Branch 2 (35→36) taken 844 times.
✗ Branch 3 (35→59) not taken.
✓ Branch 4 (36→37) taken 844 times.
✗ Branch 5 (36→57) not taken.
|
844 | extDeclNode->argTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst())); |
302 | } | ||
303 | 884 | extDeclNode->isVarArg = ctx->ELLIPSIS(); | |
304 | |||
305 |
1/2✓ Branch 0 (46→47) taken 884 times.
✗ Branch 1 (46→60) not taken.
|
884 | return concludeNode(extDeclNode); |
306 | } | ||
307 | |||
308 | 526 | std::any ASTBuilder::visitImportDef(SpiceParser::ImportDefContext *ctx) { | |
309 |
1/2✓ Branch 0 (2→3) taken 526 times.
✗ Branch 1 (2→32) not taken.
|
526 | const auto importDefNode = createNode<ImportDefNode>(ctx); |
310 | |||
311 | // Extract path | ||
312 |
2/4✓ Branch 0 (3→4) taken 526 times.
✗ Branch 1 (3→32) not taken.
✓ Branch 2 (4→5) taken 526 times.
✗ Branch 3 (4→32) not taken.
|
526 | const std::string pathStr = ctx->STRING_LIT()->getText(); |
313 |
1/2✓ Branch 0 (6→7) taken 526 times.
✗ Branch 1 (6→27) not taken.
|
526 | 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 526 times.
✗ Branch 1 (9→28) not taken.
✓ Branch 2 (10→11) taken 37 times.
✓ Branch 3 (10→13) taken 489 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 489 times.
✗ Branch 9 (13→28) not taken.
|
526 | importDefNode->importName = ctx->AS() ? getIdentifier(ctx->IDENTIFIER(), false) : importDefNode->importPath; |
317 | |||
318 |
1/2✓ Branch 0 (22→23) taken 526 times.
✗ Branch 1 (22→29) not taken.
|
1052 | return concludeNode(importDefNode); |
319 | 526 | } | |
320 | |||
321 | 2413 | std::any ASTBuilder::visitUnsafeBlock(SpiceParser::UnsafeBlockContext *ctx) { | |
322 | 2413 | const auto unsafeBlockDefNode = createNode<UnsafeBlockNode>(ctx); | |
323 | |||
324 | // Visit children | ||
325 |
3/6✓ Branch 0 (3→4) taken 2413 times.
✗ Branch 1 (3→19) not taken.
✓ Branch 2 (4→5) taken 2413 times.
✗ Branch 3 (4→19) not taken.
✓ Branch 4 (5→6) taken 2413 times.
✗ Branch 5 (5→17) not taken.
|
2413 | unsafeBlockDefNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
326 | |||
327 |
1/2✓ Branch 0 (13→14) taken 2413 times.
✗ Branch 1 (13→20) not taken.
|
2413 | return concludeNode(unsafeBlockDefNode); |
328 | } | ||
329 | |||
330 | 1255 | std::any ASTBuilder::visitForLoop(SpiceParser::ForLoopContext *ctx) { | |
331 | 1255 | const auto forLoopNode = createNode<ForLoopNode>(ctx); | |
332 | |||
333 |
2/4✓ Branch 0 (3→4) taken 1255 times.
✗ Branch 1 (3→20) not taken.
✓ Branch 2 (4→5) taken 1255 times.
✗ Branch 3 (4→20) not taken.
|
1255 | visit(ctx->forHead()); |
334 |
3/6✓ Branch 0 (6→7) taken 1255 times.
✗ Branch 1 (6→23) not taken.
✓ Branch 2 (7→8) taken 1255 times.
✗ Branch 3 (7→23) not taken.
✓ Branch 4 (8→9) taken 1255 times.
✗ Branch 5 (8→21) not taken.
|
1255 | forLoopNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
335 | |||
336 |
1/2✓ Branch 0 (16→17) taken 1255 times.
✗ Branch 1 (16→24) not taken.
|
1255 | return concludeNode(forLoopNode); |
337 | } | ||
338 | |||
339 | 1255 | std::any ASTBuilder::visitForHead(SpiceParser::ForHeadContext *ctx) { | |
340 | 1255 | const auto forLoopNode = resumeForExpansion<ForLoopNode>(); | |
341 | |||
342 | // Visit children | ||
343 |
3/6✓ Branch 0 (12→13) taken 1255 times.
✗ Branch 1 (12→29) not taken.
✓ Branch 2 (13→14) taken 1255 times.
✗ Branch 3 (13→29) not taken.
✓ Branch 4 (14→15) taken 1255 times.
✗ Branch 5 (14→27) not taken.
|
1255 | forLoopNode->initDecl = std::any_cast<DeclStmtNode *>(visit(ctx->declStmt())); |
344 |
3/6✓ Branch 0 (16→17) taken 1255 times.
✗ Branch 1 (16→32) not taken.
✓ Branch 2 (17→18) taken 1255 times.
✗ Branch 3 (17→32) not taken.
✓ Branch 4 (18→19) taken 1255 times.
✗ Branch 5 (18→30) not taken.
|
1255 | forLoopNode->condAssign = std::any_cast<AssignExprNode *>(visit(ctx->assignExpr(0))); |
345 |
3/6✓ Branch 0 (20→21) taken 1255 times.
✗ Branch 1 (20→35) not taken.
✓ Branch 2 (21→22) taken 1255 times.
✗ Branch 3 (21→35) not taken.
✓ Branch 4 (22→23) taken 1255 times.
✗ Branch 5 (22→33) not taken.
|
1255 | forLoopNode->incAssign = std::any_cast<AssignExprNode *>(visit(ctx->assignExpr(1))); |
346 | |||
347 |
1/2✓ Branch 0 (24→25) taken 1255 times.
✗ Branch 1 (24→36) not taken.
|
1255 | 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 | 692 | std::any ASTBuilder::visitWhileLoop(SpiceParser::WhileLoopContext *ctx) { | |
381 | 692 | const auto whileLoopNode = createNode<WhileLoopNode>(ctx); | |
382 | |||
383 | // Visit children | ||
384 |
3/6✓ Branch 0 (3→4) taken 692 times.
✗ Branch 1 (3→23) not taken.
✓ Branch 2 (4→5) taken 692 times.
✗ Branch 3 (4→23) not taken.
✓ Branch 4 (5→6) taken 692 times.
✗ Branch 5 (5→21) not taken.
|
692 | whileLoopNode->condition = std::any_cast<AssignExprNode *>(visit(ctx->assignExpr())); |
385 |
3/6✓ Branch 0 (7→8) taken 692 times.
✗ Branch 1 (7→26) not taken.
✓ Branch 2 (8→9) taken 692 times.
✗ Branch 3 (8→26) not taken.
✓ Branch 4 (9→10) taken 692 times.
✗ Branch 5 (9→24) not taken.
|
692 | whileLoopNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
386 | |||
387 |
1/2✓ Branch 0 (17→18) taken 692 times.
✗ Branch 1 (17→27) not taken.
|
692 | 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 | 3663 | std::any ASTBuilder::visitIfStmt(SpiceParser::IfStmtContext *ctx) { | |
401 | 3663 | const auto ifStmtNode = createNode<IfStmtNode>(ctx); | |
402 | |||
403 | // Visit children | ||
404 |
3/6✓ Branch 0 (3→4) taken 3663 times.
✗ Branch 1 (3→30) not taken.
✓ Branch 2 (4→5) taken 3663 times.
✗ Branch 3 (4→30) not taken.
✓ Branch 4 (5→6) taken 3663 times.
✗ Branch 5 (5→28) not taken.
|
3663 | ifStmtNode->condition = std::any_cast<AssignExprNode *>(visit(ctx->assignExpr())); |
405 |
3/6✓ Branch 0 (7→8) taken 3663 times.
✗ Branch 1 (7→33) not taken.
✓ Branch 2 (8→9) taken 3663 times.
✗ Branch 3 (8→33) not taken.
✓ Branch 4 (9→10) taken 3663 times.
✗ Branch 5 (9→31) not taken.
|
3663 | ifStmtNode->thenBody = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
406 |
2/2✓ Branch 0 (12→13) taken 176 times.
✓ Branch 1 (12→18) taken 3487 times.
|
3663 | if (ctx->elseStmt()) |
407 |
3/6✓ Branch 0 (13→14) taken 176 times.
✗ Branch 1 (13→36) not taken.
✓ Branch 2 (14→15) taken 176 times.
✗ Branch 3 (14→36) not taken.
✓ Branch 4 (15→16) taken 176 times.
✗ Branch 5 (15→34) not taken.
|
176 | ifStmtNode->elseStmt = std::any_cast<ElseStmtNode *>(visit(ctx->elseStmt())); |
408 | |||
409 |
1/2✓ Branch 0 (24→25) taken 3663 times.
✗ Branch 1 (24→37) not taken.
|
3663 | return concludeNode(ifStmtNode); |
410 | } | ||
411 | |||
412 | 176 | std::any ASTBuilder::visitElseStmt(SpiceParser::ElseStmtContext *ctx) { | |
413 | 176 | 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 123 times.
|
176 | 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 123 times.
✗ Branch 1 (10→30) not taken.
✓ Branch 2 (11→12) taken 123 times.
✗ Branch 3 (11→30) not taken.
✓ Branch 4 (12→13) taken 123 times.
✗ Branch 5 (12→28) not taken.
|
123 | elseStmtNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
421 | } | ||
422 | |||
423 |
1/2✓ Branch 0 (21→22) taken 176 times.
✗ Branch 1 (21→31) not taken.
|
176 | 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 | 28 | std::any ASTBuilder::visitAnonymousBlockStmt(SpiceParser::AnonymousBlockStmtContext *ctx) { | |
460 | 28 | const auto anonymousBlockStmtNode = createNode<AnonymousBlockStmtNode>(ctx); | |
461 | |||
462 | // Visit children | ||
463 |
3/6✓ Branch 0 (3→4) taken 28 times.
✗ Branch 1 (3→19) not taken.
✓ Branch 2 (4→5) taken 28 times.
✗ Branch 3 (4→19) not taken.
✓ Branch 4 (5→6) taken 28 times.
✗ Branch 5 (5→17) not taken.
|
28 | anonymousBlockStmtNode->body = std::any_cast<StmtLstNode *>(visit(ctx->stmtLst())); |
464 | |||
465 |
1/2✓ Branch 0 (13→14) taken 28 times.
✗ Branch 1 (13→20) not taken.
|
28 | return concludeNode(anonymousBlockStmtNode); |
466 | } | ||
467 | |||
468 | 18579 | std::any ASTBuilder::visitStmtLst(SpiceParser::StmtLstContext *ctx) { | |
469 | 18579 | const auto stmtLstNode = createNode<StmtLstNode>(ctx); | |
470 | |||
471 | // Enrich | ||
472 |
2/4✓ Branch 0 (3→4) taken 18579 times.
✗ Branch 1 (3→116) not taken.
✓ Branch 2 (4→5) taken 18579 times.
✗ Branch 3 (4→116) not taken.
|
18579 | stmtLstNode->closingBraceCodeLoc = CodeLoc(ctx->getStop(), sourceFile); |
473 | |||
474 | // Visit children | ||
475 |
2/2✓ Branch 0 (105→7) taken 71187 times.
✓ Branch 1 (105→106) taken 18575 times.
|
89762 | for (ParserRuleContext::ParseTree *stmt : ctx->children) { |
476 |
3/4✓ Branch 0 (8→9) taken 71187 times.
✗ Branch 1 (8→10) not taken.
✓ Branch 2 (11→12) taken 25227 times.
✓ Branch 3 (11→17) taken 45960 times.
|
71187 | if (auto *stmtCtx = dynamic_cast<SpiceParser::StmtContext *>(stmt)) |
477 |
4/6✓ Branch 0 (12→13) taken 25223 times.
✓ Branch 1 (12→119) taken 4 times.
✓ Branch 2 (13→14) taken 25223 times.
✗ Branch 3 (13→117) not taken.
✓ Branch 4 (14→15) taken 25223 times.
✗ Branch 5 (14→117) not taken.
|
25227 | stmtLstNode->statements.push_back(std::any_cast<StmtNode *>(visit(stmtCtx))); |
478 |
3/4✓ Branch 0 (17→18) taken 45960 times.
✗ Branch 1 (17→19) not taken.
✓ Branch 2 (20→21) taken 1255 times.
✓ Branch 3 (20→26) taken 44705 times.
|
45960 | else if (auto *forLoopCtx = dynamic_cast<SpiceParser::ForLoopContext *>(stmt)) |
479 |
3/6✓ Branch 0 (21→22) taken 1255 times.
✗ Branch 1 (21→123) not taken.
✓ Branch 2 (22→23) taken 1255 times.
✗ Branch 3 (22→121) not taken.
✓ Branch 4 (23→24) taken 1255 times.
✗ Branch 5 (23→121) not taken.
|
1255 | stmtLstNode->statements.push_back(std::any_cast<ForLoopNode *>(visit(forLoopCtx))); |
480 |
3/4✓ Branch 0 (26→27) taken 44705 times.
✗ Branch 1 (26→28) not taken.
✓ Branch 2 (29→30) taken 100 times.
✓ Branch 3 (29→35) taken 44605 times.
|
44705 | 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 44605 times.
✗ Branch 1 (35→37) not taken.
✓ Branch 2 (38→39) taken 692 times.
✓ Branch 3 (38→44) taken 43913 times.
|
44605 | else if (auto *whileLoopCtx = dynamic_cast<SpiceParser::WhileLoopContext *>(stmt)) |
483 |
3/6✓ Branch 0 (39→40) taken 692 times.
✗ Branch 1 (39→131) not taken.
✓ Branch 2 (40→41) taken 692 times.
✗ Branch 3 (40→129) not taken.
✓ Branch 4 (41→42) taken 692 times.
✗ Branch 5 (41→129) not taken.
|
692 | stmtLstNode->statements.push_back(std::any_cast<WhileLoopNode *>(visit(whileLoopCtx))); |
484 |
3/4✓ Branch 0 (44→45) taken 43913 times.
✗ Branch 1 (44→46) not taken.
✓ Branch 2 (47→48) taken 9 times.
✓ Branch 3 (47→53) taken 43904 times.
|
43913 | 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 43904 times.
✗ Branch 1 (53→55) not taken.
✓ Branch 2 (56→57) taken 3610 times.
✓ Branch 3 (56→62) taken 40294 times.
|
43904 | else if (auto *ifStmtCtx = dynamic_cast<SpiceParser::IfStmtContext *>(stmt)) |
487 |
3/6✓ Branch 0 (57→58) taken 3610 times.
✗ Branch 1 (57→139) not taken.
✓ Branch 2 (58→59) taken 3610 times.
✗ Branch 3 (58→137) not taken.
✓ Branch 4 (59→60) taken 3610 times.
✗ Branch 5 (59→137) not taken.
|
3610 | stmtLstNode->statements.push_back(std::any_cast<IfStmtNode *>(visit(ifStmtCtx))); |
488 |
3/4✓ Branch 0 (62→63) taken 40294 times.
✗ Branch 1 (62→64) not taken.
✓ Branch 2 (65→66) taken 12 times.
✓ Branch 3 (65→71) taken 40282 times.
|
40294 | 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 40282 times.
✗ Branch 1 (71→73) not taken.
✓ Branch 2 (74→75) taken 687 times.
✓ Branch 3 (74→80) taken 39595 times.
|
40282 | else if (auto *assetStmtCtx = dynamic_cast<SpiceParser::AssertStmtContext *>(stmt)) |
491 |
3/6✓ Branch 0 (75→76) taken 687 times.
✗ Branch 1 (75→147) not taken.
✓ Branch 2 (76→77) taken 687 times.
✗ Branch 3 (76→145) not taken.
✓ Branch 4 (77→78) taken 687 times.
✗ Branch 5 (77→145) not taken.
|
687 | stmtLstNode->statements.push_back(std::any_cast<AssertStmtNode *>(visit(assetStmtCtx))); |
492 |
3/4✓ Branch 0 (80→81) taken 39595 times.
✗ Branch 1 (80→82) not taken.
✓ Branch 2 (83→84) taken 2413 times.
✓ Branch 3 (83→89) taken 37182 times.
|
39595 | else if (auto *unsafeBlockCtx = dynamic_cast<SpiceParser::UnsafeBlockContext *>(stmt)) |
493 |
3/6✓ Branch 0 (84→85) taken 2413 times.
✗ Branch 1 (84→151) not taken.
✓ Branch 2 (85→86) taken 2413 times.
✗ Branch 3 (85→149) not taken.
✓ Branch 4 (86→87) taken 2413 times.
✗ Branch 5 (86→149) not taken.
|
2413 | stmtLstNode->statements.push_back(std::any_cast<UnsafeBlockNode *>(visit(unsafeBlockCtx))); |
494 |
3/4✓ Branch 0 (89→90) taken 37182 times.
✗ Branch 1 (89→91) not taken.
✓ Branch 2 (92→93) taken 28 times.
✓ Branch 3 (92→98) taken 37154 times.
|
37182 | else if (auto *anonymousScopeCtx = dynamic_cast<SpiceParser::AnonymousBlockStmtContext *>(stmt)) |
495 |
3/6✓ Branch 0 (93→94) taken 28 times.
✗ Branch 1 (93→155) not taken.
✓ Branch 2 (94→95) taken 28 times.
✗ Branch 3 (94→153) not taken.
✓ Branch 4 (95→96) taken 28 times.
✗ Branch 5 (95→153) not taken.
|
28 | 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 18575 times.
✗ Branch 1 (112→158) not taken.
|
18575 | return concludeNode(stmtLstNode); |
501 | } | ||
502 | |||
503 | 5543 | std::any ASTBuilder::visitTypeLst(SpiceParser::TypeLstContext *ctx) { | |
504 | 5543 | const auto typeLstNode = createNode<TypeLstNode>(ctx); | |
505 | |||
506 | // Visit children | ||
507 |
2/4✓ Branch 0 (3→4) taken 5543 times.
✗ Branch 1 (3→18) not taken.
✓ Branch 2 (4→5) taken 5543 times.
✗ Branch 3 (4→16) not taken.
|
5543 | fetchChildrenIntoVector(typeLstNode->dataTypes, ctx->dataType()); |
508 | |||
509 |
1/2✓ Branch 0 (12→13) taken 5543 times.
✗ Branch 1 (12→19) not taken.
|
5543 | return concludeNode(typeLstNode); |
510 | } | ||
511 | |||
512 | 818 | std::any ASTBuilder::visitTypeAltsLst(SpiceParser::TypeAltsLstContext *ctx) { | |
513 | 818 | const auto typeAltsLstNode = createNode<TypeAltsLstNode>(ctx); | |
514 | |||
515 | // Visit children | ||
516 |
2/4✓ Branch 0 (3→4) taken 818 times.
✗ Branch 1 (3→18) not taken.
✓ Branch 2 (4→5) taken 818 times.
✗ Branch 3 (4→16) not taken.
|
818 | fetchChildrenIntoVector(typeAltsLstNode->dataTypes, ctx->dataType()); |
517 | |||
518 |
1/2✓ Branch 0 (12→13) taken 818 times.
✗ Branch 1 (12→19) not taken.
|
818 | return concludeNode(typeAltsLstNode); |
519 | } | ||
520 | |||
521 | 7388 | std::any ASTBuilder::visitParamLst(SpiceParser::ParamLstContext *ctx) { | |
522 | 7388 | const auto paramLstNode = createNode<ParamLstNode>(ctx); | |
523 | |||
524 | // Visit children | ||
525 |
2/4✓ Branch 0 (3→4) taken 7388 times.
✗ Branch 1 (3→24) not taken.
✓ Branch 2 (4→5) taken 7388 times.
✗ Branch 3 (4→22) not taken.
|
7388 | 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 11470 times.
✓ Branch 1 (11→12) taken 7388 times.
|
18858 | for (DeclStmtNode *declStmt : paramLstNode->params) { |
529 | 11470 | declStmt->isFctParam = true; | |
530 | 11470 | declStmt->dataType->isParamType = true; | |
531 | } | ||
532 | |||
533 |
1/2✓ Branch 0 (18→19) taken 7388 times.
✗ Branch 1 (18→25) not taken.
|
7388 | return concludeNode(paramLstNode); |
534 | } | ||
535 | |||
536 | 11097 | std::any ASTBuilder::visitArgLst(SpiceParser::ArgLstContext *ctx) { | |
537 | 11097 | const auto argLstNode = createNode<ArgLstNode>(ctx); | |
538 | |||
539 | // Visit children | ||
540 |
2/4✓ Branch 0 (3→4) taken 11097 times.
✗ Branch 1 (3→20) not taken.
✓ Branch 2 (4→5) taken 11097 times.
✗ Branch 3 (4→18) not taken.
|
11097 | fetchChildrenIntoVector(argLstNode->args, ctx->assignExpr()); |
541 | 11097 | argLstNode->argInfos.reserve(argLstNode->args.size()); | |
542 | |||
543 |
1/2✓ Branch 0 (14→15) taken 11097 times.
✗ Branch 1 (14→21) not taken.
|
11097 | 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(), false); |
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 | 1324 | std::any ASTBuilder::visitField(SpiceParser::FieldContext *ctx) { | |
569 | 1324 | const auto fieldNode = createNode<FieldNode>(ctx); | |
570 | |||
571 | // Enrich | ||
572 |
2/4✓ Branch 0 (3→4) taken 1324 times.
✗ Branch 1 (3→29) not taken.
✓ Branch 2 (4→5) taken 1324 times.
✗ Branch 3 (4→29) not taken.
|
1324 | fieldNode->fieldName = getIdentifier(ctx->IDENTIFIER(), false); |
573 | |||
574 | // Visit children | ||
575 |
3/6✓ Branch 0 (7→8) taken 1324 times.
✗ Branch 1 (7→32) not taken.
✓ Branch 2 (8→9) taken 1324 times.
✗ Branch 3 (8→32) not taken.
✓ Branch 4 (9→10) taken 1324 times.
✗ Branch 5 (9→30) not taken.
|
1324 | fieldNode->dataType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
576 | 1324 | fieldNode->dataType->setFieldTypeRecursive(); | |
577 |
2/2✓ Branch 0 (13→14) taken 176 times.
✓ Branch 1 (13→19) taken 1148 times.
|
1324 | 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 1324 times.
✗ Branch 1 (25→36) not taken.
|
1324 | 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(), false); |
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 | 25227 | std::any ASTBuilder::visitStmt(SpiceParser::StmtContext *ctx) { | |
615 |
2/2✓ Branch 0 (3→4) taken 4708 times.
✓ Branch 1 (3→11) taken 20519 times.
|
25227 | if (ctx->declStmt()) |
616 |
5/8✓ Branch 0 (4→5) taken 4708 times.
✗ Branch 1 (4→60) not taken.
✓ Branch 2 (5→6) taken 4704 times.
✓ Branch 3 (5→60) taken 4 times.
✓ Branch 4 (6→7) taken 4704 times.
✗ Branch 5 (6→58) not taken.
✓ Branch 6 (7→8) taken 4704 times.
✗ Branch 7 (7→58) not taken.
|
4708 | return static_cast<StmtNode *>(std::any_cast<DeclStmtNode *>(visit(ctx->declStmt()))); |
617 |
2/2✓ Branch 0 (12→13) taken 12249 times.
✓ Branch 1 (12→20) taken 8270 times.
|
20519 | if (ctx->exprStmt()) |
618 |
4/8✓ Branch 0 (13→14) taken 12249 times.
✗ Branch 1 (13→64) not taken.
✓ Branch 2 (14→15) taken 12249 times.
✗ Branch 3 (14→64) not taken.
✓ Branch 4 (15→16) taken 12249 times.
✗ Branch 5 (15→62) not taken.
✓ Branch 6 (16→17) taken 12249 times.
✗ Branch 7 (16→62) not taken.
|
12249 | return static_cast<StmtNode *>(std::any_cast<ExprStmtNode *>(visit(ctx->exprStmt()))); |
619 |
2/2✓ Branch 0 (21→22) taken 7973 times.
✓ Branch 1 (21→29) taken 297 times.
|
8270 | if (ctx->returnStmt()) |
620 |
4/8✓ Branch 0 (22→23) taken 7973 times.
✗ Branch 1 (22→68) not taken.
✓ Branch 2 (23→24) taken 7973 times.
✗ Branch 3 (23→68) not taken.
✓ Branch 4 (24→25) taken 7973 times.
✗ Branch 5 (24→66) not taken.
✓ Branch 6 (25→26) taken 7973 times.
✗ Branch 7 (25→66) not taken.
|
7973 | return static_cast<StmtNode *>(std::any_cast<ReturnStmtNode *>(visit(ctx->returnStmt()))); |
621 |
2/2✓ Branch 0 (30→31) taken 106 times.
✓ Branch 1 (30→38) taken 191 times.
|
297 | if (ctx->breakStmt()) |
622 |
4/8✓ Branch 0 (31→32) taken 106 times.
✗ Branch 1 (31→72) not taken.
✓ Branch 2 (32→33) taken 106 times.
✗ Branch 3 (32→72) not taken.
✓ Branch 4 (33→34) taken 106 times.
✗ Branch 5 (33→70) not taken.
✓ Branch 6 (34→35) taken 106 times.
✗ Branch 7 (34→70) not taken.
|
106 | return static_cast<StmtNode *>(std::any_cast<BreakStmtNode *>(visit(ctx->breakStmt()))); |
623 |
2/2✓ Branch 0 (39→40) taken 185 times.
✓ Branch 1 (39→47) taken 6 times.
|
191 | if (ctx->continueStmt()) |
624 |
4/8✓ Branch 0 (40→41) taken 185 times.
✗ Branch 1 (40→76) not taken.
✓ Branch 2 (41→42) taken 185 times.
✗ Branch 3 (41→76) not taken.
✓ Branch 4 (42→43) taken 185 times.
✗ Branch 5 (42→74) not taken.
✓ Branch 6 (43→44) taken 185 times.
✗ Branch 7 (43→74) not taken.
|
185 | 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 | 17539 | std::any ASTBuilder::visitDeclStmt(SpiceParser::DeclStmtContext *ctx) { | |
632 | 17539 | const auto declStmtNode = createNode<DeclStmtNode>(ctx); | |
633 | |||
634 | // Enrich | ||
635 |
3/4✓ Branch 0 (3→4) taken 17539 times.
✗ Branch 1 (3→28) not taken.
✓ Branch 2 (4→5) taken 17538 times.
✓ Branch 3 (4→28) taken 1 times.
|
17539 | declStmtNode->varName = getIdentifier(ctx->IDENTIFIER(), false); |
636 | |||
637 | // Visit children | ||
638 |
4/6✓ Branch 0 (7→8) taken 17538 times.
✗ Branch 1 (7→31) not taken.
✓ Branch 2 (8→9) taken 17537 times.
✓ Branch 3 (8→31) taken 1 times.
✓ Branch 4 (9→10) taken 17537 times.
✗ Branch 5 (9→29) not taken.
|
17538 | declStmtNode->dataType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
639 |
2/2✓ Branch 0 (12→13) taken 6536 times.
✓ Branch 1 (12→18) taken 11001 times.
|
17537 | if (ctx->assignExpr()) { |
640 | 6536 | declStmtNode->hasAssignment = true; | |
641 |
4/6✓ Branch 0 (13→14) taken 6536 times.
✗ Branch 1 (13→34) not taken.
✓ Branch 2 (14→15) taken 6534 times.
✓ Branch 3 (14→34) taken 2 times.
✓ Branch 4 (15→16) taken 6534 times.
✗ Branch 5 (15→32) not taken.
|
6536 | declStmtNode->assignExpr = std::any_cast<AssignExprNode *>(visit(ctx->assignExpr())); |
642 | } | ||
643 | |||
644 |
1/2✓ Branch 0 (24→25) taken 17535 times.
✗ Branch 1 (24→35) not taken.
|
17535 | return concludeNode(declStmtNode); |
645 | } | ||
646 | |||
647 | 12249 | std::any ASTBuilder::visitExprStmt(SpiceParser::ExprStmtContext *ctx) { | |
648 | 12249 | const auto exprStmtNode = createNode<ExprStmtNode>(ctx); | |
649 | |||
650 | // Enrich | ||
651 |
3/6✓ Branch 0 (3→4) taken 12249 times.
✗ Branch 1 (3→19) not taken.
✓ Branch 2 (4→5) taken 12249 times.
✗ Branch 3 (4→19) not taken.
✓ Branch 4 (5→6) taken 12249 times.
✗ Branch 5 (5→17) not taken.
|
12249 | exprStmtNode->expr = std::any_cast<AssignExprNode *>(visit(ctx->assignExpr())); |
652 | |||
653 |
1/2✓ Branch 0 (13→14) taken 12249 times.
✗ Branch 1 (13→20) not taken.
|
12249 | return concludeNode(exprStmtNode); |
654 | } | ||
655 | |||
656 | 26211 | std::any ASTBuilder::visitQualifierLst(SpiceParser::QualifierLstContext *ctx) { | |
657 | 26211 | const auto qualifierLstNode = createNode<QualifierLstNode>(ctx); | |
658 | |||
659 | // Visit children | ||
660 |
2/4✓ Branch 0 (3→4) taken 26211 times.
✗ Branch 1 (3→37) not taken.
✓ Branch 2 (4→5) taken 26211 times.
✗ Branch 3 (4→35) not taken.
|
26211 | fetchChildrenIntoVector(qualifierLstNode->qualifiers, ctx->qualifier()); |
661 | |||
662 | // Check if qualifier combination is invalid | ||
663 | 26211 | bool seenSignedOrUnsigned = false; | |
664 |
2/2✓ Branch 0 (24→8) taken 31983 times.
✓ Branch 1 (24→25) taken 26210 times.
|
58193 | for (const QualifierNode *qualifier : qualifierLstNode->qualifiers) { |
665 | // Check if we have both, signed and unsigned qualifier | ||
666 |
2/2✓ Branch 0 (9→10) taken 31980 times.
✓ Branch 1 (9→12) taken 3 times.
|
31983 | if (qualifier->type != QualifierNode::QualifierType::TY_SIGNED && |
667 |
2/2✓ Branch 0 (10→11) taken 23611 times.
✓ Branch 1 (10→12) taken 8369 times.
|
31980 | qualifier->type != QualifierNode::QualifierType::TY_UNSIGNED) |
668 | 23611 | continue; | |
669 |
2/2✓ Branch 0 (12→13) taken 1 times.
✓ Branch 1 (12→21) taken 8371 times.
|
8372 | 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 | 8371 | seenSignedOrUnsigned = true; | |
672 | } | ||
673 | |||
674 |
1/2✓ Branch 0 (31→32) taken 26210 times.
✗ Branch 1 (31→48) not taken.
|
26210 | return concludeNode(qualifierLstNode); |
675 | } | ||
676 | |||
677 | 31983 | std::any ASTBuilder::visitQualifier(SpiceParser::QualifierContext *ctx) { | |
678 | 31983 | const auto qualifierNode = createNode<QualifierNode>(ctx); | |
679 | |||
680 |
3/4✓ Branch 0 (6→7) taken 31983 times.
✗ Branch 1 (6→8) not taken.
✓ Branch 2 (32→5) taken 31983 times.
✓ Branch 3 (32→33) taken 31983 times.
|
63966 | for (ParserRuleContext::ParseTree *subTree : ctx->children) { |
681 | 31983 | const auto token = spice_pointer_cast<TerminalNode *>(subTree); | |
682 |
2/4✓ Branch 0 (13→14) taken 31983 times.
✗ Branch 1 (13→43) not taken.
✓ Branch 2 (14→15) taken 31983 times.
✗ Branch 3 (14→43) not taken.
|
31983 | const size_t symbolType = token->getSymbol()->getType(); |
683 |
2/2✓ Branch 0 (15→16) taken 6918 times.
✓ Branch 1 (15→17) taken 25065 times.
|
31983 | if (symbolType == SpiceParser::CONST) |
684 | 6918 | qualifierNode->type = QualifierNode::QualifierType::TY_CONST; | |
685 |
2/2✓ Branch 0 (17→18) taken 3 times.
✓ Branch 1 (17→19) taken 25062 times.
|
25065 | else if (symbolType == SpiceParser::SIGNED) |
686 | 3 | qualifierNode->type = QualifierNode::QualifierType::TY_SIGNED; | |
687 |
2/2✓ Branch 0 (19→20) taken 8369 times.
✓ Branch 1 (19→21) taken 16693 times.
|
25062 | else if (symbolType == SpiceParser::UNSIGNED) |
688 | 8369 | qualifierNode->type = QualifierNode::QualifierType::TY_UNSIGNED; | |
689 |
2/2✓ Branch 0 (21→22) taken 2807 times.
✓ Branch 1 (21→23) taken 13886 times.
|
16693 | else if (symbolType == SpiceParser::INLINE) |
690 | 2807 | qualifierNode->type = QualifierNode::QualifierType::TY_INLINE; | |
691 |
2/2✓ Branch 0 (23→24) taken 10679 times.
✓ Branch 1 (23→25) taken 3207 times.
|
13886 | else if (symbolType == SpiceParser::PUBLIC) |
692 | 10679 | qualifierNode->type = QualifierNode::QualifierType::TY_PUBLIC; | |
693 |
2/2✓ Branch 0 (25→26) taken 3200 times.
✓ Branch 1 (25→27) taken 7 times.
|
3207 | else if (symbolType == SpiceParser::HEAP) |
694 | 3200 | 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 31983 times.
✗ Branch 1 (39→44) not taken.
|
31983 | return concludeNode(qualifierNode); |
702 | } | ||
703 | |||
704 | 305 | std::any ASTBuilder::visitModAttr(SpiceParser::ModAttrContext *ctx) { | |
705 | 305 | const auto modAttrNode = createNode<ModAttrNode>(ctx); | |
706 | |||
707 | // Visit children | ||
708 |
4/6✓ Branch 0 (3→4) taken 305 times.
✗ Branch 1 (3→25) not taken.
✓ Branch 2 (4→5) taken 304 times.
✓ Branch 3 (4→25) taken 1 times.
✓ Branch 4 (5→6) taken 304 times.
✗ Branch 5 (5→23) not taken.
|
305 | 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 738 times.
✓ Branch 1 (12→13) taken 304 times.
|
1042 | for (AttrNode *attr : modAttrNode->attrLst->attributes) |
712 | 738 | attr->target = AttrNode::TARGET_MODULE; | |
713 | |||
714 |
1/2✓ Branch 0 (19→20) taken 304 times.
✗ Branch 1 (19→26) not taken.
|
304 | return concludeNode(modAttrNode); |
715 | } | ||
716 | |||
717 | 416 | std::any ASTBuilder::visitTopLevelDefAttr(SpiceParser::TopLevelDefAttrContext *ctx) { | |
718 | 416 | const auto fctAttrNode = createNode<TopLevelDefinitionAttrNode>(ctx); | |
719 | |||
720 | // Visit children | ||
721 |
3/6✓ Branch 0 (3→4) taken 416 times.
✗ Branch 1 (3→19) not taken.
✓ Branch 2 (4→5) taken 416 times.
✗ Branch 3 (4→19) not taken.
✓ Branch 4 (5→6) taken 416 times.
✗ Branch 5 (5→17) not taken.
|
416 | fctAttrNode->attrLst = std::any_cast<AttrLstNode *>(visit(ctx->attrLst())); |
722 | |||
723 |
1/2✓ Branch 0 (13→14) taken 416 times.
✗ Branch 1 (13→20) not taken.
|
416 | 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 | 737 | std::any ASTBuilder::visitAttrLst(SpiceParser::AttrLstContext *ctx) { | |
740 | 737 | const auto attrLstNode = createNode<AttrLstNode>(ctx); | |
741 | |||
742 | // Visit children | ||
743 |
3/4✓ Branch 0 (3→4) taken 737 times.
✗ Branch 1 (3→18) not taken.
✓ Branch 2 (4→5) taken 736 times.
✓ Branch 3 (4→16) taken 1 times.
|
738 | fetchChildrenIntoVector(attrLstNode->attributes, ctx->attr()); |
744 | |||
745 |
1/2✓ Branch 0 (12→13) taken 736 times.
✗ Branch 1 (12→19) not taken.
|
736 | return concludeNode(attrLstNode); |
746 | } | ||
747 | |||
748 | 1176 | std::any ASTBuilder::visitAttr(SpiceParser::AttrContext *ctx) { | |
749 | 1176 | const auto attrNode = createNode<AttrNode>(ctx); | |
750 | |||
751 | // Extract key | ||
752 |
3/4✓ Branch 0 (3→4) taken 1176 times.
✗ Branch 1 (3→66) not taken.
✓ Branch 2 (16→6) taken 2917 times.
✓ Branch 3 (16→17) taken 1176 times.
|
4093 | for (const TerminalNode *keyFragment : ctx->IDENTIFIER()) { |
753 |
2/2✓ Branch 0 (8→9) taken 1741 times.
✓ Branch 1 (8→10) taken 1176 times.
|
2917 | if (!attrNode->key.empty()) |
754 |
1/2✓ Branch 0 (9→10) taken 1741 times.
✗ Branch 1 (9→64) not taken.
|
1741 | attrNode->key += MEMBER_ACCESS_TOKEN; |
755 |
3/6✓ Branch 0 (10→11) taken 2917 times.
✗ Branch 1 (10→63) not taken.
✓ Branch 2 (11→12) taken 2917 times.
✗ Branch 3 (11→63) not taken.
✓ Branch 4 (12→13) taken 2917 times.
✗ Branch 5 (12→61) not taken.
|
2917 | attrNode->key += keyFragment->getSymbol()->getText(); |
756 | 1176 | } | |
757 | |||
758 | // Visit children | ||
759 |
2/2✓ Branch 0 (19→20) taken 858 times.
✓ Branch 1 (19→50) taken 318 times.
|
1176 | if (ctx->constant()) { |
760 |
3/6✓ Branch 0 (20→21) taken 858 times.
✗ Branch 1 (20→69) not taken.
✓ Branch 2 (21→22) taken 858 times.
✗ Branch 3 (21→69) not taken.
✓ Branch 4 (22→23) taken 858 times.
✗ Branch 5 (22→67) not taken.
|
858 | 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 416 times.
|
858 | 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 356 times.
|
416 | 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 352 times.
✓ Branch 2 (37→38) taken 3 times.
✓ Branch 3 (37→39) taken 1 times.
✓ Branch 4 (40→41) taken 355 times.
✓ Branch 5 (40→42) taken 1 times.
|
356 | else if (ctx->constant()->TRUE() || ctx->constant()->FALSE()) |
767 | 355 | 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 | 318 | attrNode->type = AttrNode::AttrType::TYPE_BOOL; | |
773 | } | ||
774 | |||
775 |
1/2✓ Branch 0 (57→58) taken 1175 times.
✗ Branch 1 (57→79) not taken.
|
1175 | 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, false); | |
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, false); |
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 | 7973 | std::any ASTBuilder::visitReturnStmt(SpiceParser::ReturnStmtContext *ctx) { | |
812 | 7973 | const auto returnStmtNode = createNode<ReturnStmtNode>(ctx); | |
813 | |||
814 | // Visit children | ||
815 |
2/2✓ Branch 0 (4→5) taken 7779 times.
✓ Branch 1 (4→10) taken 194 times.
|
7973 | if (ctx->assignExpr()) { |
816 | 7779 | returnStmtNode->hasReturnValue = true; | |
817 |
3/6✓ Branch 0 (5→6) taken 7779 times.
✗ Branch 1 (5→22) not taken.
✓ Branch 2 (6→7) taken 7779 times.
✗ Branch 3 (6→22) not taken.
✓ Branch 4 (7→8) taken 7779 times.
✗ Branch 5 (7→20) not taken.
|
7779 | returnStmtNode->assignExpr = std::any_cast<AssignExprNode *>(visit(ctx->assignExpr())); |
818 | } | ||
819 | |||
820 |
1/2✓ Branch 0 (16→17) taken 7973 times.
✗ Branch 1 (16→23) not taken.
|
7973 | return concludeNode(returnStmtNode); |
821 | } | ||
822 | |||
823 | 106 | std::any ASTBuilder::visitBreakStmt(SpiceParser::BreakStmtContext *ctx) { | |
824 | 106 | 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 100 times.
|
106 | 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 106 times.
✗ Branch 1 (10→25) not taken.
|
106 | visitChildren(ctx); |
832 | |||
833 |
1/2✓ Branch 0 (18→19) taken 106 times.
✗ Branch 1 (18→26) not taken.
|
106 | return concludeNode(breakStmtNode); |
834 | } | ||
835 | |||
836 | 185 | std::any ASTBuilder::visitContinueStmt(SpiceParser::ContinueStmtContext *ctx) { | |
837 | 185 | const auto continueStmtNode = createNode<ContinueStmtNode>(ctx); | |
838 | |||
839 | // Extract number of continues | ||
840 |
2/2✓ Branch 0 (4→5) taken 184 times.
✓ Branch 1 (4→10) taken 1 times.
|
185 | if (ctx->INT_LIT()) |
841 |
3/6✓ Branch 0 (5→6) taken 184 times.
✗ Branch 1 (5→24) not taken.
✓ Branch 2 (6→7) taken 184 times.
✗ Branch 3 (6→24) not taken.
✓ Branch 4 (7→8) taken 184 times.
✗ Branch 5 (7→22) not taken.
|
184 | continueStmtNode->continueTimes = std::stoi(ctx->INT_LIT()->toString()); |
842 | |||
843 | // Visit children | ||
844 |
1/2✓ Branch 0 (10→11) taken 185 times.
✗ Branch 1 (10→25) not taken.
|
185 | visitChildren(ctx); |
845 | |||
846 |
1/2✓ Branch 0 (18→19) taken 185 times.
✗ Branch 1 (18→26) not taken.
|
185 | 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 | 687 | std::any ASTBuilder::visitAssertStmt(SpiceParser::AssertStmtContext *ctx) { | |
859 |
1/2✓ Branch 0 (2→3) taken 687 times.
✗ Branch 1 (2→30) not taken.
|
687 | const auto assertStmtNode = createNode<AssertStmtNode>(ctx); |
860 | |||
861 | // Enrich | ||
862 |
5/10✓ Branch 0 (3→4) taken 687 times.
✗ Branch 1 (3→30) not taken.
✓ Branch 2 (4→5) taken 687 times.
✗ Branch 3 (4→30) not taken.
✓ Branch 4 (5→6) taken 687 times.
✗ Branch 5 (5→30) not taken.
✓ Branch 6 (6→7) taken 687 times.
✗ Branch 7 (6→30) not taken.
✓ Branch 8 (7→8) taken 687 times.
✗ Branch 9 (7→30) not taken.
|
687 | const antlr4::misc::Interval interval(ctx->assignExpr()->start->getStartIndex(), ctx->assignExpr()->stop->getStopIndex()); |
863 |
1/2✓ Branch 0 (8→9) taken 687 times.
✗ Branch 1 (8→25) not taken.
|
687 | assertStmtNode->expressionString = inputStream->getText(interval); |
864 | |||
865 | // Visit children | ||
866 |
3/6✓ Branch 0 (11→12) taken 687 times.
✗ Branch 1 (11→28) not taken.
✓ Branch 2 (12→13) taken 687 times.
✗ Branch 3 (12→28) not taken.
✓ Branch 4 (13→14) taken 687 times.
✗ Branch 5 (13→26) not taken.
|
687 | assertStmtNode->assignExpr = std::any_cast<AssignExprNode *>(visit(ctx->assignExpr())); |
867 | |||
868 |
1/2✓ Branch 0 (21→22) taken 687 times.
✗ Branch 1 (21→29) not taken.
|
687 | return concludeNode(assertStmtNode); |
869 | } | ||
870 | |||
871 | 1950 | std::any ASTBuilder::visitBuiltinCall(SpiceParser::BuiltinCallContext *ctx) { | |
872 | 1950 | const auto builtinCallNode = createNode<BuiltinCallNode>(ctx); | |
873 | |||
874 |
2/2✓ Branch 0 (4→5) taken 800 times.
✓ Branch 1 (4→10) taken 1150 times.
|
1950 | if (ctx->printfCall()) { |
875 |
3/6✓ Branch 0 (5→6) taken 800 times.
✗ Branch 1 (5→65) not taken.
✓ Branch 2 (6→7) taken 800 times.
✗ Branch 3 (6→65) not taken.
✓ Branch 4 (7→8) taken 800 times.
✗ Branch 5 (7→63) not taken.
|
800 | builtinCallNode->printfCall = std::any_cast<PrintfCallNode *>(visit(ctx->printfCall())); |
876 |
2/2✓ Branch 0 (11→12) taken 208 times.
✓ Branch 1 (11→17) taken 942 times.
|
1150 | } 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 931 times.
|
942 | } 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 929 times.
|
931 | } 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 125 times.
✓ Branch 1 (32→38) taken 804 times.
|
929 | } else if (ctx->lenCall()) { |
883 |
3/6✓ Branch 0 (33→34) taken 125 times.
✗ Branch 1 (33→77) not taken.
✓ Branch 2 (34→35) taken 125 times.
✗ Branch 3 (34→77) not taken.
✓ Branch 4 (35→36) taken 125 times.
✗ Branch 5 (35→75) not taken.
|
125 | builtinCallNode->lenCall = std::any_cast<LenCallNode *>(visit(ctx->lenCall())); |
884 |
2/2✓ Branch 0 (39→40) taken 803 times.
✓ Branch 1 (39→45) taken 1 times.
|
804 | } else if (ctx->panicCall()) { |
885 |
3/6✓ Branch 0 (40→41) taken 803 times.
✗ Branch 1 (40→80) not taken.
✓ Branch 2 (41→42) taken 803 times.
✗ Branch 3 (41→80) not taken.
✓ Branch 4 (42→43) taken 803 times.
✗ Branch 5 (42→78) not taken.
|
803 | 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 1950 times.
✗ Branch 1 (59→84) not taken.
|
1950 | return concludeNode(builtinCallNode); |
893 | } | ||
894 | |||
895 | 800 | std::any ASTBuilder::visitPrintfCall(SpiceParser::PrintfCallContext *ctx) { | |
896 |
1/2✓ Branch 0 (2→3) taken 800 times.
✗ Branch 1 (2→32) not taken.
|
800 | const auto printfCallNode = createNode<PrintfCallNode>(ctx); |
897 | |||
898 | // Enrich | ||
899 |
2/4✓ Branch 0 (3→4) taken 800 times.
✗ Branch 1 (3→32) not taken.
✓ Branch 2 (4→5) taken 800 times.
✗ Branch 3 (4→32) not taken.
|
800 | std::string templatedString = ctx->STRING_LIT()->getText(); |
900 |
1/2✓ Branch 0 (6→7) taken 800 times.
✗ Branch 1 (6→25) not taken.
|
800 | templatedString = templatedString.substr(1, templatedString.size() - 2); |
901 |
1/2✓ Branch 0 (9→10) taken 800 times.
✗ Branch 1 (9→30) not taken.
|
800 | replaceEscapeChars(templatedString); |
902 |
1/2✓ Branch 0 (10→11) taken 800 times.
✗ Branch 1 (10→30) not taken.
|
800 | printfCallNode->templatedString = templatedString; |
903 | |||
904 | // Visit children | ||
905 |
2/4✓ Branch 0 (11→12) taken 800 times.
✗ Branch 1 (11→28) not taken.
✓ Branch 2 (12→13) taken 800 times.
✗ Branch 3 (12→26) not taken.
|
800 | fetchChildrenIntoVector(printfCallNode->args, ctx->assignExpr()); |
906 | |||
907 |
1/2✓ Branch 0 (20→21) taken 800 times.
✗ Branch 1 (20→29) not taken.
|
1600 | return concludeNode(printfCallNode); |
908 | 800 | } | |
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 | 125 | std::any ASTBuilder::visitLenCall(SpiceParser::LenCallContext *ctx) { | |
953 | 125 | const auto lenCallNode = createNode<LenCallNode>(ctx); | |
954 | |||
955 | // Visit children | ||
956 |
3/6✓ Branch 0 (3→4) taken 125 times.
✗ Branch 1 (3→19) not taken.
✓ Branch 2 (4→5) taken 125 times.
✗ Branch 3 (4→19) not taken.
✓ Branch 4 (5→6) taken 125 times.
✗ Branch 5 (5→17) not taken.
|
125 | lenCallNode->assignExpr = std::any_cast<AssignExprNode *>(visit(ctx->assignExpr())); |
957 | |||
958 |
1/2✓ Branch 0 (13→14) taken 125 times.
✗ Branch 1 (13→20) not taken.
|
125 | return concludeNode(lenCallNode); |
959 | } | ||
960 | |||
961 | 803 | std::any ASTBuilder::visitPanicCall(SpiceParser::PanicCallContext *ctx) { | |
962 | 803 | const auto panicCallNode = createNode<PanicCallNode>(ctx); | |
963 | |||
964 | // Visit children | ||
965 |
3/6✓ Branch 0 (3→4) taken 803 times.
✗ Branch 1 (3→19) not taken.
✓ Branch 2 (4→5) taken 803 times.
✗ Branch 3 (4→19) not taken.
✓ Branch 4 (5→6) taken 803 times.
✗ Branch 5 (5→17) not taken.
|
803 | panicCallNode->assignExpr = std::any_cast<AssignExprNode *>(visit(ctx->assignExpr())); |
966 | |||
967 |
1/2✓ Branch 0 (13→14) taken 803 times.
✗ Branch 1 (13→20) not taken.
|
803 | 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 | 65449 | std::any ASTBuilder::visitAssignExpr(SpiceParser::AssignExprContext *ctx) { | |
980 | 65449 | const auto assignExprNode = createNode<AssignExprNode>(ctx); | |
981 | |||
982 | // Visit children | ||
983 |
2/2✓ Branch 0 (4→5) taken 58993 times.
✓ Branch 1 (4→10) taken 6456 times.
|
65449 | if (ctx->ternaryExpr()) { |
984 |
4/6✓ Branch 0 (5→6) taken 58993 times.
✗ Branch 1 (5→37) not taken.
✓ Branch 2 (6→7) taken 58991 times.
✓ Branch 3 (6→37) taken 2 times.
✓ Branch 4 (7→8) taken 58991 times.
✗ Branch 5 (7→35) not taken.
|
58993 | assignExprNode->ternaryExpr = std::any_cast<TernaryExprNode *>(visit(ctx->ternaryExpr())); |
985 |
1/2✓ Branch 0 (11→12) taken 6456 times.
✗ Branch 1 (11→24) not taken.
|
6456 | } else if (ctx->prefixUnaryExpr()) { |
986 |
3/6✓ Branch 0 (12→13) taken 6456 times.
✗ Branch 1 (12→40) not taken.
✓ Branch 2 (13→14) taken 6456 times.
✗ Branch 3 (13→40) not taken.
✓ Branch 4 (14→15) taken 6456 times.
✗ Branch 5 (14→38) not taken.
|
6456 | assignExprNode->lhs = std::any_cast<PrefixUnaryExprNode *>(visit(ctx->prefixUnaryExpr())); |
987 |
2/4✓ Branch 0 (16→17) taken 6456 times.
✗ Branch 1 (16→41) not taken.
✓ Branch 2 (17→18) taken 6456 times.
✗ Branch 3 (17→41) not taken.
|
6456 | visit(ctx->assignOp()); |
988 |
3/6✓ Branch 0 (19→20) taken 6456 times.
✗ Branch 1 (19→44) not taken.
✓ Branch 2 (20→21) taken 6456 times.
✗ Branch 3 (20→44) not taken.
✓ Branch 4 (21→22) taken 6456 times.
✗ Branch 5 (21→42) not taken.
|
6456 | 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 65447 times.
✗ Branch 1 (31→45) not taken.
|
65447 | return concludeNode(assignExprNode); |
994 | } | ||
995 | |||
996 | 59169 | std::any ASTBuilder::visitTernaryExpr(SpiceParser::TernaryExprContext *ctx) { | |
997 | 59169 | const auto ternaryExprNode = createNode<TernaryExprNode>(ctx); | |
998 | |||
999 |
4/6✓ Branch 0 (3→4) taken 59169 times.
✗ Branch 1 (3→41) not taken.
✓ Branch 2 (4→5) taken 59167 times.
✓ Branch 3 (4→41) taken 2 times.
✓ Branch 4 (5→6) taken 59167 times.
✗ Branch 5 (5→39) not taken.
|
59169 | ternaryExprNode->condition = std::any_cast<LogicalOrExprNode *>(visit(ctx->logicalOrExpr(0))); |
1000 |
3/4✓ Branch 0 (7→8) taken 59167 times.
✗ Branch 1 (7→42) not taken.
✓ Branch 2 (10→11) taken 333 times.
✓ Branch 3 (10→20) taken 58834 times.
|
59167 | if (ctx->logicalOrExpr().size() == 3) { |
1001 |
3/6✓ Branch 0 (11→12) taken 333 times.
✗ Branch 1 (11→45) not taken.
✓ Branch 2 (12→13) taken 333 times.
✗ Branch 3 (12→45) not taken.
✓ Branch 4 (13→14) taken 333 times.
✗ Branch 5 (13→43) not taken.
|
333 | ternaryExprNode->trueExpr = std::any_cast<LogicalOrExprNode *>(visit(ctx->logicalOrExpr(1))); |
1002 |
3/6✓ Branch 0 (15→16) taken 333 times.
✗ Branch 1 (15→48) not taken.
✓ Branch 2 (16→17) taken 333 times.
✗ Branch 3 (16→48) not taken.
✓ Branch 4 (17→18) taken 333 times.
✗ Branch 5 (17→46) not taken.
|
333 | ternaryExprNode->falseExpr = std::any_cast<LogicalOrExprNode *>(visit(ctx->logicalOrExpr(2))); |
1003 |
3/4✓ Branch 0 (20→21) taken 58834 times.
✗ Branch 1 (20→49) not taken.
✓ Branch 2 (23→24) taken 1 times.
✓ Branch 3 (23→29) taken 58833 times.
|
58834 | } 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 59167 times.
✗ Branch 1 (35→53) not taken.
|
59167 | return concludeNode(ternaryExprNode); |
1009 | } | ||
1010 | |||
1011 | 59836 | std::any ASTBuilder::visitLogicalOrExpr(SpiceParser::LogicalOrExprContext *ctx) { | |
1012 | 59836 | const auto logicalOrExprNode = createNode<LogicalOrExprNode>(ctx); | |
1013 | |||
1014 | // Visit children | ||
1015 |
3/4✓ Branch 0 (3→4) taken 59836 times.
✗ Branch 1 (3→18) not taken.
✓ Branch 2 (4→5) taken 59834 times.
✓ Branch 3 (4→16) taken 2 times.
|
59838 | fetchChildrenIntoVector(logicalOrExprNode->operands, ctx->logicalAndExpr()); |
1016 | |||
1017 |
1/2✓ Branch 0 (12→13) taken 59834 times.
✗ Branch 1 (12→19) not taken.
|
59834 | return concludeNode(logicalOrExprNode); |
1018 | } | ||
1019 | |||
1020 | 60989 | std::any ASTBuilder::visitLogicalAndExpr(SpiceParser::LogicalAndExprContext *ctx) { | |
1021 | 60989 | const auto logicalAndExprNode = createNode<LogicalAndExprNode>(ctx); | |
1022 | |||
1023 | // Visit children | ||
1024 |
3/4✓ Branch 0 (3→4) taken 60989 times.
✗ Branch 1 (3→18) not taken.
✓ Branch 2 (4→5) taken 60987 times.
✓ Branch 3 (4→16) taken 2 times.
|
60991 | fetchChildrenIntoVector(logicalAndExprNode->operands, ctx->bitwiseOrExpr()); |
1025 | |||
1026 |
1/2✓ Branch 0 (12→13) taken 60987 times.
✗ Branch 1 (12→19) not taken.
|
60987 | return concludeNode(logicalAndExprNode); |
1027 | } | ||
1028 | |||
1029 | 61229 | std::any ASTBuilder::visitBitwiseOrExpr(SpiceParser::BitwiseOrExprContext *ctx) { | |
1030 | 61229 | const auto bitwiseOrExprNode = createNode<BitwiseOrExprNode>(ctx); | |
1031 | |||
1032 | // Visit children | ||
1033 |
3/4✓ Branch 0 (3→4) taken 61229 times.
✗ Branch 1 (3→18) not taken.
✓ Branch 2 (4→5) taken 61227 times.
✓ Branch 3 (4→16) taken 2 times.
|
61231 | fetchChildrenIntoVector(bitwiseOrExprNode->operands, ctx->bitwiseXorExpr()); |
1034 | |||
1035 |
1/2✓ Branch 0 (12→13) taken 61227 times.
✗ Branch 1 (12→19) not taken.
|
61227 | return concludeNode(bitwiseOrExprNode); |
1036 | } | ||
1037 | |||
1038 | 61295 | std::any ASTBuilder::visitBitwiseXorExpr(SpiceParser::BitwiseXorExprContext *ctx) { | |
1039 | 61295 | const auto bitwiseXorExprNode = createNode<BitwiseXorExprNode>(ctx); | |
1040 | |||
1041 | // Visit children | ||
1042 |
3/4✓ Branch 0 (3→4) taken 61295 times.
✗ Branch 1 (3→18) not taken.
✓ Branch 2 (4→5) taken 61293 times.
✓ Branch 3 (4→16) taken 2 times.
|
61297 | fetchChildrenIntoVector(bitwiseXorExprNode->operands, ctx->bitwiseAndExpr()); |
1043 | |||
1044 |
1/2✓ Branch 0 (12→13) taken 61293 times.
✗ Branch 1 (12→19) not taken.
|
61293 | return concludeNode(bitwiseXorExprNode); |
1045 | } | ||
1046 | |||
1047 | 61299 | std::any ASTBuilder::visitBitwiseAndExpr(SpiceParser::BitwiseAndExprContext *ctx) { | |
1048 | 61299 | const auto bitwiseAndExprNode = createNode<BitwiseAndExprNode>(ctx); | |
1049 | |||
1050 | // Visit children | ||
1051 |
3/4✓ Branch 0 (3→4) taken 61299 times.
✗ Branch 1 (3→18) not taken.
✓ Branch 2 (4→5) taken 61297 times.
✓ Branch 3 (4→16) taken 2 times.
|
61301 | fetchChildrenIntoVector(bitwiseAndExprNode->operands, ctx->equalityExpr()); |
1052 | |||
1053 |
1/2✓ Branch 0 (12→13) taken 61297 times.
✗ Branch 1 (12→19) not taken.
|
61297 | return concludeNode(bitwiseAndExprNode); |
1054 | } | ||
1055 | |||
1056 | 61328 | std::any ASTBuilder::visitEqualityExpr(SpiceParser::EqualityExprContext *ctx) { | |
1057 | 61328 | const auto equalityExprNode = createNode<EqualityExprNode>(ctx); | |
1058 | |||
1059 | // Visit children | ||
1060 |
3/4✓ Branch 0 (3→4) taken 61328 times.
✗ Branch 1 (3→24) not taken.
✓ Branch 2 (4→5) taken 61326 times.
✓ Branch 3 (4→22) taken 2 times.
|
61330 | fetchChildrenIntoVector(equalityExprNode->operands, ctx->relationalExpr()); |
1061 | |||
1062 | // Extract operator | ||
1063 |
2/2✓ Branch 0 (7→8) taken 3373 times.
✓ Branch 1 (7→9) taken 57953 times.
|
61326 | if (ctx->EQUAL()) |
1064 | 3373 | equalityExprNode->op = EqualityExprNode::EqualityOp::OP_EQUAL; | |
1065 |
2/2✓ Branch 0 (10→11) taken 1187 times.
✓ Branch 1 (10→12) taken 56766 times.
|
57953 | else if (ctx->NOT_EQUAL()) |
1066 | 1187 | equalityExprNode->op = EqualityExprNode::EqualityOp::OP_NOT_EQUAL; | |
1067 | |||
1068 |
1/2✓ Branch 0 (18→19) taken 61326 times.
✗ Branch 1 (18→25) not taken.
|
61326 | return concludeNode(equalityExprNode); |
1069 | } | ||
1070 | |||
1071 | 65888 | std::any ASTBuilder::visitRelationalExpr(SpiceParser::RelationalExprContext *ctx) { | |
1072 | 65888 | const auto relationalExprNode = createNode<RelationalExprNode>(ctx); | |
1073 | |||
1074 | // Visit children | ||
1075 |
3/4✓ Branch 0 (3→4) taken 65888 times.
✗ Branch 1 (3→30) not taken.
✓ Branch 2 (4→5) taken 65886 times.
✓ Branch 3 (4→28) taken 2 times.
|
65890 | fetchChildrenIntoVector(relationalExprNode->operands, ctx->shiftExpr()); |
1076 | |||
1077 | // Extract operator | ||
1078 |
2/2✓ Branch 0 (7→8) taken 1848 times.
✓ Branch 1 (7→9) taken 64038 times.
|
65886 | if (ctx->LESS()) |
1079 | 1848 | relationalExprNode->op = RelationalExprNode::RelationalOp::OP_LESS; | |
1080 |
2/2✓ Branch 0 (10→11) taken 622 times.
✓ Branch 1 (10→12) taken 63416 times.
|
64038 | else if (ctx->GREATER()) |
1081 | 622 | relationalExprNode->op = RelationalExprNode::RelationalOp::OP_GREATER; | |
1082 |
2/2✓ Branch 0 (13→14) taken 312 times.
✓ Branch 1 (13→15) taken 63104 times.
|
63416 | else if (ctx->LESS_EQUAL()) |
1083 | 312 | relationalExprNode->op = RelationalExprNode::RelationalOp::OP_LESS_EQUAL; | |
1084 |
2/2✓ Branch 0 (16→17) taken 693 times.
✓ Branch 1 (16→18) taken 62411 times.
|
63104 | else if (ctx->GREATER_EQUAL()) |
1085 | 693 | relationalExprNode->op = RelationalExprNode::RelationalOp::OP_GREATER_EQUAL; | |
1086 | |||
1087 |
1/2✓ Branch 0 (24→25) taken 65886 times.
✗ Branch 1 (24→31) not taken.
|
65886 | return concludeNode(relationalExprNode); |
1088 | } | ||
1089 | |||
1090 | 69363 | std::any ASTBuilder::visitShiftExpr(SpiceParser::ShiftExprContext *ctx) { | |
1091 | 69363 | const auto shiftExprNode = createNode<ShiftExprNode>(ctx); | |
1092 | |||
1093 | // Visit children | ||
1094 |
3/4✓ Branch 0 (3→4) taken 69363 times.
✗ Branch 1 (3→48) not taken.
✓ Branch 2 (4→5) taken 69361 times.
✓ Branch 3 (4→46) taken 2 times.
|
69365 | fetchChildrenIntoVector(shiftExprNode->operands, ctx->additiveExpr()); |
1095 | |||
1096 | 69361 | bool seenFirstLess = false; | |
1097 | 69361 | bool seenFirstGreater = false; | |
1098 |
2/2✓ Branch 0 (31→8) taken 69601 times.
✓ Branch 1 (31→32) taken 69361 times.
|
138962 | for (ParserRuleContext::ParseTree *subTree : ctx->children) { |
1099 |
1/2✓ Branch 0 (9→10) taken 69601 times.
✗ Branch 1 (9→11) not taken.
|
69601 | const auto terminal = dynamic_cast<TerminalNode *>(subTree); |
1100 |
2/2✓ Branch 0 (12→13) taken 69441 times.
✓ Branch 1 (12→14) taken 160 times.
|
69601 | if (!terminal) |
1101 | 69441 | 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 69361 times.
✗ Branch 1 (32→35) not taken.
✓ Branch 2 (33→34) taken 69361 times.
✗ Branch 3 (33→35) not taken.
|
69361 | assert(!seenFirstLess && !seenFirstGreater); |
1120 | |||
1121 |
1/2✓ Branch 0 (42→43) taken 69361 times.
✗ Branch 1 (42→54) not taken.
|
69361 | return concludeNode(shiftExprNode); |
1122 | } | ||
1123 | |||
1124 | 69443 | std::any ASTBuilder::visitAdditiveExpr(SpiceParser::AdditiveExprContext *ctx) { | |
1125 | 69443 | const auto additiveExprNode = createNode<AdditiveExprNode>(ctx); | |
1126 | |||
1127 | // Visit children | ||
1128 |
3/4✓ Branch 0 (3→4) taken 69443 times.
✗ Branch 1 (3→40) not taken.
✓ Branch 2 (4→5) taken 69441 times.
✓ Branch 3 (4→38) taken 2 times.
|
69445 | fetchChildrenIntoVector(additiveExprNode->operands, ctx->multiplicativeExpr()); |
1129 | |||
1130 |
2/2✓ Branch 0 (27→8) taken 76719 times.
✓ Branch 1 (27→28) taken 69441 times.
|
146160 | for (ParserRuleContext::ParseTree *subTree : ctx->children) { |
1131 |
1/2✓ Branch 0 (9→10) taken 76719 times.
✗ Branch 1 (9→11) not taken.
|
76719 | const auto terminal = dynamic_cast<TerminalNode *>(subTree); |
1132 |
2/2✓ Branch 0 (12→13) taken 73080 times.
✓ Branch 1 (12→14) taken 3639 times.
|
76719 | if (!terminal) |
1133 | 73080 | continue; | |
1134 | |||
1135 |
4/6✓ Branch 0 (14→15) taken 3639 times.
✗ Branch 1 (14→45) not taken.
✓ Branch 2 (15→16) taken 3639 times.
✗ Branch 3 (15→45) not taken.
✓ Branch 4 (16→17) taken 2160 times.
✓ Branch 5 (16→19) taken 1479 times.
|
3639 | if (terminal->getSymbol()->getType() == SpiceParser::PLUS) |
1136 |
1/2✓ Branch 0 (17→18) taken 2160 times.
✗ Branch 1 (17→41) not taken.
|
2160 | additiveExprNode->opQueue.emplace(AdditiveExprNode::AdditiveOp::OP_PLUS, TY_INVALID); |
1137 |
3/6✓ Branch 0 (19→20) taken 1479 times.
✗ Branch 1 (19→45) not taken.
✓ Branch 2 (20→21) taken 1479 times.
✗ Branch 3 (20→45) not taken.
✓ Branch 4 (21→22) taken 1479 times.
✗ Branch 5 (21→24) not taken.
|
1479 | else if (terminal->getSymbol()->getType() == SpiceParser::MINUS) |
1138 |
1/2✓ Branch 0 (22→23) taken 1479 times.
✗ Branch 1 (22→43) not taken.
|
1479 | 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 69441 times.
✗ Branch 1 (34→46) not taken.
|
69441 | return concludeNode(additiveExprNode); |
1144 | } | ||
1145 | |||
1146 | 73082 | std::any ASTBuilder::visitMultiplicativeExpr(SpiceParser::MultiplicativeExprContext *ctx) { | |
1147 | 73082 | const auto multiplicativeExprNode = createNode<MultiplicativeExprNode>(ctx); | |
1148 | |||
1149 | // Visit children | ||
1150 |
3/4✓ Branch 0 (3→4) taken 73082 times.
✗ Branch 1 (3→45) not taken.
✓ Branch 2 (4→5) taken 73080 times.
✓ Branch 3 (4→43) taken 2 times.
|
73084 | fetchChildrenIntoVector(multiplicativeExprNode->operands, ctx->castExpr()); |
1151 | |||
1152 |
2/2✓ Branch 0 (32→8) taken 75496 times.
✓ Branch 1 (32→33) taken 73080 times.
|
148576 | for (ParserRuleContext::ParseTree *subTree : ctx->children) { |
1153 |
1/2✓ Branch 0 (9→10) taken 75496 times.
✗ Branch 1 (9→11) not taken.
|
75496 | const auto terminal = dynamic_cast<TerminalNode *>(subTree); |
1154 |
2/2✓ Branch 0 (12→13) taken 74288 times.
✓ Branch 1 (12→14) taken 1208 times.
|
75496 | if (!terminal) |
1155 | 74288 | continue; | |
1156 | |||
1157 |
4/6✓ Branch 0 (14→15) taken 1208 times.
✗ Branch 1 (14→52) not taken.
✓ Branch 2 (15→16) taken 1208 times.
✗ Branch 3 (15→52) not taken.
✓ Branch 4 (16→17) taken 900 times.
✓ Branch 5 (16→19) taken 308 times.
|
1208 | if (terminal->getSymbol()->getType() == SpiceParser::MUL) |
1158 |
1/2✓ Branch 0 (17→18) taken 900 times.
✗ Branch 1 (17→46) not taken.
|
900 | multiplicativeExprNode->opQueue.emplace(MultiplicativeExprNode::MultiplicativeOp::OP_MUL, TY_INVALID); |
1159 |
4/6✓ Branch 0 (19→20) taken 308 times.
✗ Branch 1 (19→52) not taken.
✓ Branch 2 (20→21) taken 308 times.
✗ Branch 3 (20→52) not taken.
✓ Branch 4 (21→22) taken 127 times.
✓ Branch 5 (21→24) taken 181 times.
|
308 | else if (terminal->getSymbol()->getType() == SpiceParser::DIV) |
1160 |
1/2✓ Branch 0 (22→23) taken 127 times.
✗ Branch 1 (22→48) not taken.
|
127 | multiplicativeExprNode->opQueue.emplace(MultiplicativeExprNode::MultiplicativeOp::OP_DIV, TY_INVALID); |
1161 |
3/6✓ Branch 0 (24→25) taken 181 times.
✗ Branch 1 (24→52) not taken.
✓ Branch 2 (25→26) taken 181 times.
✗ Branch 3 (25→52) not taken.
✓ Branch 4 (26→27) taken 181 times.
✗ Branch 5 (26→29) not taken.
|
181 | else if (terminal->getSymbol()->getType() == SpiceParser::REM) |
1162 |
1/2✓ Branch 0 (27→28) taken 181 times.
✗ Branch 1 (27→50) not taken.
|
181 | 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 73080 times.
✗ Branch 1 (39→53) not taken.
|
73080 | return concludeNode(multiplicativeExprNode); |
1168 | } | ||
1169 | |||
1170 | 74290 | std::any ASTBuilder::visitCastExpr(SpiceParser::CastExprContext *ctx) { | |
1171 | 74290 | const auto castExprNode = createNode<CastExprNode>(ctx); | |
1172 | |||
1173 |
2/2✓ Branch 0 (4→5) taken 1936 times.
✓ Branch 1 (4→14) taken 72354 times.
|
74290 | if (ctx->dataType()) { |
1174 |
3/6✓ Branch 0 (5→6) taken 1936 times.
✗ Branch 1 (5→31) not taken.
✓ Branch 2 (6→7) taken 1936 times.
✗ Branch 3 (6→31) not taken.
✓ Branch 4 (7→8) taken 1936 times.
✗ Branch 5 (7→29) not taken.
|
1936 | castExprNode->dataType = std::any_cast<DataTypeNode *>(visit(ctx->dataType())); |
1175 |
3/6✓ Branch 0 (9→10) taken 1936 times.
✗ Branch 1 (9→34) not taken.
✓ Branch 2 (10→11) taken 1936 times.
✗ Branch 3 (10→34) not taken.
✓ Branch 4 (11→12) taken 1936 times.
✗ Branch 5 (11→32) not taken.
|
1936 | castExprNode->assignExpr = std::any_cast<AssignExprNode *>(visit(ctx->assignExpr())); |
1176 | 1936 | castExprNode->isCast = true; | |
1177 | } else { | ||
1178 |
4/6✓ Branch 0 (14→15) taken 72354 times.
✗ Branch 1 (14→37) not taken.
✓ Branch 2 (15→16) taken 72352 times.
✓ Branch 3 (15→37) taken 2 times.
✓ Branch 4 (16→17) taken 72352 times.
✗ Branch 5 (16→35) not taken.
|
72354 | castExprNode->prefixUnaryExpr = std::any_cast<PrefixUnaryExprNode *>(visit(ctx->prefixUnaryExpr())); |
1179 | } | ||
1180 | |||
1181 |
1/2✓ Branch 0 (25→26) taken 74288 times.
✗ Branch 1 (25→38) not taken.
|
74288 | return concludeNode(castExprNode); |
1182 | } | ||
1183 | |||
1184 | 79924 | std::any ASTBuilder::visitPrefixUnaryExpr(SpiceParser::PrefixUnaryExprContext *ctx) { | |
1185 | 79924 | const auto prefixUnaryExprNode = createNode<PrefixUnaryExprNode>(ctx); | |
1186 | |||
1187 | // Visit children | ||
1188 |
2/2✓ Branch 0 (4→5) taken 78810 times.
✓ Branch 1 (4→10) taken 1114 times.
|
79924 | if (ctx->postfixUnaryExpr()) { |
1189 |
4/6✓ Branch 0 (5→6) taken 78810 times.
✗ Branch 1 (5→51) not taken.
✓ Branch 2 (6→7) taken 78808 times.
✓ Branch 3 (6→51) taken 2 times.
✓ Branch 4 (7→8) taken 78808 times.
✗ Branch 5 (7→49) not taken.
|
78810 | prefixUnaryExprNode->postfixUnaryExpr = std::any_cast<PostfixUnaryExprNode *>(visit(ctx->postfixUnaryExpr())); |
1190 |
1/2✓ Branch 0 (11→12) taken 1114 times.
✗ Branch 1 (11→38) not taken.
|
1114 | } else if (ctx->prefixUnaryExpr()) { |
1191 | // Extract operator | ||
1192 |
2/2✓ Branch 0 (13→14) taken 12 times.
✓ Branch 1 (13→15) taken 1102 times.
|
1114 | 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 1085 times.
|
1102 | 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 1076 times.
|
1085 | else if (ctx->MINUS_MINUS()) |
1197 | 9 | prefixUnaryExprNode->op = PrefixUnaryExprNode::PrefixUnaryOp::OP_MINUS_MINUS; | |
1198 |
2/2✓ Branch 0 (22→23) taken 744 times.
✓ Branch 1 (22→24) taken 332 times.
|
1076 | else if (ctx->NOT()) |
1199 | 744 | prefixUnaryExprNode->op = PrefixUnaryExprNode::PrefixUnaryOp::OP_NOT; | |
1200 |
2/2✓ Branch 0 (25→26) taken 1 times.
✓ Branch 1 (25→27) taken 331 times.
|
332 | else if (ctx->BITWISE_NOT()) |
1201 | 1 | prefixUnaryExprNode->op = PrefixUnaryExprNode::PrefixUnaryOp::OP_BITWISE_NOT; | |
1202 |
2/2✓ Branch 0 (28→29) taken 194 times.
✓ Branch 1 (28→30) taken 137 times.
|
331 | else if (ctx->MUL()) |
1203 | 194 | 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 1114 times.
✗ Branch 1 (33→54) not taken.
✓ Branch 2 (34→35) taken 1114 times.
✗ Branch 3 (34→54) not taken.
✓ Branch 4 (35→36) taken 1114 times.
✗ Branch 5 (35→52) not taken.
|
1114 | 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 79922 times.
✗ Branch 1 (45→55) not taken.
|
79922 | return concludeNode(prefixUnaryExprNode); |
1213 | } | ||
1214 | |||
1215 | 100511 | std::any ASTBuilder::visitPostfixUnaryExpr(SpiceParser::PostfixUnaryExprContext *ctx) { | |
1216 | 100511 | const auto postfixUnaryExprNode = createNode<PostfixUnaryExprNode>(ctx); | |
1217 | |||
1218 |
2/2✓ Branch 0 (4→5) taken 78810 times.
✓ Branch 1 (4→10) taken 21701 times.
|
100511 | if (ctx->atomicExpr()) { |
1219 |
4/6✓ Branch 0 (5→6) taken 78810 times.
✗ Branch 1 (5→49) not taken.
✓ Branch 2 (6→7) taken 78808 times.
✓ Branch 3 (6→49) taken 2 times.
✓ Branch 4 (7→8) taken 78808 times.
✗ Branch 5 (7→47) not taken.
|
78810 | postfixUnaryExprNode->atomicExpr = std::any_cast<AtomicExprNode *>(visit(ctx->atomicExpr())); |
1220 |
1/2✓ Branch 0 (11→12) taken 21701 times.
✗ Branch 1 (11→36) not taken.
|
21701 | } else if (ctx->postfixUnaryExpr()) { |
1221 |
3/6✓ Branch 0 (12→13) taken 21701 times.
✗ Branch 1 (12→52) not taken.
✓ Branch 2 (13→14) taken 21701 times.
✗ Branch 3 (13→52) not taken.
✓ Branch 4 (14→15) taken 21701 times.
✗ Branch 5 (14→50) not taken.
|
21701 | postfixUnaryExprNode->postfixUnaryExpr = std::any_cast<PostfixUnaryExprNode *>(visit(ctx->postfixUnaryExpr())); |
1222 | |||
1223 | // Extract operator | ||
1224 |
2/2✓ Branch 0 (17→18) taken 3755 times.
✓ Branch 1 (17→23) taken 17946 times.
|
21701 | if (ctx->assignExpr()) { |
1225 | 3755 | postfixUnaryExprNode->op = PostfixUnaryExprNode::PostfixUnaryOp::OP_SUBSCRIPT; | |
1226 |
3/6✓ Branch 0 (18→19) taken 3755 times.
✗ Branch 1 (18→55) not taken.
✓ Branch 2 (19→20) taken 3755 times.
✗ Branch 3 (19→55) not taken.
✓ Branch 4 (20→21) taken 3755 times.
✗ Branch 5 (20→53) not taken.
|
3755 | postfixUnaryExprNode->subscriptIndexExpr = std::any_cast<AssignExprNode *>(visit(ctx->assignExpr())); |
1227 |
2/2✓ Branch 0 (24→25) taken 15813 times.
✓ Branch 1 (24→30) taken 2133 times.
|
17946 | } else if (ctx->IDENTIFIER()) { |
1228 | 15813 | postfixUnaryExprNode->op = PostfixUnaryExprNode::PostfixUnaryOp::OP_MEMBER_ACCESS; | |
1229 |
2/4✓ Branch 0 (25→26) taken 15813 times.
✗ Branch 1 (25→56) not taken.
✓ Branch 2 (26→27) taken 15813 times.
✗ Branch 3 (26→56) not taken.
|
15813 | postfixUnaryExprNode->identifier = getIdentifier(ctx->IDENTIFIER(), false); |
1230 |
2/2✓ Branch 0 (31→32) taken 1691 times.
✓ Branch 1 (31→33) taken 442 times.
|
2133 | } else if (ctx->PLUS_PLUS()) { |
1231 | 1691 | postfixUnaryExprNode->op = PostfixUnaryExprNode::PostfixUnaryOp::OP_PLUS_PLUS; | |
1232 |
1/2✓ Branch 0 (34→35) taken 442 times.
✗ Branch 1 (34→37) not taken.
|
442 | } else if (ctx->MINUS_MINUS()) { |
1233 | 442 | 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 100509 times.
✗ Branch 1 (43→57) not taken.
|
100509 | return concludeNode(postfixUnaryExprNode); |
1240 | } | ||
1241 | |||
1242 | 78810 | std::any ASTBuilder::visitAtomicExpr(SpiceParser::AtomicExprContext *ctx) { | |
1243 | 78810 | const auto atomicExprNode = createNode<AtomicExprNode>(ctx); | |
1244 | |||
1245 | // Visit children | ||
1246 |
2/2✓ Branch 0 (4→5) taken 13869 times.
✓ Branch 1 (4→10) taken 64941 times.
|
78810 | if (ctx->constant()) { |
1247 |
4/6✓ Branch 0 (5→6) taken 13869 times.
✗ Branch 1 (5→91) not taken.
✓ Branch 2 (6→7) taken 13867 times.
✓ Branch 3 (6→91) taken 2 times.
✓ Branch 4 (7→8) taken 13867 times.
✗ Branch 5 (7→89) not taken.
|
13869 | atomicExprNode->constant = std::any_cast<ConstantNode *>(visit(ctx->constant())); |
1248 |
2/2✓ Branch 0 (11→12) taken 15347 times.
✓ Branch 1 (11→17) taken 49594 times.
|
64941 | } else if (ctx->value()) { |
1249 |
3/6✓ Branch 0 (12→13) taken 15347 times.
✗ Branch 1 (12→94) not taken.
✓ Branch 2 (13→14) taken 15347 times.
✗ Branch 3 (13→94) not taken.
✓ Branch 4 (14→15) taken 15347 times.
✗ Branch 5 (14→92) not taken.
|
15347 | atomicExprNode->value = std::any_cast<ValueNode *>(visit(ctx->value())); |
1250 |
11/18✓ Branch 0 (17→18) taken 49594 times.
✗ Branch 1 (17→95) not taken.
✓ Branch 2 (19→20) taken 4171 times.
✓ Branch 3 (19→23) taken 45423 times.
✓ Branch 4 (20→21) taken 4171 times.
✗ Branch 5 (20→95) not taken.
✓ Branch 6 (22→23) taken 1624 times.
✓ Branch 7 (22→24) taken 2547 times.
✓ Branch 8 (25→26) taken 4171 times.
✓ Branch 9 (25→27) taken 45423 times.
✓ Branch 10 (27→28) taken 49594 times.
✗ Branch 11 (27→29) not taken.
✓ Branch 12 (29→30) taken 47047 times.
✓ Branch 13 (29→64) taken 2547 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.
|
49594 | } else if (!ctx->IDENTIFIER().empty() || !ctx->TYPE_IDENTIFIER().empty()) { |
1251 |
2/2✓ Branch 0 (62→32) taken 47553 times.
✓ Branch 1 (62→63) taken 47047 times.
|
94600 | for (ParserRuleContext::ParseTree *subTree : ctx->children) { |
1252 |
1/2✓ Branch 0 (33→34) taken 47553 times.
✗ Branch 1 (33→35) not taken.
|
47553 | const auto terminal = dynamic_cast<TerminalNode *>(subTree); |
1253 |
1/2✗ Branch 0 (36→37) not taken.
✓ Branch 1 (36→38) taken 47553 times.
|
47553 | if (!terminal) |
1254 | ✗ | continue; | |
1255 | |||
1256 |
4/6✓ Branch 0 (38→39) taken 47553 times.
✗ Branch 1 (38→109) not taken.
✓ Branch 2 (39→40) taken 47553 times.
✗ Branch 3 (39→109) not taken.
✓ Branch 4 (40→41) taken 45423 times.
✓ Branch 5 (40→49) taken 2130 times.
|
47553 | if (terminal->getSymbol()->getType() == SpiceParser::IDENTIFIER) { |
1257 |
1/2✓ Branch 0 (41→42) taken 45423 times.
✗ Branch 1 (41→105) not taken.
|
45423 | std::string fragment = getIdentifier(terminal, false); |
1258 |
1/2✓ Branch 0 (42→43) taken 45423 times.
✗ Branch 1 (42→103) not taken.
|
45423 | atomicExprNode->identifierFragments.push_back(fragment); |
1259 |
1/2✗ Branch 0 (44→45) not taken.
✓ Branch 1 (44→46) taken 45423 times.
|
45423 | if (!atomicExprNode->fqIdentifier.empty()) |
1260 | ✗ | atomicExprNode->fqIdentifier += SCOPE_ACCESS_TOKEN; | |
1261 |
1/2✓ Branch 0 (46→47) taken 45423 times.
✗ Branch 1 (46→103) not taken.
|
45423 | atomicExprNode->fqIdentifier += fragment; |
1262 |
4/6✓ Branch 0 (49→50) taken 2130 times.
✗ Branch 1 (49→109) not taken.
✓ Branch 2 (50→51) taken 2130 times.
✗ Branch 3 (50→109) not taken.
✓ Branch 4 (51→52) taken 1877 times.
✓ Branch 5 (51→60) taken 253 times.
|
47553 | } else if (terminal->getSymbol()->getType() == SpiceParser::TYPE_IDENTIFIER) { |
1263 |
1/2✓ Branch 0 (52→53) taken 1877 times.
✗ Branch 1 (52→108) not taken.
|
1877 | std::string fragment = getIdentifier(terminal, false); |
1264 |
1/2✓ Branch 0 (53→54) taken 1877 times.
✗ Branch 1 (53→106) not taken.
|
1877 | atomicExprNode->identifierFragments.push_back(fragment); |
1265 |
2/2✓ Branch 0 (55→56) taken 253 times.
✓ Branch 1 (55→57) taken 1624 times.
|
1877 | 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 1877 times.
✗ Branch 1 (57→106) not taken.
|
1877 | atomicExprNode->fqIdentifier += fragment; |
1268 | 1877 | } | |
1269 | } | ||
1270 |
2/2✓ Branch 0 (65→66) taken 1950 times.
✓ Branch 1 (65→71) taken 597 times.
|
2547 | } else if (ctx->builtinCall()) { |
1271 |
3/6✓ Branch 0 (66→67) taken 1950 times.
✗ Branch 1 (66→112) not taken.
✓ Branch 2 (67→68) taken 1950 times.
✗ Branch 3 (67→112) not taken.
✓ Branch 4 (68→69) taken 1950 times.
✗ Branch 5 (68→110) not taken.
|
1950 | atomicExprNode->builtinCall = std::any_cast<BuiltinCallNode *>(visit(ctx->builtinCall())); |
1272 |
1/2✓ Branch 0 (72→73) taken 597 times.
✗ Branch 1 (72→78) not taken.
|
597 | } else if (ctx->assignExpr()) { |
1273 |
3/6✓ Branch 0 (73→74) taken 597 times.
✗ Branch 1 (73→115) not taken.
✓ Branch 2 (74→75) taken 597 times.
✗ Branch 3 (74→115) not taken.
✓ Branch 4 (75→76) taken 597 times.
✗ Branch 5 (75→113) not taken.
|
597 | 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 78808 times.
✗ Branch 1 (85→116) not taken.
|
78808 | return concludeNode(atomicExprNode); |
1279 | } | ||
1280 | |||
1281 | 15347 | std::any ASTBuilder::visitValue(SpiceParser::ValueContext *ctx) { | |
1282 | 15347 | const auto valueNode = createNode<ValueNode>(ctx); | |
1283 | |||
1284 | // Visit children | ||
1285 |
2/2✓ Branch 0 (4→5) taken 14075 times.
✓ Branch 1 (4→10) taken 1272 times.
|
15347 | if (ctx->fctCall()) { |
1286 |
3/6✓ Branch 0 (5→6) taken 14075 times.
✗ Branch 1 (5→65) not taken.
✓ Branch 2 (6→7) taken 14075 times.
✗ Branch 3 (6→65) not taken.
✓ Branch 4 (7→8) taken 14075 times.
✗ Branch 5 (7→63) not taken.
|
14075 | valueNode->fctCall = std::any_cast<FctCallNode *>(visit(ctx->fctCall())); |
1287 |
2/2✓ Branch 0 (11→12) taken 70 times.
✓ Branch 1 (11→17) taken 1202 times.
|
1272 | } 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 213 times.
✓ Branch 1 (18→24) taken 989 times.
|
1202 | } else if (ctx->structInstantiation()) { |
1290 |
3/6✓ Branch 0 (19→20) taken 213 times.
✗ Branch 1 (19→71) not taken.
✓ Branch 2 (20→21) taken 213 times.
✗ Branch 3 (20→71) not taken.
✓ Branch 4 (21→22) taken 213 times.
✗ Branch 5 (21→69) not taken.
|
213 | valueNode->structInstantiation = std::any_cast<StructInstantiationNode *>(visit(ctx->structInstantiation())); |
1291 |
2/2✓ Branch 0 (25→26) taken 12 times.
✓ Branch 1 (25→31) taken 977 times.
|
989 | } 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 950 times.
|
977 | } 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 949 times.
|
950 | } 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 949 times.
✗ Branch 1 (46→52) not taken.
|
949 | } else if (ctx->dataType()) { |
1298 | 949 | valueNode->isNil = true; | |
1299 |
3/6✓ Branch 0 (47→48) taken 949 times.
✗ Branch 1 (47→83) not taken.
✓ Branch 2 (48→49) taken 949 times.
✗ Branch 3 (48→83) not taken.
✓ Branch 4 (49→50) taken 949 times.
✗ Branch 5 (49→81) not taken.
|
949 | 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 15347 times.
✗ Branch 1 (59→84) not taken.
|
15347 | return concludeNode(valueNode); |
1305 | } | ||
1306 | |||
1307 | 15948 | std::any ASTBuilder::visitConstant(SpiceParser::ConstantContext *ctx) { | |
1308 | 15948 | const auto constantNode = createNode<ConstantNode>(ctx); | |
1309 | |||
1310 | // Enrich | ||
1311 |
2/2✓ Branch 0 (4→5) taken 301 times.
✓ Branch 1 (4→10) taken 15647 times.
|
15948 | 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 3546 times.
✓ Branch 1 (11→15) taken 12101 times.
|
15647 | } else if (ctx->INT_LIT()) { |
1315 | 3546 | constantNode->type = ConstantNode::PrimitiveValueType::TYPE_INT; | |
1316 | 3546 | constantNode->compileTimeValue.intValue = parseInt(ctx->INT_LIT()); | |
1317 |
2/2✓ Branch 0 (16→17) taken 539 times.
✓ Branch 1 (16→20) taken 11562 times.
|
12101 | } else if (ctx->SHORT_LIT()) { |
1318 | 539 | constantNode->type = ConstantNode::PrimitiveValueType::TYPE_SHORT; | |
1319 | 539 | constantNode->compileTimeValue.shortValue = parseShort(ctx->SHORT_LIT()); | |
1320 |
2/2✓ Branch 0 (21→22) taken 4943 times.
✓ Branch 1 (21→25) taken 6619 times.
|
11562 | } else if (ctx->LONG_LIT()) { |
1321 | 4943 | constantNode->type = ConstantNode::PrimitiveValueType::TYPE_LONG; | |
1322 | 4943 | constantNode->compileTimeValue.longValue = parseLong(ctx->LONG_LIT()); | |
1323 |
2/2✓ Branch 0 (26→27) taken 2572 times.
✓ Branch 1 (26→30) taken 4047 times.
|
6619 | } else if (ctx->CHAR_LIT()) { |
1324 | 2572 | constantNode->type = ConstantNode::PrimitiveValueType::TYPE_CHAR; | |
1325 | 2572 | constantNode->compileTimeValue.charValue = parseChar(ctx->CHAR_LIT()); | |
1326 |
2/2✓ Branch 0 (31→32) taken 2503 times.
✓ Branch 1 (31→40) taken 1544 times.
|
4047 | } else if (ctx->STRING_LIT()) { |
1327 | // Save a pointer to the string in the compile time value | ||
1328 | 2503 | constantNode->type = ConstantNode::PrimitiveValueType::TYPE_STRING; | |
1329 | 2503 | 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 2503 times.
✗ Branch 1 (33→64) not taken.
✓ Branch 2 (34→35) taken 2503 times.
✗ Branch 3 (34→64) not taken.
✓ Branch 4 (35→36) taken 2503 times.
✗ Branch 5 (35→62) not taken.
✓ Branch 6 (36→37) taken 2503 times.
✗ Branch 7 (36→60) not taken.
|
2503 | resourceManager.compileTimeStringValues.push_back(parseString(ctx->STRING_LIT()->toString())); |
1332 |
2/2✓ Branch 0 (41→42) taken 786 times.
✓ Branch 1 (41→43) taken 758 times.
|
1544 | } else if (ctx->TRUE()) { |
1333 | 786 | constantNode->type = ConstantNode::PrimitiveValueType::TYPE_BOOL; | |
1334 | 786 | constantNode->compileTimeValue.boolValue = true; | |
1335 |
1/2✓ Branch 0 (44→45) taken 758 times.
✗ Branch 1 (44→46) not taken.
|
758 | } else if (ctx->FALSE()) { |
1336 | 758 | constantNode->type = ConstantNode::PrimitiveValueType::TYPE_BOOL; | |
1337 | 758 | 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 15946 times.
✗ Branch 1 (53→66) not taken.
|
15946 | return concludeNode(constantNode); |
1343 | } | ||
1344 | |||
1345 | 14075 | std::any ASTBuilder::visitFctCall(SpiceParser::FctCallContext *ctx) { | |
1346 | 14075 | const auto fctCallNode = createNode<FctCallNode>(ctx); | |
1347 | |||
1348 |
2/2✓ Branch 0 (37→5) taken 68440 times.
✓ Branch 1 (37→38) taken 14075 times.
|
82515 | for (antlr4::ParserRuleContext::ParseTree *subTree : ctx->children) { |
1349 |
1/2✓ Branch 0 (6→7) taken 68440 times.
✗ Branch 1 (6→8) not taken.
|
68440 | const auto terminal = dynamic_cast<antlr4::tree::TerminalNode *>(subTree); |
1350 |
2/2✓ Branch 0 (9→10) taken 11317 times.
✓ Branch 1 (9→11) taken 57123 times.
|
68440 | if (!terminal) |
1351 | 11317 | continue; | |
1352 | |||
1353 |
4/6✓ Branch 0 (11→12) taken 57123 times.
✗ Branch 1 (11→68) not taken.
✓ Branch 2 (12→13) taken 57123 times.
✗ Branch 3 (12→68) not taken.
✓ Branch 4 (13→14) taken 18483 times.
✓ Branch 5 (13→19) taken 38640 times.
|
57123 | if (terminal->getSymbol()->getType() == SpiceParser::IDENTIFIER) { |
1354 |
1/2✓ Branch 0 (14→15) taken 18483 times.
✗ Branch 1 (14→64) not taken.
|
18483 | const std::string fragment = terminal->toString(); |
1355 |
1/2✓ Branch 0 (15→16) taken 18483 times.
✗ Branch 1 (15→62) not taken.
|
18483 | fctCallNode->functionNameFragments.push_back(fragment); |
1356 |
1/2✓ Branch 0 (16→17) taken 18483 times.
✗ Branch 1 (16→62) not taken.
|
18483 | fctCallNode->fqFunctionName += fragment; |
1357 |
4/6✓ Branch 0 (19→20) taken 38640 times.
✗ Branch 1 (19→68) not taken.
✓ Branch 2 (20→21) taken 38640 times.
✗ Branch 3 (20→68) not taken.
✓ Branch 4 (21→22) taken 2555 times.
✓ Branch 5 (21→27) taken 36085 times.
|
57123 | } else if (terminal->getSymbol()->getType() == SpiceParser::TYPE_IDENTIFIER) { |
1358 |
1/2✓ Branch 0 (22→23) taken 2555 times.
✗ Branch 1 (22→67) not taken.
|
2555 | const std::string fragment = terminal->toString(); |
1359 |
1/2✓ Branch 0 (23→24) taken 2555 times.
✗ Branch 1 (23→65) not taken.
|
2555 | fctCallNode->functionNameFragments.push_back(fragment); |
1360 |
1/2✓ Branch 0 (24→25) taken 2555 times.
✗ Branch 1 (24→65) not taken.
|
2555 | fctCallNode->fqFunctionName += fragment; |
1361 |
4/6✓ Branch 0 (27→28) taken 36085 times.
✗ Branch 1 (27→68) not taken.
✓ Branch 2 (28→29) taken 36085 times.
✗ Branch 3 (28→68) not taken.
✓ Branch 4 (29→30) taken 66 times.
✓ Branch 5 (29→31) taken 36019 times.
|
38640 | } 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 36019 times.
✗ Branch 1 (31→68) not taken.
✓ Branch 2 (32→33) taken 36019 times.
✗ Branch 3 (32→68) not taken.
✓ Branch 4 (33→34) taken 6897 times.
✓ Branch 5 (33→35) taken 29122 times.
|
36019 | } else if (terminal->getSymbol()->getType() == SpiceParser::DOT) { |
1364 |
1/2✓ Branch 0 (34→35) taken 6897 times.
✗ Branch 1 (34→68) not taken.
|
6897 | fctCallNode->fqFunctionName += MEMBER_ACCESS_TOKEN; |
1365 | } | ||
1366 | } | ||
1367 | |||
1368 | // Visit children | ||
1369 |
2/2✓ Branch 0 (39→40) taken 486 times.
✓ Branch 1 (39→45) taken 13589 times.
|
14075 | if (ctx->typeLst()) { |
1370 | 486 | fctCallNode->hasTemplateTypes = true; | |
1371 |
3/6✓ Branch 0 (40→41) taken 486 times.
✗ Branch 1 (40→71) not taken.
✓ Branch 2 (41→42) taken 486 times.
✗ Branch 3 (41→71) not taken.
✓ Branch 4 (42→43) taken 486 times.
✗ Branch 5 (42→69) not taken.
|
486 | fctCallNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst())); |
1372 | } | ||
1373 |
2/2✓ Branch 0 (46→47) taken 10831 times.
✓ Branch 1 (46→52) taken 3244 times.
|
14075 | if (ctx->argLst()) { |
1374 | 10831 | fctCallNode->hasArgs = true; | |
1375 |
3/6✓ Branch 0 (47→48) taken 10831 times.
✗ Branch 1 (47→74) not taken.
✓ Branch 2 (48→49) taken 10831 times.
✗ Branch 3 (48→74) not taken.
✓ Branch 4 (49→50) taken 10831 times.
✗ Branch 5 (49→72) not taken.
|
10831 | fctCallNode->argLst = std::any_cast<ArgLstNode *>(visit(ctx->argLst())); |
1376 | } | ||
1377 | |||
1378 |
1/2✓ Branch 0 (58→59) taken 14075 times.
✗ Branch 1 (58→75) not taken.
|
14075 | 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 | 213 | std::any ASTBuilder::visitStructInstantiation(SpiceParser::StructInstantiationContext *ctx) { | |
1392 | 213 | const auto structInstantiationNode = createNode<StructInstantiationNode>(ctx); | |
1393 | |||
1394 | // Enrich | ||
1395 |
2/2✓ Branch 0 (31→5) taken 890 times.
✓ Branch 1 (31→32) taken 213 times.
|
1103 | for (antlr4::ParserRuleContext::ParseTree *subTree : ctx->children) { |
1396 |
1/2✓ Branch 0 (6→7) taken 890 times.
✗ Branch 1 (6→8) not taken.
|
890 | const auto terminal = dynamic_cast<antlr4::tree::TerminalNode *>(subTree); |
1397 |
2/2✓ Branch 0 (9→10) taken 213 times.
✓ Branch 1 (9→11) taken 677 times.
|
890 | if (!terminal) |
1398 | 213 | continue; | |
1399 | |||
1400 |
4/6✓ Branch 0 (11→12) taken 677 times.
✗ Branch 1 (11→65) not taken.
✓ Branch 2 (12→13) taken 677 times.
✗ Branch 3 (12→65) not taken.
✓ Branch 4 (13→14) taken 3 times.
✓ Branch 5 (13→21) taken 674 times.
|
677 | 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 674 times.
✗ Branch 1 (21→65) not taken.
✓ Branch 2 (22→23) taken 674 times.
✗ Branch 3 (22→65) not taken.
✓ Branch 4 (23→24) taken 213 times.
✓ Branch 5 (23→29) taken 461 times.
|
677 | } else if (terminal->getSymbol()->getType() == SpiceParser::TYPE_IDENTIFIER) { |
1405 |
1/2✓ Branch 0 (24→25) taken 213 times.
✗ Branch 1 (24→64) not taken.
|
213 | const std::string fragment = terminal->toString(); |
1406 |
1/2✓ Branch 0 (25→26) taken 213 times.
✗ Branch 1 (25→62) not taken.
|
213 | structInstantiationNode->structNameFragments.push_back(fragment); |
1407 |
1/2✓ Branch 0 (26→27) taken 213 times.
✗ Branch 1 (26→62) not taken.
|
213 | structInstantiationNode->fqStructName += fragment; |
1408 | 213 | } | |
1409 | } | ||
1410 | |||
1411 | // Visit children | ||
1412 |
2/2✓ Branch 0 (33→34) taken 16 times.
✓ Branch 1 (33→39) taken 197 times.
|
213 | 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 197 times.
✓ Branch 1 (40→46) taken 16 times.
|
213 | if (ctx->argLst()) |
1417 |
3/6✓ Branch 0 (41→42) taken 197 times.
✗ Branch 1 (41→71) not taken.
✓ Branch 2 (42→43) taken 197 times.
✗ Branch 3 (42→71) not taken.
✓ Branch 4 (43→44) taken 197 times.
✗ Branch 5 (43→69) not taken.
|
197 | structInstantiationNode->fieldLst = std::any_cast<ArgLstNode *>(visit(ctx->argLst())); |
1418 | |||
1419 |
1/2✓ Branch 0 (52→53) taken 213 times.
✗ Branch 1 (52→72) not taken.
|
213 | 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 | 39385 | std::any ASTBuilder::visitDataType(SpiceParser::DataTypeContext *ctx) { | |
1467 | 39385 | const auto dataTypeNode = createNode<DataTypeNode>(ctx); | |
1468 | |||
1469 | // Visit children | ||
1470 |
2/2✓ Branch 0 (4→5) taken 16370 times.
✓ Branch 1 (4→10) taken 23015 times.
|
39385 | if (ctx->qualifierLst()) |
1471 |
4/6✓ Branch 0 (5→6) taken 16370 times.
✗ Branch 1 (5→74) not taken.
✓ Branch 2 (6→7) taken 16369 times.
✓ Branch 3 (6→74) taken 1 times.
✓ Branch 4 (7→8) taken 16369 times.
✗ Branch 5 (7→72) not taken.
|
16370 | dataTypeNode->qualifierLst = std::any_cast<QualifierLstNode *>(visit(ctx->qualifierLst())); |
1472 |
3/6✓ Branch 0 (10→11) taken 39384 times.
✗ Branch 1 (10→77) not taken.
✓ Branch 2 (11→12) taken 39384 times.
✗ Branch 3 (11→77) not taken.
✓ Branch 4 (12→13) taken 39384 times.
✗ Branch 5 (12→75) not taken.
|
39384 | dataTypeNode->baseDataType = std::any_cast<BaseDataTypeNode *>(visit(ctx->baseDataType())); |
1473 | |||
1474 | // Enrich | ||
1475 |
2/2✓ Branch 0 (61→15) taken 64974 times.
✓ Branch 1 (61→62) taken 39384 times.
|
104358 | for (size_t i = 0; i < ctx->children.size(); i++) { |
1476 | 64974 | antlr4::tree::ParseTree *subTree = ctx->children.at(i); | |
1477 |
1/2✓ Branch 0 (16→17) taken 64974 times.
✗ Branch 1 (16→18) not taken.
|
64974 | auto terminal = dynamic_cast<TerminalNode *>(subTree); |
1478 |
2/2✓ Branch 0 (19→20) taken 55753 times.
✓ Branch 1 (19→21) taken 9221 times.
|
64974 | if (!terminal) |
1479 | 55753 | continue; | |
1480 | |||
1481 |
2/2✓ Branch 0 (23→24) taken 4535 times.
✓ Branch 1 (23→26) taken 4686 times.
|
9221 | if (terminal->getSymbol()->getType() == SpiceParser::MUL) { |
1482 |
1/2✓ Branch 0 (24→25) taken 4535 times.
✗ Branch 1 (24→78) not taken.
|
4535 | dataTypeNode->tmQueue.emplace(DataTypeNode::TypeModifierType::TYPE_PTR, false, 0); |
1483 |
2/2✓ Branch 0 (28→29) taken 4585 times.
✓ Branch 1 (28→31) taken 101 times.
|
4686 | } else if (terminal->getSymbol()->getType() == SpiceParser::BITWISE_AND) { |
1484 |
1/2✓ Branch 0 (29→30) taken 4585 times.
✗ Branch 1 (29→81) not taken.
|
4585 | 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, true); |
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 39384 times.
✗ Branch 1 (68→94) not taken.
|
39384 | return concludeNode(dataTypeNode); |
1506 |
1/2✓ Branch 0 (54→55) taken 101 times.
✗ Branch 1 (54→90) not taken.
|
101 | } |
1507 | |||
1508 | 39384 | std::any ASTBuilder::visitBaseDataType(SpiceParser::BaseDataTypeContext *ctx) { | |
1509 | 39384 | const auto baseDataTypeNode = createNode<BaseDataTypeNode>(ctx); | |
1510 | |||
1511 | // Enrich | ||
1512 |
2/2✓ Branch 0 (4→5) taken 262 times.
✓ Branch 1 (4→6) taken 39122 times.
|
39384 | if (ctx->TYPE_DOUBLE()) { |
1513 | 262 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_DOUBLE; | |
1514 |
2/2✓ Branch 0 (7→8) taken 2374 times.
✓ Branch 1 (7→9) taken 36748 times.
|
39122 | } else if (ctx->TYPE_INT()) { |
1515 | 2374 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_INT; | |
1516 |
2/2✓ Branch 0 (10→11) taken 702 times.
✓ Branch 1 (10→12) taken 36046 times.
|
36748 | } else if (ctx->TYPE_SHORT()) { |
1517 | 702 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_SHORT; | |
1518 |
2/2✓ Branch 0 (13→14) taken 7884 times.
✓ Branch 1 (13→15) taken 28162 times.
|
36046 | } else if (ctx->TYPE_LONG()) { |
1519 | 7884 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_LONG; | |
1520 |
2/2✓ Branch 0 (16→17) taken 1895 times.
✓ Branch 1 (16→18) taken 26267 times.
|
28162 | } else if (ctx->TYPE_BYTE()) { |
1521 | 1895 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_BYTE; | |
1522 |
2/2✓ Branch 0 (19→20) taken 4310 times.
✓ Branch 1 (19→21) taken 21957 times.
|
26267 | } else if (ctx->TYPE_CHAR()) { |
1523 | 4310 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_CHAR; | |
1524 |
2/2✓ Branch 0 (22→23) taken 3595 times.
✓ Branch 1 (22→24) taken 18362 times.
|
21957 | } else if (ctx->TYPE_STRING()) { |
1525 | 3595 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_STRING; | |
1526 |
2/2✓ Branch 0 (25→26) taken 3304 times.
✓ Branch 1 (25→27) taken 15058 times.
|
18362 | } else if (ctx->TYPE_BOOL()) { |
1527 | 3304 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_BOOL; | |
1528 |
2/2✓ Branch 0 (28→29) taken 382 times.
✓ Branch 1 (28→30) taken 14676 times.
|
15058 | } else if (ctx->TYPE_DYN()) { |
1529 | 382 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_DYN; | |
1530 |
2/2✓ Branch 0 (31→32) taken 14594 times.
✓ Branch 1 (31→37) taken 82 times.
|
14676 | } else if (ctx->customDataType()) { |
1531 | 14594 | baseDataTypeNode->type = BaseDataTypeNode::Type::TYPE_CUSTOM; | |
1532 |
3/6✓ Branch 0 (32→33) taken 14594 times.
✗ Branch 1 (32→57) not taken.
✓ Branch 2 (33→34) taken 14594 times.
✗ Branch 3 (33→57) not taken.
✓ Branch 4 (34→35) taken 14594 times.
✗ Branch 5 (34→55) not taken.
|
14594 | 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 39384 times.
✗ Branch 1 (51→61) not taken.
|
39384 | return concludeNode(baseDataTypeNode); |
1541 | } | ||
1542 | |||
1543 | 14594 | std::any ASTBuilder::visitCustomDataType(SpiceParser::CustomDataTypeContext *ctx) { | |
1544 | 14594 | const auto customDataTypeNode = createNode<CustomDataTypeNode>(ctx); | |
1545 | |||
1546 | // Enrich | ||
1547 |
2/2✓ Branch 0 (31→5) taken 20361 times.
✓ Branch 1 (31→32) taken 14594 times.
|
34955 | for (ParserRuleContext::ParseTree *subTree : ctx->children) { |
1548 |
1/2✓ Branch 0 (6→7) taken 20361 times.
✗ Branch 1 (6→8) not taken.
|
20361 | const auto terminal = dynamic_cast<TerminalNode *>(subTree); |
1549 |
2/2✓ Branch 0 (9→10) taken 1905 times.
✓ Branch 1 (9→11) taken 18456 times.
|
20361 | if (!terminal) |
1550 | 1905 | continue; | |
1551 | |||
1552 |
4/6✓ Branch 0 (11→12) taken 18456 times.
✗ Branch 1 (11→58) not taken.
✓ Branch 2 (12→13) taken 18456 times.
✗ Branch 3 (12→58) not taken.
✓ Branch 4 (13→14) taken 26 times.
✓ Branch 5 (13→21) taken 18430 times.
|
18456 | 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 18430 times.
✗ Branch 1 (21→58) not taken.
✓ Branch 2 (22→23) taken 18430 times.
✗ Branch 3 (22→58) not taken.
✓ Branch 4 (23→24) taken 14594 times.
✓ Branch 5 (23→29) taken 3836 times.
|
18456 | } else if (terminal->getSymbol()->getType() == SpiceParser::TYPE_IDENTIFIER) { |
1557 |
1/2✓ Branch 0 (24→25) taken 14594 times.
✗ Branch 1 (24→57) not taken.
|
14594 | const std::string fragment = terminal->toString(); |
1558 |
1/2✓ Branch 0 (25→26) taken 14594 times.
✗ Branch 1 (25→55) not taken.
|
14594 | customDataTypeNode->typeNameFragments.push_back(fragment); |
1559 |
1/2✓ Branch 0 (26→27) taken 14594 times.
✗ Branch 1 (26→55) not taken.
|
14594 | customDataTypeNode->fqTypeName += fragment; |
1560 | 14594 | } | |
1561 | } | ||
1562 | |||
1563 | // Visit children | ||
1564 |
2/2✓ Branch 0 (33→34) taken 1905 times.
✓ Branch 1 (33→39) taken 12689 times.
|
14594 | if (ctx->typeLst()) |
1565 |
3/6✓ Branch 0 (34→35) taken 1905 times.
✗ Branch 1 (34→61) not taken.
✓ Branch 2 (35→36) taken 1905 times.
✗ Branch 3 (35→61) not taken.
✓ Branch 4 (36→37) taken 1905 times.
✗ Branch 5 (36→59) not taken.
|
1905 | customDataTypeNode->templateTypeLst = std::any_cast<TypeLstNode *>(visit(ctx->typeLst())); |
1566 | |||
1567 |
1/2✓ Branch 0 (45→46) taken 14594 times.
✗ Branch 1 (45→62) not taken.
|
14594 | 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 | 6456 | std::any ASTBuilder::visitAssignOp(SpiceParser::AssignOpContext *ctx) { | |
1585 | 6456 | const auto assignExprNode = resumeForExpansion<AssignExprNode>(); | |
1586 | |||
1587 | // Extract assign operator | ||
1588 |
2/2✓ Branch 0 (13→14) taken 5721 times.
✓ Branch 1 (13→15) taken 735 times.
|
6456 | if (ctx->ASSIGN()) |
1589 | 5721 | assignExprNode->op = AssignExprNode::AssignOp::OP_ASSIGN; | |
1590 |
2/2✓ Branch 0 (16→17) taken 350 times.
✓ Branch 1 (16→18) taken 385 times.
|
735 | else if (ctx->PLUS_EQUAL()) |
1591 | 350 | assignExprNode->op = AssignExprNode::AssignOp::OP_PLUS_EQUAL; | |
1592 |
2/2✓ Branch 0 (19→20) taken 55 times.
✓ Branch 1 (19→21) taken 330 times.
|
385 | 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 310 times.
|
330 | else if (ctx->MUL_EQUAL()) |
1595 | 20 | assignExprNode->op = AssignExprNode::AssignOp::OP_MUL_EQUAL; | |
1596 |
2/2✓ Branch 0 (25→26) taken 43 times.
✓ Branch 1 (25→27) taken 267 times.
|
310 | else if (ctx->DIV_EQUAL()) |
1597 | 43 | assignExprNode->op = AssignExprNode::AssignOp::OP_DIV_EQUAL; | |
1598 |
2/2✓ Branch 0 (28→29) taken 7 times.
✓ Branch 1 (28→30) taken 260 times.
|
267 | 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 258 times.
|
260 | 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 255 times.
|
258 | 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 254 times.
|
255 | 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 253 times.
|
254 | else if (ctx->OR_EQUAL()) |
1607 | 1 | assignExprNode->op = AssignExprNode::AssignOp::OP_OR_EQUAL; | |
1608 |
1/2✓ Branch 0 (43→44) taken 253 times.
✗ Branch 1 (43→45) not taken.
|
253 | else if (ctx->XOR_EQUAL()) |
1609 | 253 | assignExprNode->op = AssignExprNode::AssignOp::OP_XOR_EQUAL; | |
1610 | else | ||
1611 | ✗ | assert_fail("Unknown assign operator"); | |
1612 | |||
1613 |
1/2✓ Branch 0 (46→47) taken 6456 times.
✗ Branch 1 (46→49) not taken.
|
6456 | return nullptr; |
1614 | } | ||
1615 | |||
1616 | 1572 | std::any ASTBuilder::visitOverloadableOp(SpiceParser::OverloadableOpContext *ctx) { | |
1617 | 1572 | const auto fctNameNode = resumeForExpansion<FctNameNode>(); | |
1618 | |||
1619 | // Enrich | ||
1620 |
2/2✓ Branch 0 (13→14) taken 85 times.
✓ Branch 1 (13→15) taken 1487 times.
|
1572 | if (ctx->PLUS()) |
1621 | 85 | fctNameNode->name = OP_FCT_PLUS; | |
1622 |
2/2✓ Branch 0 (16→17) taken 1 times.
✓ Branch 1 (16→18) taken 1486 times.
|
1487 | else if (ctx->MINUS()) |
1623 | 1 | fctNameNode->name = OP_FCT_MINUS; | |
1624 |
2/2✓ Branch 0 (19→20) taken 169 times.
✓ Branch 1 (19→21) taken 1317 times.
|
1486 | else if (ctx->MUL()) |
1625 | 169 | fctNameNode->name = OP_FCT_MUL; | |
1626 |
2/2✓ Branch 0 (22→23) taken 22 times.
✓ Branch 1 (22→24) taken 1295 times.
|
1317 | else if (ctx->DIV()) |
1627 | 22 | fctNameNode->name = OP_FCT_DIV; | |
1628 |
2/2✓ Branch 0 (25→26) taken 374 times.
✓ Branch 1 (25→27) taken 921 times.
|
1295 | else if (ctx->EQUAL()) |
1629 | 374 | fctNameNode->name = OP_FCT_EQUAL; | |
1630 |
2/2✓ Branch 0 (28→29) taken 371 times.
✓ Branch 1 (28→30) taken 550 times.
|
921 | else if (ctx->NOT_EQUAL()) |
1631 | 371 | fctNameNode->name = OP_FCT_NOT_EQUAL; | |
1632 |
3/4✓ Branch 0 (30→31) taken 550 times.
✗ Branch 1 (30→67) not taken.
✓ Branch 2 (33→34) taken 13 times.
✓ Branch 3 (33→35) taken 537 times.
|
550 | else if (ctx->LESS().size() == 2) |
1633 | 13 | fctNameNode->name = OP_FCT_SHL; | |
1634 |
3/4✓ Branch 0 (35→36) taken 537 times.
✗ Branch 1 (35→68) not taken.
✓ Branch 2 (38→39) taken 1 times.
✓ Branch 3 (38→40) taken 536 times.
|
537 | else if (ctx->GREATER().size() == 2) |
1635 | 1 | fctNameNode->name = OP_FCT_SHR; | |
1636 |
2/2✓ Branch 0 (41→42) taken 117 times.
✓ Branch 1 (41→43) taken 419 times.
|
536 | else if (ctx->PLUS_EQUAL()) |
1637 | 117 | fctNameNode->name = OP_FCT_PLUS_EQUAL; | |
1638 |
2/2✓ Branch 0 (44→45) taken 33 times.
✓ Branch 1 (44→46) taken 386 times.
|
419 | else if (ctx->MINUS_EQUAL()) |
1639 | 33 | fctNameNode->name = OP_FCT_MINUS_EQUAL; | |
1640 |
2/2✓ Branch 0 (47→48) taken 85 times.
✓ Branch 1 (47→49) taken 301 times.
|
386 | else if (ctx->MUL_EQUAL()) |
1641 | 85 | fctNameNode->name = OP_FCT_MUL_EQUAL; | |
1642 |
2/2✓ Branch 0 (50→51) taken 22 times.
✓ Branch 1 (50→52) taken 279 times.
|
301 | else if (ctx->DIV_EQUAL()) |
1643 | 22 | fctNameNode->name = OP_FCT_DIV_EQUAL; | |
1644 |
2/2✓ Branch 0 (53→54) taken 38 times.
✓ Branch 1 (53→55) taken 241 times.
|
279 | 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 208 times.
|
241 | else if (ctx->MINUS_MINUS()) |
1647 | 33 | fctNameNode->name = OP_FCT_POSTFIX_MINUS_MINUS; | |
1648 |
1/2✓ Branch 0 (59→60) taken 208 times.
✗ Branch 1 (59→61) not taken.
|
208 | else if (ctx->LBRACKET()) |
1649 | 208 | fctNameNode->name = OP_FCT_SUBSCRIPT; | |
1650 | else | ||
1651 | − | assert_fail("Unsupported overloadable operator"); // GCOV_EXCL_LINE | |
1652 | |||
1653 | 1572 | fctNameNode->fqName = fctNameNode->name; | |
1654 | 1572 | fctNameNode->nameFragments.push_back(fctNameNode->name); | |
1655 | |||
1656 |
1/2✓ Branch 0 (64→65) taken 1572 times.
✗ Branch 1 (64→69) not taken.
|
1572 | return nullptr; |
1657 | } | ||
1658 | |||
1659 | 3955 | int32_t ASTBuilder::parseInt(TerminalNode *terminal) { | |
1660 | 7910 | 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 3944 times.
✓ Branch 1 (2→4) taken 11 times.
|
3955 | const int64_t upperLimit = isSigned ? INT32_MAX : UINT32_MAX; |
1663 |
2/2✓ Branch 0 (5→6) taken 3944 times.
✓ Branch 1 (5→7) taken 11 times.
|
3955 | const int64_t lowerLimit = isSigned ? INT32_MIN : 0; |
1664 | // Parse number and check for limits | ||
1665 | 3955 | const int64_t number = std::stoll(substr, nullptr, base); | |
1666 |
2/4✓ Branch 0 (9→10) taken 3954 times.
✗ Branch 1 (9→11) not taken.
✗ Branch 2 (10→11) not taken.
✓ Branch 3 (10→14) taken 3954 times.
|
3954 | if (number < lowerLimit || number > upperLimit) |
1667 | ✗ | throw std::out_of_range("Number out of range"); | |
1668 | 3954 | return static_cast<int32_t>(number); | |
1669 | 3955 | }; | |
1670 |
2/2✓ Branch 0 (3→4) taken 3954 times.
✓ Branch 1 (3→8) taken 1 times.
|
7909 | return parseNumeric(terminal, cb); |
1671 | 3955 | } | |
1672 | |||
1673 | 539 | int16_t ASTBuilder::parseShort(TerminalNode *terminal) { | |
1674 | 1078 | 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 205 times.
✓ Branch 1 (2→4) taken 334 times.
|
539 | const int64_t upperLimit = isSigned ? INT16_MAX : UINT16_MAX; |
1677 |
2/2✓ Branch 0 (5→6) taken 205 times.
✓ Branch 1 (5→7) taken 334 times.
|
539 | const int64_t lowerLimit = isSigned ? INT16_MIN : 0; |
1678 | // Parse number and check for limits | ||
1679 | 539 | const int64_t number = std::stoll(substr, nullptr, base); | |
1680 |
2/4✓ Branch 0 (9→10) taken 539 times.
✗ Branch 1 (9→11) not taken.
✗ Branch 2 (10→11) not taken.
✓ Branch 3 (10→14) taken 539 times.
|
539 | if (number < lowerLimit || number > upperLimit) |
1681 | ✗ | throw std::out_of_range("Number out of range"); | |
1682 | 539 | return static_cast<int16_t>(number); | |
1683 | 539 | }; | |
1684 |
1/2✓ Branch 0 (3→4) taken 539 times.
✗ Branch 1 (3→8) not taken.
|
1078 | return parseNumeric(terminal, cb); |
1685 | 539 | } | |
1686 | |||
1687 | 4943 | int64_t ASTBuilder::parseLong(TerminalNode *terminal) { | |
1688 | 9886 | const NumericParserCallback<int64_t> cb = [](const std::string &substr, short base, bool isSigned) -> int64_t { | |
1689 |
2/2✓ Branch 0 (2→3) taken 4934 times.
✓ Branch 1 (2→5) taken 9 times.
|
4943 | return isSigned ? std::stoll(substr, nullptr, base) : static_cast<int64_t>(std::stoull(substr, nullptr, base)); |
1690 | 4943 | }; | |
1691 |
1/2✓ Branch 0 (3→4) taken 4943 times.
✗ Branch 1 (3→8) not taken.
|
9886 | return parseNumeric(terminal, cb); |
1692 | 4943 | } | |
1693 | |||
1694 | 2572 | int8_t ASTBuilder::parseChar(TerminalNode *terminal) const { | |
1695 |
1/2✓ Branch 0 (2→3) taken 2572 times.
✗ Branch 1 (2→59) not taken.
|
2572 | const std::string input = terminal->toString(); |
1696 |
2/2✓ Branch 0 (4→5) taken 1613 times.
✓ Branch 1 (4→7) taken 959 times.
|
2572 | if (input.length() == 3) // Normal char literals |
1697 | 1613 | return input[1]; | |
1698 | |||
1699 |
3/6✓ Branch 0 (8→9) taken 959 times.
✗ Branch 1 (8→12) not taken.
✓ Branch 2 (10→11) taken 959 times.
✗ Branch 3 (10→12) not taken.
✓ Branch 4 (13→14) taken 959 times.
✗ Branch 5 (13→34) not taken.
|
959 | 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 11 times.
✓ Branch 3 (15→19) taken 100 times.
✓ Branch 4 (15→20) taken 84 times.
✓ Branch 5 (15→21) taken 84 times.
✗ Branch 6 (15→22) not taken.
✗ Branch 7 (15→23) not taken.
✗ Branch 8 (15→24) not taken.
✓ Branch 9 (15→25) taken 674 times.
✓ Branch 10 (15→26) taken 1 times.
|
959 | switch (input[2]) { |
1701 | 5 | case '\'': | |
1702 | 5 | return '\''; | |
1703 | ✗ | case '"': | |
1704 | ✗ | return '\"'; | |
1705 | 11 | case '\\': | |
1706 | 11 | return '\\'; | |
1707 | 100 | case 'n': | |
1708 | 100 | return '\n'; | |
1709 | 84 | case 'r': | |
1710 | 84 | return '\r'; | |
1711 | 84 | case 't': | |
1712 | 84 | return '\t'; | |
1713 | ✗ | case 'b': | |
1714 | ✗ | return '\b'; | |
1715 | ✗ | case 'f': | |
1716 | ✗ | return '\f'; | |
1717 | ✗ | case 'v': | |
1718 | ✗ | return '\v'; | |
1719 | 674 | case '0': | |
1720 | 674 | 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 | 2572 | } | |
1730 | |||
1731 | 2503 | std::string ASTBuilder::parseString(std::string input) { | |
1732 |
1/2✓ Branch 0 (3→4) taken 2503 times.
✗ Branch 1 (3→9) not taken.
|
2503 | input = input.substr(1, input.size() - 2); |
1733 | 2503 | replaceEscapeChars(input); | |
1734 | 2503 | return input; | |
1735 | } | ||
1736 | |||
1737 | 9437 | template <typename T> T ASTBuilder::parseNumeric(TerminalNode *terminal, const NumericParserCallback<T> &cb) { | |
1738 |
1/2✓ Branch 0 (2→3) taken 9437 times.
✗ Branch 1 (2→87) not taken.
|
9437 | 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 9426 times.
✓ Branch 1 (4→9) taken 11 times.
✓ Branch 2 (6→7) taken 9092 times.
✓ Branch 3 (6→9) taken 334 times.
✓ Branch 4 (8→9) taken 9 times.
✓ Branch 5 (8→10) taken 9083 times.
|
9437 | 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 1965 times.
✓ Branch 1 (12→30) taken 7472 times.
|
9437 | if (input.length() >= 3) { |
1745 |
2/2✓ Branch 0 (14→15) taken 314 times.
✓ Branch 1 (14→30) taken 1651 times.
|
1965 | if (input[0] == '0') { |
1746 |
1/2✓ Branch 0 (15→16) taken 314 times.
✗ Branch 1 (15→37) not taken.
|
314 | 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 307 times.
✓ Branch 4 (17→26) taken 4 times.
|
314 | 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 | 307 | case 'o': // fall-through | |
1760 | case 'O': | ||
1761 |
1/2✓ Branch 0 (24→25) taken 307 times.
✗ Branch 1 (24→35) not taken.
|
307 | 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 | 314 | } | |
1766 | } | ||
1767 |
2/2✓ Branch 0 (30→31) taken 9122 times.
✓ Branch 1 (30→38) taken 1 times.
|
9123 | 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 | 9437 | } | |
1776 | |||
1777 | 3303 | 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 3303 times.
✗ Branch 1 (4→40) not taken.
|
6606 | }; |
1782 | |||
1783 | 3303 | size_t writeIndex = 0; | |
1784 | 3303 | size_t readIndex = 0; | |
1785 | 3303 | const size_t len = input.length(); | |
1786 | |||
1787 |
2/2✓ Branch 0 (36→8) taken 50074 times.
✓ Branch 1 (36→37) taken 3303 times.
|
53377 | while (readIndex < len) { |
1788 | 50074 | const char c = input[readIndex]; | |
1789 |
3/4✓ Branch 0 (9→10) taken 664 times.
✓ Branch 1 (9→33) taken 49410 times.
✓ Branch 2 (10→11) taken 664 times.
✗ Branch 3 (10→33) not taken.
|
50074 | if (c == '\\' && readIndex + 1 < len) { |
1790 | 664 | char next = input[readIndex + 1]; | |
1791 |
1/2✓ Branch 0 (12→13) taken 664 times.
✗ Branch 1 (12→45) not taken.
|
664 | auto it = escapeMap.find(next); |
1792 |
2/2✓ Branch 0 (15→16) taken 655 times.
✓ Branch 1 (15→19) taken 9 times.
|
664 | if (it != escapeMap.end()) { |
1793 | 655 | input[writeIndex++] = it->second; | |
1794 | 655 | readIndex += 2; | |
1795 | 661 | continue; | |
1796 | } | ||
1797 | |||
1798 | // Handle octal escape sequences (up to 3 digits) | ||
1799 |
3/4✓ Branch 0 (19→20) taken 9 times.
✗ Branch 1 (19→31) not taken.
✓ Branch 2 (20→21) taken 6 times.
✓ Branch 3 (20→31) taken 3 times.
|
9 | if (next >= '0' && next <= '7') { |
1800 | 6 | int value = 0; | |
1801 | 6 | size_t octalDigits = 0; | |
1802 | |||
1803 | // Look ahead up to 3 digits | ||
1804 |
3/4✓ Branch 0 (26→27) taken 18 times.
✓ Branch 1 (26→28) taken 6 times.
✓ Branch 2 (27→22) taken 18 times.
✗ Branch 3 (27→28) not taken.
|
24 | for (size_t i = 1; i <= 3 && readIndex + i < len; ++i) { |
1805 | 18 | const char oc = input[readIndex + i]; | |
1806 |
2/4✓ Branch 0 (23→24) taken 18 times.
✗ Branch 1 (23→28) not taken.
✓ Branch 2 (24→25) taken 18 times.
✗ Branch 3 (24→28) not taken.
|
18 | if (oc >= '0' && oc <= '7') { |
1807 | 18 | value = value << 3 | oc - '0'; // multiply by 8 and add digit | |
1808 | 18 | octalDigits++; | |
1809 | } else { | ||
1810 | break; | ||
1811 | } | ||
1812 | } | ||
1813 | |||
1814 |
1/2✓ Branch 0 (28→29) taken 6 times.
✗ Branch 1 (28→31) not taken.
|
6 | if (octalDigits > 0) { |
1815 | 6 | input[writeIndex++] = static_cast<char>(value); | |
1816 | 6 | readIndex += 1 + octalDigits; // backslash + octal digits | |
1817 | 6 | continue; | |
1818 | } | ||
1819 | } | ||
1820 | } | ||
1821 | |||
1822 | // Copy current character | ||
1823 | 49413 | input[writeIndex++] = c; | |
1824 | 49413 | readIndex++; | |
1825 | } | ||
1826 | |||
1827 |
1/2✓ Branch 0 (37→38) taken 3303 times.
✗ Branch 1 (37→46) not taken.
|
3303 | input.resize(writeIndex); |
1828 | 3303 | } | |
1829 | |||
1830 | 100728 | std::string ASTBuilder::getIdentifier(TerminalNode *terminal, bool isTypeIdentifier) const { | |
1831 | 100728 | const std::string identifier = terminal->getText(); | |
1832 | |||
1833 | // Check if the list of reserved keywords contains the given identifier | ||
1834 |
3/4✓ Branch 0 (3→4) taken 100728 times.
✗ Branch 1 (3→56) not taken.
✓ Branch 2 (6→7) taken 1 times.
✓ Branch 3 (6→16) taken 100727 times.
|
201456 | if (std::ranges::find(RESERVED_KEYWORDS, identifier) != std::end(RESERVED_KEYWORDS)) { |
1835 |
2/4✓ Branch 0 (7→8) taken 1 times.
✗ Branch 1 (7→45) not taken.
✓ Branch 2 (8→9) taken 1 times.
✗ Branch 3 (8→45) not taken.
|
1 | const CodeLoc codeLoc(terminal->getSymbol(), sourceFile); |
1836 |
3/6✓ Branch 0 (10→11) taken 1 times.
✗ Branch 1 (10→41) not taken.
✓ Branch 2 (11→12) taken 1 times.
✗ Branch 3 (11→39) not taken.
✓ Branch 4 (12→13) taken 1 times.
✗ Branch 5 (12→36) not taken.
|
1 | throw ParserError(codeLoc, RESERVED_KEYWORD, "'" + identifier + "' is a reserved keyword. Please use another name instead"); |
1837 | } | ||
1838 | |||
1839 | // Check if the identifier is a type identifier and is reserved | ||
1840 |
6/6✓ Branch 0 (16→17) taken 8581 times.
✓ Branch 1 (16→23) taken 92146 times.
✓ Branch 2 (17→18) taken 767 times.
✓ Branch 3 (17→23) taken 7814 times.
✓ Branch 4 (24→25) taken 1 times.
✓ Branch 5 (24→34) taken 100726 times.
|
101494 | if (isTypeIdentifier && !sourceFile->isStdFile && |
1841 |
3/4✓ Branch 0 (18→19) taken 767 times.
✗ Branch 1 (18→56) not taken.
✓ Branch 2 (21→22) taken 1 times.
✓ Branch 3 (21→23) taken 766 times.
|
1534 | std::ranges::find(RESERVED_TYPE_NAMES, identifier) != std::end(RESERVED_TYPE_NAMES)) { |
1842 |
2/4✓ Branch 0 (25→26) taken 1 times.
✗ Branch 1 (25→55) not taken.
✓ Branch 2 (26→27) taken 1 times.
✗ Branch 3 (26→55) not taken.
|
1 | const CodeLoc codeLoc(terminal->getSymbol(), sourceFile); |
1843 |
3/6✓ Branch 0 (28→29) taken 1 times.
✗ Branch 1 (28→51) not taken.
✓ Branch 2 (29→30) taken 1 times.
✗ Branch 3 (29→49) not taken.
✓ Branch 4 (30→31) taken 1 times.
✗ Branch 5 (30→46) not taken.
|
1 | throw ParserError(codeLoc, RESERVED_TYPENAME, "'" + identifier + "' is a reserved type name. Please use another one instead"); |
1844 | } | ||
1845 | |||
1846 | 100726 | return identifier; | |
1847 | 2 | } | |
1848 | |||
1849 | } // namespace spice::compiler | ||
1850 |