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 667 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 667 times.
✗ Branch 3 (3→8) not taken.
|
667 | 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 6210 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 6210 times.
✗ Branch 3 (3→8) not taken.
|
6210 | std::any visitFctDef(FctDefNode *ctx) override { return buildNode(ctx); } |
30 |
2/4✓ Branch 0 (2→3) taken 3367 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 3367 times.
✗ Branch 3 (3→8) not taken.
|
3367 | std::any visitProcDef(ProcDefNode *ctx) override { return buildNode(ctx); } |
31 |
2/4✓ Branch 0 (2→3) taken 9577 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 9577 times.
✗ Branch 3 (3→8) not taken.
|
9577 | std::any visitFctName(FctNameNode *ctx) override { return buildNode(ctx); } |
32 |
2/4✓ Branch 0 (2→3) taken 493 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 493 times.
✗ Branch 3 (3→8) not taken.
|
493 | 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 779 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 779 times.
✗ Branch 3 (3→8) not taken.
|
779 | std::any visitGenericTypeDef(GenericTypeDefNode *ctx) override { return buildNode(ctx); } |
36 |
2/4✓ Branch 0 (2→3) taken 47 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 47 times.
✗ Branch 3 (3→8) not taken.
|
47 | std::any visitAliasDef(AliasDefNode *ctx) override { return buildNode(ctx); } |
37 |
2/4✓ Branch 0 (2→3) taken 1181 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 1181 times.
✗ Branch 3 (3→8) not taken.
|
1181 | std::any visitGlobalVarDef(GlobalVarDefNode *ctx) override { return buildNode(ctx); } |
38 |
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 visitExtDecl(ExtDeclNode *ctx) override { return buildNode(ctx); } |
39 |
2/4✓ Branch 0 (2→3) taken 396 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 396 times.
✗ Branch 3 (3→8) not taken.
|
396 | std::any visitImportDef(ImportDefNode *ctx) override { return buildNode(ctx); } |
40 |
2/4✓ Branch 0 (2→3) taken 2406 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 2406 times.
✗ Branch 3 (3→8) not taken.
|
2406 | std::any visitUnsafeBlock(UnsafeBlockNode *ctx) override { return buildNode(ctx); } |
41 |
2/4✓ Branch 0 (2→3) taken 1205 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 1205 times.
✗ Branch 3 (3→8) not taken.
|
1205 | 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 676 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 676 times.
✗ Branch 3 (3→8) not taken.
|
676 | 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 3597 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 3597 times.
✗ Branch 3 (3→8) not taken.
|
3597 | 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 17687 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 17687 times.
✗ Branch 3 (3→8) not taken.
|
17687 | std::any visitStmtLst(StmtLstNode *ctx) override { return buildNode(ctx); } |
53 |
2/4✓ Branch 0 (2→3) taken 5338 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 5338 times.
✗ Branch 3 (3→8) not taken.
|
5338 | std::any visitTypeLst(TypeLstNode *ctx) override { return buildNode(ctx); } |
54 |
2/4✓ Branch 0 (2→3) taken 779 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 779 times.
✗ Branch 3 (3→8) not taken.
|
779 | std::any visitTypeAltsLst(TypeAltsLstNode *ctx) override { return buildNode(ctx); } |
55 |
2/4✓ Branch 0 (2→3) taken 7258 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 7258 times.
✗ Branch 3 (3→8) not taken.
|
7258 | std::any visitParamLst(ParamLstNode *ctx) override { return buildNode(ctx); } |
56 |
2/4✓ Branch 0 (2→3) taken 10048 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 10048 times.
✗ Branch 3 (3→8) not taken.
|
10048 | std::any visitArgLst(ArgLstNode *ctx) override { return buildNode(ctx); } |
57 |
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); } |
58 |
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); } |
59 |
2/4✓ Branch 0 (2→3) taken 1112 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 1112 times.
✗ Branch 3 (3→8) not taken.
|
1112 | std::any visitField(FieldNode *ctx) override { return buildNode(ctx); } |
60 |
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); } |
61 |
2/4✓ Branch 0 (2→3) taken 16609 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 16609 times.
✗ Branch 3 (3→8) not taken.
|
16609 | std::any visitDeclStmt(DeclStmtNode *ctx) override { return buildNode(ctx); } |
62 |
2/4✓ Branch 0 (2→3) taken 10936 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 10936 times.
✗ Branch 3 (3→8) not taken.
|
10936 | std::any visitExprStmt(ExprStmtNode *ctx) override { return buildNode(ctx); } |
63 |
2/4✓ Branch 0 (2→3) taken 26059 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 26059 times.
✗ Branch 3 (3→8) not taken.
|
26059 | std::any visitQualifierLst(QualifierLstNode *ctx) override { return buildNode(ctx); } |
64 |
2/4✓ Branch 0 (2→3) taken 31826 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 31826 times.
✗ Branch 3 (3→8) not taken.
|
31826 | std::any visitQualifier(QualifierNode *ctx) override { return buildNode(ctx); } |
65 |
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); } |
66 |
2/4✓ Branch 0 (2→3) taken 402 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 402 times.
✗ Branch 3 (3→8) not taken.
|
402 | std::any visitTopLevelDefinitionAttr(TopLevelDefinitionAttrNode *ctx) override { return buildNode(ctx); } |
67 |
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); } |
68 |
2/4✓ Branch 0 (2→3) taken 705 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 705 times.
✗ Branch 3 (3→8) not taken.
|
705 | std::any visitAttrLst(AttrLstNode *ctx) override { return buildNode(ctx); } |
69 |
2/4✓ Branch 0 (2→3) taken 1140 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 1140 times.
✗ Branch 3 (3→8) not taken.
|
1140 | std::any visitAttr(AttrNode *ctx) override { return buildNode(ctx); } |
70 |
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); } |
71 |
2/4✓ Branch 0 (2→3) taken 7800 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 7800 times.
✗ Branch 3 (3→8) not taken.
|
7800 | std::any visitReturnStmt(ReturnStmtNode *ctx) override { return buildNode(ctx); } |
72 |
2/4✓ Branch 0 (2→3) taken 100 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 100 times.
✗ Branch 3 (3→8) not taken.
|
100 | std::any visitBreakStmt(BreakStmtNode *ctx) override { return buildNode(ctx); } |
73 |
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 visitContinueStmt(ContinueStmtNode *ctx) override { return buildNode(ctx); } |
74 | ✗ | std::any visitFallthroughStmt(FallthroughStmtNode *ctx) override { return buildNode(ctx); } | |
75 |
2/4✓ Branch 0 (2→3) taken 1278 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 1278 times.
✗ Branch 3 (3→8) not taken.
|
1278 | std::any visitBuiltinCall(BuiltinCallNode *ctx) override { return buildNode(ctx); } |
76 |
2/4✓ Branch 0 (2→3) taken 173 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 173 times.
✗ Branch 3 (3→8) not taken.
|
173 | std::any visitPrintfCall(PrintfCallNode *ctx) override { return buildNode(ctx); } |
77 |
2/4✓ Branch 0 (2→3) taken 193 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 193 times.
✗ Branch 3 (3→8) not taken.
|
193 | std::any visitSizeofCall(SizeofCallNode *ctx) override { return buildNode(ctx); } |
78 | ✗ | std::any visitAlignofCall(AlignofCallNode *ctx) override { return buildNode(ctx); } | |
79 | ✗ | std::any visitTypeidCall(TypeidCallNode *ctx) override { return buildNode(ctx); } | |
80 |
2/4✓ Branch 0 (2→3) taken 110 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 110 times.
✗ Branch 3 (3→8) not taken.
|
110 | std::any visitLenCall(LenCallNode *ctx) override { return buildNode(ctx); } |
81 |
2/4✓ Branch 0 (2→3) taken 802 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 802 times.
✗ Branch 3 (3→8) not taken.
|
802 | std::any visitPanicCall(PanicCallNode *ctx) override { return buildNode(ctx); } |
82 | ✗ | std::any visitSysCall(SysCallNode *ctx) override { return buildNode(ctx); } | |
83 |
2/4✓ Branch 0 (2→3) taken 59799 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 59799 times.
✗ Branch 3 (3→8) not taken.
|
59799 | std::any visitAssignExpr(AssignExprNode *ctx) override { return buildNode(ctx); } |
84 |
2/4✓ Branch 0 (2→3) taken 53693 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 53693 times.
✗ Branch 3 (3→8) not taken.
|
53693 | std::any visitTernaryExpr(TernaryExprNode *ctx) override { return buildNode(ctx); } |
85 |
2/4✓ Branch 0 (2→3) taken 54277 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 54277 times.
✗ Branch 3 (3→8) not taken.
|
54277 | std::any visitLogicalOrExpr(LogicalOrExprNode *ctx) override { return buildNode(ctx); } |
86 |
2/4✓ Branch 0 (2→3) taken 55420 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 55420 times.
✗ Branch 3 (3→8) not taken.
|
55420 | std::any visitLogicalAndExpr(LogicalAndExprNode *ctx) override { return buildNode(ctx); } |
87 |
2/4✓ Branch 0 (2→3) taken 55640 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 55640 times.
✗ Branch 3 (3→8) not taken.
|
55640 | std::any visitBitwiseOrExpr(BitwiseOrExprNode *ctx) override { return buildNode(ctx); } |
88 |
2/4✓ Branch 0 (2→3) taken 55701 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 55701 times.
✗ Branch 3 (3→8) not taken.
|
55701 | std::any visitBitwiseXorExpr(BitwiseXorExprNode *ctx) override { return buildNode(ctx); } |
89 |
2/4✓ Branch 0 (2→3) taken 55701 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 55701 times.
✗ Branch 3 (3→8) not taken.
|
55701 | std::any visitBitwiseAndExpr(BitwiseAndExprNode *ctx) override { return buildNode(ctx); } |
90 |
2/4✓ Branch 0 (2→3) taken 55723 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 55723 times.
✗ Branch 3 (3→8) not taken.
|
55723 | std::any visitEqualityExpr(EqualityExprNode *ctx) override { return buildNode(ctx); } |
91 |
2/4✓ Branch 0 (2→3) taken 59807 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 59807 times.
✗ Branch 3 (3→8) not taken.
|
59807 | std::any visitRelationalExpr(RelationalExprNode *ctx) override { return buildNode(ctx); } |
92 |
2/4✓ Branch 0 (2→3) taken 63190 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 63190 times.
✗ Branch 3 (3→8) not taken.
|
63190 | std::any visitShiftExpr(ShiftExprNode *ctx) override { return buildNode(ctx); } |
93 |
2/4✓ Branch 0 (2→3) taken 63246 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 63246 times.
✗ Branch 3 (3→8) not taken.
|
63246 | std::any visitAdditiveExpr(AdditiveExprNode *ctx) override { return buildNode(ctx); } |
94 |
2/4✓ Branch 0 (2→3) taken 66807 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 66807 times.
✗ Branch 3 (3→8) not taken.
|
66807 | std::any visitMultiplicativeExpr(MultiplicativeExprNode *ctx) override { return buildNode(ctx); } |
95 |
2/4✓ Branch 0 (2→3) taken 67993 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 67993 times.
✗ Branch 3 (3→8) not taken.
|
67993 | std::any visitCastExpr(CastExprNode *ctx) override { return buildNode(ctx); } |
96 |
2/4✓ Branch 0 (2→3) taken 73261 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 73261 times.
✗ Branch 3 (3→8) not taken.
|
73261 | std::any visitPrefixUnaryExpr(PrefixUnaryExprNode *ctx) override { return buildNode(ctx); } |
97 |
2/4✓ Branch 0 (2→3) taken 93570 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 93570 times.
✗ Branch 3 (3→8) not taken.
|
93570 | std::any visitPostfixUnaryExpr(PostfixUnaryExprNode *ctx) override { return buildNode(ctx); } |
98 |
2/4✓ Branch 0 (2→3) taken 72329 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 72329 times.
✗ Branch 3 (3→8) not taken.
|
72329 | std::any visitAtomicExpr(AtomicExprNode *ctx) override { return buildNode(ctx); } |
99 |
2/4✓ Branch 0 (2→3) taken 13665 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 13665 times.
✗ Branch 3 (3→8) not taken.
|
13665 | std::any visitValue(ValueNode *ctx) override { return buildNode(ctx); } |
100 |
2/4✓ Branch 0 (2→3) taken 13333 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 13333 times.
✗ Branch 3 (3→8) not taken.
|
13333 | std::any visitConstant(ConstantNode *ctx) override { return buildNode(ctx); } |
101 |
2/4✓ Branch 0 (2→3) taken 12561 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 12561 times.
✗ Branch 3 (3→8) not taken.
|
12561 | std::any visitFctCall(FctCallNode *ctx) override { return buildNode(ctx); } |
102 |
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); } |
103 |
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); } |
104 | ✗ | std::any visitLambdaFunc(LambdaFuncNode *ctx) override { return buildNode(ctx); } | |
105 |
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); } |
106 | ✗ | std::any visitLambdaExpr(LambdaExprNode *ctx) override { return buildNode(ctx); } | |
107 |
2/4✓ Branch 0 (2→3) taken 37838 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 37838 times.
✗ Branch 3 (3→8) not taken.
|
37838 | std::any visitDataType(DataTypeNode *ctx) override { return buildNode(ctx); } |
108 |
2/4✓ Branch 0 (2→3) taken 37838 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 37838 times.
✗ Branch 3 (3→8) not taken.
|
37838 | std::any visitBaseDataType(BaseDataTypeNode *ctx) override { return buildNode(ctx); } |
109 |
2/4✓ Branch 0 (2→3) taken 14272 times.
✗ Branch 1 (2→10) not taken.
✓ Branch 2 (3→4) taken 14272 times.
✗ Branch 3 (3→8) not taken.
|
14272 | std::any visitCustomDataType(CustomDataTypeNode *ctx) override { return buildNode(ctx); } |
110 |
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); } |
111 | |||
112 | private: | ||
113 | // Members | ||
114 | const std::vector<std::string> nodeNames; | ||
115 | std::stack<std::string> parentNodeIds; | ||
116 | |||
117 | // Private methods | ||
118 | template <typename T> | ||
119 | 1309683 | std::string buildNode(const T *node) | |
120 | requires std::is_base_of_v<ASTNode, T> | ||
121 | { | ||
122 |
1/2✓ Branch 0 (2→3) taken 1309683 times.
✗ Branch 1 (2→72) not taken.
|
1309683 | std::stringstream result; |
123 | |||
124 | // Prepare strings | ||
125 |
1/2✓ Branch 0 (4→5) taken 1309683 times.
✗ Branch 1 (4→70) not taken.
|
1309683 | const std::string typeName(CommonUtil::demangleTypeName(typeid(T).name())); |
126 |
1/2✓ Branch 0 (5→6) taken 1309683 times.
✗ Branch 1 (5→68) not taken.
|
1309683 | const std::string codeLoc = node->codeLoc.toString(); |
127 |
2/4✓ Branch 0 (6→7) taken 1309683 times.
✗ Branch 1 (6→66) not taken.
✓ Branch 2 (7→8) taken 1309683 times.
✗ Branch 3 (7→66) not taken.
|
1309683 | const std::string nodeName = typeName.substr(typeName.rfind("::") + 2); |
128 |
2/4✓ Branch 0 (8→9) taken 1309683 times.
✗ Branch 1 (8→52) not taken.
✓ Branch 2 (9→10) taken 1309683 times.
✗ Branch 3 (9→50) not taken.
|
1309683 | const std::string nodeId = codeLoc + "_" + nodeName; |
129 | |||
130 | // Build result | ||
131 |
4/8✓ Branch 0 (11→12) taken 1309683 times.
✗ Branch 1 (11→62) not taken.
✓ Branch 2 (12→13) taken 1309683 times.
✗ Branch 3 (12→62) not taken.
✓ Branch 4 (13→14) taken 1309683 times.
✗ Branch 5 (13→62) not taken.
✓ Branch 6 (14→15) taken 1309683 times.
✗ Branch 7 (14→62) not taken.
|
1309683 | result << nodeId << R"( [color="lightgreen",label=")" << nodeName << "\"];\n"; |
132 | |||
133 | // Link parent node with the current one | ||
134 |
2/2✓ Branch 0 (16→17) taken 1309016 times.
✓ Branch 1 (16→23) taken 667 times.
|
1309683 | if (!parentNodeIds.empty()) |
135 |
5/10✓ Branch 0 (17→18) taken 1309016 times.
✗ Branch 1 (17→62) not taken.
✓ Branch 2 (19→20) taken 1309016 times.
✗ Branch 3 (19→62) not taken.
✓ Branch 4 (20→21) taken 1309016 times.
✗ Branch 5 (20→62) not taken.
✓ Branch 6 (21→22) taken 1309016 times.
✗ Branch 7 (21→62) not taken.
✓ Branch 8 (22→23) taken 1309016 times.
✗ Branch 9 (22→62) not taken.
|
1309016 | result << " " << parentNodeIds.top() << " -> " << nodeId << ";\n"; |
136 | |||
137 |
1/2✓ Branch 0 (23→24) taken 1309683 times.
✗ Branch 1 (23→62) not taken.
|
1309683 | parentNodeIds.push(nodeId); // Set parentNodeId for children |
138 | |||
139 | // Visit all the children | ||
140 |
3/4✓ Branch 0 (24→25) taken 1309683 times.
✗ Branch 1 (24→61) not taken.
✓ Branch 2 (38→27) taken 1309016 times.
✓ Branch 3 (38→39) taken 1309683 times.
|
2618699 | for (ASTNode *child : node->getChildren()) |
141 |
1/2✓ Branch 0 (28→29) taken 1309016 times.
✗ Branch 1 (28→36) not taken.
|
1309016 | if (child != nullptr) |
142 |
4/8✓ Branch 0 (29→30) taken 1309016 times.
✗ Branch 1 (29→59) not taken.
✓ Branch 2 (30→31) taken 1309016 times.
✗ Branch 3 (30→57) not taken.
✓ Branch 4 (31→32) taken 1309016 times.
✗ Branch 5 (31→55) not taken.
✓ Branch 6 (32→33) taken 1309016 times.
✗ Branch 7 (32→53) not taken.
|
1309016 | result << " " << std::any_cast<std::string>(visit(child)); |
143 | |||
144 | // Remove parent node id from the stack | ||
145 | 1309683 | parentNodeIds.pop(); | |
146 | |||
147 |
1/2✓ Branch 0 (41→42) taken 1309683 times.
✗ Branch 1 (41→62) not taken.
|
2619366 | return result.str(); |
148 | 1309683 | } | |
149 | }; | ||
150 | |||
151 | } // namespace spice::compiler | ||
152 |