Line | Branch | Exec | Source |
---|---|---|---|
1 | // Copyright (c) 2021-2025 ChilliBits. All rights reserved. | ||
2 | |||
3 | #pragma once | ||
4 | |||
5 | #include <string> | ||
6 | #include <vector> | ||
7 | |||
8 | #include <CompilerPass.h> | ||
9 | #include <ast/ASTNodes.h> | ||
10 | #include <ast/AbstractASTVisitor.h> | ||
11 | #include <util/CommonUtil.h> | ||
12 | |||
13 | namespace spice::compiler { | ||
14 | |||
15 | /** | ||
16 | * Visitor for debug purposes (is only executed in the compiler debug mode and when explicitly enabling it via cli flag) | ||
17 | * | ||
18 | * Jobs: | ||
19 | * - Visualize AST | ||
20 | */ | ||
21 | class ASTVisualizer final : CompilerPass, public AbstractASTVisitor { | ||
22 | public: | ||
23 | // Constructors | ||
24 | using CompilerPass::CompilerPass; | ||
25 | |||
26 | // Visitor methods | ||
27 |
2/4✓ Branch 0 (2→3) taken 666 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 666 times.
✗ Branch 3 (3→8) not taken.
|
666 | std::any visitEntry(EntryNode *ctx) override { return buildNode(ctx); } |
28 |
2/4✓ Branch 0 (2→3) taken 8 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 8 times.
✗ Branch 3 (3→8) not taken.
|
8 | std::any visitMainFctDef(MainFctDefNode *ctx) override { return buildNode(ctx); } |
29 |
2/4✓ Branch 0 (2→3) taken 6857 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 6857 times.
✗ Branch 3 (3→8) not taken.
|
6857 | std::any visitFctDef(FctDefNode *ctx) override { return buildNode(ctx); } |
30 |
2/4✓ Branch 0 (2→3) taken 3348 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 3348 times.
✗ Branch 3 (3→8) not taken.
|
3348 | std::any visitProcDef(ProcDefNode *ctx) override { return buildNode(ctx); } |
31 |
2/4✓ Branch 0 (2→3) taken 10205 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 10205 times.
✗ Branch 3 (3→8) not taken.
|
10205 | std::any visitFctName(FctNameNode *ctx) override { return buildNode(ctx); } |
32 |
2/4✓ Branch 0 (2→3) taken 492 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 492 times.
✗ Branch 3 (3→8) not taken.
|
492 | std::any visitStructDef(StructDefNode *ctx) override { return buildNode(ctx); } |
33 |
2/4✓ Branch 0 (2→3) taken 70 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 70 times.
✗ Branch 3 (3→8) not taken.
|
70 | std::any visitInterfaceDef(InterfaceDefNode *ctx) override { return buildNode(ctx); } |
34 |
2/4✓ Branch 0 (2→3) taken 57 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 57 times.
✗ Branch 3 (3→8) not taken.
|
57 | std::any visitEnumDef(EnumDefNode *ctx) override { return buildNode(ctx); } |
35 |
2/4✓ Branch 0 (2→3) taken 776 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 776 times.
✗ Branch 3 (3→8) not taken.
|
776 | std::any visitGenericTypeDef(GenericTypeDefNode *ctx) override { return buildNode(ctx); } |
36 |
2/4✓ Branch 0 (2→3) taken 58 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 58 times.
✗ Branch 3 (3→8) not taken.
|
58 | std::any visitAliasDef(AliasDefNode *ctx) override { return buildNode(ctx); } |
37 |
2/4✓ Branch 0 (2→3) taken 1137 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 1137 times.
✗ Branch 3 (3→8) not taken.
|
1137 | std::any visitGlobalVarDef(GlobalVarDefNode *ctx) override { return buildNode(ctx); } |
38 |
2/4✓ Branch 0 (2→3) taken 911 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 911 times.
✗ Branch 3 (3→8) not taken.
|
911 | std::any visitExtDecl(ExtDeclNode *ctx) override { return buildNode(ctx); } |
39 |
2/4✓ Branch 0 (2→3) taken 393 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 393 times.
✗ Branch 3 (3→8) not taken.
|
393 | std::any visitImportDef(ImportDefNode *ctx) override { return buildNode(ctx); } |
40 |
2/4✓ Branch 0 (2→3) taken 2309 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 2309 times.
✗ Branch 3 (3→8) not taken.
|
2309 | std::any visitUnsafeBlock(UnsafeBlockNode *ctx) override { return buildNode(ctx); } |
41 |
2/4✓ Branch 0 (2→3) taken 1187 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 1187 times.
✗ Branch 3 (3→8) not taken.
|
1187 | std::any visitForLoop(ForLoopNode *ctx) override { return buildNode(ctx); } |
42 |
2/4✓ Branch 0 (2→3) taken 61 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 61 times.
✗ Branch 3 (3→8) not taken.
|
61 | std::any visitForeachLoop(ForeachLoopNode *ctx) override { return buildNode(ctx); } |
43 |
2/4✓ Branch 0 (2→3) taken 674 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 674 times.
✗ Branch 3 (3→8) not taken.
|
674 | std::any visitWhileLoop(WhileLoopNode *ctx) override { return buildNode(ctx); } |
44 |
2/4✓ Branch 0 (2→3) taken 3 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 3 times.
✗ Branch 3 (3→8) not taken.
|
3 | std::any visitDoWhileLoop(DoWhileLoopNode *ctx) override { return buildNode(ctx); } |
45 |
2/4✓ Branch 0 (2→3) taken 3589 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 3589 times.
✗ Branch 3 (3→8) not taken.
|
3589 | std::any visitIfStmt(IfStmtNode *ctx) override { return buildNode(ctx); } |
46 |
2/4✓ Branch 0 (2→3) taken 165 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 165 times.
✗ Branch 3 (3→8) not taken.
|
165 | std::any visitElseStmt(ElseStmtNode *ctx) override { return buildNode(ctx); } |
47 |
2/4✓ Branch 0 (2→3) taken 5 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 5 times.
✗ Branch 3 (3→8) not taken.
|
5 | std::any visitSwitchStmt(SwitchStmtNode *ctx) override { return buildNode(ctx); } |
48 |
2/4✓ Branch 0 (2→3) taken 31 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 31 times.
✗ Branch 3 (3→8) not taken.
|
31 | std::any visitCaseBranch(CaseBranchNode *ctx) override { return buildNode(ctx); } |
49 |
2/4✓ Branch 0 (2→3) taken 3 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 3 times.
✗ Branch 3 (3→8) not taken.
|
3 | std::any visitDefaultBranch(DefaultBranchNode *ctx) override { return buildNode(ctx); } |
50 |
2/4✓ Branch 0 (2→3) taken 102 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 102 times.
✗ Branch 3 (3→8) not taken.
|
102 | std::any visitAssertStmt(AssertStmtNode *ctx) override { return buildNode(ctx); } |
51 | ✗ | std::any visitAnonymousBlockStmt(AnonymousBlockStmtNode *ctx) override { return buildNode(ctx); } | |
52 |
2/4✓ Branch 0 (2→3) taken 18190 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 18190 times.
✗ Branch 3 (3→8) not taken.
|
18190 | std::any visitStmtLst(StmtLstNode *ctx) override { return buildNode(ctx); } |
53 |
2/4✓ Branch 0 (2→3) taken 5393 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 5393 times.
✗ Branch 3 (3→8) not taken.
|
5393 | std::any visitTypeLst(TypeLstNode *ctx) override { return buildNode(ctx); } |
54 |
2/4✓ Branch 0 (2→3) taken 873 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 873 times.
✗ Branch 3 (3→8) not taken.
|
873 | std::any visitTypeLstWithEllipsis(TypeLstWithEllipsisNode *ctx) override { return buildNode(ctx); } |
55 |
2/4✓ Branch 0 (2→3) taken 776 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 776 times.
✗ Branch 3 (3→8) not taken.
|
776 | std::any visitTypeAltsLst(TypeAltsLstNode *ctx) override { return buildNode(ctx); } |
56 |
2/4✓ Branch 0 (2→3) taken 7894 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 7894 times.
✗ Branch 3 (3→8) not taken.
|
7894 | std::any visitParamLst(ParamLstNode *ctx) override { return buildNode(ctx); } |
57 |
2/4✓ Branch 0 (2→3) taken 10271 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 10271 times.
✗ Branch 3 (3→8) not taken.
|
10271 | std::any visitArgLst(ArgLstNode *ctx) override { return buildNode(ctx); } |
58 |
2/4✓ Branch 0 (2→3) taken 57 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 57 times.
✗ Branch 3 (3→8) not taken.
|
57 | std::any visitEnumItemLst(EnumItemLstNode *ctx) override { return buildNode(ctx); } |
59 |
2/4✓ Branch 0 (2→3) taken 709 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 709 times.
✗ Branch 3 (3→8) not taken.
|
709 | std::any visitEnumItem(EnumItemNode *ctx) override { return buildNode(ctx); } |
60 |
2/4✓ Branch 0 (2→3) taken 1109 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 1109 times.
✗ Branch 3 (3→8) not taken.
|
1109 | std::any visitField(FieldNode *ctx) override { return buildNode(ctx); } |
61 |
2/4✓ Branch 0 (2→3) taken 178 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 178 times.
✗ Branch 3 (3→8) not taken.
|
178 | std::any visitSignature(SignatureNode *ctx) override { return buildNode(ctx); } |
62 |
2/4✓ Branch 0 (2→3) taken 17282 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 17282 times.
✗ Branch 3 (3→8) not taken.
|
17282 | std::any visitDeclStmt(DeclStmtNode *ctx) override { return buildNode(ctx); } |
63 |
2/4✓ Branch 0 (2→3) taken 11142 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 11142 times.
✗ Branch 3 (3→8) not taken.
|
11142 | std::any visitExprStmt(ExprStmtNode *ctx) override { return buildNode(ctx); } |
64 |
2/4✓ Branch 0 (2→3) taken 26773 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 26773 times.
✗ Branch 3 (3→8) not taken.
|
26773 | std::any visitQualifierLst(QualifierLstNode *ctx) override { return buildNode(ctx); } |
65 |
2/4✓ Branch 0 (2→3) taken 32514 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 32514 times.
✗ Branch 3 (3→8) not taken.
|
32514 | std::any visitQualifier(QualifierNode *ctx) override { return buildNode(ctx); } |
66 |
2/4✓ Branch 0 (2→3) taken 302 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 302 times.
✗ Branch 3 (3→8) not taken.
|
302 | std::any visitModAttr(ModAttrNode *ctx) override { return buildNode(ctx); } |
67 |
2/4✓ Branch 0 (2→3) taken 399 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 399 times.
✗ Branch 3 (3→8) not taken.
|
399 | std::any visitTopLevelDefinitionAttr(TopLevelDefinitionAttrNode *ctx) override { return buildNode(ctx); } |
68 |
2/4✓ Branch 0 (2→3) taken 1 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 1 times.
✗ Branch 3 (3→8) not taken.
|
1 | std::any visitLambdaAttr(LambdaAttrNode *ctx) override { return buildNode(ctx); } |
69 |
2/4✓ Branch 0 (2→3) taken 702 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 702 times.
✗ Branch 3 (3→8) not taken.
|
702 | std::any visitAttrLst(AttrLstNode *ctx) override { return buildNode(ctx); } |
70 |
2/4✓ Branch 0 (2→3) taken 1141 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 1141 times.
✗ Branch 3 (3→8) not taken.
|
1141 | std::any visitAttr(AttrNode *ctx) override { return buildNode(ctx); } |
71 |
2/4✓ Branch 0 (2→3) taken 48 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 48 times.
✗ Branch 3 (3→8) not taken.
|
48 | std::any visitCaseConstant(CaseConstantNode *ctx) override { return buildNode(ctx); } |
72 |
2/4✓ Branch 0 (2→3) taken 8368 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 8368 times.
✗ Branch 3 (3→8) not taken.
|
8368 | std::any visitReturnStmt(ReturnStmtNode *ctx) override { return buildNode(ctx); } |
73 |
2/4✓ Branch 0 (2→3) taken 99 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 99 times.
✗ Branch 3 (3→8) not taken.
|
99 | std::any visitBreakStmt(BreakStmtNode *ctx) override { return buildNode(ctx); } |
74 |
2/4✓ Branch 0 (2→3) taken 176 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 176 times.
✗ Branch 3 (3→8) not taken.
|
176 | std::any visitContinueStmt(ContinueStmtNode *ctx) override { return buildNode(ctx); } |
75 | ✗ | std::any visitFallthroughStmt(FallthroughStmtNode *ctx) override { return buildNode(ctx); } | |
76 |
2/4✓ Branch 0 (2→3) taken 1282 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 1282 times.
✗ Branch 3 (3→8) not taken.
|
1282 | std::any visitBuiltinCall(BuiltinCallNode *ctx) override { return buildNode(ctx); } |
77 |
2/4✓ Branch 0 (2→3) taken 172 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 172 times.
✗ Branch 3 (3→8) not taken.
|
172 | std::any visitPrintfCall(PrintfCallNode *ctx) override { return buildNode(ctx); } |
78 |
2/4✓ Branch 0 (2→3) taken 202 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 202 times.
✗ Branch 3 (3→8) not taken.
|
202 | std::any visitSizeofCall(SizeofCallNode *ctx) override { return buildNode(ctx); } |
79 | ✗ | std::any visitAlignofCall(AlignofCallNode *ctx) override { return buildNode(ctx); } | |
80 | ✗ | std::any visitTypeidCall(TypeidCallNode *ctx) override { return buildNode(ctx); } | |
81 |
2/4✓ Branch 0 (2→3) taken 104 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 104 times.
✗ Branch 3 (3→8) not taken.
|
104 | std::any visitLenCall(LenCallNode *ctx) override { return buildNode(ctx); } |
82 |
2/4✓ Branch 0 (2→3) taken 804 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 804 times.
✗ Branch 3 (3→8) not taken.
|
804 | std::any visitPanicCall(PanicCallNode *ctx) override { return buildNode(ctx); } |
83 | ✗ | std::any visitSysCall(SysCallNode *ctx) override { return buildNode(ctx); } | |
84 |
2/4✓ Branch 0 (2→3) taken 61908 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 61908 times.
✗ Branch 3 (3→8) not taken.
|
61908 | std::any visitAssignExpr(AssignExprNode *ctx) override { return buildNode(ctx); } |
85 |
2/4✓ Branch 0 (2→3) taken 55642 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 55642 times.
✗ Branch 3 (3→8) not taken.
|
55642 | std::any visitTernaryExpr(TernaryExprNode *ctx) override { return buildNode(ctx); } |
86 |
2/4✓ Branch 0 (2→3) taken 56392 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 56392 times.
✗ Branch 3 (3→8) not taken.
|
56392 | std::any visitLogicalOrExpr(LogicalOrExprNode *ctx) override { return buildNode(ctx); } |
87 |
2/4✓ Branch 0 (2→3) taken 57523 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 57523 times.
✗ Branch 3 (3→8) not taken.
|
57523 | std::any visitLogicalAndExpr(LogicalAndExprNode *ctx) override { return buildNode(ctx); } |
88 |
2/4✓ Branch 0 (2→3) taken 57742 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 57742 times.
✗ Branch 3 (3→8) not taken.
|
57742 | std::any visitBitwiseOrExpr(BitwiseOrExprNode *ctx) override { return buildNode(ctx); } |
89 |
2/4✓ Branch 0 (2→3) taken 57805 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 57805 times.
✗ Branch 3 (3→8) not taken.
|
57805 | std::any visitBitwiseXorExpr(BitwiseXorExprNode *ctx) override { return buildNode(ctx); } |
90 |
2/4✓ Branch 0 (2→3) taken 57810 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 57810 times.
✗ Branch 3 (3→8) not taken.
|
57810 | std::any visitBitwiseAndExpr(BitwiseAndExprNode *ctx) override { return buildNode(ctx); } |
91 |
2/4✓ Branch 0 (2→3) taken 57827 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 57827 times.
✗ Branch 3 (3→8) not taken.
|
57827 | std::any visitEqualityExpr(EqualityExprNode *ctx) override { return buildNode(ctx); } |
92 |
2/4✓ Branch 0 (2→3) taken 61947 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 61947 times.
✗ Branch 3 (3→8) not taken.
|
61947 | std::any visitRelationalExpr(RelationalExprNode *ctx) override { return buildNode(ctx); } |
93 |
2/4✓ Branch 0 (2→3) taken 65339 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 65339 times.
✗ Branch 3 (3→8) not taken.
|
65339 | std::any visitShiftExpr(ShiftExprNode *ctx) override { return buildNode(ctx); } |
94 |
2/4✓ Branch 0 (2→3) taken 65430 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 65430 times.
✗ Branch 3 (3→8) not taken.
|
65430 | std::any visitAdditiveExpr(AdditiveExprNode *ctx) override { return buildNode(ctx); } |
95 |
2/4✓ Branch 0 (2→3) taken 69079 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 69079 times.
✗ Branch 3 (3→8) not taken.
|
69079 | std::any visitMultiplicativeExpr(MultiplicativeExprNode *ctx) override { return buildNode(ctx); } |
96 |
2/4✓ Branch 0 (2→3) taken 70258 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 70258 times.
✗ Branch 3 (3→8) not taken.
|
70258 | std::any visitCastExpr(CastExprNode *ctx) override { return buildNode(ctx); } |
97 |
2/4✓ Branch 0 (2→3) taken 75176 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 75176 times.
✗ Branch 3 (3→8) not taken.
|
75176 | std::any visitPrefixUnaryExpr(PrefixUnaryExprNode *ctx) override { return buildNode(ctx); } |
98 |
2/4✓ Branch 0 (2→3) taken 95395 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 95395 times.
✗ Branch 3 (3→8) not taken.
|
95395 | std::any visitPostfixUnaryExpr(PostfixUnaryExprNode *ctx) override { return buildNode(ctx); } |
99 |
2/4✓ Branch 0 (2→3) taken 74241 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 74241 times.
✗ Branch 3 (3→8) not taken.
|
74241 | std::any visitAtomicExpr(AtomicExprNode *ctx) override { return buildNode(ctx); } |
100 |
2/4✓ Branch 0 (2→3) taken 14158 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 14158 times.
✗ Branch 3 (3→8) not taken.
|
14158 | std::any visitValue(ValueNode *ctx) override { return buildNode(ctx); } |
101 |
2/4✓ Branch 0 (2→3) taken 13896 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 13896 times.
✗ Branch 3 (3→8) not taken.
|
13896 | std::any visitConstant(ConstantNode *ctx) override { return buildNode(ctx); } |
102 |
2/4✓ Branch 0 (2→3) taken 12832 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 12832 times.
✗ Branch 3 (3→8) not taken.
|
12832 | std::any visitFctCall(FctCallNode *ctx) override { return buildNode(ctx); } |
103 |
2/4✓ Branch 0 (2→3) taken 9 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 9 times.
✗ Branch 3 (3→8) not taken.
|
9 | std::any visitArrayInitialization(ArrayInitializationNode *ctx) override { return buildNode(ctx); } |
104 |
2/4✓ Branch 0 (2→3) taken 157 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 157 times.
✗ Branch 3 (3→8) not taken.
|
157 | std::any visitStructInstantiation(StructInstantiationNode *ctx) override { return buildNode(ctx); } |
105 | ✗ | std::any visitLambdaFunc(LambdaFuncNode *ctx) override { return buildNode(ctx); } | |
106 |
2/4✓ Branch 0 (2→3) taken 2 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 2 times.
✗ Branch 3 (3→8) not taken.
|
2 | std::any visitLambdaProc(LambdaProcNode *ctx) override { return buildNode(ctx); } |
107 | ✗ | std::any visitLambdaExpr(LambdaExprNode *ctx) override { return buildNode(ctx); } | |
108 |
2/4✓ Branch 0 (2→3) taken 39987 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 39987 times.
✗ Branch 3 (3→8) not taken.
|
39987 | std::any visitDataType(DataTypeNode *ctx) override { return buildNode(ctx); } |
109 |
2/4✓ Branch 0 (2→3) taken 39987 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 39987 times.
✗ Branch 3 (3→8) not taken.
|
39987 | std::any visitBaseDataType(BaseDataTypeNode *ctx) override { return buildNode(ctx); } |
110 |
2/4✓ Branch 0 (2→3) taken 14353 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 14353 times.
✗ Branch 3 (3→8) not taken.
|
14353 | std::any visitCustomDataType(CustomDataTypeNode *ctx) override { return buildNode(ctx); } |
111 |
2/4✓ Branch 0 (2→3) taken 44 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 44 times.
✗ Branch 3 (3→8) not taken.
|
44 | std::any visitFunctionDataType(FunctionDataTypeNode *ctx) override { return buildNode(ctx); } |
112 | |||
113 | private: | ||
114 | // Members | ||
115 | const std::vector<std::string> nodeNames; | ||
116 | std::stack<std::string> parentNodeIds; | ||
117 | |||
118 | // Private methods | ||
119 | template <typename T> | ||
120 | 1355007 | std::string buildNode(const T *node) | |
121 | requires std::is_base_of_v<ASTNode, T> | ||
122 | { | ||
123 |
1/2✓ Branch 0 (2→3) taken 1355007 times.
✗ Branch 1 (2→72) not taken.
|
1355007 | std::stringstream result; |
124 | |||
125 | // Prepare strings | ||
126 |
1/2✓ Branch 0 (4→5) taken 1355007 times.
✗ Branch 1 (4→70) not taken.
|
1355007 | const std::string typeName(CommonUtil::demangleTypeName(typeid(T).name())); |
127 |
1/2✓ Branch 0 (5→6) taken 1355007 times.
✗ Branch 1 (5→68) not taken.
|
1355007 | const std::string codeLoc = node->codeLoc.toString(); |
128 |
2/4✓ Branch 0 (6→7) taken 1355007 times.
✗ Branch 1 (6→66) not taken.
✓ Branch 2 (7→8) taken 1355007 times.
✗ Branch 3 (7→66) not taken.
|
1355007 | const std::string nodeName = typeName.substr(typeName.rfind("::") + 2); |
129 |
2/4✓ Branch 0 (8→9) taken 1355007 times.
✗ Branch 1 (8→52) not taken.
✓ Branch 2 (9→10) taken 1355007 times.
✗ Branch 3 (9→50) not taken.
|
1355007 | const std::string nodeId = codeLoc + "_" + nodeName; |
130 | |||
131 | // Build result | ||
132 |
4/8✓ Branch 0 (11→12) taken 1355007 times.
✗ Branch 1 (11→62) not taken.
✓ Branch 2 (12→13) taken 1355007 times.
✗ Branch 3 (12→62) not taken.
✓ Branch 4 (13→14) taken 1355007 times.
✗ Branch 5 (13→62) not taken.
✓ Branch 6 (14→15) taken 1355007 times.
✗ Branch 7 (14→62) not taken.
|
1355007 | result << nodeId << R"( [color="lightgreen",label=")" << nodeName << "\"];\n"; |
133 | |||
134 | // Link parent node with the current one | ||
135 |
2/2✓ Branch 0 (16→17) taken 1354341 times.
✓ Branch 1 (16→23) taken 666 times.
|
1355007 | if (!parentNodeIds.empty()) |
136 |
5/10✓ Branch 0 (17→18) taken 1354341 times.
✗ Branch 1 (17→62) not taken.
✓ Branch 2 (19→20) taken 1354341 times.
✗ Branch 3 (19→62) not taken.
✓ Branch 4 (20→21) taken 1354341 times.
✗ Branch 5 (20→62) not taken.
✓ Branch 6 (21→22) taken 1354341 times.
✗ Branch 7 (21→62) not taken.
✓ Branch 8 (22→23) taken 1354341 times.
✗ Branch 9 (22→62) not taken.
|
1354341 | result << " " << parentNodeIds.top() << " -> " << nodeId << ";\n"; |
137 | |||
138 |
1/2✓ Branch 0 (23→24) taken 1355007 times.
✗ Branch 1 (23→62) not taken.
|
1355007 | parentNodeIds.push(nodeId); // Set parentNodeId for children |
139 | |||
140 | // Visit all the children | ||
141 |
3/4✓ Branch 0 (24→25) taken 1355007 times.
✗ Branch 1 (24→61) not taken.
✓ Branch 2 (38→27) taken 1354341 times.
✓ Branch 3 (38→39) taken 1355007 times.
|
2709348 | for (ASTNode *child : node->getChildren()) |
142 |
1/2✓ Branch 0 (28→29) taken 1354341 times.
✗ Branch 1 (28→36) not taken.
|
1354341 | if (child != nullptr) |
143 |
4/8✓ Branch 0 (29→30) taken 1354341 times.
✗ Branch 1 (29→59) not taken.
✓ Branch 2 (30→31) taken 1354341 times.
✗ Branch 3 (30→57) not taken.
✓ Branch 4 (31→32) taken 1354341 times.
✗ Branch 5 (31→55) not taken.
✓ Branch 6 (32→33) taken 1354341 times.
✗ Branch 7 (32→53) not taken.
|
1354341 | result << " " << std::any_cast<std::string>(visit(child)); |
144 | |||
145 | // Remove parent node id from the stack | ||
146 | 1355007 | parentNodeIds.pop(); | |
147 | |||
148 |
1/2✓ Branch 0 (41→42) taken 1355007 times.
✗ Branch 1 (41→62) not taken.
|
2710014 | return result.str(); |
149 | 1355007 | } | |
150 | }; | ||
151 | |||
152 | } // namespace spice::compiler | ||
153 |